[openwrt/openwrt] pistachio: Fix setting mtd name

LEDE Commits lede-commits at lists.infradead.org
Sun Jun 30 15:51:48 PDT 2024


hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/de01fec4a71a6dc264b6a5fcd407b2355183c4d4

commit de01fec4a71a6dc264b6a5fcd407b2355183c4d4
Author: Hauke Mehrtens <hauke at hauke-m.de>
AuthorDate: Thu Jun 27 00:12:43 2024 +0200

    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 <hauke at hauke-m.de>
---
 ...mtd-nor-support-mtd-name-from-device-tree.patch | 46 +++++++++++++---------
 1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/target/linux/pistachio/patches-6.6/401-mtd-nor-support-mtd-name-from-device-tree.patch b/target/linux/pistachio/patches-6.6/401-mtd-nor-support-mtd-name-from-device-tree.patch
index c7b07952e7..0000c22a89 100644
--- a/target/linux/pistachio/patches-6.6/401-mtd-nor-support-mtd-name-from-device-tree.patch
+++ b/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 <Abhimanyu.Vishwakarma at 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:




More information about the lede-commits mailing list