[PATCH v3 30/42] dm: core: Use separate priv/plat data region
Simon Glass
sjg at chromium.org
Mon Feb 8 05:17:55 CET 2021
Make use of the new priv/plat data region if enabled. This is implemented
as a simple offset from the position set up by dtoc to the new position.
So long as all access goes through dm_priv_to_rw() this is safe.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
(no changes since v1)
drivers/core/device.c | 12 ++++++------
drivers/core/root.c | 9 +++++++++
include/dm/util.h | 9 +++++++++
3 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 9c06f43f83c..049462e6b7b 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -558,7 +558,7 @@ void *dev_get_plat(const struct udevice *dev)
return NULL;
}
- return dev->plat_;
+ return dm_priv_to_rw(dev->plat_);
}
void *dev_get_parent_plat(const struct udevice *dev)
@@ -568,7 +568,7 @@ void *dev_get_parent_plat(const struct udevice *dev)
return NULL;
}
- return dev->parent_plat_;
+ return dm_priv_to_rw(dev->parent_plat_);
}
void *dev_get_uclass_plat(const struct udevice *dev)
@@ -578,7 +578,7 @@ void *dev_get_uclass_plat(const struct udevice *dev)
return NULL;
}
- return dev->uclass_plat_;
+ return dm_priv_to_rw(dev->uclass_plat_);
}
void *dev_get_priv(const struct udevice *dev)
@@ -588,7 +588,7 @@ void *dev_get_priv(const struct udevice *dev)
return NULL;
}
- return dev->priv_;
+ return dm_priv_to_rw(dev->priv_);
}
void *dev_get_uclass_priv(const struct udevice *dev)
@@ -598,7 +598,7 @@ void *dev_get_uclass_priv(const struct udevice *dev)
return NULL;
}
- return dev->uclass_priv_;
+ return dm_priv_to_rw(dev->uclass_priv_);
}
void *dev_get_parent_priv(const struct udevice *dev)
@@ -608,7 +608,7 @@ void *dev_get_parent_priv(const struct udevice *dev)
return NULL;
}
- return dev->parent_priv_;
+ return dm_priv_to_rw(dev->parent_priv_);
}
static int device_get_device_tail(struct udevice *dev, int ret,
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 947d1cdb912..f280eff9a7e 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -346,6 +346,15 @@ __weak int dm_scan_other(bool pre_reloc_only)
return 0;
}
+#if CONFIG_IS_ENABLED(OF_PLATDATA_INST) && CONFIG_IS_ENABLED(READ_ONLY)
+void *dm_priv_to_rw(void *priv)
+{
+ long offset = priv - (void *)__priv_data_start;
+
+ return gd_dm_priv_base() + offset;
+}
+#endif
+
/**
* dm_scan() - Scan tables to bind devices
*
diff --git a/include/dm/util.h b/include/dm/util.h
index 01a044992f2..138893c9354 100644
--- a/include/dm/util.h
+++ b/include/dm/util.h
@@ -49,3 +49,12 @@ void dm_dump_driver_compat(void);
void dm_dump_static_driver_info(void);
#endif
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA_INST) && CONFIG_IS_ENABLED(READ_ONLY)
+void *dm_priv_to_rw(void *priv);
+#else
+static inline void *dm_priv_to_rw(void *priv)
+{
+ return priv;
+}
+#endif
--
2.30.0.478.g8a0d178c01-goog
More information about the U-Boot
mailing list