From patchwork Mon Aug 29 16:05:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 112103 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3A93DB6F8F for ; Tue, 30 Aug 2011 02:05:53 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1903A280F5; Mon, 29 Aug 2011 18:05:49 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id duc+MHHuKNm4; Mon, 29 Aug 2011 18:05:48 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5A905280FF; Mon, 29 Aug 2011 18:05:42 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C302028100 for ; Mon, 29 Aug 2011 18:05:29 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oWcVAMZt1iEo for ; Mon, 29 Aug 2011 18:05:25 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp-out.google.com (smtp-out.google.com [216.239.44.51]) by theia.denx.de (Postfix) with ESMTPS id 1B74D280F5 for ; Mon, 29 Aug 2011 18:05:23 +0200 (CEST) Received: from wpaz37.hot.corp.google.com (wpaz37.hot.corp.google.com [172.24.198.101]) by smtp-out.google.com with ESMTP id p7TG5K70020890; Mon, 29 Aug 2011 09:05:20 -0700 Received: from sglass.mtv.corp.google.com (sglass.mtv.corp.google.com [172.22.72.144]) by wpaz37.hot.corp.google.com with ESMTP id p7TG5Gps006753; Mon, 29 Aug 2011 09:05:17 -0700 Received: by sglass.mtv.corp.google.com (Postfix, from userid 121222) id 6BDF6140DF8; Mon, 29 Aug 2011 09:05:16 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 29 Aug 2011 09:05:10 -0700 Message-Id: <1314633910-8550-3-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1314633910-8550-1-git-send-email-sjg@chromium.org> References: <1314633910-8550-1-git-send-email-sjg@chromium.org> X-System-Of-Record: true Subject: [U-Boot] [PATCH 2/2] Add check that console is ready before output X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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); }