Commit 543e34f2 authored by Miquel Raynal's avatar Miquel Raynal

mtd: rawnand: onfi: Use intermediate variables to improve readability

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: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200428094302.14624-5-miquel.raynal@bootlin.com
parent 1d5d08ee
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment