Browse Source

pistachio: Fix setting mtd name

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 <[email protected]>
Hauke Mehrtens 1 year ago
parent
commit
de01fec4a7

+ 27 - 19
target/linux/pistachio/patches-6.6/401-mtd-nor-support-mtd-name-from-device-tree.patch

@@ -8,29 +8,37 @@ Signed-off-by: Abhimanyu Vishwakarma <[email protected]>
  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: