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: Frank Wunderlich <frank-w@public-files.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 20871a6..e3c42da 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -474,6 +474,17 @@
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)
{