dm: core: Access device ofnode through functions
At present ofnode is present in the device even if it is never used. With
of-platdata this field is not used, so can be removed. In preparation for
this, change the access to go through inline functions.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/include/dm/device.h b/include/dm/device.h
index 4a1224b..1b27420 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -200,7 +200,11 @@
*/
static inline ofnode dev_ofnode(const struct udevice *dev)
{
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
return dev->node;
+#else
+ return ofnode_null();
+#endif
}
/* Returns non-zero if the device is active (probed and not removed) */
@@ -208,12 +212,27 @@
static inline int dev_of_offset(const struct udevice *dev)
{
- return ofnode_to_offset(dev->node);
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+ return ofnode_to_offset(dev_ofnode(dev));
+#else
+ return -1;
+#endif
}
static inline bool dev_has_ofnode(const struct udevice *dev)
{
- return ofnode_valid(dev->node);
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+ return ofnode_valid(dev_ofnode(dev));
+#else
+ return false;
+#endif
+}
+
+static inline void dev_set_ofnode(struct udevice *dev, ofnode node)
+{
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+ dev->node = node;
+#endif
}
static inline int dev_seq(const struct udevice *dev)
diff --git a/include/dm/read.h b/include/dm/read.h
index d5cdd87..fc987f7 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -21,7 +21,7 @@
#if CONFIG_IS_ENABLED(OF_LIVE)
static inline const struct device_node *dev_np(const struct udevice *dev)
{
- return ofnode_to_np(dev->node);
+ return ofnode_to_np(dev_ofnode(dev));
}
#else
static inline const struct device_node *dev_np(const struct udevice *dev)
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 54d03d0..9278549 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -334,12 +334,12 @@
#if IS_ENABLED(CONFIG_DM)
static inline void mtd_set_ofnode(struct mtd_info *mtd, ofnode node)
{
- mtd->dev->node = node;
+ dev_set_ofnode(mtd->dev, node);
}
static inline const ofnode mtd_get_ofnode(struct mtd_info *mtd)
{
- return mtd->dev->node;
+ return dev_ofnode(mtd->dev);
}
#else
struct device_node;