From patchwork Mon Jun 17 14:44:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 251877 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 7F80C2C0097 for ; Tue, 18 Jun 2013 00:48:57 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DEDE34A1D1; Mon, 17 Jun 2013 16:48:50 +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 1KDOJkATf2kn; Mon, 17 Jun 2013 16:48:50 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B90004A1D7; Mon, 17 Jun 2013 16:48:13 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 204124A1A7 for ; Mon, 17 Jun 2013 16:47:57 +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 UVJ7M45piAVx for ; Mon, 17 Jun 2013 16:47:44 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 BL_NJABL=SKIP(-1.5) (only DNSBL check requested) Received: from mail-qa0-f73.google.com (mail-qa0-f73.google.com [209.85.216.73]) by theia.denx.de (Postfix) with ESMTPS id 3F3804A1A5 for ; Mon, 17 Jun 2013 16:47:43 +0200 (CEST) Received: by mail-qa0-f73.google.com with SMTP id hu14so289893qab.4 for ; Mon, 17 Jun 2013 07:47:42 -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=P+xk1BDDnc1Aue2HOAzAWNMZ8/2a3sAyhutCMsDqLzQ=; b=K51cKWmtNffl1eUblI7HmH0bA3ROvBvZUhns+F+jNymGzrUyM++/NA10sPiHSmiffC dcMHGuLZrnBWxoSKu/ijBn1rzuAUbamCFzHtSTAWliQcfWCxkltF6WADG1cVVC7GNYcr aQzF03zHov7kJuVAF4f8GwQDvCEf8jYVt2DuL2jP+zrWJeYHgX+ryLrfTk5RlQXyANld 5T5He617kUHYyD3FHW7b9E8j/iMtszjg9KXCWWrRdjIk+vSoKemd38/dTR/qqV3QP4nQ L2UNtAzG/eBKx60T3HEnzcuthrQMMWYlHEEYwuP+wPVl0OuRHtpjaDfig17FaBBgCaiw l9fA== X-Received: by 10.236.79.67 with SMTP id h43mr9057787yhe.46.1371480461861; Mon, 17 Jun 2013 07:47:41 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id o24si899901yhm.1.2013.06.17.07.47.41 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Mon, 17 Jun 2013 07:47:41 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.83.1]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 9C2F55A423B; Mon, 17 Jun 2013 07:47:41 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 4F310160A05; Mon, 17 Jun 2013 07:47:41 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 17 Jun 2013 07:44:55 -0700 Message-Id: <1371480300-30274-4-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.3 In-Reply-To: <1371480300-30274-1-git-send-email-sjg@chromium.org> References: <1371480300-30274-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQlYnb92i6uQMCd5PtmyJj5NUSRNf6XUnF3f+nIpuCYvBV4JnnDBR9Yzevl/0QvcDibq83eWEZ7yCw5rgMXPTwFdohQfOJZU2ol8OWDbpufmz9hIyKrYih/xQ+mdS9sww5QHm0oup0ZMLzEKZWSS9rBmqbopMqdeMe+C9+uiWKMr7btWEGbUqqxhcHvcPQRiMiJVzICs Cc: David Hendrix , Graeme Russ , 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 3a143ae..3a4754d 100644 --- a/common/main.c +++ b/common/main.c @@ -86,15 +86,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]; @@ -102,33 +107,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 ? @@ -158,7 +145,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, @@ -180,45 +167,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; @@ -228,11 +209,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); @@ -243,10 +223,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; }