From 89b84b85e9c5d80e1b5eb5b52cc6596ba32135c7 Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Sat, 2 May 2020 11:35:09 +0200 Subject: dm: core: Add function to get child count of ofnode or device This patch add function used to get the child count of a ofnode or a device Signed-off-by: Chunfeng Yun Signed-off-by: Frank Wunderlich Reviewed-by: Weijie Gao Reviewed-by: Simon Glass --- drivers/core/ofnode.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers/core/ofnode.c') diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 20871a6815..e3c42dae5c 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -474,6 +474,17 @@ ofnode ofnode_get_chosen_node(const char *name) return ofnode_path(prop); } +int ofnode_get_child_count(ofnode parent) +{ + ofnode child; + int num = 0; + + ofnode_for_each_subnode(child, parent) + num++; + + return num; +} + static int decode_timing_property(ofnode node, const char *name, struct timing_entry *result) { -- cgit