[RFC 1/1] lib/utils: consider ':' in stdout-path

Heinrich Schuchardt xypron.glpk at gmx.de
Mon May 24 06:19:53 PDT 2021


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 at f00:115200";
        };

If the character ':' is present, it terminates the path of the device.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
Is it allowable to temporarily change the device-tree here?
Or should we use sbi_scratch_alloc_offset() and copy the string?
---
 lib/utils/serial/fdt_serial.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/utils/serial/fdt_serial.c b/lib/utils/serial/fdt_serial.c
index 25982ec..d1b762c 100644
--- a/lib/utils/serial/fdt_serial.c
+++ b/lib/utils/serial/fdt_serial.c
@@ -46,8 +46,16 @@ int fdt_serial_init(void)
 	coff = fdt_path_offset(fdt, "/chosen");
 	if (-1 < coff) {
 		prop = fdt_getprop(fdt, coff, "stdout-path", &len);
-		if (prop && len)
+		if (prop && len) {
+			char *s;
+
+			s = strchr(prop, ':');
+			if (s)
+				*s = 0;
 			noff = fdt_path_offset(fdt, prop);
+			if (s)
+				*s = ':';
+		}
 	}

 	/* First check DT node pointed by stdout-path */
--
2.30.2




More information about the opensbi mailing list