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
6 Signed-off-by: Abhimanyu Vishwakarma <Abhimanyu.Vishwakarma@imgtec.com>
8 drivers/mtd/spi-nor/spi-nor.c | 8 +++++++-
9 1 file changed, 7 insertions(+), 1 deletion(-)
11 --- a/drivers/mtd/spi-nor/core.c
12 +++ b/drivers/mtd/spi-nor/core.c
13 @@ -2964,12 +2964,19 @@ static void spi_nor_set_mtd_info(struct
15 struct mtd_info *mtd = &nor->mtd;
16 struct device *dev = nor->dev;
17 + struct device_node *np = spi_nor_get_flash_node(nor);
18 + const char __maybe_unused *of_mtd_name = NULL;
20 spi_nor_set_mtd_locking_ops(nor);
21 spi_nor_set_mtd_otp_ops(nor);
23 mtd->dev.parent = dev;
25 +#ifdef CONFIG_MTD_OF_PARTS
26 + of_property_read_string(np, "linux,mtd-name", &of_mtd_name);
29 + mtd->name = of_mtd_name;
30 + else if (!mtd->name)
31 mtd->name = dev_name(dev);
32 mtd->type = MTD_NORFLASH;
33 mtd->flags = MTD_CAP_NORFLASH;
34 --- a/drivers/mtd/mtdcore.c
35 +++ b/drivers/mtd/mtdcore.c
36 @@ -863,6 +863,17 @@ out_error:
38 static void mtd_set_dev_defaults(struct mtd_info *mtd)
40 +#ifdef CONFIG_MTD_OF_PARTS
41 + const char __maybe_unused *of_mtd_name = NULL;
42 + struct device_node *np;
44 + np = mtd_get_of_node(mtd);
45 + if (np && !mtd->name) {
46 + of_property_read_string(np, "linux,mtd-name", &of_mtd_name);
48 + mtd->name = of_mtd_name;
51 if (mtd->dev.parent) {
52 if (!mtd->owner && mtd->dev.parent->driver)
53 mtd->owner = mtd->dev.parent->driver->owner;