summaryrefslogtreecommitdiffstats
path: root/drivers/of/base.c
diff options
context:
space:
mode:
authorSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>2013-06-13 18:06:44 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-06-20 21:20:50 +0200
commit0b79c3bb641857f5045a42f55f0b90d160706425 (patch)
tree10ce0b10a34032f30d73337ea48b3f7cdbcffe34 /drivers/of/base.c
parent905f3ee7fb79af91ed42275c995ca0cd04a2a3d6 (diff)
downloadbarebox-0b79c3bb641857f5045a42f55f0b90d160706425.tar.gz
barebox-0b79c3bb641857f5045a42f55f0b90d160706425.tar.xz
OF: base: sync of_find_node_by_path with linux OF API
Barebox of_find_node_by_path requires a node to be passed as start node to start searching. Linux OF API does not pass this node and no current user of it in barebox is passing anything else than the root node. Therefore, we rename current function to of_find_node_by_path_from and introduce a Linux OF API compatible of_find_node_by_path that always passes the current root_node. Also, all current users of that function are updated to reflect the API change. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/of/base.c')
-rw-r--r--drivers/of/base.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 85199b69ab..a99fa43f20 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -153,7 +153,7 @@ void of_alias_scan(void)
if (!root_node)
return;
- of_aliases = of_find_node_by_path(root_node, "/aliases");
+ of_aliases = of_find_node_by_path("/aliases");
if (!of_aliases)
return;
@@ -170,7 +170,7 @@ void of_alias_scan(void)
!of_prop_cmp(pp->name, "linux,phandle"))
continue;
- np = of_find_node_by_path(root_node, pp->value);
+ np = of_find_node_by_path(pp->value);
if (!np)
continue;
@@ -556,19 +556,18 @@ int of_machine_is_compatible(const char *compat)
EXPORT_SYMBOL(of_machine_is_compatible);
/**
- * of_find_node_by_path - Find a node matching a full OF path
- * @root: The root node of this tree
+ * of_find_node_by_path_from - Find a node matching a full OF path
+ * relative to a given root node.
* @path: The full path to match
*
- * Returns a node pointer with refcount incremented, use
- * of_node_put() on it when done.
+ * Returns a pointer to the node found or NULL.
*/
-struct device_node *of_find_node_by_path(struct device_node *root, const char *path)
+struct device_node *of_find_node_by_path_from(struct device_node *from,
+ const char *path)
{
char *slash, *p, *freep;
- struct device_node *dn = root;
- if (*path != '/')
+ if (!from || !path || *path != '/')
return NULL;
path++;
@@ -583,8 +582,8 @@ struct device_node *of_find_node_by_path(struct device_node *root, const char *p
if (slash)
*slash = 0;
- dn = of_find_child_by_name(dn, p);
- if (!dn)
+ from = of_find_child_by_name(from, p);
+ if (!from)
goto out;
if (!slash)
@@ -595,7 +594,19 @@ struct device_node *of_find_node_by_path(struct device_node *root, const char *p
out:
free(freep);
- return dn;
+ return from;
+}
+EXPORT_SYMBOL(of_find_node_by_path_from);
+
+/**
+ * of_find_node_by_path - Find a node matching a full OF path
+ * @path: The full path to match
+ *
+ * Returns a pointer to the node found or NULL.
+ */
+struct device_node *of_find_node_by_path(const char *path)
+{
+ return of_find_node_by_path_from(root_node, path);
}
EXPORT_SYMBOL(of_find_node_by_path);
@@ -1156,12 +1167,12 @@ int of_probe(void)
if(!root_node)
return -ENODEV;
- of_chosen = of_find_node_by_path(root_node, "/chosen");
+ of_chosen = of_find_node_by_path("/chosen");
of_property_read_string(root_node, "model", &of_model);
__of_parse_phandles(root_node);
- memory = of_find_node_by_path(root_node, "/memory");
+ memory = of_find_node_by_path("/memory");
if (memory)
of_add_memory(memory, false);
@@ -1234,8 +1245,8 @@ int of_device_is_stdout_path(struct device_d *dev)
name = of_get_property(of_chosen, "linux,stdout-path", NULL);
if (name == NULL)
return 0;
- dn = of_find_node_by_path(root_node, name);
+ dn = of_find_node_by_path(name);
if (!dn)
return 0;
@@ -1264,7 +1275,7 @@ int of_add_initrd(struct device_node *root, resource_size_t start,
struct device_node *chosen;
__be32 buf[2];
- chosen = of_find_node_by_path(root, "/chosen");
+ chosen = of_find_node_by_path("/chosen");
if (!chosen)
return -EINVAL;