mtd: add get/set of_node/flash_node helpers
authorBrian Norris <computersforpeace@gmail.com>
Sat, 31 Oct 2015 03:33:20 +0000 (20:33 -0700)
committerBrian Norris <computersforpeace@gmail.com>
Wed, 11 Nov 2015 21:45:05 +0000 (13:45 -0800)
We are going to begin using the mtd->dev.of_node field for MTD device
nodes, so let's add helpers for it. Also, we'll be making some
conversions on spi_nor (and nand_chip eventually) too, so get that ready
with their own helpers.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
include/linux/mtd/mtd.h
include/linux/mtd/nand.h
include/linux/mtd/spi-nor.h

index f17fa75809aa1d05a6164fabb4f02b87106c4657..cc84923011c0654118b0ae32d2ff4dc9cf66b250 100644 (file)
@@ -254,6 +254,17 @@ struct mtd_info {
        int usecount;
 };
 
+static inline void mtd_set_of_node(struct mtd_info *mtd,
+                                  struct device_node *np)
+{
+       mtd->dev.of_node = np;
+}
+
+static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)
+{
+       return mtd->dev.of_node;
+}
+
 int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
 int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
              void **virt, resource_size_t *phys);
index 5a9d1d4c2487fc2cf8f08489f317bf60df93b06f..4f7c9b97982f649a07765532ac18b60762e194b6 100644 (file)
@@ -719,6 +719,17 @@ struct nand_chip {
        void *priv;
 };
 
+static inline void nand_set_flash_node(struct nand_chip *chip,
+                                      struct device_node *np)
+{
+       chip->flash_node = np;
+}
+
+static inline struct device_node *nand_get_flash_node(struct nand_chip *chip)
+{
+       return chip->flash_node;
+}
+
 /*
  * NAND Flash Manufacturer ID Codes
  */
index c8723b62c4cd286aa7b6b382507dbb25cd975ab1..6d991df8f98630236f0df7e867491b136811caea 100644 (file)
@@ -185,6 +185,17 @@ struct spi_nor {
        void *priv;
 };
 
+static inline void spi_nor_set_flash_node(struct spi_nor *nor,
+                                         struct device_node *np)
+{
+       nor->flash_node = np;
+}
+
+static inline struct device_node *spi_nor_get_flash_node(struct spi_nor *nor)
+{
+       return nor->flash_node;
+}
+
 /**
  * spi_nor_scan() - scan the SPI NOR
  * @nor:       the spi_nor structure