pistachio: add 4.9 kernel support
[openwrt/openwrt.git] / target / linux / pistachio / patches-4.9 / 401-mtd-nor-support-mtd-name-from-device-tree.patch
1 From f32bc2aa01edcba2f2ed5db151cf183eac9ef919 Mon Sep 17 00:00:00 2001
2 From: Abhimanyu Vishwakarma <Abhimanyu.Vishwakarma@imgtec.com>
3 Date: Sat, 25 Feb 2017 16:42:50 +0000
4 Subject: mtd: nor: support mtd name from device tree
5
6 Signed-off-by: Abhimanyu Vishwakarma <Abhimanyu.Vishwakarma@imgtec.com>
7 ---
8 drivers/mtd/spi-nor/spi-nor.c | 8 +++++++-
9 1 file changed, 7 insertions(+), 1 deletion(-)
10
11 diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
12 index d0fc165..fcee697 100644
13 --- a/drivers/mtd/spi-nor/spi-nor.c
14 +++ b/drivers/mtd/spi-nor/spi-nor.c
15 @@ -1306,6 +1306,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
16 struct device *dev = nor->dev;
17 struct mtd_info *mtd = &nor->mtd;
18 struct device_node *np = spi_nor_get_flash_node(nor);
19 + const char __maybe_unused *of_mtd_name = NULL;
20 int ret;
21 int i;
22
23 @@ -1361,7 +1362,12 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
24 spi_nor_wait_till_ready(nor);
25 }
26
27 - if (!mtd->name)
28 +#ifdef CONFIG_MTD_OF_PARTS
29 + of_property_read_string(np, "linux,mtd-name", &of_mtd_name);
30 +#endif
31 + if (of_mtd_name)
32 + mtd->name = of_mtd_name;
33 + else if (!mtd->name)
34 mtd->name = dev_name(dev);
35 mtd->priv = nor;
36 mtd->type = MTD_NORFLASH;
37 --
38 2.7.4
39