[U-Boot] [PATCH v4 4/8] main: Use autoconf to remove #ifdefs around process_boot_delay()

Simon Glass sjg at chromium.org
Sat Oct 26 17:14:13 CEST 2013


Use autoconf to make process_boot_delay() be compiled always, and adjust
the caller and related functions as needed.

Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v4:
- Split out new patch to remove #ifdefs around process_boot_delay()

Changes in v3: None
Changes in v2: None

 common/main.c | 71 ++++++++++++++++++++++++++---------------------------------
 1 file changed, 31 insertions(+), 40 deletions(-)

diff --git a/common/main.c b/common/main.c
index 5768a16..824f5f7 100644
--- a/common/main.c
+++ b/common/main.c
@@ -63,8 +63,6 @@ extern void mdm_init(void); /* defined in board.c */
  * Watch for 'delay' seconds for autoboot stop or autoboot delay string.
  * returns: 0 -  no key string, allow autoboot 1 - got key string, abort
  */
-#if defined(CONFIG_BOOTDELAY)
-# if defined(CONFIG_AUTOBOOT_KEYED)
 static int abortboot_keyed(int bootdelay)
 {
 	int abort = 0;
@@ -157,8 +155,6 @@ static int abortboot_keyed(int bootdelay)
 	return abort;
 }
 
-# else	/* !defined(CONFIG_AUTOBOOT_KEYED) */
-
 static int menukey;
 
 static int abortboot_normal(int bootdelay)
@@ -212,17 +208,14 @@ static int abortboot_normal(int bootdelay)
 
 	return abort;
 }
-# endif	/* CONFIG_AUTOBOOT_KEYED */
 
 static int abortboot(int bootdelay)
 {
-#ifdef CONFIG_AUTOBOOT_KEYED
-	return abortboot_keyed(bootdelay);
-#else
-	return abortboot_normal(bootdelay);
-#endif
+	if (autoconf_autoboot_keyed())
+		return abortboot_keyed(bootdelay);
+	else
+		return abortboot_normal(bootdelay);
 }
-#endif	/* CONFIG_BOOTDELAY */
 
 /*
  * Runs the given boot command securely.  Specifically:
@@ -238,7 +231,6 @@ static int abortboot(int bootdelay)
  * printing the error message to console.
  */
 
-#if defined(CONFIG_BOOTDELAY) && defined(CONFIG_OF_CONTROL)
 static void secure_boot_cmd(char *cmd)
 {
 	cmd_tbl_t *cmdtp;
@@ -279,22 +271,21 @@ static void process_fdt_options(const void *blob)
 
 	/* Add an env variable to point to a kernel payload, if available */
 	addr = fdtdec_get_config_int(gd->fdt_blob, "kernel-offset", 0);
-	if (addr)
-		setenv_addr("kernaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
+	if (addr) {
+		setenv_addr("kernaddr",
+			    (void *)(autoconf_sys_text_base() + addr));
+	}
 
 	/* Add an env variable to point to a root disk, if available */
 	addr = fdtdec_get_config_int(gd->fdt_blob, "rootdisk-offset", 0);
-	if (addr)
-		setenv_addr("rootaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
+	if (addr) {
+		setenv_addr("rootaddr",
+			    (void *)(autoconf_sys_text_base() + addr));
+	}
 }
-#endif /* CONFIG_OF_CONTROL */
 
-#ifdef CONFIG_BOOTDELAY
 static void process_boot_delay(void)
 {
-#ifdef CONFIG_OF_CONTROL
-	char *env;
-#endif
 	char *s;
 	int bootdelay;
 #ifdef CONFIG_BOOTCOUNT_LIMIT
@@ -311,7 +302,7 @@ static void process_boot_delay(void)
 #endif /* CONFIG_BOOTCOUNT_LIMIT */
 
 	s = getenv ("bootdelay");
-	bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;
+	bootdelay = s ? (int)simple_strtol(s, NULL, 10) : autoconf_bootdelay();
 
 #ifdef CONFIG_OF_CONTROL
 	bootdelay = fdtdec_get_config_int(gd->fdt_blob, "bootdelay",
@@ -341,23 +332,24 @@ static void process_boot_delay(void)
 	else
 #endif /* CONFIG_BOOTCOUNT_LIMIT */
 		s = getenv ("bootcmd");
-#ifdef CONFIG_OF_CONTROL
-	/* Allow the fdt to override the boot command */
-	env = fdtdec_get_config_string(gd->fdt_blob, "bootcmd");
-	if (env)
-		s = env;
+	if (autoconf_of_control()) {
+		char *env;
 
-	process_fdt_options(gd->fdt_blob);
+		/* Allow the fdt to override the boot command */
+		env = fdtdec_get_config_string(gd->fdt_blob, "bootcmd");
+		if (env)
+			s = env;
 
-	/*
-	 * If the bootsecure option was chosen, use secure_boot_cmd().
-	 * Always use 'env' in this case, since bootsecure requres that the
-	 * bootcmd was specified in the FDT too.
-	 */
-	if (fdtdec_get_config_int(gd->fdt_blob, "bootsecure", 0))
-		secure_boot_cmd(env);
+		process_fdt_options(gd->fdt_blob);
 
-#endif /* CONFIG_OF_CONTROL */
+		/*
+		* If the bootsecure option was chosen, use secure_boot_cmd().
+		* Always use 'env' in this case, since bootsecure requres that
+		* the bootcmd was specified in the FDT too.
+		*/
+		if (fdtdec_get_config_int(gd->fdt_blob, "bootsecure", 0))
+			secure_boot_cmd(env);
+	}
 
 	debug ("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>");
 
@@ -381,7 +373,6 @@ static void process_boot_delay(void)
 	}
 #endif /* CONFIG_MENUKEY */
 }
-#endif /* CONFIG_BOOTDELAY */
 
 void main_loop(void)
 {
@@ -441,9 +432,9 @@ void main_loop(void)
 	update_tftp(0UL);
 #endif /* CONFIG_UPDATE_TFTP */
 
-#ifdef CONFIG_BOOTDELAY
-	process_boot_delay();
-#endif
+	if (autoconf_has_bootdelay() && autoconf_bootdelay() >= 0)
+		process_boot_delay();
+
 	/*
 	 * Main Loop for Monitor Command Processing
 	 */
-- 
1.8.4.1



More information about the U-Boot mailing list