Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 322028
b: refs/heads/master
c: 3296193
h: refs/heads/master
v: v3
  • Loading branch information
Timur Tabi authored and David S. Miller committed Aug 20, 2012
1 parent 69bf783 commit 521e3f1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 476ad154f3b41dd7d9a08a2f641e28388abc2fd1
refs/heads/master: 3296193d1421c2d6f9e49e181cecfd917f0f5764
27 changes: 27 additions & 0 deletions trunk/drivers/of/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,33 @@ struct device_node *of_get_next_child(const struct device_node *node,
}
EXPORT_SYMBOL(of_get_next_child);

/**
* of_get_next_available_child - Find the next available child node
* @node: parent node
* @prev: previous child of the parent node, or NULL to get first
*
* This function is like of_get_next_child(), except that it
* automatically skips any disabled nodes (i.e. status = "disabled").
*/
struct device_node *of_get_next_available_child(const struct device_node *node,
struct device_node *prev)
{
struct device_node *next;

read_lock(&devtree_lock);
next = prev ? prev->sibling : node->child;
for (; next; next = next->sibling) {
if (!of_device_is_available(next))
continue;
if (of_node_get(next))
break;
}
of_node_put(prev);
read_unlock(&devtree_lock);
return next;
}
EXPORT_SYMBOL(of_get_next_available_child);

/**
* of_find_node_by_path - Find a node matching a full OF path
* @path: The full path to match
Expand Down
7 changes: 7 additions & 0 deletions trunk/include/linux/of.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,17 @@ extern struct device_node *of_get_parent(const struct device_node *node);
extern struct device_node *of_get_next_parent(struct device_node *node);
extern struct device_node *of_get_next_child(const struct device_node *node,
struct device_node *prev);
extern struct device_node *of_get_next_available_child(
const struct device_node *node, struct device_node *prev);

#define for_each_child_of_node(parent, child) \
for (child = of_get_next_child(parent, NULL); child != NULL; \
child = of_get_next_child(parent, child))

#define for_each_available_child_of_node(parent, child) \
for (child = of_get_next_available_child(parent, NULL); child != NULL; \
child = of_get_next_available_child(parent, child))

static inline int of_get_child_count(const struct device_node *np)
{
struct device_node *child;
Expand Down

0 comments on commit 521e3f1

Please sign in to comment.