
Introudce fdt_get_child_count for get the number of subnodes of one parent node.
Signed-off-by: Peng Fan van.freenix@gmail.com Cc: Simon Glass sjg@chromium.org --- include/libfdt.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/include/libfdt.h b/include/libfdt.h index e48c21a..94d29e6 100644 --- a/include/libfdt.h +++ b/include/libfdt.h @@ -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 */ /**********************************************************************/