mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 08:42:12 +02:00
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>
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user