kernel: bump 6.1 to 6.1.53
[openwrt/staging/stintel.git] / target / linux / ath79 / patches-6.1 / 400-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 --- a/drivers/mtd/spi-nor/core.c
12 +++ b/drivers/mtd/spi-nor/core.c
13 @@ -2942,12 +2942,19 @@ static void spi_nor_set_mtd_info(struct
14 {
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;
19
20 spi_nor_set_mtd_locking_ops(nor);
21 spi_nor_set_mtd_otp_ops(nor);
22
23 mtd->dev.parent = dev;
24 - if (!mtd->name)
25 +#ifdef CONFIG_MTD_OF_PARTS
26 + of_property_read_string(np, "linux,mtd-name", &of_mtd_name);
27 +#endif
28 + if (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 @@ -840,6 +840,17 @@ out_error:
37 */
38 static void mtd_set_dev_defaults(struct mtd_info *mtd)
39 {
40 +#ifdef CONFIG_MTD_OF_PARTS
41 + const char __maybe_unused *of_mtd_name = NULL;
42 + struct device_node *np;
43 +
44 + np = mtd_get_of_node(mtd);
45 + if (np && !mtd->name) {
46 + of_property_read_string(np, "linux,mtd-name", &of_mtd_name);
47 + if (of_mtd_name)
48 + mtd->name = of_mtd_name;
49 + } else
50 +#endif
51 if (mtd->dev.parent) {
52 if (!mtd->owner && mtd->dev.parent->driver)
53 mtd->owner = mtd->dev.parent->driver->owner;