On Wed, 2026-09-16 at 07:03 +0200, Heiko Schocher wrote:
> Hello Tim,
> 
> dropped [email protected] and added
> [email protected]
> 
> Please ust the new list for further patches, thanks!
> 
> On 14.09.26 05:32, Tim Kuo wrote:
> > From: Tim Kuo <[email protected]>
> > 
> > spi_nand_idx numbers the "spi-nandN" MTD names and was incremented
> > inside
> > the sprintf() before chip had been initialized and registered.
> > If spinand_init() or add_mtd_device() subsequently fails, the index
> > is
> > consumed anyway and the numbering gets a hole: on a board where the
> > first
> > SPI NAND fails to probe, the second one comes up as "spi-nand1" and
> > no
> > "spi-nand0" exists at all.
> > 
> > This patch will pass the current value to sprintf() and increment
> > only
> > after add_mtd_device() has succeeded, so spi_nand_idx counts the
> > SPI
> > NAND devices actually registered and the names stay contiguous
> > starting
> > at spi-nand0.
> > 
> > Signed-off-by: Tim Kuo <[email protected]>
> > ---
> >   drivers/mtd/nand/spi/core.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/mtd/nand/spi/core.c
> > b/drivers/mtd/nand/spi/core.c
> > index 14af4264612..1fa669f3def 100644
> > --- a/drivers/mtd/nand/spi/core.c
> > +++ b/drivers/mtd/nand/spi/core.c
> > @@ -1691,7 +1691,7 @@ static int spinand_probe(struct udevice *dev)
> >     mtd->name = malloc(20);
> >     if (!mtd->name)
> >             return -ENOMEM;
> > -   sprintf(mtd->name, "spi-nand%d", spi_nand_idx++);
> > +   sprintf(mtd->name, "spi-nand%d", spi_nand_idx);
> >     spinand->slave = slave;
> >     spinand_set_ofnode(spinand, dev_ofnode(dev));
> >   #endif
> > @@ -1709,6 +1709,7 @@ static int spinand_probe(struct udevice *dev)
> >             goto err_spinand_cleanup;
> >   
> >     plat->mtd = mtd;
> > +   spi_nand_idx++;
> >   
> >     return 0;
> >   
> > 
> 
> Reviewed-by: Heiko Schocher <[email protected]>
> 
> bye,
> Heiko

Hi all,

This is just a gentle ping.
Any further comments/reviews are appreciated.
Is this patch able to be merged?

BRs,
Tim Kuo

Reply via email to