From patchwork Mon Aug 29 16:05:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [U-Boot,2/2] Add check that console is ready before output Date: Mon, 29 Aug 2011 06:05:10 -0000 From: Simon Glass X-Patchwork-Id: 112103 Message-Id: <1314633910-8550-3-git-send-email-sjg@chromium.org> To: U-Boot Mailing List 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 Signed-off-by: Simon Glass --- 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); }