mediatek: sync and patches add support for several boards
[openwrt.git] / target / linux / mediatek / patches-4.4 / 0056-mtd-add-get-set-of_node-flash_node-helpers.patch
1 From 6b4858de63badb90d820a1d343528d8575f3f28c Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Tue, 22 Mar 2016 03:52:07 +0100
4 Subject: [PATCH 56/90] mtd: add get/set of_node/flash_node helpers
5
6 We are going to begin using the mtd->dev.of_node field for MTD device
7 nodes, so let's add helpers for it. Also, we'll be making some
8 conversions on spi_nor (and nand_chip eventually) too, so get that ready
9 with their own helpers.
10
11 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
12 Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
13 ---
14  include/linux/mtd/mtd.h     |   11 +++++++++++
15  include/linux/mtd/nand.h    |   11 +++++++++++
16  include/linux/mtd/spi-nor.h |   11 +++++++++++
17  3 files changed, 33 insertions(+)
18
19 diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
20 index f17fa75..cc84923 100644
21 --- a/include/linux/mtd/mtd.h
22 +++ b/include/linux/mtd/mtd.h
23 @@ -254,6 +254,17 @@ struct mtd_info {
24         int usecount;
25  };
26  
27 +static inline void mtd_set_of_node(struct mtd_info *mtd,
28 +                                  struct device_node *np)
29 +{
30 +       mtd->dev.of_node = np;
31 +}
32 +
33 +static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)
34 +{
35 +       return mtd->dev.of_node;
36 +}
37 +
38  int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
39  int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
40               void **virt, resource_size_t *phys);
41 diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
42 index 1ded588..3c34ca4 100644
43 --- a/include/linux/mtd/nand.h
44 +++ b/include/linux/mtd/nand.h
45 @@ -741,6 +741,17 @@ static inline void nand_set_controller_data(struct nand_chip *chip, void *priv)
46         chip->priv = priv;
47  }
48  
49 +static inline void nand_set_flash_node(struct nand_chip *chip,
50 +                                      struct device_node *np)
51 +{
52 +       chip->flash_node = np;
53 +}
54 +
55 +static inline struct device_node *nand_get_flash_node(struct nand_chip *chip)
56 +{
57 +       return chip->flash_node;
58 +}
59 +
60  /*
61   * NAND Flash Manufacturer ID Codes
62   */
63 diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
64 index c8723b6..6d991df 100644
65 --- a/include/linux/mtd/spi-nor.h
66 +++ b/include/linux/mtd/spi-nor.h
67 @@ -185,6 +185,17 @@ struct spi_nor {
68         void *priv;
69  };
70  
71 +static inline void spi_nor_set_flash_node(struct spi_nor *nor,
72 +                                         struct device_node *np)
73 +{
74 +       nor->flash_node = np;
75 +}
76 +
77 +static inline struct device_node *spi_nor_get_flash_node(struct spi_nor *nor)
78 +{
79 +       return nor->flash_node;
80 +}
81 +
82  /**
83   * spi_nor_scan() - scan the SPI NOR
84   * @nor:       the spi_nor structure
85 -- 
86 1.7.10.4
87