summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2012-02-14 19:59:21 +0000
committerWolfgang Denk <wd@denx.de>2012-03-06 21:09:26 +0100
commit5307153236caaf2304e578c148e00a4b65cb8604 (patch)
tree6c15ac7b41232fd580a2a2ff75ee5bdee76a20e7 /common
parent009dde1955583e306cf904c864068f3acb0db499 (diff)
downloadblackbird-obmc-uboot-5307153236caaf2304e578c148e00a4b65cb8604.tar.gz
blackbird-obmc-uboot-5307153236caaf2304e578c148e00a4b65cb8604.zip
Stop using builtin_run_command()
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>
Diffstat (limited to 'common')
-rw-r--r--common/cmd_bedbug.c2
-rw-r--r--common/cmd_bootm.c8
-rw-r--r--common/cmd_source.c4
-rw-r--r--common/main.c49
4 files changed, 30 insertions, 33 deletions
diff --git a/common/cmd_bedbug.c b/common/cmd_bedbug.c
index 0228ee875c..5b08123822 100644
--- a/common/cmd_bedbug.c
+++ b/common/cmd_bedbug.c
@@ -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 */
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 2e3e1593ce..6bfef6292f 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -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;
}
diff --git a/common/cmd_source.c b/common/cmd_source.c
index 481241cfdf..32fff5cec8 100644
--- a/common/cmd_source.c
+++ b/common/cmd_source.c
@@ -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);
diff --git a/common/main.c b/common/main.c
index 797b245c39..10ee12c278 100644
--- a/common/main.c
+++ b/common/main.c
@@ -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)
OpenPOWER on IntegriCloud