diff options
author | Lokesh Vutla <lokeshvutla@ti.com> | 2019-09-04 16:01:26 +0530 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-10-11 10:07:33 -0400 |
commit | 240b93201007183d5fd651a210ddb4c50ee30980 (patch) | |
tree | 0c26904b4c83bebecc358ac33aa1025ce13f1d0c /drivers/core/device.c | |
parent | bc74163a46208d1f9af8bfd2d06859b62145ef56 (diff) |
dm: core: Add a function to count the children of a device
Add a function to count the available children of a device.
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Diffstat (limited to 'drivers/core/device.c')
-rw-r--r-- | drivers/core/device.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c index 84f0f0fbf0..ce66c72e5e 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -568,6 +568,17 @@ int device_get_child(struct udevice *parent, int index, struct udevice **devp) return -ENODEV; } +int device_get_child_count(struct udevice *parent) +{ + struct udevice *dev; + int count = 0; + + list_for_each_entry(dev, &parent->child_head, sibling_node) + count++; + + return count; +} + int device_find_child_by_seq(struct udevice *parent, int seq_or_req_seq, bool find_req_seq, struct udevice **devp) { |