From 23522645b3b3d8366ab4307a0a0f0e9873e7bdb1 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Wed, 14 Jun 2017 20:02:49 +0200 Subject: of_device_is_stdout_path: split off options and support aliases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Sascha Hauer --- drivers/of/base.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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; } -- cgit v1.2.3