lkml.org 
[lkml]   [2019]   [May]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v1] mtd: rawnand: Add Macronix NAND read retry support
Hello,

On Tue, 14 May 2019 09:53:16 +0800
masonccyang@mxic.com.tw 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 * ?
>
> Due to got a warning:
>
> warning: initialization from incompatible pointer type
> struct nand_onfi_vendor_macronix *mxic = p->onfi->vendor;

You didn't look at my code, I suggested:

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

I.e, you indeed still need a cast, because p->info->vendor is a u8[].
But instead of casting to void*, and then implicitly casting to struct
nand_onfi_vendor_macronix *, I suggest to cast directly to struct
nand_onfi_vendor_macronix *.

> > > 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;
>
> Also got a warning:
>
> warning: ISO C90 forbids mixed declarations and code
> [-Wdeclaration-after-statement]

No, you don't get this warning if you use my code. You get this warning
if you declare and initialized the "mxic" variable at the same location.

> 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;

You are dereferencing p->info...

>
> if (!p->onfi)
> return;

... before you check it is NULL. This is wrong.

Please check again the code I sent in my previous e-mail:

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 Petazzoni
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

\
 
 \ /
  Last update: 2019-05-14 09:42    [W:0.135 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site