lantiq: fix PHY state handling issue
[openwrt.git] / target / linux / lantiq / patches-4.4 / 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 @@ -19,6 +19,7 @@
18  #include <linux/errno.h>
19  #include <linux/module.h>
20  #include <linux/device.h>
21 +#include <linux/of.h>
22  
23  #include <linux/mtd/mtd.h>
24  #include <linux/mtd/partitions.h>
25 @@ -182,6 +183,10 @@ static int m25p_probe(struct spi_device
26         enum read_mode mode = SPI_NOR_NORMAL;
27         char *flash_name = NULL;
28         int ret;
29 +       const char __maybe_unused       *of_mtd_name = NULL;
30 +
31 +       of_property_read_string(spi->dev.of_node,
32 +               "linux,mtd-name", &of_mtd_name);
33  
34         data = dev_get_platdata(&spi->dev);
35  
36 @@ -212,6 +217,8 @@ static int m25p_probe(struct spi_device
37  
38         if (data && data->name)
39                 nor->mtd.name = data->name;
40 +       else if (of_mtd_name)
41 +               nor->mtd.name = of_mtd_name;
42  
43         /* For some (historical?) reason many platforms provide two different
44          * names in flash_platform_data: "name" and "type". Quite often name is