44970a5466b6b6cb7873550c4400ad152bdbee49
[openwrt/openwrt.git] / target / linux / lantiq / patches-3.14 / 0022-MTD-m25p80-allow-loading-mtd-name-from-OF.patch
1 From 4400e1f593ea40a51912128adb4f53d59e62cad8 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Wed, 10 Sep 2014 22:40:18 +0200
4 Subject: [PATCH 22/36] MTD: m25p80: allow loading mtd name from OF
5
6 In accordance with the physmap flash we should honour the linux,mtd-name
7 property when deciding what name the mtd device has.
8
9 Signed-off-by: Thomas Langer <thomas.langer@lantiq.com>
10 Signed-off-by: John Crispin <blogic@openwrt.org>
11 ---
12 drivers/mtd/devices/m25p80.c | 6 ++++++
13 1 file changed, 6 insertions(+)
14
15 diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
16 index ad19139..9f7b35a 100644
17 --- a/drivers/mtd/devices/m25p80.c
18 +++ b/drivers/mtd/devices/m25p80.c
19 @@ -1097,6 +1097,10 @@ static int m25p_probe(struct spi_device *spi)
20 struct mtd_part_parser_data ppdata;
21 struct device_node *np = spi->dev.of_node;
22 int ret;
23 + const char __maybe_unused *of_mtd_name = NULL;
24 +
25 + of_property_read_string(spi->dev.of_node,
26 + "linux,mtd-name", &of_mtd_name);
27
28 /* Platform data helps sort out which chip type we have, as
29 * well as how this board partitions it. If we don't have
30 @@ -1169,6 +1173,8 @@ static int m25p_probe(struct spi_device *spi)
31
32 if (data && data->name)
33 flash->mtd.name = data->name;
34 + else if (of_mtd_name)
35 + flash->mtd.name = of_mtd_name;
36 else
37 flash->mtd.name = dev_name(&spi->dev);
38
39 --
40 1.7.10.4
41