Unified command execution in one place
v5 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:
- Add a 'repeatable' parameter to cmd_process()
- Make cmd_process() return only success (0) or failure (1)
- Minor comment change for call to builtin_run_command()
- Rationalise return codes to 0, 1 and usage
Changes in v5:
- Add function comment to run_command()
- Adjust commit message to make it easier for Mike to grok
- Move cmd_call() prototype inside existing #ifdef __ASSEMBLY__
- Tidy up function comment to bring in changes in a later patch
- Use existing #ifdef __ASSEMBLY__ rather than create a new one
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 | 101 +++++++++++---------------------- include/command.h | 30 ++++++++++ include/common.h | 5 +- 65 files changed, 315 insertions(+), 306 deletions(-)
Signature · 1 line
1.7.7.3
PATCH v5 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
@@ -270,9 +270,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 timeout);
Signature · 1 line
1.7.7.3
PATCH v5 1/9 Remove CMD_PXE's static on run_command()
Quoted 2 lines · On Wednesday 15 February 2012 00:59:18 Simon Glass wrote:
It really isn't clear why this is here and there is no comment, so drop it.
i think it's kind of easy ... the only code that needed this was pxe, so might as well localize it if there's no consumers
-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/20120305/3aa37d4f/attachment.pgp>
Wolfgang Denk
AppliedPATCH v5 1/9 Remove CMD_PXE's static on run_command()
In reply to Simon GlassDear Simon Glass,
Quoted 10 lines · In message <[email protected]> you wrote:
It really isn't clear why this is here and there is no comment, so drop it.
Signed-off-by Simon Glass <[email protected]>---
common/main.c | 3 --- include/common.h | 2 -- 2 files changed, 0 insertions(+), 5 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "There are three principal ways to lose money: wine, women, and engi- neers. While the first two are more pleasant, the third is by far the more certain." - Baron Rothschild, ca. 1800
PATCH v5 2/9 Rename run_command() to builtin_run_command()
In reply to Simon GlassThe current run_command() is only one of the parsing options - the other is hush. We should not call run_command() when the hush parser is being used. So we rename this function to better explain its purpose.
---
Changes in v4:
- Minor comment change for call to builtin_run_command()
Changes in v5:
- Adjust commit message to make it easier for Mike to grok
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
@@ -274,9 +274,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 ;
@@ -457,7 +458,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 */
@@ -1278,7 +1279,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 v5 2/9 Rename run_command() to builtin_run_command()
-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/20120305/21177da6/attachment.pgp>
Wolfgang Denk
AppliedPATCH v5 2/9 Rename run_command() to builtin_run_command()
In reply to Simon GlassDear Simon Glass,
Quoted 12 lines · In message <[email protected]> you wrote:
The current
run_command()is only one of the parsing options - the other is hush. We should not callrun_command()when the hush parser is being used. So we rename this function to better explain its purpose.Signed-off-by Simon Glass <[email protected]>---
Changes in v4:
- Minor comment change for call tobuiltin_run_command()Changes in v5:
- Adjust commit message to make it easier for Mike to grok
Quoted 10 lines
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(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Of all possible committee reactions to any given agenda item, the reaction that will occur is the one which will liberate the greatest amount of hot air. -- Thomas L. Martin
PATCH v5 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
@@ -270,7 +270,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 /*
@@ -353,7 +353,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 */
@@ -401,7 +401,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 */
@@ -412,7 +412,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 */
@@ -1422,7 +1422,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 timeout);
Signature · 1 line
1.7.7.3
PATCH v5 3/9 Rename run_command2() to run_command()
-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/20120305/f27349c3/attachment.pgp>
Wolfgang Denk
AppliedPATCH v5 3/9 Rename run_command2() to run_command()
In reply to Simon GlassDear Simon Glass,
Quoted 9 lines · In message <[email protected]> you wrote:
This is a more sensible name, so rename it.
Signed-off-by Simon Glass <[email protected]>---
common/cmd_pxe.c | 2 +- common/main.c | 10 +++++----- include/common.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Always try to do things in chronological order; it's less confusing that way.
PATCH v5 4/9 Stop using builtin_run_command()
In reply to Simon GlassBoards 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.
---
Changes in v5:
- Add function comment to run_command()
- Adjust commit message to make it easier for Mike to grok
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 | 49 +++++++++++++++++--------------- include/common.h | 1 - 9 files changed, 34 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 +26 -23
73 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 v5 4/9 Stop using builtin_run_command()
-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/20120305/4ed4b34f/attachment.pgp>
Wolfgang Denk
AppliedPATCH v5 4/9 Stop using builtin_run_command()
In reply to Simon GlassDear Simon Glass,
Quoted 11 lines · In message <[email protected]> you wrote:
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 userun_command()instead, since it knows how to call the correct parser.Signed-off-by Simon Glass <[email protected]>---
Changes in v5:
- Add function comment torun_command()
- Adjust commit message to make it easier for Mike to grok
Quoted 10 lines
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 | 49 +++++++++++++++++--------------- include/common.h | 1 - 9 files changed, 34 insertions(+), 43 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It is dangerous to be sincere unless you are also stupid.
- George Bernard ShawPATCH v5 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
@@ -1132,6 +1132,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;
@@ -1382,6 +1383,7 @@ static int builtin_run_command(const char *cmd, int flag) return rc ? rc : repeatable; } +#endif /* * Run a command using the selected parser.
Signature · 1 line
1.7.7.3
PATCH v5 5/9 Don't include standard parser if hush is used
Quoted 15 lines · On Wednesday 15 February 2012 00:59:22 Simon Glass wrote:
This saves about 1KB of code space on ARM with
CONFIG_SYS_HUSH_PARSERdefined.common/main.c +1
-0@@ -1132,6 +1132,7 @@ int parse_line (char *line, char *argv[])/************************************************************************* ***/ +#ifndef CONFIG_SYS_HUSH_PARSER static void process_macros (const char *input,char *output) {common/main.c +0
-0char c, prev;
common/main.c static int builtin_run_command(const char *cmd, int · line 1387
Quoted 5 lines
common/main.c +1
-0@@ -1382,6 +1383,7 @@ static int builtin_run_command(const char *cmd, int flag) return rc ? rc : repeatable; } +#endif
not sure why this is needed ... this wraps two static funcs, so gcc should be able to see that they're unused and automatically delete them shouldn't it ? why do you need the explicit ifdef ?
-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/20120305/e550d94a/attachment.pgp>
PATCH v5 5/9 Don't include standard parser if hush is used
Hi Mike,
Quoted 18 lines · Mike Frysinger
Quoted 17 lines · On Wednesday 15 February 2012 00:59:22 Simon Glass wrote:
This saves about 1KB of code space on ARM with
CONFIG_SYS_HUSH_PARSERdefined.common/main.c +0
-0@@ -1132,6 +1132,7 @@ int parse_line (char *line, char *argv[])?/************************************************************************* ***/
+#ifndef
CONFIG_SYS_HUSH_PARSER
?static voidprocess_macros(const char *input, char *output) ?{
? ? ? char c, prev;common/main.c +0
-0@@ -1382,6 +1383,7 @@ static int builtin_run_command(const char *cmd, int flag)
Quoted 7 lines
common/main.c static int builtin_run_command(const char *cmd, int · line 1387
Quoted 3 lines
common/main.c +1
-0? ? ? return rc ? rc : repeatable; ?} +#endif not sure why this is needed ... this wraps two static funcs, so gcc should be able to see that they're unused and automatically delete them shouldn't it ? why do you need the explicit ifdef ?
Actually I think this can be dropped. I think originally I didn't go as far as making builtin_run_command() static (due to calls from elsewhere), which might explain why I wanted that. Now that the function is not exported, this patch is not needed. It can be dropped from the series.
Regards,
Simon
Quoted 1 line
-mike
Wolfgang Denk
AppliedPATCH v5 5/9 Don't include standard parser if hush is used
In reply to Simon GlassDear Simon Glass,
Quoted 8 lines · In message <[email protected]> you wrote:
This saves about 1KB of code space on ARM with
CONFIG_SYS_HUSH_PARSERdefined.Signed-off-by Simon Glass <[email protected]>---
common/main.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de If A equals success, then the formula is A = X + Y + Z. X is work. Y is play. Z is keep your mouth shut. - Albert Einstein
PATCH v5 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.
---
Changes in v5:
- Move cmd_call() prototype inside existing #ifdef __ASSEMBLY__
- Tidy up function comment to bring in changes in a later patch
common/command.c | 21 +++++++++++++++++++++ common/hush.c | 9 +++------ common/main.c | 3 +-- include/command.h | 3 +++ 4 files changed, 28 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 (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; +}
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
@@ -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;
include/command.h +3 -0
@@ -112,6 +112,8 @@ static inline int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)#endif extern int do_reset (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]); +int cmd_call (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]); +#endif /* __ASSEMBLY__ */ /*
@@ -150,4 +152,5 @@ 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 +#endif /* __COMMAND_H */
Signature · 1 line
1.7.7.3
PATCH v5 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 Wednesday 15 February 2012 00:59:23 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; +}
be nice to actually display the command's name here ...
include/command.h extern int do_reset(cmd_tbl_t *cmdtp, int flag, int · line 156
Quoted 8 lines
include/command.h +1
-0@@ -150,4 +152,5 @@ 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 +#endif /* __COMMAND_H */
unrelated whitespace change
-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/20120305/a29180eb/attachment.pgp>
PATCH v5 6/9 Create a single cmd_call() function to handle command execution
Hi Mike,
Quoted 4 lines · Mike Frysinger
Quoted 3 lines · On Wednesday 15 February 2012 00:59:23 Simon Glass wrote:
common/command.c +0
-0
Quoted 11 lines
common/command.c
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; +}be nice to actually display the command's name here ...
OK I can do that.
Quoted 11 lines
Quoted 9 lines
include/command.h +0
-0@@ -150,4 +152,5 @@ 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
+
?#endif ? ? ? /*__COMMAND_H*/unrelated whitespace change
Done. I will send a new version of this patch and mark the dropped one 'archived' in patchwork. Do you think that is enough?
I wonder who is going to pick up this series? Stefan pulled it through staging last time but it had a problem with true/false handling I think, when Wolfgang tested it.
Regards,
Simon
Quoted 1 line
-mike
PATCH v5 6/9 Create a single cmd_call() function to handle command execution
Quoted 13 lines · On Tuesday 06 March 2012 01:14:10 Simon Glass wrote:
Quoted 11 lines · Mike Frysinger
include/command.h extern int do_reset(cmd_tbl_t *cmdtp, int flag, int · line 156
Quoted 8 lines · On Wednesday 15 February 2012 00:59:23 Simon Glass wrote:
include/command.h +1
-0@@ -150,4 +152,5 @@ 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 +#endif /* __COMMAND_H */ unrelated whitespace change
Quoted 2 lines
Done. I will send a new version of this patch and mark the dropped one 'archived' in patchwork. Do you think that is enough?
should be. i change the state of all previous versions of patches that i post as "superseded".
-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/20120306/0af43557/attachment.pgp>
Wolfgang Denk
AppliedPATCH v5 6/9 Create a single cmd_call() function to handle command execution
In reply to Simon GlassDear Simon Glass,
Quoted 9 lines · In message <[email protected]> you wrote:
We should aim for a single point of entry to the commands, whichever parser is used.
Signed-off-by Simon Glass <[email protected]>---
Changes in v5:
- Movecmd_call()prototype inside existing #ifdef__ASSEMBLY__
- Tidy up function comment to bring in changes in a later patch
Quoted 5 lines
common/command.c | 21 +++++++++++++++++++++ common/hush.c | 9 +++------ common/main.c | 3 +-- include/command.h | 3 +++ 4 files changed, 28 insertions(+), 8 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de When you say "I wrote a program that crashed Windows", people just stare at you blankly and say "Hey, I got those with the system, *for free*". - Linus Torvalds in <[email protected]>
PATCH v5 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
Wolfgang Denk
AppliedPATCH v5 7/9 Remove interleave of non-U-Boot code in hush
Dear Simon Glass,
Quoted 9 lines · In message <[email protected]> you wrote:
There is a nasty interleave of #ifdefs in
hush.cwhere the two code paths have different indents. Remove this ickiness.Signed-off-by Simon Glass <[email protected]>Acked-by Mike Frysinger <[email protected]>---
common/hush.c | 24 +++++++++++------------- 1 files changed, 11 insertions(+), 13 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 7 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The evolution of the human race will not be accomplished in the ten
thousand years of tame animals, but in the million years of wild
animals, because man is and will always be a wild animal.
- Charles Galton DarwinPATCH v5 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()
- Make cmd_process() return only success (0) or failure (1)
- Rationalise return codes to 0, 1 and usage
Changes in v5:
- Use existing #ifdef __ASSEMBLY__ rather than create a new one
common/command.c | 41 ++++++++++++++++++++++++++++++++++++++++- common/hush.c | 52 ++++++++++++---------------------------------------- common/main.c | 37 +------------------------------------ include/command.h | 29 ++++++++++++++++++++++++++++- 4 files changed, 81 insertions(+), 78 deletions(-)
common/command.c +40 -1
@@ -499,7 +499,7 @@ void fixup_cmdtable(cmd_tbl_t *cmdtp, int size)* @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[]) +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
@@ -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 ())
include/command.h +28 -1
@@ -112,7 +112,34 @@ static inline int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)#endif extern int do_reset (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]); -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__ */
Signature · 1 line
1.7.7.3
Wolfgang Denk
AppliedPATCH v5 8/9 Add cmd_process() to process commands in one place
Dear Simon Glass,
Quoted 16 lines · In message <[email protected]> you wrote:
We currently have the same code in
hush.candmain.c. This brings the code into one place.As an added feature, if the command function returns
CMD_RET_USAGEthencmd_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 <[email protected]>---
Changes in v4:
- Add a 'repeatable' parameter tocmd_process()
- Makecmd_process()return only success (0) or failure (1)
- Rationalise return codes to 0, 1 and usage
Quoted 8 lines
Changes in v5:
- Use existing #ifdef__ASSEMBLY__rather than create a new onecommon/command.c | 41 ++++++++++++++++++++++++++++++++++++++++- common/hush.c | 52 ++++++++++++---------------------------------------- common/main.c | 37 +------------------------------------ include/command.h | 29 ++++++++++++++++++++++++++++- 4 files changed, 81 insertions(+), 78 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de ... bacteriological warfare ... hard to believe we were once foolish enough to play around with that. -- McCoy, "The Omega Glory", stardate unknown
PATCH v5 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. This saves about 100 byte or so on ARM.
---
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
@@ -1381,7 +1381,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
Wolfgang Denk
AppliedPATCH v5 9/9 Convert cmd_usage() calls in common to use a return value
Dear Simon Glass,
Quoted 62 lines · In message <[email protected]> you wrote:
Change all files in common/ to use
CMD_RET_USAGEinstead of callingcmd_usage()directly. This saves about 100 byte or so on ARM.Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Fix minor errors one of which created a warning
- Squash i2c patch into the common/ patchChanges in v3:
- Rebase to mastercommon/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 +-
Quoted 8 lines
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(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de It may be bad manners to talk with your mouth full, but it isn't too good either if you speak when your head is empty.
v5 cover Unified command execution in one place
In reply to Simon GlassDear Simon Glass,
Quoted 18 lines · In message <[email protected]> you wrote:
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 calledcmd_process().This new function understands return codes, and in particular
CMD_RET_USAGEto indicate a usage error. So rather than callingcmd_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 justrun_command(), and renames the oldrun_command()tobuiltin_run_command(). No one should call this outsidemain.csince 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.
Quoted 3 lines
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.
I tested this on PPC (TQM5200 config):
add/remove: 2/0 grow/shrink: 3/40 up/down: 268/-740 (-472)
and ARM (m28evk config):
add/remove: 1/0 grow/shrink: 5/38 up/down: 212/-1404 (-1192)
so this looks good to me.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de NOTE: The Most Fundamental Particles in This Product Are Held Together by a "Gluing" Force About Which Little is Currently Known and Whose Adhesive Power Can Therefore Not Be Permanently Guaranteed.
v5 cover Unified command execution in one place
Hi Wolfgang,
Quoted 27 lines · Wolfgang Denk
Dear Simon Glass,
Quoted 18 lines · In message <[email protected]> you wrote:
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 calledcmd_process().This new function understands return codes, and in particular
CMD_RET_USAGEto indicate a usage error. So rather than callingcmd_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 justrun_command(), and renames the oldrun_command()tobuiltin_run_command(). No one should call this outsidemain.csince 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.Quoted 3 lines
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.
I tested this on PPC (TQM5200 config):
Quoted 7 lines
add/remove: 2/0 grow/shrink: 3/40 up/down: 268/-740 (-472)
and ARM (m28evk config):
add/remove: 1/0 grow/shrink: 5/38 up/down: 212/-1404 (-1192)
so this looks good to me.
OK good. Hoping it sorts out the command success/failure problem you saw with the last version also.
Out of interest what tool are you using to display that information?
Regards,
Simon
Quoted 12 lines
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
NOTE: The ?Most ?Fundamental ?Particles ?in ?This ?Product ?Are ?Held Together ?by ?a ?"Gluing" Force About Which Little is Currently Known and Whose Adhesive Power Can Therefore Not Be Permanently Guaranteed.
v5 cover Unified command execution in one place
Dear Simon Glass,
Quoted 3 lines · In message <CAPnjgZ3p_Qt42YE+HXE86OwDEn8C9gr+M4e+JwkGDhnGd7uLkg@mail.gmail.com>…
OK good. Hoping it sorts out the command success/failure problem you saw with the last version also.
I've pulled it, further testing will show ;-)
Quoted 1 line
Out of interest what tool are you using to display that information?
bloat-o-meter from the kernel directory, like that:
-> bloat-o-meter u-boot-before-arm u-boot-after-arm add/remove: 1/0 grow/shrink: 5/38 up/down: 212/-1404 (-1192)
function old new delta cmd_process - 180 +180 static.mod_mem 316 328 +12 do_env_export 596 604 +8 do_run 116 120 +4 do_mem_crc 168 172 +4 do_env_set 28 32 +4 do_ubifs_mount 88 84 -4 do_nandboot 608 604 -4 do_mem_mw 188 184 -4 do_mem_loop 244 240 -4 do_mem_cp 216 212 -4 do_gpio 288 284 -4 do_go 112 108 -4 do_ext2ls 296 292 -4 do_ext2load 768 764 -4 do_env_edit 104 100 -4 do_env_default 72 68 -4 netboot_common 676 668 -8 do_usbboot 836 828 -8 do_spi_flash 1364 1356 -8 do_setexpr 416 408 -8 do_nand 2476 2468 -8 do_i2c_mw 252 244 -8 do_i2c_md 424 416 -8 do_i2c_loop 220 212 -8 do_i2c_crc 276 268 -8 do_date 284 276 -8 static.mod_i2c_mem 520 508 -12 do_sleep 128 116 -12 do_ping 132 120 -12 do_mtdparts 1408 1396 -12 do_mem_md 216 204 -12 do_mem_cmp 396 384 -12 do_ubifs_load 212 196 -16 do_mmcops 1072 1056 -16 do_mii 1920 1904 -16 do_mem_nm 24 8 -16 do_mem_mm 24 8 -16 do_i2c_read 188 172 -16 do_eeprom 292 276 -16 do_i2c_nm 28 8 -20 do_i2c_mm 28 8 -20 run_list_real 2072 1984 -88
run_command 976 8 -968
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "It is easier to port a shell than a shell script." - Larry Wall