3be1bebbe2fce06899ab8d553b01e5b11258d819
[openwrt/svn-archive/archive.git] / target / linux / lantiq / patches-3.10 / 0012-MTD-m25p80-allow-loading-mtd-name-from-OF.patch
1 From 65d48cd98505800c6765ff94fc007797e00d466f Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Tue, 29 Jan 2013 21:11:55 +0100
4 Subject: [PATCH 12/34] 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 | 5 +++++
13 1 file changed, 5 insertions(+)
14
15 --- a/drivers/mtd/devices/m25p80.c
16 +++ b/drivers/mtd/devices/m25p80.c
17 @@ -925,10 +925,13 @@ static int m25p_probe(struct spi_device
18 unsigned i;
19 struct mtd_part_parser_data ppdata;
20 struct device_node __maybe_unused *np = spi->dev.of_node;
21 + const char __maybe_unused *of_mtd_name = NULL;
22
23 #ifdef CONFIG_MTD_OF_PARTS
24 if (!of_device_is_available(np))
25 return -ENODEV;
26 + of_property_read_string(spi->dev.of_node,
27 + "linux,mtd-name", &of_mtd_name);
28 #endif
29
30 /* Platform data helps sort out which chip type we have, as
31 @@ -1004,6 +1007,8 @@ static int m25p_probe(struct spi_device
32
33 if (data && data->name)
34 flash->mtd.name = data->name;
35 + else if (of_mtd_name)
36 + flash->mtd.name = of_mtd_name;
37 else
38 flash->mtd.name = dev_name(&spi->dev);
39