[PATCH 19/30] dm: core: Move flags to device-runtime info

Simon Glass sjg at chromium.org
Thu Dec 31 05:09:49 CET 2020


When of-platdata-inst is active, use the flags in the new udevice_rt
table, dropping them from the main struct udevice. This ensures that the
latter is not updated at runtime.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 drivers/core/device.c | 33 +++++++++++++++++++++++++++++++++
 include/dm/device.h   | 10 +++++++++-
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index cdcf5f43ad2..2fe42888e90 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -1077,3 +1077,36 @@ int dev_enable_by_path(const char *path)
 	return lists_bind_fdt(parent, node, NULL, false);
 }
 #endif
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
+static struct udevice_rt *dev_get_rt(const struct udevice *dev)
+{
+	struct udevice *base = ll_entry_start(struct udevice, udevice);
+	int idx = dev - base;
+
+	struct udevice_rt *urt = gd_dm_udevice_rt() + idx;
+
+	return urt;
+}
+
+u32 dev_get_flags(const struct udevice *dev)
+{
+	const struct udevice_rt *urt = dev_get_rt(dev);
+
+	return urt->flags_;
+}
+
+void dev_or_flags(const struct udevice *dev, u32 or)
+{
+	struct udevice_rt *urt = dev_get_rt(dev);
+
+	urt->flags_ |= or;
+}
+
+void dev_bic_flags(const struct udevice *dev, u32 bic)
+{
+	struct udevice_rt *urt = dev_get_rt(dev);
+
+	urt->flags_ &= ~bic;
+}
+#endif /* OF_PLATDATA_RT */
diff --git a/include/dm/device.h b/include/dm/device.h
index ba62b5f0365..b89cc89988e 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -164,11 +164,13 @@ struct udevice {
 	struct list_head uclass_node;
 	struct list_head child_head;
 	struct list_head sibling_node;
-	u32 flags_;
 	int seq_;
 #if !CONFIG_IS_ENABLED(OF_PLATDATA_RT)
 	ofnode node_;
 #endif
+#if !CONFIG_IS_ENABLED(OF_PLATDATA_RT)
+	u32 flags_;
+#endif
 #ifdef CONFIG_DEVRES
 	struct list_head devres_head;
 #endif
@@ -195,6 +197,11 @@ struct udevice_rt {
 /* Returns the operations for a device */
 #define device_get_ops(dev)	(dev->driver->ops)
 
+#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
+u32 dev_get_flags(const struct udevice *dev);
+void dev_or_flags(const struct udevice *dev, u32 or);
+void dev_bic_flags(const struct udevice *dev, u32 bic);
+#else
 static inline u32 dev_get_flags(const struct udevice *dev)
 {
 	return dev->flags_;
@@ -209,6 +216,7 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic)
 {
 	dev->flags_ &= ~bic;
 }
+#endif /* OF_PLATDATA_RT */
 
 /**
  * dev_ofnode() - get the DT node reference associated with a udevice
-- 
2.29.2.729.g45daf8777d-goog



More information about the U-Boot mailing list