Skip to content

Commit

Permalink
mtd: nand: gpmi: replace _manual_ swap with swap macro
Browse files Browse the repository at this point in the history
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>
Acked-by: Han Xu <han.xu@nxp.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
  • Loading branch information
Gustavo A. R. Silva authored and Boris Brezillon committed Nov 30, 2017
1 parent f883199 commit b13a973
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions drivers/mtd/nand/gpmi-nand/gpmi-nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit b13a973

Please sign in to comment.