Rename bootretry functions and remove #ifdefs
authorSimon Glass <sjg@chromium.org>
Fri, 11 Apr 2014 02:01:31 +0000 (20:01 -0600)
committerTom Rini <trini@ti.com>
Thu, 29 May 2014 21:49:00 +0000 (17:49 -0400)
Add a bootretry_ prefix to these two functions, and remove the need for
the #ifdef around everything (it moves to the Makefile).

Signed-off-by: Simon Glass <sjg@chromium.org>
board/hymod/hymod.c
board/hymod/input.c
common/autoboot.c
common/bootretry.c
common/cli_hush.c
common/cli_simple.c
common/cmd_i2c.c
common/cmd_mem.c
common/cmd_pci.c
include/bootretry.h
include/cli.h

index f6990e929f975898952263ed1bd05ab4fa3ec7ee..0183f781dec43dffe706f345de0d59ef846d0a07 100644 (file)
@@ -415,13 +415,11 @@ last_stage_init (void)
        hymod_conf_t *cp = &gd->bd->bi_hymod_conf;
        int rc;
 
-#ifdef CONFIG_BOOT_RETRY_TIME
        /*
         * we use the cli_readline() function, but we also want
         * command timeout enabled
         */
-       init_cmd_timeout ();
-#endif
+       bootretry_init_cmd_timeout();
 
        memset ((void *) cp, 0, sizeof (*cp));
 
index 2f857c06ae92683bd515fedaf60db2ac5f408d3a..a9035d340591042d4113b1af0b3019b53d3f8e9d 100644 (file)
@@ -16,9 +16,7 @@ hymod_get_serno (const char *prompt)
                int n, serno;
                char *p;
 
-#ifdef CONFIG_BOOT_RETRY_TIME
-               reset_cmd_timeout ();
-#endif
+               bootretry_reset_cmd_timeout();
 
                n = cli_readline(prompt);
 
@@ -44,9 +42,7 @@ hymod_get_ethaddr (void)
        for (;;) {
                int n;
 
-#ifdef CONFIG_BOOT_RETRY_TIME
-               reset_cmd_timeout ();
-#endif
+               bootretry_reset_cmd_timeout();
 
                n = cli_readline("Enter board ethernet address: ");
 
index 5f8d9c3445cdc6e7c873e7e9822254f901a05d6f..984389885f2c0a66007a490e1e29e75888e3e337 100644 (file)
@@ -113,11 +113,9 @@ 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)
                                        bootretry_dont_retry();
-#  endif
                                abort = 1;
                        }
                }
@@ -305,9 +303,7 @@ void bootdelay_process(void)
 #if defined(CONFIG_MENU_SHOW)
        bootdelay = menu_show(bootdelay);
 #endif
