dm: Use an allocated array for run-time device info
At present we update the driver_info struct with a pointer to the device
that it created (i.e. caused to be bound). This works fine when U-Boot SPL
is stored in read-write memory. But on some platforms, such as Intel
Apollo Lake, it is not possible to update the data memory.
In any case, it is bad form to put this information in a structure that is
in the data region, since it expands the size of the binary.
Create a new driver_rt structure which holds runtime information about
drivers. Update the code to store the device pointer in this instead.
Also update the test check that this works.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c
index 57f9036..e827d45 100644
--- a/test/dm/of_platdata.c
+++ b/test/dm/of_platdata.c
@@ -109,16 +109,16 @@
/* If not the root device, find the entry that caused it to be bound */
if (parent->parent) {
- const struct driver_info *info =
- ll_entry_start(struct driver_info, driver_info);
const int n_ents =
ll_entry_count(struct driver_info, driver_info);
- const struct driver_info *entry;
int idx = -1;
+ int i;
- for (entry = info; entry != info + n_ents; entry++) {
- if (entry->dev == parent) {
- idx = entry - info;
+ for (i = 0; i < n_ents; i++) {
+ const struct driver_rt *drt = gd_dm_driver_rt() + i;
+
+ if (drt->dev == parent) {
+ idx = i;
found[idx] = true;
break;
}
@@ -153,16 +153,17 @@
/* Make sure that the driver entries without devices have no ->dev */
for (i = 0; i < n_ents; i++) {
+ const struct driver_rt *drt = gd_dm_driver_rt() + i;
const struct driver_info *entry = info + i;
struct udevice *dev;
if (found[i]) {
/* Make sure we can find it */
- ut_assertnonnull(entry->dev);
+ ut_assertnonnull(drt->dev);
ut_assertok(device_get_by_driver_info(entry, &dev));
- ut_asserteq_ptr(dev, entry->dev);
+ ut_asserteq_ptr(dev, drt->dev);
} else {
- ut_assertnull(entry->dev);
+ ut_assertnull(drt->dev);
ut_asserteq(-ENOENT,
device_get_by_driver_info(entry, &dev));
}