summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-04-05 15:38:19 -0600
committerSimon Glass <sjg@chromium.org>2020-04-16 08:07:58 -0600
commitb0dcc87106464c3fc019e3771378a092fd32ebdb (patch)
tree21e2f8cce6e9a5f4c8d143b2bd3de23650b094ac /test
parent528d6b37ae81a6111e53fb8717a95b802c72a476 (diff)
dm: core: Read parent ofdata before children
At present a device can read its ofdata before its parent has done the same. This can cause problems in the case where the parent has a 'ranges' property, thus affecting the operation of dev_read_addr(), for example. We already probe parent devices before children so it does not seem to be a large step to do the same with ofdata. Make the change and update the documentation in this area. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Ley Foon Tan <ley.foon.tan@intel.com>
Diffstat (limited to 'test')
-rw-r--r--test/dm/test-fdt.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 7c9472a358..a56275aef9 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -992,3 +992,28 @@ static int dm_test_first_child_probe(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_first_child_probe, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that ofdata is read for parents before children */
+static int dm_test_ofdata_order(struct unit_test_state *uts)
+{
+ struct udevice *bus, *dev;
+
+ ut_assertok(uclass_find_first_device(UCLASS_I2C, &bus));
+ ut_assertnonnull(bus);
+ ut_assert(!(bus->flags & DM_FLAG_PLATDATA_VALID));
+
+ ut_assertok(device_find_first_child(bus, &dev));
+ ut_assertnonnull(dev);
+ ut_assert(!(dev->flags & DM_FLAG_PLATDATA_VALID));
+
+ /* read the child's ofdata which should cause the parent's to be read */
+ ut_assertok(device_ofdata_to_platdata(dev));
+ ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID);
+ ut_assert(bus->flags & DM_FLAG_PLATDATA_VALID);
+
+ ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
+ ut_assert(!(bus->flags & DM_FLAG_ACTIVATED));
+
+ return 0;
+}
+DM_TEST(dm_test_ofdata_order, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);