Commit 183f1d0c authored by Dong Aisheng's avatar Dong Aisheng Committed by Linus Walleij

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: default avatarRob Herring <rob.herring@calxeda.com>
Acked-by: default avatarStephen Warren <swarren@wwwdotorg.org>
Signed-off-by: default avatarDong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 4650b7cb
...@@ -193,6 +193,17 @@ extern struct device_node *of_get_next_child(const struct device_node *node, ...@@ -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; \ for (child = of_get_next_child(parent, NULL); child != NULL; \
child = of_get_next_child(parent, child)) 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( extern struct device_node *of_find_node_with_property(
struct device_node *from, const char *prop_name); struct device_node *from, const char *prop_name);
#define for_each_node_with_property(dn, prop_name) \ #define for_each_node_with_property(dn, prop_name) \
...@@ -300,6 +311,11 @@ static inline bool of_have_populated_dt(void) ...@@ -300,6 +311,11 @@ static inline bool of_have_populated_dt(void)
#define for_each_child_of_node(parent, child) \ #define for_each_child_of_node(parent, child) \
while (0) 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, static inline int of_device_is_compatible(const struct device_node *device,
const char *name) const char *name)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment