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>
This commit is contained in:
Simon Glass
2020-01-27 08:49:47 -07:00
parent bd933bfd83
commit f262d4ca4b
4 changed files with 99 additions and 1 deletions

View File

@@ -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;