@@ -3132,7 +3132,7 @@ static void spi_nor_debugfs_init(struct spi_nor *nor,
{
struct mtd_info *mtd = &nor->mtd;
- mtd->dbg.partname = info->name;
+ mtd->dbg.partname = nor->name;
mtd->dbg.partid = devm_kasprintf(nor->dev, GFP_KERNEL, "spi-nor:%*phN",
info->id_len, info->id);
}
@@ -3271,7 +3271,10 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
spi_nor_set_mtd_info(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,
@@ -25,7 +25,7 @@ static ssize_t partname_show(struct device *dev,
struct spi_mem *spimem = spi_get_drvdata(spi);
struct spi_nor *nor = spi_mem_get_drvdata(spimem);
- return sysfs_emit(buf, "%s\n", nor->info->name);
+ return sysfs_emit(buf, "%s\n", nor->name);
}
static DEVICE_ATTR_RO(partname);
@@ -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
* @addr_width: number of address bytes
@@ -398,6 +399,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;
u8 addr_width;
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@microchip.com> --- drivers/mtd/spi-nor/core.c | 7 +++++-- drivers/mtd/spi-nor/sysfs.c | 2 +- include/linux/mtd/spi-nor.h | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-)