aboutsummaryrefslogtreecommitdiff
path: root/drivers/core/device.c
diff options
context:
space:
mode:
authorSimon Glass2020-01-27 08:49:47 -0700
committerSimon Glass2020-02-05 19:33:45 -0700
commitf262d4ca4b2bf8a99acb37c6151c54cd80251566 (patch)
treeb61079187edfb4d66f8fed45577f694e083beafb /drivers/core/device.c
parentbd933bfd834364bca6cc6f3a62e4255090a5bec1 (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.c36
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;