All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: spi-nor: Fix SF MTDIDS when registering multiple MTDs with DM enabled
@ 2021-09-14 23:06 Marek Vasut
  2021-09-15  4:23 ` Heiko Schocher
  2021-09-16 15:16 ` Marek Behún
  0 siblings, 2 replies; 13+ messages in thread
From: Marek Vasut @ 2021-09-14 23:06 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Heiko Schocher, Jagan Teki, Marek Behún,
	Miquel Raynal, Pali Rohár, Patrice Chotard,
	Patrick Delaunay, Priyanka Jain, Simon Glass

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 <marex@denx.de>
Cc: Heiko Schocher <hs@denx.de>
Cc: Jagan Teki <jagan@amarulasolutions.com>
Cc: Marek Behún <marek.behun@nic.cz>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Pali Rohár <pali@kernel.org>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Priyanka Jain <priyanka.jain@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
---
 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


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-09-16 17:44 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 23:06 [PATCH] mtd: spi-nor: Fix SF MTDIDS when registering multiple MTDs with DM enabled Marek Vasut
2021-09-15  4:23 ` Heiko Schocher
2021-09-15  5:59   ` Marek Vasut
2021-09-15  8:53     ` Patrice CHOTARD
2021-09-15  8:57       ` Marek Vasut
2021-09-15  9:17         ` Patrice CHOTARD
2021-09-15  9:21           ` Marek Vasut
2021-09-15 12:00             ` Patrick DELAUNAY
2021-09-15 12:10               ` Marek Vasut
2021-09-16  7:50                 ` Patrick DELAUNAY
2021-09-16 14:06                   ` Patrick DELAUNAY
2021-09-16 15:16 ` Marek Behún
2021-09-16 17:40   ` Marek Vasut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.