diff mbox series

[03/23] console: Avoid serial output before the console is running

Message ID 20211119202408.1815506-4-sjg@chromium.org
State Accepted
Commit 4057e2772d043ecfa0efc4d16bd8ab664afb69a0
Delegated to: Anatolij Gustschin
Headers show
Series video: Support a U-Boot logo more easily | expand

Commit Message

Simon Glass Nov. 19, 2021, 8:23 p.m. UTC
The video driver uses this for debugging, but if used before relocation it
crashes at present. Avoid trying to output debugging before the console is
ready.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/console.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/common/console.c b/common/console.c
index 0013d183aeb..a9d3319977f 100644
--- a/common/console.c
+++ b/common/console.c
@@ -348,7 +348,8 @@  static void console_puts_select(int file, bool serial_only, const char *s)
 
 void console_puts_select_stderr(bool serial_only, const char *s)
 {
-	console_puts_select(stderr, serial_only, s);
+	if (gd->flags & GD_FLG_DEVINIT)
+		console_puts_select(stderr, serial_only, s);
 }
 
 static void console_puts(int file, const char *s)
@@ -401,7 +402,8 @@  static inline void console_putc(int file, const char c)
 
 void console_puts_select(int file, bool serial_only, const char *s)
 {
-	if (serial_only == console_dev_is_serial(stdio_devices[file]))
+	if ((gd->flags & GD_FLG_DEVINIT) &&
+	    serial_only == console_dev_is_serial(stdio_devices[file]))
 		stdio_devices[file]->puts(stdio_devices[file], s);
 }