summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTeresa Gámez <t.gamez@phytec.de>2014-09-30 13:15:27 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-10-01 08:13:02 +0200
commit55475204cd0939f9c426c648706bf63486029657 (patch)
treea22eee57d8070a990f93986f1ba31207460ba38f /drivers
parent1e19346e978944599ef05899314706ab2f800707 (diff)
downloadbarebox-55475204cd0939f9c426c648706bf63486029657.tar.gz
barebox-55475204cd0939f9c426c648706bf63486029657.tar.xz
of: base: Add of_find_node_by_phandle_from
Added of_find_node_by_phandle_from() to find nodes by phandle with a given root node. Signed-off-by: Teresa Gámez <t.gamez@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/of/base.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index c440a69e6c..061fc79e60 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -265,19 +265,39 @@ struct device_node *of_find_node_by_alias(struct device_node *root, const char *
EXPORT_SYMBOL_GPL(of_find_node_by_alias);
/*
- * of_find_node_by_phandle - Find a node given a phandle
- * @handle: phandle of the node to find
+ * of_find_node_by_phandle_from - Find a node given a phandle from given
+ * root node.
+ * @handle: phandle of the node to find
+ * @root: root node of the tree to search in. If NULL use the
+ * internal tree.
*/
-struct device_node *of_find_node_by_phandle(phandle phandle)
+struct device_node *of_find_node_by_phandle_from(phandle phandle,
+ struct device_node *root)
{
struct device_node *node;
- of_tree_for_each_node_from(node, root_node)
+ if (!root)
+ root = root_node;
+
+ if (!root)
+ return 0;
+
+ of_tree_for_each_node_from(node, root)
if (node->phandle == phandle)
return node;
return NULL;
}
+EXPORT_SYMBOL(of_find_node_by_phandle_from);
+
+/*
+ * of_find_node_by_phandle - Find a node given a phandle
+ * @handle: phandle of the node to find
+ */
+struct device_node *of_find_node_by_phandle(phandle phandle)
+{
+ return of_find_node_by_phandle_from(phandle, root_node);
+}
EXPORT_SYMBOL(of_find_node_by_phandle);
/*