Re: [PATCH v2 14/15] mtd: rawnand: Get rid of chip->numchips

Sascha Hauer
2019-05-21T07:58:46Z

On Tue, May 21, 2019 at 09:51:30AM +0200, Boris Brezillon wrote:
> On Tue, 21 May 2019 09:33:02 +0200
> Boris Brezillon <boris.brezillon@collabora.com> wrote:
>
> > On Tue, 21 May 2019 08:59:48 +0200
> > Sascha Hauer <s.hauer@pengutronix.de> wrote:
> >
> > > Hi,
> > >
> > > On Mon, Mar 04, 2019 at 09:15:21PM +0100, Miquel Raynal wrote:
> > > > diff --git a/drivers/mtd/nand/raw/internals.h b/drivers/mtd/nand/raw/internals.h
> > > > index fbf6ca015cd7..a204f9d7e123 100644
> > > > --- a/drivers/mtd/nand/raw/internals.h
> > > > +++ b/drivers/mtd/nand/raw/internals.h
> > > > @@ -110,7 +110,7 @@ static inline int nand_exec_op(struct nand_chip *chip,
> > > > if (!nand_has_exec_op(chip))
> > > > return -ENOTSUPP;
> > > >
> > > > - if (WARN_ON(op->cs >= chip->numchips))
> > > > + if (WARN_ON(op->cs >= nanddev_ntargets(&chip->base)))
> > > > return -EINVAL;
> > >
> > > This warning triggers when I apply my gpmi nand exec_op series.
> > >
> > > The gpmi driver calls:
> > >
> > > ret = nand_scan(chip, GPMI_IS_MX6(this) ? 2 : 1);
> > >
> > > This ends up in nand_scan_ident() with maxchips = 2. Here nand_detect()
> > > is called which sets memorg->ntargets = 1; Later in nand_scan_ident() we
> > > have:
> > >
> > > for (i = 1; i < maxchips; i++) {
> >
> > This loop should be fixed to test against nanddev_ntargets() instead of
> > maxchips.
>
> Nevermind, I see what you mean. I guess we should set ->ntargets to
> maxchips before entering this loop.

Okay, you got the same conclusion in the meantime ;)

Sascha

--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |