summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2021-05-28 20:06:32 +0300
committerAnup Patel <anup@brainfault.org>2021-06-02 14:36:17 +0300
commit66c4fca532288c750681f33339016772b0ffbf2a (patch)
treeb8b187a802156646642492e24dd2fcec202c2c2e
parentd9ba6536d307f05a838e7c96cd20b0b7e43ec886 (diff)
downloadopensbi-66c4fca532288c750681f33339016772b0ffbf2a.tar.xz
lib: utils: consider ':' in stdout-path
The value of the /chosen/stdout-path devicetree property is used to determine the UART used by openSBI. According to the devicetree specification the value may contain a hyphen, e.g. chosen {                 stdout-path = "/serial@f00:115200";         }; If the character ':' is present, it terminates the path of the device. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Atish Patra <atish.patra@wdc.com>
-rw-r--r--lib/utils/serial/fdt_serial.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/utils/serial/fdt_serial.c b/lib/utils/serial/fdt_serial.c
index 25982ec..1d1eba8 100644
--- a/lib/utils/serial/fdt_serial.c
+++ b/lib/utils/serial/fdt_serial.c
@@ -42,12 +42,21 @@ int fdt_serial_init(void)
int pos, noff = -1, len, coff, rc;
void *fdt = sbi_scratch_thishart_arg1_ptr();
- /* Find offset of node pointed by stdout-path */
+ /* Find offset of node pointed to by stdout-path */
coff = fdt_path_offset(fdt, "/chosen");
if (-1 < coff) {
prop = fdt_getprop(fdt, coff, "stdout-path", &len);
- if (prop && len)
- noff = fdt_path_offset(fdt, prop);
+ if (prop && len) {
+ const char *sep, *start = prop;
+
+ /* The device path may be followed by ':' */
+ sep = strchr(start, ':');
+ if (sep)
+ noff = fdt_path_offset_namelen(fdt, prop,
+ sep - start);
+ else
+ noff = fdt_path_offset(fdt, prop);
+ }
}
/* First check DT node pointed by stdout-path */