All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: nand: gpmi: replace _manual_ swap with swap macro
@ 2017-11-03 20:31 Gustavo A. R. Silva
  2017-11-03 20:38 ` Han Xu
  2017-11-30 21:16 ` Boris Brezillon
  0 siblings, 2 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2017-11-03 20:31 UTC (permalink / raw)
  To: Han Xu, Boris Brezillon, Richard Weinberger, David Woodhouse,
	Brian Norris, Marek Vasut, Cyrille Pitchen
  Cc: linux-mtd, linux-kernel, Gustavo A. R. Silva

Make use of the swap macro and remove unnecessary variables swap.
This makes the code easier to read and maintain.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 50f8d4a..9e365d4 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -1487,12 +1487,8 @@ static int gpmi_ecc_read_page_raw(struct mtd_info *mtd,
 	 * See the layout description for a detailed explanation on why this
 	 * is needed.
 	 */
-	if (this->swap_block_mark) {
-		u8 swap = tmp_buf[0];
-
-		tmp_buf[0] = tmp_buf[mtd->writesize];
-		tmp_buf[mtd->writesize] = swap;
-	}
+	if (this->swap_block_mark)
+		swap(tmp_buf[0], tmp_buf[mtd->writesize]);
 
 	/*
 	 * Copy the metadata section into the oob buffer (this section is
@@ -1615,12 +1611,8 @@ static int gpmi_ecc_write_page_raw(struct mtd_info *mtd,
 	 * See the layout description for a detailed explanation on why this
 	 * is needed.
 	 */
-	if (this->swap_block_mark) {
-		u8 swap = tmp_buf[0];
-
-		tmp_buf[0] = tmp_buf[mtd->writesize];
-		tmp_buf[mtd->writesize] = swap;
-	}
+	if (this->swap_block_mark)
+		swap(tmp_buf[0], tmp_buf[mtd->writesize]);
 
 	chip->write_buf(mtd, tmp_buf, mtd->writesize + mtd->oobsize);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: nand: gpmi: replace _manual_ swap with swap macro
  2017-11-03 20:31 [PATCH] mtd: nand: gpmi: replace _manual_ swap with swap macro Gustavo A. R. Silva
@ 2017-11-03 20:38 ` Han Xu
  2017-11-03 21:44   ` Gustavo A. R. Silva
  2017-11-30 21:16 ` Boris Brezillon
  1 sibling, 1 reply; 4+ messages in thread
From: Han Xu @ 2017-11-03 20:38 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Boris Brezillon, Richard Weinberger,
	David Woodhouse, Brian Norris, Marek Vasut, Cyrille Pitchen
  Cc: linux-mtd, linux-kernel


________________________________________
From: Gustavo A. R. Silva <garsilva@embeddedor.com>
Sent: Friday, November 3, 2017 3:31 PM
To: Han Xu; Boris Brezillon; Richard Weinberger; David Woodhouse; Brian Norris; Marek Vasut; Cyrille Pitchen
Cc: linux-mtd@lists.infradead.org; linux-kernel@vger.kernel.org; Gustavo A. R. Silva
Subject: [PATCH] mtd: nand: gpmi: replace _manual_ swap with swap macro

Make use of the swap macro and remove unnecessary variables swap.
This makes the code easier to read and maintain.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 50f8d4a..9e365d4 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -1487,12 +1487,8 @@ static int gpmi_ecc_read_page_raw(struct mtd_info *mtd,
         * See the layout description for a detailed explanation on why this
         * is needed.
         */
-       if (this->swap_block_mark) {
-               u8 swap = tmp_buf[0];
-
-               tmp_buf[0] = tmp_buf[mtd->writesize];
-               tmp_buf[mtd->writesize] = swap;
-       }
+       if (this->swap_block_mark)
+               swap(tmp_buf[0], tmp_buf[mtd->writesize]);

        /*
         * Copy the metadata section into the oob buffer (this section is
@@ -1615,12 +1611,8 @@ static int gpmi_ecc_write_page_raw(struct mtd_info *mtd,
         * See the layout description for a detailed explanation on why this
         * is needed.
         */
-       if (this->swap_block_mark) {
-               u8 swap = tmp_buf[0];
-
-               tmp_buf[0] = tmp_buf[mtd->writesize];
-               tmp_buf[mtd->writesize] = swap;
-       }
+       if (this->swap_block_mark)
+               swap(tmp_buf[0], tmp_buf[mtd->writesize]);

        chip->write_buf(mtd, tmp_buf, mtd->writesize + mtd->oobsize);

Acked-by: Han Xu <han.xu@nxp.com>

--
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: nand: gpmi: replace _manual_ swap with swap macro
  2017-11-03 20:38 ` Han Xu
@ 2017-11-03 21:44   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2017-11-03 21:44 UTC (permalink / raw)
  To: Han Xu
  Cc: Boris Brezillon, Richard Weinberger, David Woodhouse,
	Brian Norris, Marek Vasut, Cyrille Pitchen, linux-mtd,
	linux-kernel


Quoting Han Xu <han.xu@nxp.com>:

> ________________________________________
> From: Gustavo A. R. Silva <garsilva@embeddedor.com>
> Sent: Friday, November 3, 2017 3:31 PM
> To: Han Xu; Boris Brezillon; Richard Weinberger; David Woodhouse;  
> Brian Norris; Marek Vasut; Cyrille Pitchen
> Cc: linux-mtd@lists.infradead.org; linux-kernel@vger.kernel.org;  
> Gustavo A. R. Silva
> Subject: [PATCH] mtd: nand: gpmi: replace _manual_ swap with swap macro
>
> Make use of the swap macro and remove unnecessary variables swap.
> This makes the code easier to read and maintain.
>
> This code was detected with the help of Coccinelle.
>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
>  drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 16 ++++------------
>  1 file changed, 4 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c  
> b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> index 50f8d4a..9e365d4 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> @@ -1487,12 +1487,8 @@ static int gpmi_ecc_read_page_raw(struct  
> mtd_info *mtd,
>          * See the layout description for a detailed explanation on why this
>          * is needed.
>          */
> -       if (this->swap_block_mark) {
> -               u8 swap = tmp_buf[0];
> -
> -               tmp_buf[0] = tmp_buf[mtd->writesize];
> -               tmp_buf[mtd->writesize] = swap;
> -       }
> +       if (this->swap_block_mark)
> +               swap(tmp_buf[0], tmp_buf[mtd->writesize]);
>
>         /*
>          * Copy the metadata section into the oob buffer (this section is
> @@ -1615,12 +1611,8 @@ static int gpmi_ecc_write_page_raw(struct  
> mtd_info *mtd,
>          * See the layout description for a detailed explanation on why this
>          * is needed.
>          */
> -       if (this->swap_block_mark) {
> -               u8 swap = tmp_buf[0];
> -
> -               tmp_buf[0] = tmp_buf[mtd->writesize];
> -               tmp_buf[mtd->writesize] = swap;
> -       }
> +       if (this->swap_block_mark)
> +               swap(tmp_buf[0], tmp_buf[mtd->writesize]);
>
>         chip->write_buf(mtd, tmp_buf, mtd->writesize + mtd->oobsize);
>
> Acked-by: Han Xu <han.xu@nxp.com>
>

Thank you, Han.
--
Gustavo A. R. Silva

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: nand: gpmi: replace _manual_ swap with swap macro
  2017-11-03 20:31 [PATCH] mtd: nand: gpmi: replace _manual_ swap with swap macro Gustavo A. R. Silva
  2017-11-03 20:38 ` Han Xu
@ 2017-11-30 21:16 ` Boris Brezillon
  1 sibling, 0 replies; 4+ messages in thread
From: Boris Brezillon @ 2017-11-30 21:16 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Han Xu, Richard Weinberger, David Woodhouse, Brian Norris,
	Marek Vasut, Cyrille Pitchen, linux-mtd, linux-kernel

On Fri, 3 Nov 2017 15:31:47 -0500
"Gustavo A. R. Silva" <garsilva@embeddedor.com> wrote:

> Make use of the swap macro and remove unnecessary variables swap.
> This makes the code easier to read and maintain.
> 
> This code was detected with the help of Coccinelle.

Applied.

Thanks,

Boris

> 
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
>  drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 16 ++++------------
>  1 file changed, 4 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> index 50f8d4a..9e365d4 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> @@ -1487,12 +1487,8 @@ static int gpmi_ecc_read_page_raw(struct mtd_info *mtd,
>  	 * See the layout description for a detailed explanation on why this
>  	 * is needed.
>  	 */
> -	if (this->swap_block_mark) {
> -		u8 swap = tmp_buf[0];
> -
> -		tmp_buf[0] = tmp_buf[mtd->writesize];
> -		tmp_buf[mtd->writesize] = swap;
> -	}
> +	if (this->swap_block_mark)
> +		swap(tmp_buf[0], tmp_buf[mtd->writesize]);
>  
>  	/*
>  	 * Copy the metadata section into the oob buffer (this section is
> @@ -1615,12 +1611,8 @@ static int gpmi_ecc_write_page_raw(struct mtd_info *mtd,
>  	 * See the layout description for a detailed explanation on why this
>  	 * is needed.
>  	 */
> -	if (this->swap_block_mark) {
> -		u8 swap = tmp_buf[0];
> -
> -		tmp_buf[0] = tmp_buf[mtd->writesize];
> -		tmp_buf[mtd->writesize] = swap;
> -	}
> +	if (this->swap_block_mark)
> +		swap(tmp_buf[0], tmp_buf[mtd->writesize]);
>  
>  	chip->write_buf(mtd, tmp_buf, mtd->writesize + mtd->oobsize);
>  

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-30 21:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-03 20:31 [PATCH] mtd: nand: gpmi: replace _manual_ swap with swap macro Gustavo A. R. Silva
2017-11-03 20:38 ` Han Xu
2017-11-03 21:44   ` Gustavo A. R. Silva
2017-11-30 21:16 ` Boris Brezillon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.