[U-Boot] [PATCH v6 05/31] mtd: add get/set of_node/flash_node helpers

Miquel Raynal miquel.raynal at bootlin.com
Thu Aug 16 15:30:03 UTC 2018


From: Brian Norris <computersforpeace at gmail.com>

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 at gmail.com>
Reviewed-by: Boris Brezillon <boris.brezillon at free-electrons.com>
Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>
Reviewed-by: Jagan Teki <jagan at openedev.com>
---
 include/linux/mtd/mtd.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index eb39f38887..73b19b57b1 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -306,6 +306,31 @@ struct mtd_info {
 	int usecount;
 };
 
+#if IS_ENABLED(CONFIG_DM)
+static inline void mtd_set_of_node(struct mtd_info *mtd,
+				   const struct device_node *np)
+{
+	mtd->dev->node.np = np;
+}
+
+static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd)
+{
+	return mtd->dev->node.np;
+}
+#else
+struct device_node;
+
+static inline void mtd_set_of_node(struct mtd_info *mtd,
+				   const struct device_node *np)
+{
+}
+
+static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd)
+{
+	return NULL;
+}
+#endif
+
 int mtd_ooblayout_ecc(struct mtd_info *mtd, int section,
 		      struct mtd_oob_region *oobecc);
 int mtd_ooblayout_find_eccregion(struct mtd_info *mtd, int eccbyte,
-- 
2.17.1



More information about the U-Boot mailing list