[PATCH] of: find also nodes by mixture of alias and path
Jan Weitzel
j.weitzel at phytec.de
Thu Dec 19 03:39:37 EST 2013
Let of_find_node_by_path_or_alias also find a node starting with an alias
followed by a path like "i2c0/tps at 24"
Signed-off-by: Jan Weitzel <j.weitzel at phytec.de>
---
drivers/of/base.c | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index ea2d879..dc3d459 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1378,11 +1378,31 @@ EXPORT_SYMBOL(of_find_node_by_path);
struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
const char *str)
{
+ struct device_node *ret;
+ char *slash, *alias;
+ size_t len = 0;
+
if (*str == '/')
return of_find_node_by_path_from(root, str);
- else
+
+ slash = _strchr(str, '/');
+
+ if (!slash)
return of_find_node_by_alias(root, str);
+ len = slash - str + 1;
+ alias = xmalloc(len);
+ strlcpy(alias, str, len);
+
+ ret = of_find_node_by_alias(root, alias);
+
+ if (!ret)
+ goto out;
+
+ ret = of_find_node_by_path_from(ret, slash);
+out:
+ free(alias);
+ return ret;
}
EXPORT_SYMBOL(of_find_node_by_path_or_alias);
--
1.7.0.4
More information about the barebox
mailing list