diff options
author | Simon Glass <sjg@chromium.org> | 2018-10-01 12:22:07 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-10-09 04:40:27 -0600 |
commit | cdb6aa0afb52da34306c4339f2f4d6cbd3b0ad02 (patch) | |
tree | 4940b03e27947c496c460da6df96d719fe29dedc /drivers/core | |
parent | 9f15cc14bf88a9ee8d7b1fbf607cde22923889d6 (diff) | |
download | u-boot-cdb6aa0afb52da34306c4339f2f4d6cbd3b0ad02.tar.gz |
dm: core: Add a function to find the first inactive child
Some devices have children and want to press an existing inactive child
into service when needed. Add a function to help with this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core')
-rw-r--r-- | drivers/core/device.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c index a9e5906e7c..5176aa3f86 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -681,6 +681,24 @@ int device_find_next_child(struct udevice **devp) return 0; } +int device_find_first_inactive_child(struct udevice *parent, + enum uclass_id uclass_id, + struct udevice **devp) +{ + struct udevice *dev; + + *devp = NULL; + list_for_each_entry(dev, &parent->child_head, sibling_node) { + if (!device_active(dev) && + device_get_uclass_id(dev) == uclass_id) { + *devp = dev; + return 0; + } + } + + return -ENODEV; +} + struct udevice *dev_get_parent(const struct udevice *child) { return child->parent; |