-# ifdef CONFIG_BOOT_RETRY_TIME
-       init_cmd_timeout();
-# endif        /* CONFIG_BOOT_RETRY_TIME */
+       bootretry_init_cmd_timeout();
 
 #ifdef CONFIG_POST
        if (gd->flags & GD_FLG_POSTFAIL) {
index 12653c00d0f259dcd06ae60d21812557f64e447e..2d82798cd04bc6ba004d2382ceaab79637c79a85 100644 (file)
@@ -21,7 +21,7 @@ static int      retry_time = -1; /* -1 so can call readline before main_loop */
 /***************************************************************************
  * initialize command line timeout
  */
-void init_cmd_timeout(void)
+void bootretry_init_cmd_timeout(void)
 {
        char *s = getenv("bootretry");
 
@@ -37,7 +37,7 @@ void init_cmd_timeout(void)
 /***************************************************************************
  * reset command line timeout to retry_time seconds
  */
-void reset_cmd_timeout(void)
+void bootretry_reset_cmd_timeout(void)
 {
        endtime = endtick(retry_time);
 }
index d6544ae63111fc034c2cba57b0f1fddfc25c6254..0f069b010a2d39975635574fdbd5dc36554c09d4 100644 (file)
@@ -1000,12 +1000,7 @@ static void get_user_input(struct in_str *i)
        int n;
        static char the_command[CONFIG_SYS_CBSIZE + 1];
 
-#ifdef CONFIG_BOOT_RETRY_TIME
-#  ifndef CONFIG_RESET_TO_RETRY
-#      error "This currently only works with CONFIG_RESET_TO_RETRY enabled"
-#  endif
-       reset_cmd_timeout();
-#endif
+       bootretry_reset_cmd_timeout();
        i->__promptme = 1;
        if (i->promptmode == 1) {
                n = cli_readline(CONFIG_SYS_PROMPT);
index 5b7e2ce7d53a832a71edd7a8ad5f38f1bf7cb899..bba586ed44e2f9a6c2b2c1c944eb6d4977f3c4d1 100644 (file)
@@ -265,14 +265,12 @@ void cli_loop(void)
        int rc = 1;
 
        for (;;) {
-#ifdef CONFIG_BOOT_RETRY_TIME
                if (rc >= 0) {
                        /* Saw enough of a valid command to
                         * restart the timeout.
                         */
-                       reset_cmd_timeout();
+                       bootretry_reset_cmd_timeout();
                }
-#endif
                len = cli_readline(CONFIG_SYS_PROMPT);
 
                flag = 0;       /* assume no special flags for now */
index 4fa12138c357a785c5622c6b969e8a59cbaf6bf8..d714658d7f548fc7089e184e6fd8f63c6322a80c 100644 (file)
@@ -564,9 +564,7 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg
        if (argc != 3)
                return CMD_RET_USAGE;
 
-#ifdef CONFIG_BOOT_RETRY_TIME
-       reset_cmd_timeout();    /* got a good command to get here */
-#endif
+       bootretry_reset_cmd_timeout();  /* got a good command to get here */
        /*
         * We use the last specified parameters, unless new ones are
         * entered.
@@ -623,9 +621,8 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg
                        if (incrflag)
                                addr += size;
                        nbytes = size;
-#ifdef CONFIG_BOOT_RETRY_TIME
-                       reset_cmd_timeout(); /* good enough to not time out */
-#endif
+                       /* good enough to not time out */
+                       bootretry_reset_cmd_timeout();
                }
 #ifdef CONFIG_BOOT_RETRY_TIME
                else if (nbytes == -2)
@@ -642,12 +639,10 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg
                        data = be32_to_cpu(data);
                        nbytes = endp - console_buffer;
                        if (nbytes) {
-#ifdef CONFIG_BOOT_RETRY_TIME
                                /*
                                 * good enough to not time out
                                 */
-                               reset_cmd_timeout();
-#endif
+                               bootretry_reset_cmd_timeout();
                                if (i2c_write(chip, addr, alen, (uchar *)&data, size) != 0)
                                        puts ("Error writing the chip.\n");
 #ifdef CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS
index 9bd7c0eedb93d89cf444836a04654861d77b0c8b..1febddb916c2fc6603ab890679782700923b88fa 100644 (file)
@@ -1098,9 +1098,7 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
        if (argc != 2)
                return CMD_RET_USAGE;
 
-#ifdef CONFIG_BOOT_RETRY_TIME
-       reset_cmd_timeout();    /* got a good command to get here */
-#endif
+       bootretry_reset_cmd_timeout();  /* got a good command to get here */
        /* We use the last specified parameters, unless new ones are
         * entered.
         */
@@ -1159,9 +1157,8 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
                        if (incrflag)
                                addr += nbytes ? -size : size;
                        nbytes = 1;
-#ifdef CONFIG_BOOT_RETRY_TIME
-                       reset_cmd_timeout(); /* good enough to not time out */
-#endif
+                       /* good enough to not time out */
+                       bootretry_reset_cmd_timeout();
                }
 #ifdef CONFIG_BOOT_RETRY_TIME
                else if (nbytes == -2) {
@@ -1177,11 +1174,9 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
 #endif
                        nbytes = endp - console_buffer;
                        if (nbytes) {
-#ifdef CONFIG_BOOT_RETRY_TIME
                                /* good enough to not time out
                                 */
-                               reset_cmd_timeout();
-#endif
+                               bootretry_reset_cmd_timeout();
                                if (size == 4)
                                        *((u32 *)ptr) = i;
 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
index 180b35ab0f777fe4f822d8f100a66267c9c99310..a1ba42e2f3a2c3a4abc625af674a4599af451f38 100644 (file)
@@ -355,9 +355,8 @@ pci_cfg_modify (pci_dev_t bdf, ulong addr, ulong size, ulong value, int incrflag
                        if (incrflag)
                                addr += nbytes ? -size : size;
                        nbytes = 1;
-#ifdef CONFIG_BOOT_RETRY_TIME
-                       reset_cmd_timeout(); /* good enough to not time out */
-#endif
+                       /* good enough to not time out */
+                       bootretry_reset_cmd_timeout();
                }
 #ifdef CONFIG_BOOT_RETRY_TIME
                else if (nbytes == -2) {
@@ -369,11 +368,9 @@ pci_cfg_modify (pci_dev_t bdf, ulong addr, ulong size, ulong value, int incrflag
                        i = simple_strtoul(console_buffer, &endp, 16);
                        nbytes = endp - console_buffer;
                        if (nbytes) {
-#ifdef CONFIG_BOOT_RETRY_TIME
                                /* good enough to not time out
                                 */
-                               reset_cmd_timeout();
-#endif
+                               bootretry_reset_cmd_timeout();
                                pci_cfg_write (bdf, addr, size, i);
                                if (incrflag)
                                        addr += size;
index 025c29d526ac871f1cd1edb00d9168cac9fa598d..2ecd7a48b06c9552a94499cdf2e58ea78bc9b4c7 100644 (file)
@@ -5,8 +5,8 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
-#ifndef __bootretry_h
-#define __bootretry_h
+#ifndef __BOOTRETRY_H
+#define __BOOTRETRY_H
 
 #ifdef CONFIG_BOOT_RETRY_TIME
 /**
  * @return 0 if a key is received in time, -ETIMEDOUT if not
  */
 int bootretry_tstc_timeout(void);
+
+/**
+ * bootretry_init_cmd_timeout() - set up command timeout
+ *
+ * Get the required command timeout from the environment.
+ */
+void bootretry_init_cmd_timeout(void);
+
+/**
+ * bootretry_reset_cmd_timeout() - reset command timeout
+ *
+ * Reset the command timeout so that the user has a fresh start. This is
+ * typically used when input is received from the user.
+ */
+void bootretry_reset_cmd_timeout(void);
+
+/** bootretry_dont_retry() - Indicate that we should not retry the boot */
+void bootretry_dont_retry(void);
 #else
 static inline int bootretry_tstc_timeout(void)
 {
        return 0;
 }
-#endif
 
-void init_cmd_timeout(void);
-void reset_cmd_timeout(void);
+static inline void bootretry_init_cmd_timeout(void)
+{
+}
+
+static inline void bootretry_reset_cmd_timeout(void)
+{
+}
+
+static inline void bootretry_dont_retry(void)
+{
+}
+
+#endif
 
 #endif
index 61f8aee4add979f5af97e7e2e8c29e1676f15270..10dbc6665153427c215bed6fffdf65f8a222ef4e 100644 (file)
@@ -100,9 +100,6 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer,
  */
 int cli_simple_parse_line(char *line, char *argv[]);
 
-/** bootretry_dont_retry() - Indicate that we should not retry the boot */
-void bootretry_dont_retry(void);
-
 #define endtick(seconds) (get_ticks() + (uint64_t)(seconds) * get_tbclk())
 
 #endif