summaryrefslogtreecommitdiffstats
path: root/common/command.c
diff options
context:
space:
mode:
authorSascha Hauer <sha@pengutronix.de>2009-10-17 12:01:14 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2009-10-19 10:18:51 +0200
commitef7ff70ca445f380548fe17f488dc6428aa1efc5 (patch)
tree1a672d375d001ff844d979e79dbe93ec3c92e8e5 /common/command.c
parent2dc2132f0e3c707a86fe332fd94b1c05b137dfe7 (diff)
downloadbarebox-ef7ff70ca445f380548fe17f488dc6428aa1efc5.tar.gz
barebox-ef7ff70ca445f380548fe17f488dc6428aa1efc5.tar.xz
consolidate command calling in execute_command
Signed-off-by: Sascha Hauer <sha@pengutronix.de>
Diffstat (limited to 'common/command.c')
-rw-r--r--common/command.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/common/command.c b/common/command.c
index accaffa4be..24c2e2407f 100644
--- a/common/command.c
+++ b/common/command.c
@@ -91,6 +91,25 @@ static int compare(struct list_head *a, struct list_head *b)
return strcmp(na, nb);
}
+int execute_command(int argc, char **argv)
+{
+ cmd_tbl_t *cmdtp;
+
+ /* Look up command in command table */
+ if ((cmdtp = find_cmd(argv[0]))) {
+ /* found - check max args */
+ if (argc > cmdtp->maxargs) {
+ u_boot_cmd_usage(cmdtp);
+ return -1;
+ }
+ /* OK - call function to do the command */
+ return cmdtp->cmd(cmdtp, argc, argv);
+ } else {
+ printf ("Unknown command '%s' - try 'help'\n", argv[0]);
+ return -1; /* give up after bad command */
+ }
+}
+
int register_command(cmd_tbl_t *cmd)
{
/*