mtd: rawnand: onfi: Use intermediate variables to improve readability
authorMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 28 Apr 2020 09:42:57 +0000 (11:42 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 11 May 2020 07:51:40 +0000 (09:51 +0200)
Before reworking a little bit the ONFI detection code, let's
clean the coding style of the if statements to improve readability.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200428094302.14624-5-miquel.raynal@bootlin.com
drivers/mtd/nand/raw/nand_onfi.c

index 8fe8d7b..7d9a313 100644 (file)
@@ -146,6 +146,7 @@ int nand_onfi_detect(struct nand_chip *chip)
        int onfi_version = 0;
        char id[4];
        int i, ret, val;
+       u16 crc;
 
        memorg = nanddev_get_memorg(&chip->base);
 
@@ -172,8 +173,8 @@ int nand_onfi_detect(struct nand_chip *chip)
                        goto free_onfi_param_page;
                }
 
-               if (onfi_crc16(ONFI_CRC_BASE, (u8 *)&p[i], 254) ==
-                   le16_to_cpu(p[i].crc)) {
+               crc = onfi_crc16(ONFI_CRC_BASE, (u8 *)&p[i], 254);
+               if (crc == le16_to_cpu(p[i].crc)) {
                        if (i)
                                memcpy(p, &p[i], sizeof(*p));
                        break;
@@ -187,8 +188,8 @@ int nand_onfi_detect(struct nand_chip *chip)
                nand_bit_wise_majority(srcbufs, ARRAY_SIZE(srcbufs), p,
                                       sizeof(*p));
 
-               if (onfi_crc16(ONFI_CRC_BASE, (u8 *)p, 254) !=
-                               le16_to_cpu(p->crc)) {
+               crc = onfi_crc16(ONFI_CRC_BASE, (u8 *)p, 254);
+               if (crc != le16_to_cpu(p->crc)) {
                        pr_err("ONFI parameter recovery failed, aborting\n");
                        goto free_onfi_param_page;
                }