]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Stop using builtin_run_command()
authorSimon Glass <sjg@chromium.org>
Tue, 14 Feb 2012 19:59:21 +0000 (19:59 +0000)
committerWolfgang Denk <wd@denx.de>
Tue, 6 Mar 2012 20:09:26 +0000 (21:09 +0100)
Boards can select either the 'built-in' parser or the hush parser. We
should not call builtin_run_command() if we are using the hush parser.
We use run_command() instead, since it knows how to call the correct
parser.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
arch/arm/cpu/arm926ejs/kirkwood/cpu.c
board/esd/common/auto_update.c
board/esd/common/cmd_loadpci.c
board/esd/du440/du440.c
common/cmd_bedbug.c
common/cmd_bootm.c
common/cmd_source.c
common/main.c
include/common.h

index 54d15ea347de273b6158a3184f1e264c690fd401..fba5e01454d85200205d3cf6d56c1d6aac96634c 100644 (file)
@@ -226,12 +226,7 @@ static void kw_sysrst_action(void)
        }
 
        debug("Starting %s process...\n", __FUNCTION__);
-#if !defined(CONFIG_SYS_HUSH_PARSER)
-       ret = builtin_run_command(s, 0);
-#else
-       ret = parse_string_outer(s, FLAG_PARSE_SEMICOLON
-                                 | FLAG_EXIT_FROM_LOOP);
-#endif
+       ret = run_command(s, 0);
        if (ret < 0)
                debug("Error.. %s failed\n", __FUNCTION__);
        else
index 4cc15fa2b8896d7a47a89ac3d8d2951e11fd5f9c..fc60545d048b249febd17993929c17192d191193 100644 (file)
@@ -169,7 +169,7 @@ int au_do_update(int i, long sz)
                                k++;
                        }
 
-                       builtin_run_command(addr, 0);
+                       run_command(addr, 0);
                        return 0;
                }
 
index c2bf2792e90297acbfe63a4199bfb38e20179356..8fcae63f232f40d96f4f814d5fbe6e531391cdac 100644 (file)
@@ -110,7 +110,7 @@ int do_loadpci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                         * Call run_cmd
                         */
                        printf("running command at addr 0x%s ...\n", addr);
-                       builtin_run_command((char *)la, 0);
+                       run_command((char *)la, 0);
                        break;
 
                default:
index 75fb20079e9b171d59125be9ee24bc7cc04a3928..1ada1bc98490787c883aa792dc037c85813b416f 100644 (file)
@@ -831,7 +831,7 @@ int do_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        *d = '\0';
 
        start = get_ticks();
-       ret = builtin_run_command(cmd, 0);
+       ret = run_command(cmd, 0);
        end = get_ticks();
 
        printf("ticks=%ld\n", (ulong)(end - start));
index 0228ee875cead91532e7bf4077a13089aca708d6..5b0812382205d0a25066fc3f22374fece3ceaf5e 100644 (file)
@@ -237,7 +237,7 @@ void bedbug_main_loop (unsigned long addr, struct pt_regs *regs)
                if (len == -1)
                        printf ("<INTERRUPT>\n");
                else
