Unified command execution in one place
v4 cover Unified command execution in one place
At present two parsers have similar code to execute commands. Also cmd_usage() is called all over the place. This series adds a single function which processes commands called cmd_process().
This new function understands return codes, and in particular CMD_RET_USAGE to indicate a usage error. So rather than calling cmd_usage() themselves, the command handlers can just return this error.
There appears to be a run_command2() which is used to run commands with the selected parser. This series changes this in two separate steps to just run_command(), and renames the old run_command() to builtin_run_command(). No one should call this outside main.c since if the hush parser is being used it is wrong to call it. The built-in parser code could move into a separate file perhaps in a future patch.
The overall series reduces code size on ARM by about 1KB on my ~160KB U-Boot text region when the hush parser is used, and around 60 bytes when it isn't.
As an aside the only user of parse_line() is fsl_ddr_interactive() which seems to have its own command line interface which operates before DRAM is set up. Do I have this right? Is there no way this could be done later from a normal U-Boot command?
(I have run this through MAKEALL and it seems clean)
Changes in v2:
- Fix minor errors one of which created a warning
- Squash i2c patch into the common/ patch
Changes in v3:
- Rebase to master
Changes in v4:
- Minor comment change for call to builtin_run_command()
- Add a 'repeatable' parameter to cmd_process()
- Rationalise return codes to 0, 1 and usage
- Make cmd_process() return only success (0) or failure (1)
Simon Glass (9):
Remove CMD_PXE's static on run_command()
Rename run_command() to builtin_run_command()
Rename run_command2() to run_command()
Stop using builtin_run_command()
Don't include standard parser if hush is used
Create a single cmd_call() function to handle command execution Remove interleave of non-U-Boot code in hush
Add cmd_process() to process commands in one place Convert cmd_usage() calls in common to use a return value
arch/arm/cpu/arm926ejs/kirkwood/cpu.c | 7 +-- board/esd/common/cmd_loadpci.c | 2 +- board/esd/du440/du440.c | 2 +- common/cmd_bedbug.c | 6 +- common/cmd_bmp.c | 6 +- common/cmd_boot.c | 2 +- common/cmd_bootm.c | 10 +--- common/cmd_cache.c | 4 +- common/cmd_dataflash_mmc_mux.c | 2 +- common/cmd_date.c | 3 +- common/cmd_dcr.c | 8 ++-- common/cmd_df.c | 2 +- common/cmd_eeprom.c | 2 +- common/cmd_ext2.c | 4 +- common/cmd_fdc.c | 2 +- common/cmd_fdos.c | 2 +- common/cmd_fdt.c | 14 +++--- common/cmd_fitupd.c | 2 +- common/cmd_flash.c | 14 +++--- common/cmd_fpga.c | 4 +- common/cmd_gpio.c | 2 +- common/cmd_i2c.c | 32 ++++++------ common/cmd_ide.c | 10 ++-- common/cmd_irq.c | 2 +- common/cmd_itest.c | 2 +- common/cmd_led.c | 6 +- common/cmd_load.c | 2 +- common/cmd_log.c | 4 +- common/cmd_md5sum.c | 2 +- common/cmd_mdio.c | 2 +- common/cmd_mem.c | 22 ++++---- common/cmd_mfsl.c | 10 ++-- common/cmd_mgdisk.c | 2 +- common/cmd_mii.c | 4 +- common/cmd_misc.c | 2 +- common/cmd_mmc.c | 14 +++--- common/cmd_mmc_spi.c | 3 +- common/cmd_mp.c | 8 ++-- common/cmd_mtdparts.c | 2 +- common/cmd_nand.c | 6 +- common/cmd_net.c | 6 +- common/cmd_nvedit.c | 22 ++++---- common/cmd_onenand.c | 12 ++-- common/cmd_otp.c | 2 +- common/cmd_pci.c | 2 +- common/cmd_portio.c | 4 +- common/cmd_pxe.c | 10 ++-- common/cmd_reiser.c | 4 +- common/cmd_sata.c | 8 ++-- common/cmd_scsi.c | 15 +++--- common/cmd_setexpr.c | 2 +- common/cmd_sf.c | 2 +- common/cmd_sha1sum.c | 2 +- common/cmd_source.c | 2 +- common/cmd_strings.c | 2 +- common/cmd_time.c | 4 +- common/cmd_ubi.c | 4 +- common/cmd_ubifs.c | 10 ++-- common/cmd_unzip.c | 2 +- common/cmd_usb.c | 6 +- common/command.c | 60 ++++++++++++++++++++ common/hush.c | 69 ++++++----------------- common/main.c | 97 ++++++++++----------------------- include/command.h | 32 +++++++++++ include/common.h | 5 +-- 65 files changed, 313 insertions(+), 306 deletions(-)
Signature · 1 line
1.7.7.3
PATCH v4 1/9 Remove CMD_PXE's static on run_command()
It really isn't clear why this is here and there is no comment, so drop it.
---
common/main.c | 3 --- include/common.h | 2 -- 2 files changed, 0 insertions(+), 5 deletions(-)
common/main.c +0 -3
@@ -269,9 +269,6 @@ int abortboot(int bootdelay)/* * Return 0 on success, or != 0 on error. */ -#ifndef CONFIG_CMD_PXE -static inline -#endifint run_command2 (const char *cmd,int flag) {#ifndef CONFIG_SYS_HUSH_PARSER
include/common.h +0 -2
@@ -261,9 +261,7 @@ int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen);/* common/main.c */ void main_loop (void );int run_command (const char *cmd,int flag); -#ifdef CONFIG_CMD_PXE int run_command2 (const char *cmd,int flag); -#endif int readline (const char *const prompt);int readline_into_buffer (const char *const prompt,char * buffer);int parse_line (char *,char *[]);
Signature · 1 line
1.7.7.3
PATCH v4 2/9 Rename run_command() to builtin_run_command()
In reply to Simon GlassThe current run_command() is only one of the options, with hush providing the other. It really shouldn't be called directly in case the hush parser is being used, so rename this function to better explain its purpose.
---
Changes in v4:
- Minor comment change for call to builtin_run_command()
arch/arm/cpu/arm926ejs/kirkwood/cpu.c | 2 +- board/esd/common/auto_update.c | 2 +- board/esd/common/cmd_loadpci.c | 2 +- board/esd/du440/du440.c | 2 +- common/cmd_bedbug.c | 2 +- common/cmd_bootm.c | 2 +- common/cmd_source.c | 4 ++-- common/main.c | 9 +++++---- include/common.h | 2 +- 9 files changed, 14 insertions(+), 13 deletions(-)
arch/arm/cpu/arm926ejs/kirkwood/cpu.c +1 -1
@@ -227,7 +227,7 @@ static void kw_sysrst_action(void)debug ("Starting %s process...\n" , __FUNCTION__);#if !defined(CONFIG_SYS_HUSH_PARSER ) - ret =run_command (s,0 ); + ret =builtin_run_command (s,0 );#else ret =parse_string_outer (s,FLAG_PARSE_SEMICOLON |FLAG_EXIT_FROM_LOOP );
board/esd/common/auto_update.c +1 -1
@@ -169,7 +169,7 @@ int au_do_update(int i, long sz) k++; } -run_command (addr,0 ); +builtin_run_command (addr,0 );return 0 ; }
board/esd/common/cmd_loadpci.c +1 -1
@@ -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); -run_command ((char *)la,0 ); +builtin_run_command ((char *)la,0 );break ;default :
board/esd/du440/du440.c +1 -1
@@ -831,7 +831,7 @@ int do_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) *d ='\0' ; start =get_ticks (); - ret =run_command (cmd,0 ); + ret =builtin_run_command (cmd,0 ); end =get_ticks ();printf ("ticks=%ld\n" , (ulong)(end - start));
common/cmd_bedbug.c +1 -1
@@ -237,7 +237,7 @@ void bedbug_main_loop (unsigned long addr, struct pt_regs *regs)if (len ==-1 )printf ("<INTERRUPT>\n" );else - rc =run_command (lastcommand, flag); + rc =builtin_run_command (lastcommand, flag);if (rc <=0 ) {/* invalid command or not repeatable, forget it */
common/cmd_bootm.c +1 -1
@@ -1046,7 +1046,7 @@ int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int rcode =0 ;#ifndef CONFIG_SYS_HUSH_PARSER -if (run_command (getenv ("bootcmd" ), flag) <0 ) +if (builtin_run_command (getenv ("bootcmd" ), flag) <0 ) rcode =1 ;#else if (parse_string_outer(getenv("bootcmd"),
common/cmd_source.c +2 -2
@@ -179,7 +179,7 @@ source (ulong addr, const char *fit_uname)if (*line) {debug ("** exec: \"%s\"\n" , line); -if (run_command (line,0 ) <0 ) { +if (builtin_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 = (run_command (line,0 ) >=0 ); + rcode = (builtin_run_command (line,0 ) >=0 ); }#endif free (cmd);
common/main.c +5 -4
@@ -273,9 +273,10 @@ int run_command2(const char *cmd, int flag) {#ifndef CONFIG_SYS_HUSH_PARSER /* -* run_command can return 0 or 1 for success, so clean up its result. +* builtin_run_command can return 0 or 1 for success, so clean up +* its result. */ -if (run_command (cmd, flag) ==-1 ) +if (builtin_run_command (cmd, flag) ==-1 )return 1 ;return 0 ;
@@ -453,7 +454,7 @@ void main_loop (void)if (len ==-1 )puts ("<INTERRUPT>\n" );else - rc =run_command (lastcommand, flag); + rc =builtin_run_command (lastcommand, flag);if (rc <=0 ) {/* invalid command or not repeatable, forget it */
@@ -1262,7 +1263,7 @@ static void process_macros (const char *input, char *output)* creates or modifies environment variables (like "bootp" does). */ -int run_command (const char *cmd,int flag) +int builtin_run_command (const char *cmd,int flag) {cmd_tbl_t *cmdtp;char cmdbuf[CONFIG_SYS_CBSIZE ];/* working copy of cmd */
include/common.h +1 -1
@@ -260,7 +260,7 @@ int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen);/* common/main.c */ void main_loop (void ); -int run_command (const char *cmd,int flag); +int builtin_run_command (const char *cmd,int flag);int run_command2 (const char *cmd,int flag);int readline (const char *const prompt);int readline_into_buffer (const char *const prompt,char * buffer);
Signature · 1 line
1.7.7.3
PATCH v4 2/9 Rename run_command() to builtin_run_command()
Quoted 2 lines · On Saturday 14 January 2012 01:45:50 Simon Glass wrote:
The current
run_command()is only one of the options, with hush providing the other.
i can't grok this sentence
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120204/e3032786/attachment.pgp>
PATCH v4 2/9 Rename run_command() to builtin_run_command()
Hi Mike,
Quoted 7 lines · Mike Frysinger
Quoted 2 lines · On Saturday 14 January 2012 01:45:50 Simon Glass wrote:
The current
run_command()is only one of the options, with hush providing the other.i can't grok this sentence
-mike
OK I will reword it.
Regards,
Simon
PATCH v4 3/9 Rename run_command2() to run_command()
In reply to Simon GlassThis is a more sensible name, so rename it.
---
common/cmd_pxe.c | 2 +- common/main.c | 10 +++++----- include/common.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)
common/cmd_pxe.c +1 -1
@@ -537,7 +537,7 @@ static int label_localboot(struct pxe_label *label)printf ("running: %s\n" , dupcmd); - ret =run_command2 (dupcmd,0 ); + ret =run_command (dupcmd,0 );free (dupcmd);
common/main.c +5 -5
@@ -269,7 +269,7 @@ int abortboot(int bootdelay)/* * Return 0 on success, or != 0 on error. */ -int run_command2 (const char *cmd,int flag) +int run_command (const char *cmd,int flag) {#ifndef CONFIG_SYS_HUSH_PARSER /*
@@ -352,7 +352,7 @@ void main_loop (void)int prev =disable_ctrlc (1 );/* disable Control C checking */ # endif -run_command2 (p,0 ); +run_command (p,0 );# ifdef CONFIG_AUTOBOOT_KEYED disable_ctrlc (prev);/* restore Control C checking */
@@ -397,7 +397,7 @@ void main_loop (void)int prev =disable_ctrlc (1 );/* disable Control C checking */ # endif -run_command2 (s,0 ); +run_command (s,0 );# ifdef CONFIG_AUTOBOOT_KEYED disable_ctrlc (prev);/* restore Control C checking */
@@ -408,7 +408,7 @@ void main_loop (void)if (menukey ==CONFIG_MENUKEY ) { s =getenv ("menucmd" );if (s) -run_command2 (s,0 ); +run_command (s,0 ); }#endif /* CONFIG_MENUKEY */ #endif /* CONFIG_BOOTDELAY */
@@ -1406,7 +1406,7 @@ int do_run (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])return 1 ; } -if (run_command2 (arg, flag) !=0 ) +if (run_command (arg, flag) !=0 )return 1 ; }return 0 ;
include/common.h +1 -1
@@ -261,7 +261,7 @@ 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_command2 (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);int parse_line (char *,char *[]);
Signature · 1 line
1.7.7.3
PATCH v4 4/9 Stop using builtin_run_command()
In reply to Simon GlassThis function is only one of the parser options, so use run_command() instead. It knows how to use hush if selected.
---
arch/arm/cpu/arm926ejs/kirkwood/cpu.c | 7 +---- board/esd/common/auto_update.c | 2 +- board/esd/common/cmd_loadpci.c | 2 +- board/esd/du440/du440.c | 2 +- common/cmd_bedbug.c | 2 +- common/cmd_bootm.c | 8 +----- common/cmd_source.c | 4 +- common/main.c | 45 ++++++++++++++++----------------- include/common.h | 1 - 9 files changed, 30 insertions(+), 43 deletions(-)
arch/arm/cpu/arm926ejs/kirkwood/cpu.c +1 -6
@@ -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
board/esd/common/auto_update.c +1 -1
@@ -169,7 +169,7 @@ int au_do_update(int i, long sz) k++; } -builtin_run_command (addr,0 ); +run_command (addr,0 );return 0 ; }
board/esd/common/cmd_loadpci.c +1 -1
@@ -110,7 +110,7 @@ int do_loadpci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])* Call run_cmd */ printf ("running command@addr 0x%s ...\n" , addr); -builtin_run_command ((char *)la,0 ); +run_command ((char *)la,0 );break ;default :
board/esd/du440/du440.c +1 -1
@@ -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));
common/cmd_bedbug.c +1 -1
@@ -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 */
common/cmd_bootm.c +1 -7
@@ -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; }
common/cmd_source.c +2 -2
@@ -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);
common/main.c +22 -23
69 lines not on this page · raw message
include/common.h +0 -1
@@ -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);
Signature · 1 line
1.7.7.3
PATCH v4 4/9 Stop using builtin_run_command()
Hi Simon,
Am Samstag 14 Januar 2012, 07:45:52 schrieb Simon Glass:
common/cmd_source.c source (ulong addr, const char *fit_uname) · line 182
Quoted 9 lines
common/cmd_source.c +0
-1@@ -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 )
{
common/cmd_source.c source (ulong addr, const char *fit_uname) · line 195
Quoted 13 lines
common/cmd_source.c +2
-1+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);
Please have a look at this file. There is already a conditional on CONFIG_SYS_HUSH_PARSER, which can be removed, since it is now handled in run_command(). Do not forget to remove the hush.h include, too.
Could you move this script handling into an own function into common/main.c? This way others can easily execute whole scripts without duplicating this code. I'm planning to submit support for a board which needs exactly that, so there will be at least one board which make use of this.
Mike proposed source_commands() as a function name. My original patch named it run_script(). Dunno whats a better name.
Feel free to reuse/incorporate my patch at
http://patchwork.ozlabs.org/patch/137122/
into your patchset ;)
Signature · 1 line
michael
PATCH v4 4/9 Stop using builtin_run_command()
Hi Michael,
Quoted 24 lines · Michael Walle
Hi Simon,
Am Samstag 14 Januar 2012, 07:45:52 schrieb Simon Glass:
common/cmd_source.c source (ulong addr, const char *fit_uname) · line 182
Quoted 9 lines
common/cmd_source.c +0
-1@@ -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)
{Quoted 9 lines
common/cmd_source.c +1
-1+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 );
Quoted 9 lines
common/cmd_source.c source (ulong addr, const char *fit_uname) · line 195
Quoted 4 lines
common/cmd_source.c +1
-0+ rcode = (run_command(line, 0) >= 0); }#endif free (cmd);Please have a look at this file. There is already a conditional on
CONFIG_SYS_HUSH_PARSER, which can be removed, since it is now handled inrun_command(). Do not forget to remove thehush.hinclude, too.
OK
Quoted 8 lines
Could you move this script handling into an own function into
common/main.c?
This way others can easily execute whole scripts without duplicating this code. I'm planning to submit support for a board which needs exactly that, so
there will be at least one board which make use of this.
Quoted 4 lines
Mike proposed
source_commands()as a function name. My original patch named itrun_script(). Dunno whats a better name.
I will go with run_command_list() so it matches run_command(). Will send an updated series with two new commits which hopefully does what you want.
Quoted 5 lines
Feel free to reuse/incorporate my patch at
http://patchwork.ozlabs.org/patch/137122/
into your patchset ;)
Thanks, have done so.
Quoted 4 lines
--
michael
Regards,
Simon
PATCH v4 4/9 Stop using builtin_run_command()
Hi Michael,
Quoted 58 lines · Simon Glass
Hi Michael,
Quoted 24 lines · Michael Walle
Hi Simon,
Am Samstag 14 Januar 2012, 07:45:52 schrieb Simon Glass:
common/cmd_source.c source (ulong addr, const char *fit_uname) · line 182
Quoted 9 lines
common/cmd_source.c +0
-1@@ -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)
{Quoted 9 lines
common/cmd_source.c +1
-1+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 );Quoted 9 lines
common/cmd_source.c source (ulong addr, const char *fit_uname) · line 195
Quoted 4 lines
common/cmd_source.c +1
-0+ rcode = (run_command(line, 0) >= 0); }#endif free (cmd);Please have a look at this file. There is already a conditional on
CONFIG_SYS_HUSH_PARSER, which can be removed, since it is now handled inrun_command(). Do not forget to remove thehush.hinclude, too.OK
Quoted 8 lines
Could you move this script handling into an own function into
common/main.c?
This way others can easily execute whole scripts without duplicating this code. I'm planning to submit support for a board which needs exactly that, so
there will be at least one board which make use of this.Quoted 4 lines
Mike proposed
source_commands()as a function name. My original patch named itrun_script(). Dunno whats a better name.I will go with
run_command_list()so it matchesrun_command(). Will send an updated series with two new commits which hopefully does what you want.Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Feel free to reuse/incorporate my patch at
http://patchwork.ozlabs.org/patch/137122/
into your patchset ;)Thanks, have done so.
Unfortunately I think that this approach is a little broken. We are running a command sequence from getenv(), but while processing it, we might update the environment variable. Worse, we actually overwrite the newlines in the variable as we process it.
Since this seems like a bigger change than I thought, and I think it missed the merge window, I have created a two separate patches for this so people can review it properly. Will send through shortly.
Regards,
Simon
Quoted 11 lines
Quoted 6 lines
--
michaelRegards,
Simon
PATCH v4 4/9 Stop using builtin_run_command()
Am Mittwoch 15 Februar 2012, 07:05:24 schrieb Simon Glass:
Quoted 4 lines
Unfortunately I think that this approach is a little broken. We are running a command sequence from
getenv(), but while processing it, we might update the environment variable. Worse, we actually overwrite the newlines in the variable as we process it.
Isn't it as easy as copying the current content and processing that instead?
Signature · 1 line
Michael
PATCH v4 4/9 Stop using builtin_run_command()
Hi Michael,
Quoted 6 lines · Michael Walle
Am Mittwoch 15 Februar 2012, 07:05:24 schrieb Simon Glass:
Quoted 4 lines
Unfortunately I think that this approach is a little broken. We are running a command sequence from
getenv(), but while processing it, we might update the environment variable. Worse, we actually overwrite the newlines in the variable as we process it.Isn't it as easy as copying the current content and processing that instead?
Yes, that's what I have done - but it is not trivial so did not try to bring it into the old series.
Regards,
Simon
Quoted 4 lines
--
Michael
PATCH v4 4/9 Stop using builtin_run_command()
In reply to Simon GlassQuoted 2 lines · On Saturday 14 January 2012 01:45:52 Simon Glass wrote:
This function is only one of the parser options, so use
run_command()instead. It knows how to use hush if selected.
i can't grok this either :/
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120204/4309cb1c/attachment.pgp>
PATCH v4 4/9 Stop using builtin_run_command()
Hi Mike,
Quoted 7 lines · Mike Frysinger
Quoted 2 lines · On Saturday 14 January 2012 01:45:52 Simon Glass wrote:
This function is only one of the parser options, so use
run_command()instead. It knows how to use hush if selected.i can't grok this either :/
-mike
Reworded...
Regards,
Simon
PATCH v4 5/9 Don't include standard parser if hush is used
In reply to Simon GlassThis saves about 1KB of code space on ARM with CONFIG_SYS_HUSH_PARSER defined.
---
common/main.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
common/main.c +2 -0
@@ -1116,6 +1116,7 @@ int parse_line (char *line, char *argv[])/****************************************************************************/ +#ifndef CONFIG_SYS_HUSH_PARSER static void process_macros (const char *input,char *output) {char c, prev;
@@ -1366,6 +1367,7 @@ static int builtin_run_command(const char *cmd, int flag) return rc ? rc : repeatable; } +#endif /* * Return 0 on success, or != 0 on error.
Signature · 1 line
1.7.7.3
PATCH v4 5/9 Don't include standard parser if hush is used
Quoted 2 lines · On Saturday 14 January 2012 01:45:53 Simon Glass wrote:
This saves about 1KB of code space on ARM with
CONFIG_SYS_HUSH_PARSERdefined.
are you not using --gc-sections ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120204/44ef8ae8/attachment.pgp>
PATCH v4 5/9 Don't include standard parser if hush is used
Hi Mike,
Quoted 7 lines · Mike Frysinger
Quoted 2 lines · On Saturday 14 January 2012 01:45:53 Simon Glass wrote:
This saves about 1KB of code space on ARM with
CONFIG_SYS_HUSH_PARSERdefined.are you not using --gc-sections ?
-mike
No, not on ARM. Ultimately we could move this out to its own file, but for now I think this is a step forward.
Regards,
Simon
PATCH v4 6/9 Create a single cmd_call() function to handle command execution
In reply to Simon GlassWe should aim for a single point of entry to the commands, whichever parser is used.
---
common/command.c | 21 +++++++++++++++++++++ common/hush.c | 9 +++------ common/main.c | 3 +-- include/command.h | 5 +++++ 4 files changed, 30 insertions(+), 8 deletions(-)
common/command.c +21 -0
@@ -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 +*/ +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; +}
common/hush.c +3 -6
@@ -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__
common/main.c +1 -2
@@ -1354,9 +1354,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;
include/command.h +5 -0
@@ -150,4 +150,9 @@ extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);#if defined(CONFIG_NEEDS_MANUAL_RELOC )void fixup_cmdtable (cmd_tbl_t *cmdtp,int size);#endif + +#ifndef __ASSEMBLY__ +int cmd_call (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]); +#endif /* __ASSEMBLY__ */ +#endif /* __COMMAND_H */
Signature · 1 line
1.7.7.3
PATCH v4 6/9 Create a single cmd_call() function to handle command execution
common/command.c void fixup_cmdtable(cmd_tbl_t *cmdtp, int size) · line 510
Quoted 12 lines · On Saturday 14 January 2012 01:45:54 Simon Glass wrote:
common/command.c +9
-0+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; +}
does a static inline in the header produce the same code size or better ?
include/command.h extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); · line 156
Quoted 6 lines
include/command.h +3
-0+#ifndef __ASSEMBLY__ +int cmd_call (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]); +#endif /* __ASSEMBLY__ */
move the prototype up to the rest of the !ASSEMBLY code rather than putting it at the end by itself ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120204/6433763c/attachment.pgp>
PATCH v4 6/9 Create a single cmd_call() function to handle command execution
Hi Mike,
Quoted 4 lines · Mike Frysinger
Quoted 3 lines · On Saturday 14 January 2012 01:45:54 Simon Glass wrote:
common/command.c +0
-0
Quoted 12 lines
common/command.c void fixup_cmdtable(cmd_tbl_t *cmdtp, int size) · line 510
Quoted 9 lines
common/command.c +9
-0+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; +}does a static inline in the header produce the same code size or better ?
It doesn't really matter - this function becomes static in a later patch. The common code is teased out of hush and main in two separate commits, since otherwise it gets very confusing.
Quoted 4 lines
Quoted 4 lines
include/command.h +0
-0
Quoted 9 lines
include/command.h extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); · line 156
Quoted 3 lines
include/command.h +3
-0+#ifndef __ASSEMBLY__ +int cmd_call (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]); +#endif /* __ASSEMBLY__ */ move the prototype up to the rest of the !ASSEMBLY code rather than putting it
at the end by itself ?
-mike
Will do.
Regards,
Simon
PATCH v4 7/9 Remove interleave of non-U-Boot code in hush
In reply to Simon GlassThere is a nasty interleave of #ifdefs in hush.c where the two code paths have different indents. Remove this ickiness.
---
common/hush.c | 24 +++++++++++------------- 1 files changed, 11 insertions(+), 13 deletions(-)
common/hush.c +11 -13
@@ -1642,6 +1642,15 @@ static int run_pipe_real(struct pipe *pi)* Is it really safe for inline use? Experimentally, * things seem to work with glibc. */ setup_redirects (child, squirrel); + + child->argv += i;/* XXX horrible hack */ + rcode = x->function (child); +/* XXX restore hack so free() can work right */ + child->argv -= i; + restore_redirects(squirrel); + } +return rcode; + }#else /* check ";", because ,example , argv consist from * "help;flinfo" must not execute
@@ -1674,22 +1683,11 @@ static int run_pipe_real(struct pipe *pi)if ((child->argc - i) > cmdtp->maxargs)return cmd_usage (cmdtp);#endif - child->argv+=i;/* XXX horrible hack */ -#ifndef __U_BOOT__ - rcode = x->function (child); -#else /* OK - call function to do the command */ - rcode =cmd_call (cmdtp, flag, child->argc-i, - &child->argv[i]); + rcode =cmd_call (cmdtp, flag, child->argc, + child->argv);if (!cmdtp->repeatable) flag_repeat =0 ; -#endif - child->argv-=i;/* XXX restore hack so free() can work right */ -#ifndef __U_BOOT__ - -restore_redirects (squirrel); -#endif -return rcode; } }
Signature · 1 line
1.7.7.3
PATCH v4 7/9 Remove interleave of non-U-Boot code in hush
Quoted 2 lines · On Saturday 14 January 2012 01:45:55 Simon Glass wrote:
There is a nasty interleave of #ifdefs in
hush.cwhere the two code paths have different indents. Remove this ickiness.
i think we've moved beyond hopes of keeping hush.c unified with its "upstream", so this is fine
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120204/cb3e2022/attachment.pgp>
PATCH v4 8/9 Add cmd_process() to process commands in one place
In reply to Simon GlassWe 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.
---
Changes in v4:
- Add a 'repeatable' parameter to cmd_process()
- Rationalise return codes to 0, 1 and usage
- Make cmd_process() return only success (0) or failure (1)
common/command.c | 43 +++++++++++++++++++++++++++++++++++++++++-- common/hush.c | 52 ++++++++++++---------------------------------------- common/main.c | 37 +------------------------------------ include/command.h | 29 ++++++++++++++++++++++++++++- 4 files changed, 82 insertions(+), 79 deletions(-)
common/command.c +41 -2
@@ -497,9 +497,9 @@ void fixup_cmdtable(cmd_tbl_t *cmdtp, int size)* @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 +* @return 0 if command succeeded, else non-zero (CMD_RET_...) */ -int cmd_call (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +static int cmd_call (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {int result;
@@ -508,3 +508,42 @@ int cmd_call(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])debug ("Command failed, result=%d" , result);return result; } + +enum command_ret_t cmd_process (int flag,int argc,char *const argv[], +int *repeatable) +{ +enum command_ret_t rc =CMD_RET_SUCCESS ; +cmd_tbl_t *cmdtp; + +/* Look up command in command table */ + cmdtp =find_cmd (argv[0 ]); +if (cmdtp ==NULL ) { +printf ("Unknown command '%s' - try 'help'\n" , argv[0 ]); +return 1 ; + } + +/* found - check max args */ +if (argc > cmdtp->maxargs) + rc =CMD_RET_USAGE ; + +#if defined(CONFIG_CMD_BOOTD ) +/* avoid "bootd" recursion */ + else if (cmdtp->cmd == do_bootd) { +if (flag &CMD_FLAG_BOOTD ) { +puts ("'bootd' recursion detected\n" ); + rc =CMD_RET_FAILURE ; + }else { + flag |=CMD_FLAG_BOOTD ; + } + } +#endif + +/* If OK so far, then do the command */ +if (!rc) { + rc =cmd_call (cmdtp, flag, argc, argv); + *repeatable &= cmdtp->repeatable; + } +if (rc ==CMD_RET_USAGE ) + rc =cmd_usage (cmdtp); +return rc; +}
common/hush.c +12 -40
66 lines not on this page · raw message
common/main.c +1 -36
@@ -1245,7 +1245,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 */
@@ -1323,41 +1322,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 ())
include/command.h +28 -1
@@ -152,7 +152,34 @@ void fixup_cmdtable(cmd_tbl_t *cmdtp, int size);#endif #ifndef __ASSEMBLY__ -int cmd_call (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]); +/* +* Error codes that commands return to cmd_process(). We use the standard 0 +* and 1 for success and failure, but add one more case - failure with a +* request to call cmd_usage(). But the cmd_process() function handles +* CMD_RET_USAGE itself and after calling cmd_usage() it will return 1. +* This is just a convenience for commands to avoid them having to call +* cmd_usage() all over the place. +*/ +enum command_ret_t { +CMD_RET_SUCCESS ,/* 0 = Success */ +CMD_RET_FAILURE ,/* 1 = Failure */ +CMD_RET_USAGE =-1 ,/* Failure, please report 'usage' error */ +}; + +/** +* Process a command with arguments. We look up the command and execute it +* if valid. Otherwise we print a usage message. +* +* @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 +* @param repeatable This function sets this to 0 if the command is not +* repeatable. If the command is repeatable, the value +* is left unchanged. +* @return 0 if the command succeeded, 1 if it failed +*/ +int cmd_process (int flag,int argc,char *const argv[], +int *repeatable);#endif /* __ASSEMBLY__ */ #endif /* __COMMAND_H */
Signature · 1 line
1.7.7.3
PATCH v4 9/9 Convert cmd_usage() calls in common to use a return value
In reply to Simon GlassChange all files in common/ to use CMD_RET_USAGE instead of calling cmd_usage() directly. I'm not completely sure about this patch since the code since impact is small (100 byte or so on ARM) and it might need splitting into smaller patches. But for now here it is.
---
Changes in v2:
- Fix minor errors one of which created a warning
- Squash i2c patch into the common/ patch
Changes in v3:
- Rebase to master
common/cmd_bedbug.c | 4 ++-- common/cmd_bmp.c | 6 +++--- common/cmd_boot.c | 2 +- common/cmd_bootm.c | 4 ++-- common/cmd_cache.c | 4 ++-- common/cmd_dataflash_mmc_mux.c | 2 +- common/cmd_date.c | 3 +-- common/cmd_dcr.c | 8 ++++---- common/cmd_df.c | 2 +- common/cmd_eeprom.c | 2 +- common/cmd_ext2.c | 4 ++-- common/cmd_fdc.c | 2 +- common/cmd_fdos.c | 2 +- common/cmd_fdt.c | 14 +++++++------- common/cmd_fitupd.c | 2 +- common/cmd_flash.c | 14 +++++++------- common/cmd_fpga.c | 4 ++-- common/cmd_gpio.c | 2 +- common/cmd_i2c.c | 32 ++++++++++++++++---------------- common/cmd_ide.c | 10 +++++----- common/cmd_irq.c | 2 +- common/cmd_itest.c | 2 +- common/cmd_led.c | 6 +++--- common/cmd_load.c | 2 +- common/cmd_log.c | 4 ++-- common/cmd_md5sum.c | 2 +- common/cmd_mdio.c | 2 +- common/cmd_mem.c | 22 +++++++++++----------- common/cmd_mfsl.c | 10 +++++----- common/cmd_mgdisk.c | 2 +- common/cmd_mii.c | 4 ++-- common/cmd_misc.c | 2 +- common/cmd_mmc.c | 14 +++++++------- common/cmd_mmc_spi.c | 3 +-- common/cmd_mp.c | 8 ++++---- common/cmd_mtdparts.c | 2 +- common/cmd_nand.c | 6 +++--- common/cmd_net.c | 6 +++--- common/cmd_nvedit.c | 22 +++++++++++----------- common/cmd_onenand.c | 12 ++++++------ common/cmd_otp.c | 2 +- common/cmd_pci.c | 2 +- common/cmd_portio.c | 4 ++-- common/cmd_pxe.c | 8 ++++---- common/cmd_reiser.c | 4 ++-- common/cmd_sata.c | 8 ++++---- common/cmd_scsi.c | 15 ++++++++------- common/cmd_setexpr.c | 2 +- common/cmd_sf.c | 2 +- common/cmd_sha1sum.c | 2 +- common/cmd_strings.c | 2 +- common/cmd_time.c | 4 ++-- common/cmd_ubi.c | 4 ++-- common/cmd_ubifs.c | 10 +++++----- common/cmd_unzip.c | 2 +- common/cmd_usb.c | 6 +++--- common/main.c | 2 +- 57 files changed, 167 insertions(+), 168 deletions(-)
common/cmd_bedbug.c +2 -2
@@ -84,7 +84,7 @@ int do_bedbug_dis (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) len = dis_last_len;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if ((flag &CMD_FLAG_REPEAT ) ==0 ) {/* New command */
@@ -123,7 +123,7 @@ int do_bedbug_asm (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])int rcode =0 ;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;printf ("\nEnter '.' when done\n" ); mem_addr =simple_strtoul (argv[1 ],NULL ,16 );
common/cmd_bmp.c +3 -3
@@ -102,7 +102,7 @@ static int do_bmp_info(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[ addr =simple_strtoul (argv[1 ],NULL ,16 );break ;default : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }return (bmp_info (addr));
@@ -126,7 +126,7 @@ static int do_bmp_display(cmd_tbl_t * cmdtp, int flag, int argc, char * const ar y =simple_strtoul (argv[3 ],NULL ,10 );break ;default : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }return (bmp_display (addr, x, y));
@@ -166,7 +166,7 @@ static int do_bmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (c)return c->cmd (cmdtp, flag, argc, argv);else -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; } U_BOOT_CMD(
common/cmd_boot.c +1 -1
@@ -43,7 +43,7 @@ int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int rcode =0 ;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; addr =simple_strtoul (argv[1 ],NULL ,16 );
common/cmd_bootm.c +2 -2
@@ -493,12 +493,12 @@ int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc, } }else {/* Unrecognized command */ -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }if (images.state >= state) {printf ("Trying to execute a command out of order\n" ); -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; } images.state |= state;
common/cmd_cache.c +2 -2
@@ -54,7 +54,7 @@ int do_icache ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) icache_status() ? "ON" : "OFF");return 0 ;default : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }return 0 ; }
@@ -83,7 +83,7 @@ int do_dcache ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) dcache_status() ? "ON" : "OFF");return 0 ;default : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }return 0 ;
common/cmd_dataflash_mmc_mux.c +1 -1
@@ -41,7 +41,7 @@ int do_dataflash_mmc_mux (cmd_tbl_t *cmdtp, int flag, int argc, char * const arg AT91F_GetMuxStatus () ? "MMC" : "SPI");return 0 ;default : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }return 0 ; }
common/cmd_date.c +1 -2
@@ -93,8 +93,7 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])break ;default : -cmd_usage (cmdtp); - rcode =1 ; + rcode =CMD_RET_USAGE ; }/* switch back to original I2C bus */
common/cmd_dcr.c +4 -4
@@ -45,7 +45,7 @@ int do_getdcr ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] )/* Validate arguments */ if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* Get a DCR */ dcrn = (unsigned short )simple_strtoul (argv[1 ],NULL ,16 );
@@ -71,7 +71,7 @@ int do_setdcr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])/* Validate arguments */ if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* Set a DCR */ dcrn = (unsigned short )simple_strtoul (argv[1 ],NULL ,16 );
@@ -116,7 +116,7 @@ int do_getidcr (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])/* Validate arguments */ if (argc <3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* Find out whether ther is '.' (dot) symbol in the first parameter. */ strncpy (buf, argv[1 ],sizeof (buf)-1 );
@@ -170,7 +170,7 @@ int do_setidcr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])/* Validate arguments */ if (argc <4 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* Find out whether ther is '.' (dot) symbol in the first parameter. */ strncpy (buf, argv[1 ],sizeof (buf)-1 );
common/cmd_df.c +1 -1
@@ -27,7 +27,7 @@ static int do_df(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } usage: -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; } U_BOOT_CMD(
common/cmd_eeprom.c +1 -1
@@ -104,7 +104,7 @@ int do_eeprom ( cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) } } -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }#endif
common/cmd_ext2.c +2 -2
@@ -66,7 +66,7 @@ int do_ext2ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int part_length;if (argc <3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; dev = (int )simple_strtoul (argv[2 ], &ep,16 ); dev_desc =get_dev (argv[1 ],dev);
@@ -163,7 +163,7 @@ int do_ext2load (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])break ;default : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }if (!filename) {
common/cmd_fdc.c +1 -1
@@ -744,7 +744,7 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) boot_drive=simple_strtoul (argv[2 ],NULL ,10 );break ;default : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }/* setup FDC and scan for drives */ if (fdc_setup (boot_drive,pCMD,pFG)==FALSE) {
common/cmd_fdos.c +1 -1
@@ -72,7 +72,7 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) name = argv [2 ];break ;default : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }/* Init physical layer */
common/cmd_fdt.c +7 -7
@@ -66,7 +66,7 @@ void set_working_fdt_addr(void *addr)int do_fdt (cmd_tbl_t * cmdtp,int flag,int argc,char *const argv[]) {if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* * Set the address of the fdt
@@ -123,7 +123,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])int err;if (argc <4 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* * Set the address and length of the fdt.
@@ -175,7 +175,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])* Parameters: Node path, new node to be appended to the path. */ if (argc <4 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; pathp = argv[2 ]; nodep = argv[3 ];
@@ -211,7 +211,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])* Parameters: Node path, property, optional value. */ if (argc <4 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; pathp = argv[2 ]; prop = argv[3 ];
@@ -409,7 +409,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) } }else {/* Unrecognized command */ -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; } }#ifdef CONFIG_OF_BOARD_SETUP
@@ -422,7 +422,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])unsigned long initrd_start =0 , initrd_end =0 ;if ((argc !=2 ) && (argc !=4 )) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if (argc ==4 ) { initrd_start =simple_strtoul (argv[2 ],NULL ,16 );
@@ -438,7 +438,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) }else {/* Unrecognized command */ -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }return 0 ;
common/cmd_fitupd.c +1 -1
@@ -20,7 +20,7 @@ static int do_fitupd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])ulong addr =0UL ;if (argc >2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if (argc ==2 ) addr =simple_strtoul (argv[1 ],NULL ,16 );
common/cmd_flash.c +7 -7
@@ -335,7 +335,7 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int rcode =0 ;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if (strcmp (argv[1 ],"all" ) ==0 ) {for (bank=1 ; bank<=CONFIG_SYS_MAX_FLASH_BANKS ; ++bank) {
@@ -384,7 +384,7 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])#endif if (argc !=3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if (strcmp (argv[1 ],"bank" ) ==0 ) { bank =simple_strtoul (argv[2 ],NULL ,16 );
@@ -405,7 +405,7 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) }if (addr_first >= addr_last) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; rcode =flash_sect_erase (addr_first, addr_last);return rcode;
@@ -475,7 +475,7 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])#endif if (argc <3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;#if !defined(CONFIG_SYS_NO_FLASH ) || defined(CONFIG_HAS_DATAFLASH )if (strcmp (argv[1 ],"off" ) ==0 )
@@ -483,7 +483,7 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) else if (strcmp(argv[1], "on") == 0) p =1 ; else - return cmd_usage(cmdtp); + return CMD_RET_USAGE;#endif #ifdef CONFIG_HAS_DATAFLASH
@@ -583,7 +583,7 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])#endif if (argc !=4 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if (strcmp (argv[2 ],"bank" ) ==0 ) { bank =simple_strtoul (argv[3 ],NULL ,16 );
@@ -623,7 +623,7 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) }if (addr_first >= addr_last) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; rcode =flash_sect_protect (p, addr_first, addr_last);#endif /* CONFIG_SYS_NO_FLASH */
common/cmd_fpga.c +2 -2
@@ -255,7 +255,7 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])switch (op) {case FPGA_NONE : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;case FPGA_INFO : rc =fpga_info (dev);
@@ -334,7 +334,7 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])default :printf ("Unknown operation\n" ); -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }return (rc); }
common/cmd_gpio.c +1 -1
@@ -38,7 +38,7 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (argc !=3 ) show_usage: -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; str_cmd = argv[1 ]; str_gpio = argv[2 ];
common/cmd_i2c.c +16 -16
@@ -190,7 +190,7 @@ static int do_i2c_read ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argvu_char *memaddr;if (argc !=5 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* * I2C chip address
@@ -204,7 +204,7 @@ static int do_i2c_read ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv devaddr =simple_strtoul (argv[2 ],NULL ,16 ); alen =get_alen (argv[2 ]);if (alen >3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* * Length is the number of objects, not number of bytes.
@@ -242,7 +242,7 @@ static int do_i2c_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] length = i2c_dp_last_length;if (argc <3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if ((flag &CMD_FLAG_REPEAT ) ==0 ) {/*
@@ -261,7 +261,7 @@ static int do_i2c_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] addr =simple_strtoul (argv[2 ],NULL ,16 ); alen =get_alen (argv[2 ]);if (alen >3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* * If another parameter, it is the length to display.
@@ -330,7 +330,7 @@ static int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]int count;if ((argc <4 ) || (argc >5 )) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* * Chip is always specified.
@@ -343,7 +343,7 @@ static int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] addr =simple_strtoul (argv[2 ],NULL ,16 ); alen =get_alen (argv[2 ]);if (alen >3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* * Value to write is always specified.
@@ -392,7 +392,7 @@ static int do_i2c_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]ulong err;if (argc <4 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* * Chip is always specified.
@@ -405,7 +405,7 @@ static int do_i2c_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] addr =simple_strtoul (argv[2 ],NULL ,16 ); alen =get_alen (argv[2 ]);if (alen >3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* * Count is always specified
@@ -451,7 +451,7 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argint nbytes;if (argc !=3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;#ifdef CONFIG_BOOT_RETRY_TIME reset_cmd_timeout ();/* got a good command to get here */
@@ -482,7 +482,7 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg addr =simple_strtoul (argv[2 ],NULL ,16 ); alen =get_alen (argv[2 ]);if (alen >3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }/*
@@ -613,7 +613,7 @@ static int do_i2c_loop(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]int delay;if (argc <3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* * Chip is always specified.
@@ -626,7 +626,7 @@ static int do_i2c_loop(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] addr =simple_strtoul (argv[2 ],NULL ,16 ); alen =get_alen (argv[2 ]);if (alen >3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* * Length is the number of objects, not number of bytes.
@@ -765,7 +765,7 @@ static int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) };if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* * Chip is always specified.
@@ -1300,7 +1300,7 @@ static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])cmd_tbl_t *c;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* Strip off leading 'i2c' command argument */ argc--;
@@ -1309,9 +1309,9 @@ static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) c =find_cmd_tbl (argv[0 ], &cmd_i2c_sub[0 ],ARRAY_SIZE (cmd_i2c_sub));if (c) -return c->cmd (cmdtp, flag, argc, argv); +return c->cmd (cmdtp, flag, argc, argv);else -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }/***************************************************/
common/cmd_ide.c +5 -5
@@ -179,7 +179,7 @@ int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])switch (argc) {case 0 :case 1 : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;case 2 :if (strncmp (argv[1 ],"res" ,3 ) ==0 ) { puts("\nReset IDE"
@@ -232,7 +232,7 @@ int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) }return rcode; } -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;case 3 :if (strncmp (argv[1 ],"dev" ,3 ) ==0 ) {int dev = (int )simple_strtoul (argv[2 ],NULL ,10 );
@@ -266,7 +266,7 @@ int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])return rcode; } -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;default :/* at least 4 args */
@@ -325,7 +325,7 @@ int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])else return 1 ; }else { -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }return rcode;
@@ -361,7 +361,7 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])break ;default :show_boot_progress (-42 ); -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }show_boot_progress (42 );
common/cmd_irq.c +1 -1
@@ -28,7 +28,7 @@ int do_interrupts(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {if (argc !=2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* on */ if (strncmp (argv[1 ],"on" ,2 ) ==0 )
common/cmd_itest.c +1 -1
@@ -161,7 +161,7 @@ int do_itest ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] )/* Validate arguments */ if ((argc !=4 )) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* Check for a data width specification. * Defaults to long (4) if no specification.
common/cmd_led.c +3 -3
@@ -93,12 +93,12 @@ int do_led (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])/* Validate arguments */ if ((argc !=3 )) { -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; } cmd =get_led_cmd (argv[2 ]);if (cmd <0 ) { -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }for (i =0 ; led_commands[i].string; i++) {
@@ -132,7 +132,7 @@ int do_led (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])/* If we ran out of matches, print Usage */ if (!match) { -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }return 0 ;
common/cmd_load.c +1 -1
@@ -1102,7 +1102,7 @@ int do_hwflow (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (strcmp (argv[1 ],"on" ) ==0 )hwflow_onoff (1 );else -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }printf ("RTS/CTS hardware flow control: %s\n" ,hwflow_onoff (0 ) ?"on" :"off" );return 0 ;
common/cmd_log.c +2 -2
@@ -241,10 +241,10 @@ int do_log (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) }return 0 ; } -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;default : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; } }
common/cmd_md5sum.c +1 -1
@@ -32,7 +32,7 @@ static int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])u8 output[16 ];if (argc <3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; addr =simple_strtoul (argv[1 ],NULL ,16 ); len =simple_strtoul (argv[2 ],NULL ,16 );
common/cmd_mdio.c +1 -1
@@ -193,7 +193,7 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])struct mii_dev *bus;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* * We use the last specified parameters, unless new ones are
common/cmd_mem.c +11 -11
@@ -74,7 +74,7 @@ int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) length = dp_last_length;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if ((flag &CMD_FLAG_REPEAT ) ==0 ) {/* New command specified. Check for a size specification.
@@ -168,7 +168,7 @@ int do_mem_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int size;if ((argc <3 ) || (argc >4 )) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* Check for size specification. */
@@ -210,7 +210,7 @@ int do_mem_mdc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])ulong count;if (argc <4 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; count =simple_strtoul (argv[3 ],NULL ,10 );
@@ -237,7 +237,7 @@ int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])ulong count;if (argc <4 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; count =simple_strtoul (argv[3 ],NULL ,10 );
@@ -266,7 +266,7 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int rcode =0 ;if (argc !=4 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* Check for size specification. */
@@ -352,7 +352,7 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int size;if (argc !=4 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* Check for size specification. */
@@ -478,7 +478,7 @@ int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])volatile u_char *cp;if (argc <3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* Check for a size spefication. * Defaults to long if no or incorrect specification.
@@ -547,7 +547,7 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])volatile u_char *cp;if (argc <4 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* Check for a size spefication. * Defaults to long if no or incorrect specification.
@@ -979,7 +979,7 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])int nbytes, size;if (argc !=2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;#ifdef CONFIG_BOOT_RETRY_TIME reset_cmd_timeout ();/* got a good command to get here */
@@ -1084,7 +1084,7 @@ int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])ulong *ptr;if (argc <3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; addr =simple_strtoul (argv[1 ],NULL ,16 ); addr += base_address;
@@ -1118,7 +1118,7 @@ int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (argc <3 ) { usage: -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; } av = argv +1 ;
common/cmd_mfsl.c +5 -5
@@ -38,13 +38,13 @@ int do_frd (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])unsigned int blocking;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; fslnum = (unsigned int )simple_strtoul (argv[1 ],NULL ,16 ); blocking = (unsigned int )simple_strtoul (argv[2 ],NULL ,16 );if (fslnum <0 || fslnum >=XILINX_FSL_NUMBER ) {puts ("Bad number of FSL\n" ); -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }switch (fslnum) {
@@ -193,13 +193,13 @@ int do_fwr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])unsigned int blocking;if (argc <3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; fslnum = (unsigned int )simple_strtoul (argv[1 ],NULL ,16 ); num = (unsigned int )simple_strtoul (argv[2 ],NULL ,16 ); blocking = (unsigned int )simple_strtoul (argv[3 ],NULL ,16 );if (fslnum <0 || fslnum >=XILINX_FSL_NUMBER ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;switch (fslnum) {#if (XILINX_FSL_NUMBER >0 )
@@ -347,7 +347,7 @@ int do_rspr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])unsigned int val =0 ;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; reg = (unsigned int )simple_strtoul (argv[1 ],NULL ,16 ); val = (unsigned int )simple_strtoul (argv[2 ],NULL ,16 );
common/cmd_mgdisk.c +1 -1
@@ -54,7 +54,7 @@ int do_mg_disk_cmd (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])return 1 ;break ;default : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }return 0 ; }
common/cmd_mii.c +2 -2
@@ -293,7 +293,7 @@ static int do_mii(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])const char *devname;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;#if defined(CONFIG_MII_INIT )mii_init ();
@@ -420,7 +420,7 @@ static int do_mii(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])else miiphy_set_current_dev (argv[2 ]); }else { -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }/*
common/cmd_misc.c +1 -1
@@ -33,7 +33,7 @@ int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])ulong delay;if (argc !=2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; delay =simple_strtoul (argv[1 ],NULL ,10 ) *CONFIG_SYS_HZ ;
common/cmd_mmc.c +7 -7
@@ -32,7 +32,7 @@ int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int dev;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if (strcmp (argv[1 ],"init" ) ==0 ) {if (argc ==2 ) {
@@ -43,7 +43,7 @@ int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) }else if (argc ==3 ) { dev = (int )simple_strtoul (argv[2 ],NULL ,10 ); }else { -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }if (mmc_legacy_init (dev) !=0 ) {
@@ -68,12 +68,12 @@ int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])#endif curr_device = dev; }else { -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }printf ("mmc%d is current device\n" , curr_device); }else { -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }return 0 ;
@@ -153,7 +153,7 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])enum mmc_state state;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if (curr_device <0 ) {if (get_mmc_num () >0 )
@@ -216,7 +216,7 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])return 1 ; } }else -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; mmc =find_mmc_device (dev);if (!mmc) {
@@ -307,7 +307,7 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])return (n == cnt) ?0 :1 ; } -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; } U_BOOT_CMD(
common/cmd_mmc_spi.c +1 -2
@@ -78,8 +78,7 @@ static int do_mmc_spi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])return 0 ; usage: -cmd_usage (cmdtp); -return 1 ; +return CMD_RET_USAGE ; } U_BOOT_CMD(
common/cmd_mp.c +4 -4
@@ -29,7 +29,7 @@ cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])unsigned long cpuid;if (argc <3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; cpuid =simple_strtoul (argv[1 ],NULL ,10 );if (!is_core_valid (cpuid)) {
@@ -46,17 +46,17 @@ cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])else if (strncmp (argv[2 ],"disable" ,7 ) ==0 )return cpu_disable (cpuid);else -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;return 0 ; }/* 4 or greater, make sure its release */ if (strncmp (argv[2 ],"release" ,7 ) !=0 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if (cpu_release (cpuid, argc -3 , argv +3 )) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;return 0 ; }
common/cmd_mtdparts.c +1 -1
@@ -2035,7 +2035,7 @@ int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])return spread_partitions ();#endif /* CONFIG_CMD_MTDPARTS_SPREAD */ -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }/***************************************************/
common/cmd_nand.c +3 -3
@@ -357,7 +357,7 @@ int do_nand_env_oob(cmd_tbl_t *cmdtp, int argc, char *const argv[])return ret; usage: - return cmd_usage(cmdtp); + return CMD_RET_USAGE; }#endif
@@ -719,7 +719,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])#endif usage: -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; } U_BOOT_CMD(
@@ -908,7 +908,7 @@ int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) usage:#endif show_boot_progress (-53 ); -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }show_boot_progress (53 );
common/cmd_net.c +3 -3
@@ -231,7 +231,7 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,#endif default :show_boot_progress (-80 ); -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }show_boot_progress (80 );
@@ -271,7 +271,7 @@ int do_ping (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) NetPingIP =string_to_ip (argv[1 ]);if (NetPingIP ==0 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if (NetLoop (PING ) <0 ) {printf ("ping failed; host %s is not alive\n" , argv[1 ]);
@@ -377,7 +377,7 @@ U_BOOT_CMD(int do_dns (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {if (argc ==1 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* * We should check for a valid hostname:
common/cmd_nvedit.c +11 -11
@@ -173,7 +173,7 @@ static int do_env_grep(cmd_tbl_t *cmdtp, int flag,int rcode =1 , arg =1 , idx;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;memset (matched,0 , env_htab.size /8 );
@@ -411,7 +411,7 @@ int setenv_addr(const char *varname, const void *addr)int do_env_set (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;return _do_env_set (flag, argc, argv); }
@@ -435,7 +435,7 @@ int do_env_ask(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])/* Check the syntax */ switch (argc) {case 1 : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;case 2 :/* env_ask envname */ sprintf (message,"Please enter '%s':" , argv[1 ]);
@@ -493,7 +493,7 @@ int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])char *init_val;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* Set read buffer to initial value or empty sting */ init_val =getenv (argv[1 ]);
@@ -631,7 +631,7 @@ static int do_env_default(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {if (argc !=2 ||strcmp (argv[1 ],"-f" ) !=0 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;set_default_env ("## Resetting to default environment\n" );return 0 ;
@@ -730,14 +730,14 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, sep ='\n' ;break ;default : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; } } NXTARG: ; }if (argc <1 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; addr = (char *)simple_strtoul (argv[0 ],NULL ,16 );
@@ -838,13 +838,13 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag, del =1 ;break ;default : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; } } }if (argc <1 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if (!fmt)printf ("## Warning: defaulting to text format\n" );
@@ -944,7 +944,7 @@ static int do_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])cmd_tbl_t *cp;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* drop initial "env" arg */ argc--;
@@ -955,7 +955,7 @@ static int do_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (cp)return cp->cmd (cmdtp, flag, argc, argv); -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; } U_BOOT_CMD(
common/cmd_onenand.c +6 -6
@@ -390,7 +390,7 @@ static int do_onenand_read(cmd_tbl_t * cmdtp, int flag, int argc, char * const asize_t retlen =0 ;if (argc <3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; s =strchr (argv[0 ],'.' );if ((s !=NULL ) && (!strcmp (s,".oob" )))
@@ -417,7 +417,7 @@ static int do_onenand_write(cmd_tbl_t * cmdtp, int flag, int argc, char * constsize_t retlen =0 ;if (argc <3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if (strncmp (argv[0 ] +6 ,"yaffs" ,5 ) ==0 ) withoob =1 ;
@@ -503,7 +503,7 @@ static int do_onenand_dump(cmd_tbl_t * cmdtp, int flag, int argc, char * const achar *s;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; s =strchr (argv[0 ],'.' ); ofs = (int )simple_strtoul (argv[1 ],NULL ,16 );
@@ -525,7 +525,7 @@ static int do_onenand_markbad(cmd_tbl_t * cmdtp, int flag, int argc, char * cons argv +=2 ;if (argc <=0 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;while (argc >0 ) { addr =simple_strtoul (*argv,NULL ,16 );
@@ -569,7 +569,7 @@ static int do_onenand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]cmd_tbl_t *c;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; mtd = &onenand_mtd;
@@ -582,7 +582,7 @@ static int do_onenand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]if (c)return c->cmd (cmdtp, flag, argc, argv);else -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; } U_BOOT_CMD(
common/cmd_otp.c +1 -1
@@ -89,7 +89,7 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (argc <4 ) { usage: -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; } prompt_user = false;
common/cmd_pci.c +1 -1
@@ -480,7 +480,7 @@ int do_pci (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])return 1 ; usage: -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }/***************************************************/
common/cmd_portio.c +2 -2
@@ -44,7 +44,7 @@ int do_portio_out (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])uint value = out_last_value;if (argc !=3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if ((flag &CMD_FLAG_REPEAT ) ==0 ) {/*
@@ -102,7 +102,7 @@ int do_portio_in (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])uint size = in_last_size;if (argc !=2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if ((flag &CMD_FLAG_REPEAT ) ==0 ) {/*
common/cmd_pxe.c +4 -4
@@ -322,7 +322,7 @@ do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int err;if (argc !=1 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; pxefile_addr_str =from_env ("pxefile_addr_r" );
@@ -1312,7 +1312,7 @@ do_pxe_boot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) }else if (argc ==2 ) { pxefile_addr_str = argv[1 ]; }else { -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }if (strict_strtoul (pxefile_addr_str,16 , &pxefile_addr_r) <0 ) {
@@ -1344,7 +1344,7 @@ int do_pxe(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])cmd_tbl_t *cp;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* drop initial "pxe" arg */ argc--;
@@ -1355,7 +1355,7 @@ int do_pxe(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (cp)return cp->cmd (cmdtp, flag, argc, argv); -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; } U_BOOT_CMD(
common/cmd_reiser.c +2 -2
@@ -57,7 +57,7 @@ int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int part_length;if (argc <3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; dev = (int )simple_strtoul (argv[2 ], &ep,16 ); dev_desc =get_dev (argv[1 ],dev);
@@ -149,7 +149,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])break ;default : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }if (!filename) {
common/cmd_sata.c +4 -4
@@ -79,7 +79,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])switch (argc) {case 0 :case 1 : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;case 2 :if (strncmp (argv[1 ],"inf" ,3 ) ==0 ) {int i;
@@ -116,7 +116,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) }return rc; } -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;case 3 :if (strncmp (argv[1 ],"dev" ,3 ) ==0 ) {int dev = (int )simple_strtoul (argv[2 ],NULL ,10 );
@@ -147,7 +147,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) }return rc; } -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;default :/* at least 4 args */ if (strcmp (argv[1 ],"read" ) ==0 ) {
@@ -183,7 +183,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) n, (n == cnt) ? "OK" : "ERROR");return (n == cnt) ?0 :1 ; }else { -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }return rc;
common/cmd_scsi.c +8 -7
@@ -230,7 +230,7 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) boot_device = argv[2 ];break ;default : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }if (!boot_device) {
@@ -336,10 +336,11 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int do_scsi (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {switch (argc) { -case 0 : -case 1 :return cmd_usage (cmdtp); +case 0 : +case 1 : +return CMD_RET_USAGE ; -case 2 : +case 2 :if (strncmp (argv[1 ],"res" ,3 ) ==0 ) {printf ("\nReset SCSI\n" );scsi_bus_reset ();
@@ -384,7 +385,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])printf ("\nno SCSI devices available\n" );return 1 ; } -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;case 3 :if (strncmp (argv[1 ],"dev" ,3 ) ==0 ) {int dev = (int )simple_strtoul (argv[2 ],NULL ,10 );
@@ -412,7 +413,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) }return 1 ; } -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;default :/*@least 4 args */ if (strcmp (argv[1 ],"read" ) ==0 ) {
@@ -427,7 +428,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])return 0 ; } }/* switch */ -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }/****************************************************************************************
common/cmd_setexpr.c +1 -1
@@ -58,7 +58,7 @@ int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])/* Validate arguments */ if ((argc !=5 ) || (strlen (argv[3 ]) !=1 )) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; w =cmd_get_data_size (argv[0 ],4 );
common/cmd_sf.c +1 -1
@@ -293,7 +293,7 @@ done:return ret; usage: -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; } U_BOOT_CMD(
common/cmd_sha1sum.c +1 -1
@@ -32,7 +32,7 @@ static int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])u8 output[20 ];if (argc <3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; addr =simple_strtoul (argv[1 ],NULL ,16 ); len =simple_strtoul (argv[2 ],NULL ,16 );
common/cmd_strings.c +1 -1
@@ -15,7 +15,7 @@ static char *start_addr, *last_addr;int do_strings (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {if (argc ==1 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if ((flag &CMD_FLAG_REPEAT ) ==0 ) { start_addr = (char *)simple_strtoul (argv[1 ],NULL ,16 );
common/cmd_time.c +2 -2
@@ -38,7 +38,7 @@ static int run_command_and_time_it(int flag, int argc, char * const argv[],return 1 ; }if (argc > cmdtp->maxargs) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;/* * TODO(clchiou): get_timer_masked() is only defined in certain ARM
@@ -77,7 +77,7 @@ static int do_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int retval =0 ;if (argc ==1 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; retval =run_command_and_time_it (0 , argc -1 , argv +1 , &cycles);report_time (cycles);
common/cmd_ubi.c +2 -2
@@ -438,7 +438,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])int err =0 ;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if (mtdparts_init () !=0 ) {printf ("Error initializing mtdparts!\n" );
@@ -465,7 +465,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) }if (argc <3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;#ifdef CONFIG_CMD_UBIFS /*
common/cmd_ubifs.c +5 -5
@@ -53,7 +53,7 @@ int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int ret;if (argc !=2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; vol_name = argv[1 ];debug ("Using volume %s\n" , vol_name);
@@ -94,7 +94,7 @@ void cmd_ubifs_umount(void)int do_ubifs_umount (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {if (argc !=1 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if (ubifs_initialized ==0 ) {printf ("No UBIFS volume mounted!\n" );
@@ -141,18 +141,18 @@ int do_ubifs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) }if (argc <3 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; addr =simple_strtoul (argv[1 ], &endp,16 );if (endp == argv[1 ]) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; filename = argv[2 ];if (argc ==4 ) { size =simple_strtoul (argv[3 ], &endp,16 );if (endp == argv[3 ]) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }debug ("Loading file '%s' to address 0x%08x (size %d)\n" , filename, addr, size);
common/cmd_unzip.c +1 -1
@@ -39,7 +39,7 @@ static int do_unzip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) dst =simple_strtoul (argv[2 ],NULL ,16 );break ;default : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }if (gunzip ((void *) dst, dst_len, (void *) src, &src_len) !=0 )
common/cmd_usb.c +3 -3
@@ -379,7 +379,7 @@ int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) boot_device = argv[2 ];break ;default : -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }if (!boot_device) {
@@ -509,7 +509,7 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])#endif if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;if ((strncmp (argv[1 ],"reset" ,5 ) ==0 ) || (strncmp (argv[1 ],"start" ,5 ) ==0 )) {
@@ -694,7 +694,7 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; }#endif /* CONFIG_USB_STORAGE */ -return cmd_usage (cmdtp); +return CMD_RET_USAGE ; }#ifdef CONFIG_USB_STORAGE
common/main.c +1 -1
@@ -1361,7 +1361,7 @@ int do_run (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])int i;if (argc <2 ) -return cmd_usage (cmdtp); +return CMD_RET_USAGE ;for (i=1 ; i<argc; ++i) {char *arg;
Signature · 1 line
1.7.7.3