|
@@ -695,6 +695,22 @@ struct device_node *of_get_next_parent(struct device_node *node)
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(of_get_next_parent);
|
|
EXPORT_SYMBOL(of_get_next_parent);
|
|
|
|
|
|
|
|
+static struct device_node *__of_get_next_child(const struct device_node *node,
|
|
|
|
+ struct device_node *prev)
|
|
|
|
+{
|
|
|
|
+ struct device_node *next;
|
|
|
|
+
|
|
|
|
+ next = prev ? prev->sibling : node->child;
|
|
|
|
+ for (; next; next = next->sibling)
|
|
|
|
+ if (of_node_get(next))
|
|
|
|
+ break;
|
|
|
|
+ of_node_put(prev);
|
|
|
|
+ return next;
|
|
|
|
+}
|
|
|
|
+#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))
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* of_get_next_child - Iterate a node childs
|
|
* of_get_next_child - Iterate a node childs
|
|
* @node: parent node
|
|
* @node: parent node
|
|
@@ -710,11 +726,7 @@ struct device_node *of_get_next_child(const struct device_node *node,
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
|
|
|
|
raw_spin_lock_irqsave(&devtree_lock, flags);
|
|
raw_spin_lock_irqsave(&devtree_lock, flags);
|
|
- next = prev ? prev->sibling : node->child;
|
|
|
|
- for (; next; next = next->sibling)
|
|
|
|
- if (of_node_get(next))
|
|
|
|
- break;
|
|
|
|
- of_node_put(prev);
|
|
|
|
|
|
+ next = __of_get_next_child(node, prev);
|
|
raw_spin_unlock_irqrestore(&devtree_lock, flags);
|
|
raw_spin_unlock_irqrestore(&devtree_lock, flags);
|
|
return next;
|
|
return next;
|
|
}
|
|
}
|