From patchwork Mon Jun 17 14:44:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 251880 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 8841B2C0084 for ; Tue, 18 Jun 2013 00:49:54 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 259A04A0F0; Mon, 17 Jun 2013 16:49:15 +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 zsvcLHxRbRLU; Mon, 17 Jun 2013 16:49:14 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 62EFB4A11C; Mon, 17 Jun 2013 16:48:48 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0C64F4A1FF for ; Mon, 17 Jun 2013 16:48:17 +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 5jC40xeiFNFp for ; Mon, 17 Jun 2013 16:48:11 +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 mail-gh0-f202.google.com (mail-gh0-f202.google.com [209.85.160.202]) by theia.denx.de (Postfix) with ESMTPS id 4745E4A1AE for ; Mon, 17 Jun 2013 16:47:42 +0200 (CEST) Received: by mail-gh0-f202.google.com with SMTP id g24so309295ghb.5 for ; Mon, 17 Jun 2013 07:47:41 -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=Xg8dl6J0y9Ty41/IbmkhokVE6zMN2nFpGw2yxX7mAUU=; b=dMwIzNnIlncykUWyVeYzVkUL28a2MnSS6fSGwZeQ0lBO3IwPaKeiuV8ft0UfoLDOtB zvJJ1Vzl40opE1axtLYIcbEIakb3e7LfmF/AYTRgQwjr5IsLebb9coTBAC9/UnJYvB2E NMZ00aWcIos5FpQgFTgZyFnl66g+OL5Nr03dEXVRtF5IppHX7ujnNOCP2Uui1nZpft7m lAp5XdJu2f1uxynSzZZUcYEu2LBBxfbJaMOFZ74X0mTWo5DHVOtxUWMnrVHp0+BCUD5d NoXNMOFCrJwLuCC6yGJsmuwydaPWyUsdyQHG1t0xQ8h3ZkPlldn6UuDlio2yZpfR9O3/ vTgA== X-Received: by 10.236.56.5 with SMTP id l5mr9104123yhc.41.1371480461722; 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 10si897652yhj.6.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 7FE445A41E8; Mon, 17 Jun 2013 07:47:41 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 305F7160730; Mon, 17 Jun 2013 07:47:41 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 17 Jun 2013 07:44:54 -0700 Message-Id: <1371480300-30274-3-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: ALoCoQm0PXtVjoyUvsjxFs6clPBbopsoC2G6x6Wx47Y0rMakWVjXmoJzdicU0a+YRW3SY2msG1774ddYbrH/Jlj4IfoH2AZwc0Mbp4ygzRCs22/0j6C3B6SVntwCu+VQmM8UfkhE0Q7rtSPP+76/M4UST7Sy8GBqNNHajHEFkH4X6VfcXqJLfYYVmeaOpEt3em+lF7QN1yOf Cc: David Hendrix , Graeme Russ , Joe Hershberger , Tom Rini , Vadim Bendebury Subject: [U-Boot] [PATCH v4 2/8] main: Use autoconf for boot retry feature 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 Change this feature to use autoconf instead of #ifdef. Signed-off-by: Simon Glass Reviewed-by: Joe Hershberger --- Changes in v4: - Rebase on current master - Tidy up code style nits with new checkpatch Changes in v3: - Fix missing && in if() statement - Remove unneeded retry_min variable Changes in v2: None common/main.c | 73 ++++++++++++++++++++++++++--------------------------------- 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/common/main.c b/common/main.c index 56da214..3a143ae 100644 --- a/common/main.c +++ b/common/main.c @@ -65,17 +65,11 @@ static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen); static const char erase_seq[] = "\b \b"; /* erase sequence */ static const char tab_seq[] = " "; /* used to expand TABs */ -#ifdef CONFIG_BOOT_RETRY_TIME static uint64_t endtime = 0; /* must be set, default is instant timeout */ static int retry_time = -1; /* -1 so can call readline before main_loop */ -#endif #define endtick(seconds) (get_ticks() + (uint64_t)(seconds) * get_tbclk()) -#ifndef CONFIG_BOOT_RETRY_MIN -#define CONFIG_BOOT_RETRY_MIN CONFIG_BOOT_RETRY_TIME -#endif - #ifdef CONFIG_MODEM_SUPPORT int do_mdm_init = 0; extern void mdm_init(void); /* defined in board.c */ @@ -174,11 +168,10 @@ static int abortboot_keyed(int bootdelay) delaykey[i].retry ? "delay" : "stop"); -# ifdef CONFIG_BOOT_RETRY_TIME - /* don't retry auto boot */ - if (! delaykey[i].retry) + /* don't retry auto boot? */ + if (autoconf_boot_retry_time() && + !delaykey[i].retry) retry_time = -1; -# endif abort = 1; } } @@ -368,9 +361,8 @@ static void process_boot_delay(void) #if defined(CONFIG_MENU_SHOW) bootdelay = menu_show(bootdelay); #endif -# ifdef CONFIG_BOOT_RETRY_TIME - init_cmd_timeout (); -# endif /* CONFIG_BOOT_RETRY_TIME */ + if (autoconf_boot_retry_time()) + init_cmd_timeout(); #ifdef CONFIG_POST if (gd->flags & GD_FLG_POSTFAIL) { @@ -499,14 +491,12 @@ void main_loop(void) for (;;); #else for (;;) { -#ifdef CONFIG_BOOT_RETRY_TIME - if (rc >= 0) { + if (autoconf_boot_retry_time() && rc >= 0) { /* Saw enough of a valid command to * restart the timeout. */ reset_cmd_timeout(); } -#endif len = readline (CONFIG_SYS_PROMPT); flag = 0; /* assume no special flags for now */ @@ -514,19 +504,16 @@ void main_loop(void) strcpy (lastcommand, console_buffer); else if (len == 0) flag |= CMD_FLAG_REPEAT; -#ifdef CONFIG_BOOT_RETRY_TIME - else if (len == -2) { + else if (autoconf_boot_retry_time() && len == -2) { /* -2 means timed out, retry autoboot */ - puts ("\nTimed out waiting for command\n"); -# ifdef CONFIG_RESET_TO_RETRY + puts("\nTimed out waiting for command\n"); /* Reinit board to run initialization code again */ - do_reset (NULL, 0, 0, NULL); -# else - return; /* retry autoboot */ -# endif + if (autoconf_reset_to_retry()) + do_reset(NULL, 0, 0, NULL); + else + return; /* retry autoboot */ } -#endif if (len == -1) puts ("\n"); @@ -541,6 +528,10 @@ void main_loop(void) #endif /*CONFIG_SYS_HUSH_PARSER*/ } +/* + * Use ifdef here for the benefit of those archs not using + * -ffunction-sections, since these functions are exported. + */ #ifdef CONFIG_BOOT_RETRY_TIME /*************************************************************************** * initialize command line timeout @@ -552,10 +543,10 @@ void init_cmd_timeout(void) if (s != NULL) retry_time = (int)simple_strtol(s, NULL, 10); else - retry_time = CONFIG_BOOT_RETRY_TIME; + retry_time = autoconf_boot_retry_time(); - if (retry_time >= 0 && retry_time < CONFIG_BOOT_RETRY_MIN) - retry_time = CONFIG_BOOT_RETRY_MIN; + if (retry_time >= 0 && retry_time < autoconf_boot_retry_min()) + retry_time = autoconf_boot_retry_min(); } /*************************************************************************** @@ -777,13 +768,13 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len, cread_add_str(buf, init_len, 1, &num, &eol_num, buf, *len); while (1) { -#ifdef CONFIG_BOOT_RETRY_TIME - while (!tstc()) { /* while no incoming data */ - if (retry_time >= 0 && get_ticks() > endtime) - return (-2); /* timed out */ - WATCHDOG_RESET(); + if (autoconf_boot_retry_time()) { + while (!tstc()) { /* while no incoming data */ + if (retry_time >= 0 && get_ticks() > endtime) + return -2; /* timed out */ + WATCHDOG_RESET(); + } } -#endif if (first && timeout) { uint64_t etime = endtick(timeout); @@ -1055,14 +1046,14 @@ int readline_into_buffer(const char *const prompt, char *buffer, int timeout) col = plen; for (;;) { -#ifdef CONFIG_BOOT_RETRY_TIME - while (!tstc()) { /* while no incoming data */ - if (retry_time >= 0 && get_ticks() > endtime) - return (-2); /* timed out */ - WATCHDOG_RESET(); + if (autoconf_boot_retry_time()) { + while (!tstc()) { /* while no incoming data */ + if (retry_time >= 0 && get_ticks() > endtime) + return -2; /* timed out */ + WATCHDOG_RESET(); + } } -#endif - WATCHDOG_RESET(); /* Trigger watchdog, if needed */ + WATCHDOG_RESET(); /* Trigger watchdog, if needed */ #ifdef CONFIG_SHOW_ACTIVITY while (!tstc()) {