Skip to content

Commit

Permalink
pistachio: Fix setting mtd name
Browse files Browse the repository at this point in the history
The bootloader provides the partition table using the boot arguments
and uses the name spi-nor and spi-nand for the different controllers.
The old code was not setting the name any more because mtd->name was
already set before. Move the setting of the name to the spi-mem code
now.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
  • Loading branch information
hauke committed Jun 30, 2024
1 parent cd080be commit de01fec
Showing 1 changed file with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,37 @@ Signed-off-by: Abhimanyu Vishwakarma <Abhimanyu.Vishwakarma@imgtec.com>
drivers/mtd/spi-nor/spi-nor.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -3420,12 +3420,20 @@ static void spi_nor_set_mtd_info(struct
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -846,7 +846,9 @@ static int spi_mem_probe(struct spi_devi
{
struct mtd_info *mtd = &nor->mtd;
struct device *dev = nor->dev;
+ struct device_node *np = spi_nor_get_flash_node(nor);
struct spi_mem_driver *memdrv = to_spi_mem_drv(spi->dev.driver);
struct spi_controller *ctlr = spi->controller;
+ const char __maybe_unused *of_mtd_name = NULL;
struct spi_mem *mem;
+ int ret;

spi_nor_set_mtd_locking_ops(nor);
spi_nor_set_mtd_otp_ops(nor);
mem = devm_kzalloc(&spi->dev, sizeof(*mem), GFP_KERNEL);
if (!mem)
@@ -854,10 +856,15 @@ static int spi_mem_probe(struct spi_devi

mtd->dev.parent = dev;
if (!mtd->name)
+#ifdef CONFIG_MTD_OF_PARTS
+ of_property_read_string(np, "linux,mtd-name", &of_mtd_name);
+#endif
+ if (of_mtd_name)
+ mtd->name = of_mtd_name;
+ else if (!mtd->name)
mtd->name = dev_name(dev);
mtd->type = MTD_NORFLASH;
mtd->flags = MTD_CAP_NORFLASH;
mem->spi = spi;

- if (ctlr->mem_ops && ctlr->mem_ops->get_name)
+ if (ctlr->mem_ops && ctlr->mem_ops->get_name) {
mem->name = ctlr->mem_ops->get_name(mem);
- else
- mem->name = dev_name(&spi->dev);
+ } else {
+ ret = device_property_read_string(&spi->dev, "linux,mtd-name", &of_mtd_name);
+ if (!ret)
+ mem->name = of_mtd_name;
+ else
+ mem->name = dev_name(&spi->dev);
+ }

if (IS_ERR_OR_NULL(mem->name))
return PTR_ERR_OR_ZERO(mem->name);
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -870,6 +870,17 @@ out_error:
Expand Down

0 comments on commit de01fec

Please sign in to comment.