04a858ff6a91bbf7a4af7c5b30370c5d8126e9b8
[openwrt.git] / target / linux / lantiq / patches-3.18 / 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 --- a/drivers/mtd/devices/m25p80.c
16 +++ b/drivers/mtd/devices/m25p80.c
17 @@ -198,6 +198,10 @@ static int m25p_probe(struct spi_device
18         enum read_mode mode = SPI_NOR_NORMAL;
19         char *flash_name = NULL;
20         int ret;
21 +       const char __maybe_unused       *of_mtd_name = NULL;
22 +
23 +       of_property_read_string(spi->dev.of_node,
24 +               "linux,mtd-name", &of_mtd_name);
25  
26         data = dev_get_platdata(&spi->dev);
27  
28 @@ -229,6 +233,8 @@ static int m25p_probe(struct spi_device
29  
30         if (data && data->name)
31                 flash->mtd.name = data->name;
32 +       else if (of_mtd_name)
33 +               flash->mtd.name = of_mtd_name;
34  
35         /* For some (historical?) reason many platforms provide two different
36          * names in flash_platform_data: "name" and "type". Quite often name is