aboutsummaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
authorLokesh Vutla <lokeshvutla@ti.com>2019-09-04 16:01:26 +0530
committerTom Rini <trini@konsulko.com>2019-10-11 10:07:33 -0400
commit240b93201007183d5fd651a210ddb4c50ee30980 (patch)
tree0c26904b4c83bebecc358ac33aa1025ce13f1d0c /drivers/core
parentbc74163a46208d1f9af8bfd2d06859b62145ef56 (diff)
downloadu-boot-240b93201007183d5fd651a210ddb4c50ee30980.zip
u-boot-240b93201007183d5fd651a210ddb4c50ee30980.tar.gz
u-boot-240b93201007183d5fd651a210ddb4c50ee30980.tar.bz2
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')
-rw-r--r--drivers/core/device.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 84f0f0f..ce66c72 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)
{