From: Hauke Mehrtens Date: Wed, 26 Jun 2024 22:12:43 +0000 (+0200) Subject: pistachio: Fix setting mtd name X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=de01fec4a71a6dc264b6a5fcd407b2355183c4d4;p=openwrt%2Fstaging%2Fpepe2k.git 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 --- 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 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: