lantiq: add v3.10 patches
[openwrt.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 diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
16 index 2f3d2a5..1828704 100644
17 --- a/drivers/mtd/devices/m25p80.c
18 +++ b/drivers/mtd/devices/m25p80.c
19 @@ -909,10 +909,13 @@ static int m25p_probe(struct spi_device *spi)
20         unsigned                        i;
21         struct mtd_part_parser_data     ppdata;
22         struct device_node __maybe_unused *np = spi->dev.of_node;
23 +       const char __maybe_unused       *of_mtd_name = NULL;
24  
25  #ifdef CONFIG_MTD_OF_PARTS
26         if (!of_device_is_available(np))
27                 return -ENODEV;
28 +       of_property_read_string(spi->dev.of_node,
29 +                                       "linux,mtd-name", &of_mtd_name);
30  #endif
31  
32         /* Platform data helps sort out which chip type we have, as
33 @@ -988,6 +991,8 @@ static int m25p_probe(struct spi_device *spi)
34  
35         if (data && data->name)
36                 flash->mtd.name = data->name;
37 +       else if (of_mtd_name)
38 +               flash->mtd.name = of_mtd_name;
39         else
40                 flash->mtd.name = dev_name(&spi->dev);
41  
42 -- 
43 1.7.10.4
44