From: Peng Fan <van.freenix@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] fdt: introudce fdt_get_child_count
Date: Sun, 31 Jan 2016 14:38:46 +0800 [thread overview]
Message-ID: <1454222326-32590-1-git-send-email-van.freenix@gmail.com> (raw)
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 */
/**********************************************************************/
--
2.6.2
next reply other threads:[~2016-01-31 6:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-31 6:38 Peng Fan [this message]
2016-01-31 13:19 ` [U-Boot] [PATCH] fdt: introudce fdt_get_child_count Fabio Estevam
2016-01-31 15:37 ` Simon Glass
2016-02-01 1:13 ` Peng Fan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1454222326-32590-1-git-send-email-van.freenix@gmail.com \
--to=van.freenix@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox