The flash->mtd.name used to be nor%d before, now it is the type of the
SPI NOR like e.g. mt25ql02g. It is possible to find plenty of examples
of the former in U-Boot configs by searching for MTDIDS.*nor.*spi, while
the later is ambiguous if there are multiple flashes of the same type in
the system and breaks existing environments.

This does no longer get recognized when running 'mtdparts' for example:
CONFIG_MTDIDS_DEFAULT="nor0=47040000.spi.0"

Fix this by setting the correct mtd.name to nor%d.

Fixes: b7f060565e3 ("mtd: spi-nor: allow registering multiple MTDs when DM is 
enabled")
Signed-off-by: Marek Vasut <[email protected]>
Cc: Heiko Schocher <[email protected]>
Cc: Jagan Teki <[email protected]>
Cc: Marek Behún <[email protected]>
Cc: Miquel Raynal <[email protected]>
Cc: Pali Rohár <[email protected]>
Cc: Patrice Chotard <[email protected]>
Cc: Patrick Delaunay <[email protected]>
Cc: Priyanka Jain <[email protected]>
Cc: Simon Glass <[email protected]>
---
 drivers/mtd/spi/sf_mtd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/sf_mtd.c b/drivers/mtd/spi/sf_mtd.c
index 04de8680809..1a81689fe4a 100644
--- a/drivers/mtd/spi/sf_mtd.c
+++ b/drivers/mtd/spi/sf_mtd.c
@@ -14,7 +14,10 @@
 
 int spi_flash_mtd_register(struct spi_flash *flash)
 {
-       return add_mtd_device(&flash->mtd);
+       int ret = add_mtd_device(&flash->mtd);
+       if (!ret)
+               sprintf(flash->mtd.name, "nor%d", flash->mtd.index);
+       return ret;
 }
 
 void spi_flash_mtd_unregister(struct spi_flash *flash)
-- 
2.33.0

Reply via email to