[PATCH 01/13] of: base: implement of_get_next_child
Sascha Hauer
s.hauer at pengutronix.de
Thu Jul 9 00:24:05 PDT 2015
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/of/base.c | 17 +++++++++++++++++
include/of.h | 8 ++++++++
2 files changed, 25 insertions(+)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 3e40a48..0eb1d6b 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1570,6 +1570,23 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
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_available_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 int of_device_is_available(const struct device_node *device);
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 @@ static inline struct device_node *of_get_next_available_child(
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;
--
2.1.4
More information about the barebox
mailing list