summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2017-06-14 20:02:49 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-06-19 08:20:54 +0200
commit23522645b3b3d8366ab4307a0a0f0e9873e7bdb1 (patch)
tree5ecfb102a05bc5a7a69ff26bcc7952ad86319f4e /drivers
parent0e193b6684798e0fedf0eb0462ba9bc8059270c0 (diff)
downloadbarebox-23522645b3b3d8366ab4307a0a0f0e9873e7bdb1.tar.gz
barebox-23522645b3b3d8366ab4307a0a0f0e9873e7bdb1.tar.xz
of_device_is_stdout_path: split off options and support aliases
Several device trees use something like: stdout-path = "serial0:115200n8"; Currently of_device_is_stdout_path fails to do the right thing here because it expects an absolute node path and no options. So split off options (everything after the colon) and resolve aliases. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/of/base.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 44a7b8b61f..ea330d1310 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2001,6 +2001,8 @@ int of_device_is_stdout_path(struct device_d *dev)
{
struct device_node *dn;
const char *name;
+ const char *p;
+ char *q;
if (!dev->device_node)
return 0;
@@ -2012,7 +2014,16 @@ int of_device_is_stdout_path(struct device_d *dev)
if (!name)
return 0;
- dn = of_find_node_by_path(name);
+ /* This could make use of strchrnul if it were available */
+ p = strchr(name, ':');
+ if (!p)
+ p = name + strlen(name);
+
+ q = xstrndup(name, p - name);
+
+ dn = of_find_node_by_path_or_alias(NULL, q);
+
+ free(q);
return dn == dev->device_node;
}