summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2012-02-14 19:59:23 +0000
committerWolfgang Denk <wd@denx.de>2012-03-06 21:09:34 +0100
commitbdf8e34b936e2b94990ab6ce8dd5463d14d173dd (patch)
tree1cd5822ee530eaba3b22fb6fcf50967c6fce6d19 /common
parent7fed89e00e0836f7894f350716b3f182ee562760 (diff)
downloadu-boot-imx-bdf8e34b936e2b94990ab6ce8dd5463d14d173dd.zip
u-boot-imx-bdf8e34b936e2b94990ab6ce8dd5463d14d173dd.tar.gz
u-boot-imx-bdf8e34b936e2b94990ab6ce8dd5463d14d173dd.tar.bz2
Create a single cmd_call() function to handle command execution
We should aim for a single point of entry to the commands, whichever parser is used. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/command.c21
-rw-r--r--common/hush.c9
-rw-r--r--common/main.c3
3 files changed, 25 insertions, 8 deletions
diff --git a/common/command.c b/common/command.c
index c5cecd3..fe29075 100644
--- a/common/command.c
+++ b/common/command.c
@@ -487,3 +487,24 @@ void fixup_cmdtable(cmd_tbl_t *cmdtp, int size)
}
}
#endif
+
+/**
+ * Call a command function. This should be the only route in U-Boot to call
+ * a command, so that we can track whether we are waiting for input or
+ * executing a command.
+ *
+ * @param cmdtp Pointer to the command to execute
+ * @param flag Some flags normally 0 (see CMD_FLAG_.. above)
+ * @param argc Number of arguments (arg 0 must be the command text)
+ * @param argv Arguments
+ * @return 0 if command succeeded, else non-zero (CMD_RET_...)
+ */
+int cmd_call(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ int result;
+
+ result = (cmdtp->cmd)(cmdtp, flag, argc, argv);
+ if (result)
+ debug("Command failed, result=%d", result);
+ return result;
+}
diff --git a/common/hush.c b/common/hush.c
index e8e24d7..6cb921d 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -1679,13 +1679,10 @@ static int run_pipe_real(struct pipe *pi)
rcode = x->function(child);
#else
/* OK - call function to do the command */
-
- rcode = (cmdtp->cmd)
-(cmdtp, flag,child->argc-i,&child->argv[i]);
- if ( !cmdtp->repeatable )
+ rcode = cmd_call(cmdtp, flag, child->argc-i,
+ &child->argv[i]);
+ if (!cmdtp->repeatable)
flag_repeat = 0;
-
-
#endif
child->argv-=i; /* XXX restore hack so free() can work right */
#ifndef __U_BOOT__
diff --git a/common/main.c b/common/main.c
index 637da2b..6a3eac2 100644
--- a/common/main.c
+++ b/common/main.c
@@ -1370,9 +1370,8 @@ static int builtin_run_command(const char *cmd, int flag)
#endif
/* OK - call function to do the command */
- if ((cmdtp->cmd) (cmdtp, flag, argc, argv) != 0) {
+ if (cmd_call(cmdtp, flag, argc, argv) != 0)
rc = -1;
- }
repeatable &= cmdtp->repeatable;