Hello,

On Mon, 13 May 2019 15:37:39 +0800
[email protected] wrote:

> -------------------------------------------------------------------
>  static void macronix_nand_onfi_init(struct nand_chip *chip)
>  {
>           struct nand_parameters *p = &chip->parameters;
>           struct nand_onfi_vendor_macronix *mxic = (void 
> *)p->onfi->vendor;

Why cast to void*, instead of casting directly to struct
nand_onfi_vendor_macronix * ?

Also,  you are dereferencing p->info before checking whether it's NULL
or not.

>           if (!p->onfi ||
>               ((mxic->reliability_func & MACRONIX_READ_RETRY_BIT) == 0))
>                   return;

So, the code should be:

        struct nand_onfi_vendor_macronix *mxic;

        if (!p->onfi)
                return;

        mxic = (struct nand_onfi_vendor_macronix *) p->info->vendor;

        if ((mxic->reliability_func & MACRONIX_READ_RETRY_BIT) == 0)
                return;

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Reply via email to