Skip to contentSkip to conversation

fdt: introudce fdt_get_child_count

PATCH New Peng Fan 3 participants 4 messages Jan 31, 2016 – Feb 1, 2016

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH 1/1 fdt: introudce fdt_get_child_count

Introudce fdt_get_child_count for get the number of subnodes of one parent node.

---
 include/libfdt.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/libfdt.h +18 -0
index e48c21a..94d29e6 100644
@@ -193,6 +193,24 @@ int fdt_next_subnode(const void *fdt, int offset);
 	     node >= 0;					\
 	     node = fdt_next_subnode(fdt, node))
 
+/**
+ * fdt_get_child_count() - get the number of subnodes of one node
+ *
+ * @fdt:	FDT blob
+ * @node:	Offset of node
+ * @return number of child nodes of node, or 0 if there is no subnode.
+ */
+static inline int fdt_get_child_count(void *fdt, int node)
+{
+	int subnode;
+	int num = 0;
+
+	fdt_for_each_subnode(fdt, subnode, node)
+		num++;
+
+	return num;
+}
+
 /**********************************************************************/
 /* General functions                                                  */
 /**********************************************************************/
Signature · 1 line
2.6.2
#1 lore raw

PATCH 1/1 fdt: introudce fdt_get_child_count

Quoted 1 line · Peng Fan

Introudce fdt_get_child_count for get the number of subnodes of

s/Introudce/Introduce

Same error in Subject.

#2 lore raw

PATCH 1/1 fdt: introudce fdt_get_child_count

In reply to Peng Fan

Hi Peng,

Quoted 15 lines · Peng Fan

Introudce fdt_get_child_count for get the number of subnodes of one parent node.

---
 include/libfdt.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/libfdt.h +0 -0
index e48c21a..94d29e6 100644
@@ -193,6 +193,24 @@ int fdt_next_subnode(const void *fdt, int offset);
             node >= 0;                                 \

include/libfdt.h int fdt_next_subnode(const void *fdt, int offset); · line 203

Quoted 10 lines
include/libfdt.h +8 -0
             node = fdt_next_subnode(fdt, node))
 
+/**
+ * fdt_get_child_count() - get the number of subnodes of one node
+ *
+ * @fdt:       FDT blob
+ * @node:      Offset of node
+ * @return number of child nodes of node, or 0 if there is no subnode.
+ */
+static inline int fdt_get_child_count(void *fdt, int node)

Does this need to be inline. It doesn't seem important to me.

Quoted 14 lines
include/libfdt.h +10 -1
+{
+       int subnode;
+       int num = 0;
+
+       fdt_for_each_subnode(fdt, subnode, node)
+               num++;
+
+       return num;
+}
+
 /**********************************************************************/
 /* General functions                                                  */
 /**********************************************************************/
--
Quoted 2 lines

2.6.2

Regards,
Simon

author
#3 lore raw

PATCH 1/1 fdt: introudce fdt_get_child_count

Hi Simon,

Quoted 20 lines · Simon Glass

Hi Peng,

Quoted 17 lines · Peng Fan

Introudce fdt_get_child_count for get the number of subnodes of one parent node.

---
 include/libfdt.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/libfdt.h +0 -0
index e48c21a..94d29e6 100644
@@ -193,6 +193,24 @@ int fdt_next_subnode(const void *fdt, int offset);
             node >= 0;                                 \
             node = fdt_next_subnode(fdt, node))
 
Quoted 10 lines

include/libfdt.h int fdt_next_subnode(const void *fdt, int offset); · line 203

Quoted 8 lines
include/libfdt.h +8 -0
+/**
+ * fdt_get_child_count() - get the number of subnodes of one node
+ *
+ * @fdt:       FDT blob
+ * @node:      Offset of node
+ * @return number of child nodes of node, or 0 if there is no subnode.
+ */
+static inline int fdt_get_child_count(void *fdt, int node)

Does this need to be inline. It doesn't seem important to me.

I just follow linux kernel and add inline. If inline is not needed, I can move the piece code to lib/fdtdec.c.

You mean this API is not important?

Thanks,
Peng

Quoted 20 lines
Quoted 15 lines
include/libfdt.h +10 -1
+{
+       int subnode;
+       int num = 0;
+
+       fdt_for_each_subnode(fdt, subnode, node)
+               num++;
+
+       return num;
+}
+
 /**********************************************************************/
 /* General functions                                                  */
 /**********************************************************************/
--
Quoted 2 lines

2.6.2

Regards,
Simon