[U-Boot] [PATCH 2/2] Add check that console is ready before output

Simon Glass sjg at chromium.org
Mon Aug 29 18:05:10 CEST 2011


If puts() or printf() is called before the console is ready, U-Boot will
either hang or die. This adds a check for this so that debug() can be used
in early code without concern that it will hang.

U-Boot boots properly

Tested-by: Simon Glass <sjg at chromium.org>
Signed-off-by: Simon Glass <sjg at chromium.org>
---
 common/console.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/console.c b/common/console.c
index 8c650e0..28ddb95 100644
--- a/common/console.c
+++ b/common/console.c
@@ -338,7 +338,7 @@ void putc(const char c)
 	if (gd->flags & GD_FLG_DEVINIT) {
 		/* Send to the standard output */
 		fputc(stdout, c);
-	} else {
+	} else if (gd->have_console) {
 		/* Send directly to the handler */
 		serial_putc(c);
 	}
@@ -359,7 +359,7 @@ void puts(const char *s)
 	if (gd->flags & GD_FLG_DEVINIT) {
 		/* Send to the standard output */
 		fputs(stdout, s);
-	} else {
+	} else if (gd->have_console) {
 		/* Send directly to the handler */
 		serial_puts(s);
 	}
-- 
1.7.3.1



More information about the U-Boot mailing list