[PATCH 2/7] mtd: spi-nor: core: Report correct name in case of ID collisions
Tudor Ambarus
tudor.ambarus at microchip.com
Fri Jul 2 07:41:05 PDT 2021
Provide a way to report the correct flash name in case of ID collisions.
There will be a single flash_info entry when flash IDs collide, and the
differentiation between the flash types will be made at runtime
if possible.
Signed-off-by: Tudor Ambarus <tudor.ambarus at microchip.com>
---
drivers/mtd/spi-nor/core.c | 5 ++++-
include/linux/mtd/spi-nor.h | 2 ++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 3d9f3698fb7b..d528e28995c6 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -3208,7 +3208,10 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
/* Configure OTP parameters and ops */
spi_nor_otp_init(nor);
- dev_info(dev, "%s (%lld Kbytes)\n", info->name,
+ if (!nor->name)
+ nor->name = info->name;
+
+ dev_info(dev, "%s (%lld Kbytes)\n", nor->name,
(long long)mtd->size >> 10);
dev_dbg(dev,
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index f67457748ed8..bd92acdd1899 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -369,6 +369,7 @@ struct spi_nor_flash_parameter;
* @bouncebuf: bounce buffer used when the buffer passed by the MTD
* layer is not DMA-able
* @bouncebuf_size: size of the bounce buffer
+ * @name: used to point to correct name in case of ID collisions.
* @info: SPI NOR part JEDEC MFR ID and other info
* @manufacturer: SPI NOR manufacturer
* @page_size: the page size of the SPI NOR
@@ -399,6 +400,7 @@ struct spi_nor {
struct spi_mem *spimem;
u8 *bouncebuf;
size_t bouncebuf_size;
+ const char *name;
const struct flash_info *info;
const struct spi_nor_manufacturer *manufacturer;
u32 page_size;
--
2.25.1
More information about the linux-mtd
mailing list