summaryrefslogtreecommitdiff
path: root/drivers/core/device.c
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 /drivers/core/device.c
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 'drivers/core/device.c')
-rw-r--r--drivers/core/device.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 534cfa7314..0157bb1fe0 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -321,6 +321,22 @@ int device_ofdata_to_platdata(struct udevice *dev)
if (dev->flags & DM_FLAG_PLATDATA_VALID)
return 0;
+ /* Ensure all parents have ofdata */
+ if (dev->parent) {
+ ret = device_ofdata_to_platdata(dev->parent);
+ if (ret)
+ goto fail;
+
+ /*
+ * The device might have already been probed during
+ * the call to device_probe() on its parent device
+ * (e.g. PCI bridge devices). Test the flags again
+ * so that we don't mess up the device.
+ */
+ if (dev->flags & DM_FLAG_PLATDATA_VALID)
+ return 0;
+ }
+
drv = dev->driver;
assert(drv);