From patchwork Sat Nov 3 00:27:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 196795 X-Patchwork-Delegate: trini@ti.com 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 0E2062C00BE for ; Sat, 3 Nov 2012 11:31:28 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 434664A9AE; Sat, 3 Nov 2012 01:30:10 +0100 (CET) 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 19bRLNwfD9hD; Sat, 3 Nov 2012 01:30:09 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 084C54A5DB; Sat, 3 Nov 2012 01:28:39 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0550E4A54B for ; Sat, 3 Nov 2012 01:28:24 +0100 (CET) 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 DXmjRdxe2Cx3 for ; Sat, 3 Nov 2012 01:28:22 +0100 (CET) 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 mail-la0-f74.google.com (mail-la0-f74.google.com [209.85.215.74]) by theia.denx.de (Postfix) with ESMTPS id BC34C4A4EC for ; Sat, 3 Nov 2012 01:28:07 +0100 (CET) Received: by mail-la0-f74.google.com with SMTP id j13so254718lah.3 for ; Fri, 02 Nov 2012 17:28:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=XP6M90EXLs79rOdXOM5TW1wT1CAb498l/7N73gytiME=; b=ApUKLK6IjjslfmYWzNmQ1VSQYC3n9aOCox1W0421PCgLnSDVR7psPXl8DI3CIZhlCv uMfN7eOupZRxffYFccP/nxeZJZQBSgzMwkIW1awtT0Dj3QEBLIeQI27/XUTF5ggrIg60 czPFzYF0+L5vOEu48cmBSzLYb3EwAgEJ+9GulJ+C36nAZDC8S9E6bU2sKNNbhvWnkcJg WI92LfEBOIVcT29PoeUT5lcpHc5G25JxQPrvxnPyYl1TGpFo69+PMgEqMBRtkJktfrkA ILT+284xXf4yKQJFybWIIz9OgS3eOgTZcuUdS6cD/47HRUy+8fevsOiaGTvO82LqcTky X3rQ== Received: by 10.14.204.201 with SMTP id h49mr3759781eeo.5.1351902484021; Fri, 02 Nov 2012 17:28:04 -0700 (PDT) Received: from hpza9.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id u8si1731446een.1.2012.11.02.17.28.03 (version=TLSv1/SSLv3 cipher=AES128-SHA); Fri, 02 Nov 2012 17:28:04 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by hpza9.eem.corp.google.com (Postfix) with ESMTP id A230E5C0060; Fri, 2 Nov 2012 17:28:03 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id E033F16192C; Fri, 2 Nov 2012 17:28:02 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Fri, 2 Nov 2012 17:27:30 -0700 Message-Id: <1351902453-27956-15-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1351902453-27956-1-git-send-email-sjg@chromium.org> References: <1351902453-27956-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQla+S3IQ/OLLuVKsncJDxafl2gqpGD1QKHi8NPELX/TZbMiu2TX/vDz86DrRAI6CN3HomY0pp9kdk1c2eHHWVvIdBbSG5NwQ6dDMHydu5mdtttvbYx/V0UR8b04Z0RA2lii0wV/A3dXGlttLDTX1xEZFIajeSDgvDCsDGc3jpVsLsiQoO7WvNEX7EnVqIS1kmEZuvoH Cc: Tom Rini , Anton Staaf Subject: [U-Boot] [PATCH 14/17] console: Call overwrite_console before searching for console devices X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 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 From: Anton Staaf Move the overwrite_console function call to before the search for the console devices. This lets the board specific function replace the environment variables and have that picked up by the console code. Signed-off-by: Simon Glass --- common/console.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/common/console.c b/common/console.c index 1177f7d..831897b 100644 --- a/common/console.c +++ b/common/console.c @@ -1,4 +1,6 @@ /* + * Copyright (c) 2009, Code Aurora Forum. All rights reserved. + * * (C) Copyright 2000 * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it * @@ -622,6 +624,7 @@ int console_init_r(void) { char *stdinname, *stdoutname, *stderrname; struct stdio_dev *inputdev = NULL, *outputdev = NULL, *errdev = NULL; + int overwrite_console_retval; #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE int i; #endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */ @@ -636,13 +639,19 @@ int console_init_r(void) gd->jt[XF_puts] = serial_puts; gd->jt[XF_printf] = serial_printf; - /* stdin stdout and stderr are in environment */ - /* scan for it */ + /* + * stdin stdout and stderr are in environment. + * Call OVERWRITE_CONSOLE function before scanning for stdio, stdout, + * stderr to get latest pointer after update. + * (getenv() returns NULL if var not present) + */ + overwrite_console_retval = OVERWRITE_CONSOLE; stdinname = getenv("stdin"); stdoutname = getenv("stdout"); stderrname = getenv("stderr"); - if (OVERWRITE_CONSOLE == 0) { /* if not overwritten by config switch */ + /* if not overwritten by config switch */ + if (overwrite_console_retval == 0) { inputdev = search_device(DEV_FLAGS_INPUT, stdinname); outputdev = search_device(DEV_FLAGS_OUTPUT, stdoutname); errdev = search_device(DEV_FLAGS_OUTPUT, stderrname);