Convert this function and its children to use autoconf instead of #ifdef.

Some header files must now be included unconditionally, so remove some of
the #ifdefs from the header section, and put these header files into the
right order.

Signed-off-by: Simon Glass <s...@chromium.org>
---
Changes in v2: None

 common/main.c  | 104 +++++++++++++++++++++++----------------------------------
 include/menu.h |   2 --
 2 files changed, 41 insertions(+), 65 deletions(-)

diff --git a/common/main.c b/common/main.c
index 4f11e58..a5d3f82 100644
--- a/common/main.c
+++ b/common/main.c
@@ -31,27 +31,17 @@
 #include <watchdog.h>
 #include <command.h>
 #include <fdtdec.h>
+#include <fdt_support.h>
 #include <malloc.h>
+#include <menu.h>
 #include <version.h>
-#ifdef CONFIG_MODEM_SUPPORT
-#include <malloc.h>            /* for free() prototype */
-#endif
 
 #ifdef CONFIG_SYS_HUSH_PARSER
 #include <hush.h>
 #endif
 
-#ifdef CONFIG_OF_CONTROL
-#include <fdtdec.h>
-#endif
-
-#ifdef CONFIG_OF_LIBFDT
-#include <fdt_support.h>
-#endif /* CONFIG_OF_LIBFDT */
-
 #include <post.h>
 #include <linux/ctype.h>
-#include <menu.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -258,7 +248,6 @@ static int abortboot(int bootdelay)
  * printing the error message to console.
  */
 
-#ifdef CONFIG_OF_CONTROL
 static void secure_boot_cmd(char *cmd)
 {
        cmd_tbl_t *cmdtp;
@@ -311,93 +300,82 @@ static void process_fdt_options(const void *blob)
                            (void *)(autoconf_sys_text_base() + addr));
        }
 }
-#endif /* CONFIG_OF_CONTROL */
 
 static void process_boot_delay(void)
 {
-#ifdef CONFIG_BOOTCOUNT_LIMIT
        unsigned long bootcount = 0;
        unsigned long bootlimit = 0;
-#endif /* CONFIG_BOOTCOUNT_LIMIT */
-#ifdef CONFIG_OF_CONTROL
-       char *env;
-#endif
-       char *s;
+       const char *s;
        int bootdelay;
 
-#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 */
+       if (autoconf_bootcount_limit()) {
+               bootcount = bootcount_load();
+               bootcount++;
+               bootcount_store(bootcount);
+               setenv_ulong("bootcount", bootcount);
+               bootlimit = getenv_ulong("bootlimit", 10, 0);
+       }
 
        s = getenv ("bootdelay");
        bootdelay = s ? (int)simple_strtol(s, NULL, 10) : autoconf_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");
-#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>");
 
        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 */
 }
 
 /****************************************************************************/
diff --git a/include/menu.h b/include/menu.h
index 7af5fdb..1cdcb88 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -28,7 +28,5 @@ int menu_item_add(struct menu *m, char *item_key, void 
*item_data);
 int menu_destroy(struct menu *m);
 void menu_display_statusline(struct menu *m);
 
-#if defined(CONFIG_MENU_SHOW)
 int menu_show(int bootdelay);
-#endif
 #endif /* __MENU_H__ */
-- 
1.8.1.3

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to