From patchwork Mon Jun 17 14:44:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 251878 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 2C0CD2C0097 for ; Tue, 18 Jun 2013 00:49:09 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 81BC64A032; Mon, 17 Jun 2013 16:48:59 +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 RBfhzb0eUV8I; Mon, 17 Jun 2013 16:48:59 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 952544A1FF; Mon, 17 Jun 2013 16:48:18 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1E6AB4A1A5 for ; Mon, 17 Jun 2013 16:48:11 +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 B6jCELrl6ApS for ; Mon, 17 Jun 2013 16:47:55 +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-qc0-f201.google.com (mail-qc0-f201.google.com [209.85.216.201]) by theia.denx.de (Postfix) with ESMTPS id 489534A1AF for ; Mon, 17 Jun 2013 16:47:43 +0200 (CEST) Received: by mail-qc0-f201.google.com with SMTP id u11so309100qcx.0 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=YPCon9JKOJmWf/aohjQpam7+8QCDNKjAGFJV1c6cgxk=; b=VhtPW+BFxIEwt2UHUmZ37I3DGmkdyh5bxXFW+4RFmkhr1hlD3krPAUI7XnCwYliG5p gZ3JoyU0eHMuWOlqlKpJL9WG/yniuIBcdePM2gwOdXpylWDzZ1lpfu9Mm6rHSLaiK2Rw PS1eCO1r/xr34FpUZOTU+jDzZDNc93gnSh9e+QPOpNb5Ep9fG4ruyh4LrHyjb8TFoCvc vDsP37A7LGQk8CQv6i9uBXAvePzG5wopQFnXAEiuBtmUbeN3GNBC8obNmLrhtSREXiGx 1LP9/1l5MGPRMvJ7uiAPDxfdYF2qCfDG8CN/jfQm7VE2JH/yAHJtvXV0ek9F5vC8+Ipt /BOg== X-Received: by 10.236.174.202 with SMTP id x50mr8729702yhl.20.1371480462124; Mon, 17 Jun 2013 07:47:42 -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 b23si898163yhj.4.2013.06.17.07.47.42 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Mon, 17 Jun 2013 07:47:42 -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 D81BD5A41E8; Mon, 17 Jun 2013 07:47:41 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 8CB2A160C68; Mon, 17 Jun 2013 07:47:41 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 17 Jun 2013 07:44:57 -0700 Message-Id: <1371480300-30274-6-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: ALoCoQkOJZASfWT53yRTWd76C8JrJUh8FmbglN1ZuvDjgj1AuLoLsqSkvdmu9cV9SBZl3oyHghj3q9D37k4Hdyz+OmauDqHyzM7V2g+nqbaU5OTB6lIMIf3QAvPFIatyeBvO239XrfA3QFW9KE01axR9KiyrvzRcmX2CIg6miqk/4t/K0vCUzlWFDEuQPFcDlKDHsgvYTymV Cc: David Hendrix , Graeme Russ , Joe Hershberger , Tom Rini , Vadim Bendebury Subject: [U-Boot] [PATCH v4 5/8] main: Use autoconf for boot_delay 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 Convert this function and its children to use autoconf instead of #ifdef. Signed-off-by: Simon Glass --- Changes in v4: - Rebase on current master Changes in v3: - Simplify code for finding out bootdelay from config or environment Changes in v2: None common/main.c | 74 +++++++++++++++++++++++++--------------------------------- include/menu.h | 2 -- 2 files changed, 32 insertions(+), 44 deletions(-) diff --git a/common/main.c b/common/main.c index dba6cee..fc55e06 100644 --- a/common/main.c +++ b/common/main.c @@ -302,52 +302,42 @@ static void process_fdt_options(const void *blob) static void process_boot_delay(void) { - char *s; - int bootdelay; -#ifdef CONFIG_BOOTCOUNT_LIMIT unsigned long bootcount = 0; unsigned long bootlimit = 0; -#endif /* CONFIG_BOOTCOUNT_LIMIT */ - -#ifdef CONFIG_BOOTCOUNT_LIMIT - bootcount = bootcount_load(); - bootcount++; - bootcount_store (bootcount); - setenv_ulong("bootcount", bootcount); - bootlimit = getenv_ulong("bootlimit", 10, 0); -#endif /* CONFIG_BOOTCOUNT_LIMIT */ - - s = getenv ("bootdelay"); - bootdelay = s ? (int)simple_strtol(s, NULL, 10) : autoconf_bootdelay(); - -#ifdef CONFIG_OF_CONTROL - bootdelay = fdtdec_get_config_int(gd->fdt_blob, "bootdelay", - bootdelay); -#endif + const char *s; + int bootdelay; + + if (autoconf_bootcount_limit()) { + bootcount = bootcount_load(); + bootcount++; + bootcount_store(bootcount); + setenv_ulong("bootcount", bootcount); + bootlimit = getenv_ulong("bootlimit", 10, 0); + } + bootdelay = getenv_ulong("bootdelay", 10, autoconf_bootdelay()); + + if (autoconf_of_control()) { + bootdelay = fdtdec_get_config_int(gd->fdt_blob, "bootdelay", + bootdelay); + } debug ("### main_loop entered: bootdelay=%d\n\n", bootdelay); -#if defined(CONFIG_MENU_SHOW) - bootdelay = menu_show(bootdelay); -#endif + if (autoconf_menu_show()) + bootdelay = menu_show(bootdelay); if (autoconf_boot_retry_time()) init_cmd_timeout(); -#ifdef CONFIG_POST - if (gd->flags & GD_FLG_POSTFAIL) { + if (autoconf_post() && (gd->flags & GD_FLG_POSTFAIL)) { s = getenv("failbootcmd"); - } - else -#endif /* CONFIG_POST */ -#ifdef CONFIG_BOOTCOUNT_LIMIT - if (bootlimit && (bootcount > bootlimit)) { + } else if (autoconf_bootcount_limit() && bootlimit && + (bootcount > bootlimit)) { printf ("Warning: Bootlimit (%u) exceeded. Using altbootcmd.\n", (unsigned)bootlimit); s = getenv ("altbootcmd"); - } - else -#endif /* CONFIG_BOOTCOUNT_LIMIT */ + } else { s = getenv ("bootcmd"); + } if (autoconf_of_control()) { char *env; @@ -370,24 +360,24 @@ static void process_boot_delay(void) debug ("### main_loop: bootcmd=\"%s\"\n", s ? s : ""); if (bootdelay != -1 && s && !abortboot(bootdelay)) { -#ifdef CONFIG_AUTOBOOT_KEYED - int prev = disable_ctrlc(1); /* disable Control C checking */ -#endif + int prev; + + /* disable Control C checking */ + if (autoconf_autoboot_keyed()) + prev = disable_ctrlc(1); run_command_list(s, -1, 0); -#ifdef CONFIG_AUTOBOOT_KEYED - disable_ctrlc(prev); /* restore Control C checking */ -#endif + /* restore Control C checking */ + if (autoconf_autoboot_keyed()) + disable_ctrlc(prev); } -#ifdef CONFIG_MENUKEY - if (menukey == CONFIG_MENUKEY) { + if (autoconf_menukey() && menukey == autoconf_menukey()) { s = getenv("menucmd"); if (s) run_command_list(s, -1, 0); } -#endif /* CONFIG_MENUKEY */ } void main_loop(void) diff --git a/include/menu.h b/include/menu.h index d8200ee..bcc3ec4 100644 --- a/include/menu.h +++ b/include/menu.h @@ -31,7 +31,5 @@ int menu_destroy(struct menu *m); void menu_display_statusline(struct menu *m); int menu_default_choice(struct menu *m, void **choice); -#if defined(CONFIG_MENU_SHOW) int menu_show(int bootdelay); -#endif #endif /* __MENU_H__ */