mtd: nand: gpmi: replace _manual_ swap with swap macro
Subsystems (2)
PATCH 1/1 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.
--- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +4 -12
@@ -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);
Signature · 1 line
2.7.4
________________________________________
From: Gustavo A. R. Silva <[email protected]>
Sent: Friday, November 3, 2017 3:31 PM
To: Han Xu; Boris Brezillon; Richard Weinberger; David Woodhouse; Brian Norris; Marek Vasut; Cyrille Pitchen
Cc: [email protected]; [email protected]; 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.
--- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +4 -12
@@ -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
Quoting Han Xu <[email protected]>:
Quoted 53 lines
________________________________________
From: Gustavo A. R. Silva <[email protected]>
Sent: Friday, November 3, 2017 3:31 PM
To: Han Xu; Boris Brezillon; Richard Weinberger; David Woodhouse; Brian Norris; Marek Vasut; Cyrille Pitchen
Cc: [email protected]; [email protected]; Gustavo A. R. Silva
Subject: [PATCH] mtd: nand: gpmi: replace _manual_ swap with swap macroMake 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 <[email protected]>--- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)drivers/mtd/nand/gpmi-nand/gpmi-nand.c +2
-6@@ -1487,12 +1487,8 @@ static int gpmi_ecc_read_page_raw(structmtd_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
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +2
-6@@ -1615,12 +1611,8 @@ static int gpmi_ecc_write_page_raw(structmtd_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);
Quoted 2 lines
Acked-by Han Xu <[email protected]>
Thank you, Han.
--
Gustavo A. R. Silva
Boris Brezillon
AppliedQuoted 4 lines · On Fri, 3 Nov 2017 15:31:47 -0500 "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.
Applied.
Thanks,
Boris
Quoted 40 lines
Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)drivers/mtd/nand/gpmi-nand/gpmi-nand.c +4
-12@@ -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);