diff options
author | Simon Glass | 2020-01-27 08:49:47 -0700 |
---|---|---|
committer | Simon Glass | 2020-02-05 19:33:45 -0700 |
commit | f262d4ca4b2bf8a99acb37c6151c54cd80251566 (patch) | |
tree | b61079187edfb4d66f8fed45577f694e083beafb /drivers/core/device.c | |
parent | bd933bfd834364bca6cc6f3a62e4255090a5bec1 (diff) |
dm: core: Add a way to read platdata for all child devices
When generating ACPI tables we need to make sure that all devices have
read their platform data, so that they can generate the tables correctly.
Rather than adding this code in ACPI, create a core function to handle it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core/device.c')
-rw-r--r-- | drivers/core/device.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c index b7f59fcde34..c948d8dbbc8 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -792,6 +792,42 @@ int device_find_child_by_name(const struct udevice *parent, const char *name, return -ENODEV; } +int device_first_child_ofdata_err(struct udevice *parent, struct udevice **devp) +{ + struct udevice *dev; + int ret; + + device_find_first_child(parent, &dev); + if (!dev) + return -ENODEV; + + ret = device_ofdata_to_platdata(dev); + if (ret) + return ret; + + *devp = dev; + + return 0; +} + +int device_next_child_ofdata_err(struct udevice **devp) +{ + struct udevice *dev = *devp; + int ret; + + device_find_next_child(&dev); + if (!dev) + return -ENODEV; + + ret = device_ofdata_to_platdata(dev); + if (ret) + return ret; + + *devp = dev; + + return 0; +} + struct udevice *dev_get_parent(const struct udevice *child) { return child->parent; |