From 6c65b0741a48ed7daf3b62938de7773ad35b123e Mon Sep 17 00:00:00 2001 From: Michael Ellerman Date: Fri, 26 Oct 2007 16:54:31 +1000 Subject: [PATCH] --- yaml --- r: 83936 b: refs/heads/master c: f4eb010706b6c96c136c7aaa9079159743f33fa8 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/of/base.c | 25 +++++++++++++++++++++++++ trunk/include/linux/of.h | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 571947941dd0..5ec53455f926 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 58119068cb27ef7513f80aff44b62a3a8f40ef5f +refs/heads/master: f4eb010706b6c96c136c7aaa9079159743f33fa8 diff --git a/trunk/drivers/of/base.c b/trunk/drivers/of/base.c index b306fef1ac41..80c9deca5f35 100644 --- a/trunk/drivers/of/base.c +++ b/trunk/drivers/of/base.c @@ -137,6 +137,31 @@ struct device_node *of_get_parent(const struct device_node *node) } EXPORT_SYMBOL(of_get_parent); +/** + * of_get_next_parent - Iterate to a node's parent + * @node: Node to get parent of + * + * This is like of_get_parent() except that it drops the + * refcount on the passed node, making it suitable for iterating + * through a node's parents. + * + * Returns a node pointer with refcount incremented, use + * of_node_put() on it when done. + */ +struct device_node *of_get_next_parent(struct device_node *node) +{ + struct device_node *parent; + + if (!node) + return NULL; + + read_lock(&devtree_lock); + parent = of_node_get(node->parent); + of_node_put(node); + read_unlock(&devtree_lock); + return parent; +} + /** * of_get_next_child - Iterate a node childs * @node: parent node diff --git a/trunk/include/linux/of.h b/trunk/include/linux/of.h index b5f33efcb8e2..6981016dcc25 100644 --- a/trunk/include/linux/of.h +++ b/trunk/include/linux/of.h @@ -50,6 +50,7 @@ extern struct device_node *of_find_matching_node(struct device_node *from, extern struct device_node *of_find_node_by_path(const char *path); extern struct device_node *of_find_node_by_phandle(phandle handle); extern struct device_node *of_get_parent(const struct device_node *node); +extern struct device_node *of_get_next_parent(struct device_node *node); extern struct device_node *of_get_next_child(const struct device_node *node, struct device_node *prev); #define for_each_child_of_node(parent, child) \