diff options
| author | Stephen Rothwell <sfr@canb.auug.org.au> | 2007-04-24 03:21:29 -0400 |
|---|---|---|
| committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2007-07-19 23:34:26 -0400 |
| commit | d1cd355a5e44dfe993efc0c0458ca9f99a28a9a3 (patch) | |
| tree | 9bcc28338f70b8c3c5076f2dbf0a8d3ce551f0b8 /drivers/of | |
| parent | e679c5f445fe142940e0962de9c5c82f10d9357c (diff) | |
Consolidate of_get_next_child
This adds a read_lock around the child/next accesses on Sparc.
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Acked-by: Paul Mackerras <paulus@samba.org>
Acked-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/of')
| -rw-r--r-- | drivers/of/base.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 82bb78680ff6..6b6dfcc56522 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
| @@ -134,3 +134,27 @@ struct device_node *of_get_parent(const struct device_node *node) | |||
| 134 | return np; | 134 | return np; |
| 135 | } | 135 | } |
| 136 | EXPORT_SYMBOL(of_get_parent); | 136 | EXPORT_SYMBOL(of_get_parent); |
| 137 | |||
| 138 | /** | ||
| 139 | * of_get_next_child - Iterate a node childs | ||
| 140 | * @node: parent node | ||
| 141 | * @prev: previous child of the parent node, or NULL to get first | ||
| 142 | * | ||
| 143 | * Returns a node pointer with refcount incremented, use | ||
| 144 | * of_node_put() on it when done. | ||
| 145 | */ | ||
| 146 | struct device_node *of_get_next_child(const struct device_node *node, | ||
| 147 | struct device_node *prev) | ||
| 148 | { | ||
| 149 | struct device_node *next; | ||
| 150 | |||
| 151 | read_lock(&devtree_lock); | ||
| 152 | next = prev ? prev->sibling : node->child; | ||
| 153 | for (; next; next = next->sibling) | ||
| 154 | if (of_node_get(next)) | ||
| 155 | break; | ||
| 156 | of_node_put(prev); | ||
| 157 | read_unlock(&devtree_lock); | ||
| 158 | return next; | ||
| 159 | } | ||
| 160 | EXPORT_SYMBOL(of_get_next_child); | ||