-                       rc = builtin_run_command(lastcommand, flag);
+                       rc = run_command(lastcommand, flag);
 
                if (rc <= 0) {
                        /* invalid command or not repeatable, forget it */
index 2e3e1593cea003faed3adaae0e4fb465f437516c..6bfef6292f4a08b4d6db609cc24e2274ecc27c76 100644 (file)
@@ -1045,14 +1045,8 @@ int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        int rcode = 0;
 
-#ifndef CONFIG_SYS_HUSH_PARSER
-       if (builtin_run_command(getenv("bootcmd"), flag) < 0)
+       if (run_command(getenv("bootcmd"), flag) < 0)
                rcode = 1;
-#else
-       if (parse_string_outer(getenv("bootcmd"),
-                       FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0)
-               rcode = 1;
-#endif
        return rcode;
 }
 
index 481241cfdf2b84eee1348f7003a33a6c1291299e..32fff5cec819f462fcff9a00691691f4181a8915 100644 (file)
@@ -179,7 +179,7 @@ source (ulong addr, const char *fit_uname)
                                if (*line) {
                                        debug ("** exec: \"%s\"\n",
                                                line);
-                                       if (builtin_run_command(line, 0) < 0) {
+                                       if (run_command(line, 0) < 0) {
                                                rcode = 1;
                                                break;
                                        }
@@ -189,7 +189,7 @@ source (ulong addr, const char *fit_uname)
                        ++next;
                }
                if (rcode == 0 && *line)
-                       rcode = (builtin_run_command(line, 0) >= 0);
+                       rcode = (run_command(line, 0) >= 0);
        }
 #endif
        free (cmd);
index 797b245c39b68e446ca3e9e2bb342b27b3ccc2af..10ee12c2789d63cb07fa0091d1b62f8dda42e0a5 100644 (file)
@@ -267,26 +267,6 @@ int abortboot(int bootdelay)
 # endif        /* CONFIG_AUTOBOOT_KEYED */
 #endif /* CONFIG_BOOTDELAY >= 0  */
 
-/*
- * Return 0 on success, or != 0 on error.
- */
-int run_command(const char *cmd, int flag)
-{
-#ifndef CONFIG_SYS_HUSH_PARSER
-       /*
-        * builtin_run_command can return 0 or 1 for success, so clean up
-        * its result.
-        */
-       if (builtin_run_command(cmd, flag) == -1)
-               return 1;
-
-       return 0;
-#else
-       return parse_string_outer(cmd,
-                       FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP);
-#endif
-}
-
 /****************************************************************************/
 
 void main_loop (void)
@@ -458,7 +438,7 @@ void main_loop (void)
                if (len == -1)
                        puts ("<INTERRUPT>\n");
                else
-                       rc = builtin_run_command(lastcommand, flag);
+                       rc = run_command(lastcommand, flag);
 
                if (rc <= 0) {
                        /* invalid command or not repeatable, forget it */
@@ -1278,8 +1258,7 @@ static void process_macros (const char *input, char *output)
  * the environment data, which may change magicly when the command we run
  * creates or modifies environment variables (like "bootp" does).
  */
-
-int builtin_run_command(const char *cmd, int flag)
+static int builtin_run_command(const char *cmd, int flag)
 {
        cmd_tbl_t *cmdtp;
        char cmdbuf[CONFIG_SYS_CBSIZE]; /* working copy of cmd          */
@@ -1404,6 +1383,30 @@ int builtin_run_command(const char *cmd, int flag)
        return rc ? rc : repeatable;
 }
 
+/*
+ * Run a command using the selected parser.
+ *
+ * @param cmd  Command to run
+ * @param flag Execution flags (CMD_FLAG_...)
+ * @return 0 on success, or != 0 on error.
+ */
+int run_command(const char *cmd, int flag)
+{
+#ifndef CONFIG_SYS_HUSH_PARSER
+       /*
+        * builtin_run_command can return 0 or 1 for success, so clean up
+        * its result.
+        */
+       if (builtin_run_command(cmd, flag) == -1)
+               return 1;
+
+       return 0;
+#else
+       return parse_string_outer(cmd,
+                       FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP);
+#endif
+}
+
 /****************************************************************************/
 
 #if defined(CONFIG_CMD_RUN)
index e8b62a96c5fd5697b6a52bf238d14b7a11aebfd2..0bda049819cf37a43a75585a82474af8effbc22c 100644 (file)
@@ -260,7 +260,6 @@ int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen);
 
 /* common/main.c */
 void   main_loop       (void);
-int builtin_run_command(const char *cmd, int flag);
 int run_command(const char *cmd, int flag);
 int    readline        (const char *const prompt);
 int    readline_into_buffer(const char *const prompt, char *buffer,