dm: core: Add a way to iterate through children, probing each

It is sometimes useful to process all children, making sure they are
probed first. Add functions to help with this and a macro to make it more
convenient.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2020-01-27 08:49:48 -07:00
parent f262d4ca4b
commit 903e83ee84
3 changed files with 80 additions and 0 deletions

View File

@@ -792,6 +792,28 @@ int device_find_child_by_name(const struct udevice *parent, const char *name,
return -ENODEV;
}
int device_first_child_err(struct udevice *parent, struct udevice **devp)
{
struct udevice *dev;
device_find_first_child(parent, &dev);
if (!dev)
return -ENODEV;
return device_get_device_tail(dev, 0, devp);
}
int device_next_child_err(struct udevice **devp)
{
struct udevice *dev = *devp;
device_find_next_child(&dev);
if (!dev)
return -ENODEV;
return device_get_device_tail(dev, 0, devp);
}
int device_first_child_ofdata_err(struct udevice *parent, struct udevice **devp)
{
struct udevice *dev;