diff options
author | Simon Glass <sjg@chromium.org> | 2020-01-27 08:49:48 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2020-02-05 19:33:45 -0700 |
commit | 903e83ee84649c1a70bfd8b9ec84dacb8c24e7cb (patch) | |
tree | 3b22285081f2921225d80a4c7437bf618335262a /drivers/core/device.c | |
parent | f262d4ca4b2bf8a99acb37c6151c54cd80251566 (diff) |
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>
Diffstat (limited to 'drivers/core/device.c')
-rw-r--r-- | drivers/core/device.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c index c948d8dbbc..89ea820d48 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -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; |