diff --git a/drivers/of/base.c b/drivers/of/base.c index 3e40a48..08ef1a1 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1570,6 +1570,23 @@ EXPORT_SYMBOL(of_get_next_available_child); /** + * of_get_next_child - Iterate a node childs + * @node: parent node + * @prev: previous child of the parent node, or NULL to get first + * + * Returns a node pointer with refcount incremented. + */ +struct device_node *of_get_next_child(const struct device_node *node, + struct device_node *prev) +{ + prev = list_prepare_entry(prev, &node->children, parent_list); + list_for_each_entry_continue(prev, &node->children, parent_list) + return prev; + return NULL; +} +EXPORT_SYMBOL(of_get_next_child); + +/** * of_get_child_count - Count child nodes of given parent node * @parent: parent node * diff --git a/include/of.h b/include/of.h index 1db210b..e0ebc39 100644 --- a/include/of.h +++ b/include/of.h @@ -153,6 +153,8 @@ extern struct device_node *of_get_parent(const struct device_node *node); extern struct device_node *of_get_next_available_child( const struct device_node *node, struct device_node *prev); +struct device_node *of_get_next_child(const struct device_node *node, + struct device_node *prev); extern int of_get_child_count(const struct device_node *parent); extern int of_get_available_child_count(const struct device_node *parent); extern struct device_node *of_get_child_by_name(const struct device_node *node, @@ -308,6 +310,12 @@ return NULL; } +static inline struct device_node *of_get_next_child(const struct device_node *node, + struct device_node *prev) +{ + return NULL; +} + static inline int of_get_child_count(const struct device_node *parent) { return -ENOSYS;