From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: masonccyang@mxic.com.tw
Cc: bbrezillon@kernel.org, computersforpeace@gmail.com,
dwmw2@infradead.org, juliensu@mxic.com.tw,
linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org,
marek.vasut@gmail.com, miquel.raynal@bootlin.com, richard@nod.at
Subject: Re: [PATCH v1] mtd: rawnand: Add Macronix NAND read retry support
Date: Tue, 14 May 2019 09:41:00 +0200 [thread overview]
Message-ID: <20190514094100.34d2a6ba@windsurf.home> (raw)
In-Reply-To: <OFB5D53BFC.6B44E7E0-ON482583FA.00090982-482583FA.000A5E93@mxic.com.tw>
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
next prev parent reply other threads:[~2019-05-14 7:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-10 7:41 [PATCH v1] mtd: rawnand: Add Macronix NAND read retry support Mason Yang
2019-05-10 7:45 ` Miquel Raynal
[not found] ` <OF5E2BF75D.98A43E33-ON482583F6.002E7A65-482583F6.0030A2DE@mxic.com.tw>
2019-05-10 9:12 ` Miquel Raynal
[not found] ` <OF3A216E48.80ABBB8A-ON482583F9.002A09DA-482583F9.002AD40E@mxic.com.tw>
2019-05-13 9:59 ` Miquel Raynal
2019-05-14 2:16 ` masonccyang
2019-05-10 13:37 ` Thomas Petazzoni
2019-05-10 13:53 ` Miquel Raynal
2019-05-10 14:18 ` Miquel Raynal
[not found] ` <OF1EDBA487.7723094D-ON482583F9.00297ABF-482583F9.0029E3EE@mxic.com.tw>
2019-05-13 9:40 ` Thomas Petazzoni
[not found] ` <OFB5D53BFC.6B44E7E0-ON482583FA.00090982-482583FA.000A5E93@mxic.com.tw>
2019-05-14 7:41 ` Thomas Petazzoni [this message]
2019-05-15 1:30 ` masonccyang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190514094100.34d2a6ba@windsurf.home \
--to=thomas.petazzoni@bootlin.com \
--cc=bbrezillon@kernel.org \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=juliensu@mxic.com.tw \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=masonccyang@mxic.com.tw \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).