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>
This commit is contained in:
Lokesh Vutla
2019-09-04 16:01:26 +05:30
committed by Tom Rini
parent bc74163a46
commit 240b932010
3 changed files with 35 additions and 26 deletions

View File

@@ -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)
{