[PATCH] OF: base: fix iterator in of_get_next_available_child

Sebastian Hesselbarth sebastian.hesselbarth at gmail.com
Wed Jul 3 19:18:41 EDT 2013


of_get_next_available_child does not iterate but always tries the
same node over and over again. This first prepares the entry and
then uses list_for_each_entry_continue, instead of for_each_child_of_node
before.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth at gmail.com>
---
Note: This should be the last iterator fix required. I have tested all
for_each_ helpers. Thanks for Hiroki for reporting this and the initial
quick fix.

Unfortunately, I found this one after I sent the patch set.

Cc: barebox at lists.infradead.org
Cc: Hiroki Nishimoto <hiroki.nishimoto.if at gmail.com>
---
 drivers/of/base.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 0500c86..8c6dbcf 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1352,7 +1352,8 @@ EXPORT_SYMBOL(of_get_parent);
 struct device_node *of_get_next_available_child(const struct device_node *node,
 	struct device_node *prev)
 {
-	for_each_child_of_node(node, prev)
+	prev = list_prepare_entry(prev, &node->children, parent_list);
+	list_for_each_entry_continue(prev, &node->children, parent_list)
 		if (of_device_is_available(prev))
 			return prev;
 	return NULL;
-- 
1.7.10.4




More information about the barebox mailing list