From patchwork Sat Oct 26 15:14:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 286285 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 4D1472C00AB for ; Sun, 27 Oct 2013 02:16:49 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 019194A28E; Sat, 26 Oct 2013 17:16:47 +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 4J4agRmXcZh7; Sat, 26 Oct 2013 17:16:46 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CF1AA4A22B; Sat, 26 Oct 2013 17:16:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A1B224A21C for ; Sat, 26 Oct 2013 17:16:23 +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 VJgQ5S4JSB7j for ; Sat, 26 Oct 2013 17:16:18 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 BL_NJABL=ERR(-1.5) (only DNSBL check requested) Received: from mail-ob0-f201.google.com (mail-ob0-f201.google.com [209.85.214.201]) by theia.denx.de (Postfix) with ESMTPS id 6F0864A20D for ; Sat, 26 Oct 2013 17:16:09 +0200 (CEST) Received: by mail-ob0-f201.google.com with SMTP id vb8so421584obc.0 for ; Sat, 26 Oct 2013 08:16:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+WyzhXULrvhPPlJmTq0t1JG5J6R8qVkYjbs/G8FBl9k=; b=KDR5NWfVS47OeU6gLsmTJZFPS3Ww7hEd3KD2pkunojavC8h5Mj1ILt81LaBOuDQwaf phJiDH9MQATnrzFbQJEXo0RWGCmJVRF9lUblmNyXWt7gtqpgks6F5fad9IGhoJlDc7BY FCGeMT1u0cLQIv2JgEBsohocLyA2w908oy6dnIORBtdRt6fGLsTgHs/phXO+TzfvCcpB swCYVGqA7ZwcvBcf1sLSeGpDubIaR0dmqDfpJV6cRXtFy7YfUcDzCWaLPhNzv8nOrV6x qzWty/m4g2gZXf0eGKT++Y0S0dcrxUUZakBkjWpx0RdDPPLei1FrIdIsWxYYhHVuhoGS Gtug== X-Gm-Message-State: ALoCoQmeVIh24GqKWAlyJNnomGgcITmhNWd/bnW8iM+/U1k3qfaUdXo3dcCCk5MQ8Be53rNhIN99N/c+7YFY0mAtCT6quQrTC5pGygzUu7f/7cDZwVt8Gc1htT8hmeK4zXzf+hmBXWbQ1OyFECUPG64aHHv1OZHq1iaCbhS55/OH7w3ZqrOmAJGHHF93eFxzmyzHQ7qRpA5a X-Received: by 10.50.61.242 with SMTP id t18mr1466132igr.3.1382800568426; Sat, 26 Oct 2013 08:16:08 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id a49si674325yhc.5.2013.10.26.08.16.08 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 26 Oct 2013 08:16:08 -0700 (PDT) Received: from kaki.bld.corp.google.com (kaki.bld.corp.google.com [172.29.216.32]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 38F5A31C1DC; Sat, 26 Oct 2013 08:16:08 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 9E975220C76; Sat, 26 Oct 2013 09:15:23 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Sat, 26 Oct 2013 09:14:12 -0600 Message-Id: <1382800457-26608-4-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.4.1 In-Reply-To: <1382800457-26608-1-git-send-email-sjg@chromium.org> References: <1382800457-26608-1-git-send-email-sjg@chromium.org> Cc: David Hendrix , Joe Hershberger , Tom Rini , Vadim Bendebury Subject: [U-Boot] [PATCH v4 3/8] main: Remove CONFIG #ifdefs from the abortboot() code 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 Move this code over to using autoconf. We can add the autoconf values to the delaykey[] array, and move the code that checks for autoconf values into the loop. Also change to using ARRAY_SIZE on delaykey[]. Signed-off-by: Simon Glass Reviewed-by: Joe Hershberger --- Changes in v4: - Rebase on current master Changes in v3: None Changes in v2: None common/main.c | 90 ++++++++++++++++++++++------------------------------------- 1 file changed, 34 insertions(+), 56 deletions(-) diff --git a/common/main.c b/common/main.c index 54c5df8..5768a16 100644 --- a/common/main.c +++ b/common/main.c @@ -70,15 +70,20 @@ static int abortboot_keyed(int bootdelay) int abort = 0; uint64_t etime = endtick(bootdelay); struct { - char* str; + const char *str; u_int len; int retry; + const char *conf; /* Configuration value */ } delaykey [] = { - { str: getenv ("bootdelaykey"), retry: 1 }, - { str: getenv ("bootdelaykey2"), retry: 1 }, - { str: getenv ("bootstopkey"), retry: 0 }, - { str: getenv ("bootstopkey2"), retry: 0 }, + { str: getenv("bootdelaykey"), retry: 1, + conf: autoconf_autoboot_delay_str() }, + { str: getenv("bootdelaykey2"), retry: 1, + conf: autoconf_autoboot_delay_str2() }, + { str: getenv("bootstopkey"), retry: 0, + conf: autoconf_autoboot_stop_str() }, + { str: getenv("bootstopkey2"), retry: 0, + conf: autoconf_autoboot_stop_str2() }, }; char presskey [MAX_DELAY_STOP_STR]; @@ -86,33 +91,15 @@ static int abortboot_keyed(int bootdelay) u_int presskey_max = 0; u_int i; -#ifndef CONFIG_ZERO_BOOTDELAY_CHECK - if (bootdelay == 0) + if (!autoconf_zero_bootdelay_check() && bootdelay == 0) return 0; -#endif -# ifdef CONFIG_AUTOBOOT_PROMPT - printf(CONFIG_AUTOBOOT_PROMPT); -# endif - -# ifdef CONFIG_AUTOBOOT_DELAY_STR - if (delaykey[0].str == NULL) - delaykey[0].str = CONFIG_AUTOBOOT_DELAY_STR; -# endif -# ifdef CONFIG_AUTOBOOT_DELAY_STR2 - if (delaykey[1].str == NULL) - delaykey[1].str = CONFIG_AUTOBOOT_DELAY_STR2; -# endif -# ifdef CONFIG_AUTOBOOT_STOP_STR - if (delaykey[2].str == NULL) - delaykey[2].str = CONFIG_AUTOBOOT_STOP_STR; -# endif -# ifdef CONFIG_AUTOBOOT_STOP_STR2 - if (delaykey[3].str == NULL) - delaykey[3].str = CONFIG_AUTOBOOT_STOP_STR2; -# endif - - for (i = 0; i < sizeof(delaykey) / sizeof(delaykey[0]); i ++) { + if (autoconf_has_autoboot_prompt()) + printf(autoconf_autoboot_prompt()); + + for (i = 0; i < ARRAY_SIZE(delaykey); i++) { + if (delaykey[i].conf && !delaykey[i].str) + delaykey[i].str = delaykey[i].conf; delaykey[i].len = delaykey[i].str == NULL ? 0 : strlen (delaykey[i].str); delaykey[i].len = delaykey[i].len > MAX_DELAY_STOP_STR ? @@ -142,7 +129,7 @@ static int abortboot_keyed(int bootdelay) } } - for (i = 0; i < sizeof(delaykey) / sizeof(delaykey[0]); i ++) { + for (i = 0; i < ARRAY_SIZE(delaykey); i++) { if (delaykey[i].len > 0 && presskey_len >= delaykey[i].len && memcmp (presskey + presskey_len - delaykey[i].len, @@ -164,45 +151,39 @@ static int abortboot_keyed(int bootdelay) if (!abort) debug_bootkeys("key timeout\n"); -#ifdef CONFIG_SILENT_CONSOLE - if (abort) + if (autoconf_silent_console() && abort) gd->flags &= ~GD_FLG_SILENT; -#endif return abort; } # else /* !defined(CONFIG_AUTOBOOT_KEYED) */ -#ifdef CONFIG_MENUKEY -static int menukey = 0; -#endif +static int menukey; static int abortboot_normal(int bootdelay) { int abort = 0; unsigned long ts; -#ifdef CONFIG_MENUPROMPT - printf(CONFIG_MENUPROMPT); -#else - if (bootdelay >= 0) + if (autoconf_menuprompt()) + printf(autoconf_menuprompt()); + else if (bootdelay >= 0) printf("Hit any key to stop autoboot: %2d ", bootdelay); -#endif -#if defined CONFIG_ZERO_BOOTDELAY_CHECK /* - * Check if key already pressed - * Don't check if bootdelay < 0 + * If we need to do a bootdelay check even if bootdelay is 0, do + * it here, since the loop below will be skipped in this case. + * We don't do this check if bootdelay < 0. */ - if (bootdelay >= 0) { - if (tstc()) { /* we got a key press */ + if (autoconf_zero_bootdelay_check() && bootdelay >= 0) { + /* Check if key already pressed */ + if (tstc()) { /* we got a key press */ (void) getc(); /* consume input */ puts ("\b\b\b 0"); abort = 1; /* don't auto boot */ } } -#endif while ((bootdelay > 0) && (!abort)) { --bootdelay; @@ -212,11 +193,10 @@ static int abortboot_normal(int bootdelay) if (tstc()) { /* we got a key press */ abort = 1; /* don't auto boot */ bootdelay = 0; /* no more delay */ -# ifdef CONFIG_MENUKEY - menukey = getc(); -# else - (void) getc(); /* consume input */ -# endif + if (autoconf_menukey()) + menukey = getc(); + else + (void) getc(); /* consume input */ break; } udelay(10000); @@ -227,10 +207,8 @@ static int abortboot_normal(int bootdelay) putc('\n'); -#ifdef CONFIG_SILENT_CONSOLE - if (abort) + if (autoconf_silent_console() && abort) gd->flags &= ~GD_FLG_SILENT; -#endif return abort; }