summaryrefslogtreecommitdiffstats
path: root/include/linux/of.h
diff options
context:
space:
mode:
authorDong Aisheng <dong.aisheng@linaro.org>2012-04-27 11:36:20 +0800
committerLinus Walleij <linus.walleij@linaro.org>2012-05-02 01:14:40 +0200
commit183f1d0c6450ee032d97a2d01ed5eb00e0dbaa49 (patch)
treeac3cd2f9a264f7f5c5ad15ec56eda8e27cc18573 /include/linux/of.h
parent4650b7cbea4db73f459181f67f939b510e3a17b2 (diff)
downloadop-kernel-dev-183f1d0c6450ee032d97a2d01ed5eb00e0dbaa49.zip
op-kernel-dev-183f1d0c6450ee032d97a2d01ed5eb00e0dbaa49.tar.gz
dt: add of_get_child_count helper function
Currently most code to get child count in kernel are almost same, add a helper to implement this function for dt to use. Cc: Grant Likely <grant.likely@secretlab.ca> Acked-by: Rob Herring <rob.herring@calxeda.com> Acked-by: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'include/linux/of.h')
-rw-r--r--include/linux/of.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/of.h b/include/linux/of.h
index e3f942d..2ec1083 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -193,6 +193,17 @@ extern struct device_node *of_get_next_child(const struct device_node *node,
for (child = of_get_next_child(parent, NULL); child != NULL; \
child = of_get_next_child(parent, child))
+static inline int of_get_child_count(const struct device_node *np)
+{
+ struct device_node *child;
+ int num = 0;
+
+ for_each_child_of_node(np, child)
+ num++;
+
+ return num;
+}
+
extern struct device_node *of_find_node_with_property(
struct device_node *from, const char *prop_name);
#define for_each_node_with_property(dn, prop_name) \
@@ -300,6 +311,11 @@ static inline bool of_have_populated_dt(void)
#define for_each_child_of_node(parent, child) \
while (0)
+static inline int of_get_child_count(const struct device_node *np)
+{
+ return 0;
+}
+
static inline int of_device_is_compatible(const struct device_node *device,
const char *name)
{
OpenPOWER on IntegriCloud