[U-Boot] [PATCH v3 04/16] main: Separate out the two abortboot() functions

Simon Glass sjg at chromium.org
Tue Feb 26 17:10:57 CET 2013


There are two implementations of abortboot(). Turn these into two separate
functions, and create a single abortboot() which calls either one or the
other.

Also it seems that nothing uses abortboot() outside main, so make it static.

At this point there is no further use of CONFIG_MENU in main.c.

Signed-off-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger at ni.com>

---
Changes in v3:
- Fix commit message which said autoboot() instead of abortboot()
- Add note about CONFIG_MENU not being needed in main.c anymore

Changes in v2: None

 common/main.c    | 22 ++++++++++------------
 include/common.h |  3 ---
 2 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/common/main.c b/common/main.c
index 2b8af2c..1e12e55 100644
--- a/common/main.c
+++ b/common/main.c
@@ -92,11 +92,7 @@ extern void mdm_init(void); /* defined in board.c */
  * returns: 0 -  no key string, allow autoboot 1 - got key string, abort
  */
 #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
-# if defined(CONFIG_AUTOBOOT_KEYED)
-#ifndef CONFIG_MENU
-static inline
-#endif
-int abortboot(int bootdelay)
+static int abortboot_keyed(int bootdelay)
 {
 	int abort = 0;
 	uint64_t etime = endtick(bootdelay);
@@ -209,16 +205,11 @@ int abortboot(int bootdelay)
 	return abort;
 }
 
-# else	/* !defined(CONFIG_AUTOBOOT_KEYED) */
-
 #ifdef CONFIG_MENUKEY
 static int menukey = 0;
 #endif
 
-#ifndef CONFIG_MENU
-static inline
-#endif
-int abortboot(int bootdelay)
+static int abortboot_normal(int bootdelay)
 {
 	int abort = 0;
 	unsigned long ts;
@@ -274,7 +265,14 @@ int abortboot(int bootdelay)
 
 	return abort;
 }
-# endif	/* CONFIG_AUTOBOOT_KEYED */
+
+static int abortboot(int bootdelay)
+{
+	if (autoconf_autoboot_keyed())
+		return abortboot_keyed(bootdelay);
+	else
+		return abortboot_normal(bootdelay);
+}
 #endif	/* CONFIG_BOOTDELAY >= 0  */
 
 /*
diff --git a/include/common.h b/include/common.h
index 491783b..fb219fd 100644
--- a/include/common.h
+++ b/include/common.h
@@ -297,9 +297,6 @@ int	readline_into_buffer(const char *const prompt, char *buffer,
 int	parse_line (char *, char *[]);
 void	init_cmd_timeout(void);
 void	reset_cmd_timeout(void);
-#ifdef CONFIG_MENU
-int	abortboot(int bootdelay);
-#endif
 extern char console_buffer[];
 
 /* arch/$(ARCH)/lib/board.c */
-- 
1.8.1.3



More information about the U-Boot mailing list