Re: [PATCH 4/8] mtd: rawnand: onfi: Use an intermediate variable to decomplefixy conditions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 21 Apr 2020 18:46:33 +0200
Miquel Raynal <miquel.raynal@xxxxxxxxxxx> wrote:

> Before reworking a little bit the ONFI detection code, let's
> decomplefixy the if statements.

It's more about coding style/formatting than complexity, but the change
improves readability indeed, so

Reviewed-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx>

> 
> Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
> ---
>  drivers/mtd/nand/raw/nand_onfi.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/nand_onfi.c b/drivers/mtd/nand/raw/nand_onfi.c
> index 8fe8d7bdd203..7d9a3130443a 100644
> --- a/drivers/mtd/nand/raw/nand_onfi.c
> +++ b/drivers/mtd/nand/raw/nand_onfi.c
> @@ -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;
>  		}


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux