[PATCH 4/8] dm: core: Add function to get child count of ofnode

Chunfeng Yun chunfeng.yun at mediatek.com
Wed Mar 11 07:50:41 CET 2020


This patch add a function used to get the child count of
a ofnode

Signed-off-by: Chunfeng Yun <chunfeng.yun at mediatek.com>
---
 include/dm/ofnode.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index b5a50e8849..b2c0118a36 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -793,6 +793,23 @@ ofnode ofnode_by_prop_value(ofnode from, const char *propname,
 	     ofnode_valid(node); \
 	     node = ofnode_next_subnode(node))
 
+/**
+ * ofnode_get_child_count() - get the child count of a ofnode
+ *
+ * @node:	valid node ot get its child count
+ * @return the count of child subnode
+ */
+static inline int ofnode_get_child_count(ofnode parent)
+{
+	ofnode child;
+	int num = 0;
+
+	ofnode_for_each_subnode(child, parent)
+		num++;
+
+	return num;
+}
+
 /**
  * ofnode_translate_address() - Translate a device-tree address
  *
-- 
2.25.1


More information about the U-Boot mailing list