summaryrefslogtreecommitdiff
path: root/drivers/of
diff options
context:
space:
mode:
authorJeremy Kerr <jeremy.kerr@canonical.com>2010-02-02 07:34:11 +0300
committerGrant Likely <grant.likely@secretlab.ca>2010-02-09 18:32:48 +0300
commit89751a7cb70a20f0d604dd7c4be29dd7b0011718 (patch)
tree17abed1974c3c79c978b20bd396078df80f19f40 /drivers/of
parentfcdeb7fedf89f4bbc2e11959794968080cd8426e (diff)
downloadlinux-89751a7cb70a20f0d604dd7c4be29dd7b0011718.tar.xz
of: merge of_find_node_by_phandle
Merge common function between powerpc, sparc and microblaze. Code is identical for powerpc and microblaze, but adds a lock (and release) of the devtree_lock on sparc. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/base.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 2ce58be314af..785e9cc1b207 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -615,6 +615,27 @@ int of_modalias_node(struct device_node *node, char *modalias, int len)
EXPORT_SYMBOL_GPL(of_modalias_node);
/**
+ * of_find_node_by_phandle - Find a node given a phandle
+ * @handle: phandle of the node to find
+ *
+ * Returns a node pointer with refcount incremented, use
+ * of_node_put() on it when done.
+ */
+struct device_node *of_find_node_by_phandle(phandle handle)
+{
+ struct device_node *np;
+
+ read_lock(&devtree_lock);
+ for (np = allnodes; np; np = np->allnext)
+ if (np->phandle == handle)
+ break;
+ of_node_get(np);
+ read_unlock(&devtree_lock);
+ return np;
+}
+EXPORT_SYMBOL(of_find_node_by_phandle);
+
+/**
* of_parse_phandle - Resolve a phandle property to a device_node pointer
* @np: Pointer to device node holding phandle property
* @phandle_name: Name of property holding a phandle value