diff options
author | Simon Glass <sjg@chromium.org> | 2012-02-14 19:59:25 +0000 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2012-03-06 21:09:41 +0100 |
commit | 9d12d5d41d5653ba2f943886f45b8c2eb0f63450 (patch) | |
tree | 03ea18e10cb7c8f06bf82525c8aacad91938ad93 /common/main.c | |
parent | 7344f9128dfa797a9b9d51b38832f77a1eaeac2d (diff) | |
download | u-boot-imx-9d12d5d41d5653ba2f943886f45b8c2eb0f63450.zip u-boot-imx-9d12d5d41d5653ba2f943886f45b8c2eb0f63450.tar.gz u-boot-imx-9d12d5d41d5653ba2f943886f45b8c2eb0f63450.tar.bz2 |
Add cmd_process() to process commands in one place
We currently have the same code in hush.c and main.c. This brings the
code into one place.
As an added feature, if the command function returns CMD_RET_USAGE then
cmd_process() will print a usage message for the command before
returning the standard failure code of 1.
ARM code size increases about 32 bytes with this clean-up.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/main.c')
-rw-r--r-- | common/main.c | 37 |
1 files changed, 1 insertions, 36 deletions
diff --git a/common/main.c b/common/main.c index 6a3eac2..4adc17a 100644 --- a/common/main.c +++ b/common/main.c @@ -1261,7 +1261,6 @@ static void process_macros (const char *input, char *output) */ static int builtin_run_command(const char *cmd, int flag) { - cmd_tbl_t *cmdtp; char cmdbuf[CONFIG_SYS_CBSIZE]; /* working copy of cmd */ char *token; /* start of token in cmdbuf */ char *sep; /* end of token (separator) in cmdbuf */ @@ -1339,41 +1338,7 @@ static int builtin_run_command(const char *cmd, int flag) continue; } - /* Look up command in command table */ - if ((cmdtp = find_cmd(argv[0])) == NULL) { - printf ("Unknown command '%s' - try 'help'\n", argv[0]); - rc = -1; /* give up after bad command */ - continue; - } - - /* found - check max args */ - if (argc > cmdtp->maxargs) { - cmd_usage(cmdtp); - rc = -1; - continue; - } - -#if defined(CONFIG_CMD_BOOTD) - /* avoid "bootd" recursion */ - if (cmdtp->cmd == do_bootd) { -#ifdef DEBUG_PARSER - printf ("[%s]\n", finaltoken); -#endif - if (flag & CMD_FLAG_BOOTD) { - puts ("'bootd' recursion detected\n"); - rc = -1; - continue; - } else { - flag |= CMD_FLAG_BOOTD; - } - } -#endif - - /* OK - call function to do the command */ - if (cmd_call(cmdtp, flag, argc, argv) != 0) - rc = -1; - - repeatable &= cmdtp->repeatable; + rc = cmd_process(flag, argc, argv, &repeatable); /* Did the user stop this? */ if (had_ctrlc ()) |