summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-10-03 11:31:33 -0600
committerSimon Glass <sjg@chromium.org>2020-10-29 14:42:18 -0600
commita294ead8d2531a641f87bf182fee257029973ac0 (patch)
tree005705b193a11822a09bb0cf32dad428968b35ec /test
parent88280529bddf0bd05c90db42b6c8e48de954cf66 (diff)
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>
Diffstat (limited to 'test')
-rw-r--r--test/dm/of_platdata.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c
index 57f903611a..e827d45ffb 100644
--- a/test/dm/of_platdata.c
+++ b/test/dm/of_platdata.c
@@ -109,16 +109,16 @@ static int find_driver_info(struct unit_test_state *uts, struct udevice *parent,
/* 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 @@ static int dm_test_of_platdata_dev(struct unit_test_state *uts)
/* 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));
}