of: find also nodes by mixture of alias and path
Let of_find_node_by_path_or_alias also find a node starting with an alias followed by a path like "i2c0/tps@24" Signed-off-by: Jan Weitzel <j.weitzel@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
d95f27aaa8
commit
1ebf5ff0c1
|
@ -1378,11 +1378,32 @@ EXPORT_SYMBOL(of_find_node_by_path);
|
||||||
struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
|
struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
|
||||||
const char *str)
|
const char *str)
|
||||||
{
|
{
|
||||||
|
struct device_node *node;
|
||||||
|
const char *slash;
|
||||||
|
char *alias;
|
||||||
|
size_t len = 0;
|
||||||
|
|
||||||
if (*str == '/')
|
if (*str == '/')
|
||||||
return of_find_node_by_path_from(root, str);
|
return of_find_node_by_path_from(root, str);
|
||||||
else
|
|
||||||
|
slash = strchr(str, '/');
|
||||||
|
|
||||||
|
if (!slash)
|
||||||
return of_find_node_by_alias(root, str);
|
return of_find_node_by_alias(root, str);
|
||||||
|
|
||||||
|
len = slash - str + 1;
|
||||||
|
alias = xmalloc(len);
|
||||||
|
strlcpy(alias, str, len);
|
||||||
|
|
||||||
|
node = of_find_node_by_alias(root, alias);
|
||||||
|
|
||||||
|
if (!node)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
node = of_find_node_by_path_from(node, slash);
|
||||||
|
out:
|
||||||
|
free(alias);
|
||||||
|
return node;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(of_find_node_by_path_or_alias);
|
EXPORT_SYMBOL(of_find_node_by_path_or_alias);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue