Skip to content

Commit

Permalink
dt: add of_get_child_count helper function
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dong Aisheng authored and Linus Walleij committed May 1, 2012
1 parent 4650b7c commit 183f1d0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions include/linux/of.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 183f1d0

Please sign in to comment.