[openwrt/openwrt] pistachio: Add mtd device name from dts

LEDE Commits lede-commits at lists.infradead.org
Fri Aug 21 08:59:50 EDT 2020


hauke pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/d2b63647cc7a9ee0cfbcd08123e9fb60c32d7a6c

commit d2b63647cc7a9ee0cfbcd08123e9fb60c32d7a6c
Author: Hauke Mehrtens <hauke at hauke-m.de>
AuthorDate: Thu Aug 13 00:45:12 2020 +0200

    pistachio: Add mtd device name from dts
    
    Parse the "linux,mtd-name" property also for SPI NAND flashes.
    
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 ...1-mtd-nor-support-mtd-name-from-device-tree.patch | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/target/linux/pistachio/patches-5.4/401-mtd-nor-support-mtd-name-from-device-tree.patch b/target/linux/pistachio/patches-5.4/401-mtd-nor-support-mtd-name-from-device-tree.patch
index 5d2f9284ab..4b600d7e8a 100644
--- a/target/linux/pistachio/patches-5.4/401-mtd-nor-support-mtd-name-from-device-tree.patch
+++ b/target/linux/pistachio/patches-5.4/401-mtd-nor-support-mtd-name-from-device-tree.patch
@@ -32,3 +32,23 @@ Signed-off-by: Abhimanyu Vishwakarma <Abhimanyu.Vishwakarma at imgtec.com>
  		mtd->name = dev_name(dev);
  	mtd->priv = nor;
  	mtd->type = MTD_NORFLASH;
+--- a/drivers/mtd/mtdcore.c
++++ b/drivers/mtd/mtdcore.c
+@@ -778,6 +778,17 @@ out_error:
+  */
+ static void mtd_set_dev_defaults(struct mtd_info *mtd)
+ {
++#ifdef CONFIG_MTD_OF_PARTS
++	const char __maybe_unused *of_mtd_name = NULL;
++	struct device_node *np;
++
++	np = mtd_get_of_node(mtd);
++	if (np && !mtd->name) {
++		of_property_read_string(np, "linux,mtd-name", &of_mtd_name);
++		if (of_mtd_name)
++			mtd->name = of_mtd_name;
++	} else
++#endif
+ 	if (mtd->dev.parent) {
+ 		if (!mtd->owner && mtd->dev.parent->driver)
+ 			mtd->owner = mtd->dev.parent->driver->owner;



More information about the lede-commits mailing list