1 From 0d0e02d605c5696a5076510f564fefe659127aa4 Mon Sep 17 00:00:00 2001
2 From: Grant Likely <grant.likely@linaro.org>
3 Date: Thu, 22 May 2014 01:04:17 +0900
4 Subject: [PATCH] of: Create unlocked version of for_each_child_of_node()
6 When iterating over nodes, sometimes it needs to be done when the DT
7 lock is already held. This patch makes an unlocked version of the
8 for_each_child_of_node() macro.
10 Signed-off-by: Grant Likely <grant.likely@linaro.org>
12 drivers/of/base.c | 22 +++++++++++++++++-----
13 1 file changed, 17 insertions(+), 5 deletions(-)
15 --- a/drivers/of/base.c
16 +++ b/drivers/of/base.c
17 @@ -545,6 +545,22 @@ struct device_node *of_get_next_parent(s
19 EXPORT_SYMBOL(of_get_next_parent);
21 +static struct device_node *__of_get_next_child(const struct device_node *node,
22 + struct device_node *prev)
24 + struct device_node *next;
26 + next = prev ? prev->sibling : node->child;
27 + for (; next; next = next->sibling)
28 + if (of_node_get(next))
33 +#define __for_each_child_of_node(parent, child) \
34 + for (child = __of_get_next_child(parent, NULL); child != NULL; \
35 + child = __of_get_next_child(parent, child))
38 * of_get_next_child - Iterate a node childs
40 @@ -560,11 +576,7 @@ struct device_node *of_get_next_child(co
43 raw_spin_lock_irqsave(&devtree_lock, flags);
44 - next = prev ? prev->sibling : node->child;
45 - for (; next; next = next->sibling)
46 - if (of_node_get(next))
49 + next = __of_get_next_child(node, prev);
50 raw_spin_unlock_irqrestore(&devtree_lock, flags);