diff options
Diffstat (limited to 'common')
47 files changed, 270 insertions, 498 deletions
diff --git a/common/cmd_bedbug.c b/common/cmd_bedbug.c index d01ee19..2bd62e2 100644 --- a/common/cmd_bedbug.c +++ b/common/cmd_bedbug.c @@ -84,10 +84,8 @@ int do_bedbug_dis (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) addr = dis_last_addr; len = dis_last_len; - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); if ((flag & CMD_FLAG_REPEAT) == 0) { /* New command */ @@ -125,10 +123,8 @@ int do_bedbug_asm (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) /* -------------------------------------------------- */ int rcode = 0; - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); printf ("\nEnter '.' when done\n"); mem_addr = simple_strtoul (argv[1], NULL, 16); diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c index 5ec798c..d51cc55 100644 --- a/common/cmd_bmp.c +++ b/common/cmd_bmp.c @@ -102,8 +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: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } return (bmp_info(addr)); @@ -127,8 +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: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } return (bmp_display(addr, x, y)); @@ -159,12 +157,10 @@ static int do_bmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) c = find_cmd_tbl(argv[0], &cmd_bmp_sub[0], ARRAY_SIZE(cmd_bmp_sub)); - if (c) { + if (c) return c->cmd(cmdtp, flag, argc, argv); - } else { - cmd_usage(cmdtp); - return 1; - } + else + return cmd_usage(cmdtp); } U_BOOT_CMD( diff --git a/common/cmd_boot.c b/common/cmd_boot.c index 9ccc8c7..72dacaa 100644 --- a/common/cmd_boot.c +++ b/common/cmd_boot.c @@ -40,10 +40,8 @@ int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ulong addr, rc; int rcode = 0; - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); addr = simple_strtoul(argv[1], NULL, 16); diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index bf77fb4..adfa6cd 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -491,17 +491,14 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv argv++; return bootm_start(cmdtp, flag, argc, argv); } - } - /* Unrecognized command */ - else { - cmd_usage(cmdtp); - return 1; + } else { + /* Unrecognized command */ + return cmd_usage(cmdtp); } if (images.state >= state) { printf ("Trying to execute a command out of order\n"); - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } images.state |= state; diff --git a/common/cmd_cache.c b/common/cmd_cache.c index be87b5c..5cdd834 100644 --- a/common/cmd_cache.c +++ b/common/cmd_cache.c @@ -34,10 +34,6 @@ int do_icache ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) switch (argc) { case 2: /* on / off */ switch (on_off(argv[1])) { -#if 0 /* prevented by varargs handling; FALLTROUGH is harmless, too */ - default: cmd_usage(cmdtp); - return; -#endif case 0: icache_disable(); break; case 1: icache_enable (); @@ -49,8 +45,7 @@ int do_icache ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) icache_status() ? "ON" : "OFF"); return 0; default: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } return 0; } @@ -60,10 +55,6 @@ int do_dcache ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) switch (argc) { case 2: /* on / off */ switch (on_off(argv[1])) { -#if 0 /* prevented by varargs handling; FALLTROUGH is harmless, too */ - default: cmd_usage(cmdtp); - return; -#endif case 0: dcache_disable(); break; case 1: dcache_enable (); @@ -75,8 +66,7 @@ int do_dcache ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) dcache_status() ? "ON" : "OFF"); return 0; default: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } return 0; diff --git a/common/cmd_dcr.c b/common/cmd_dcr.c index 45de8cd..45fe66a 100644 --- a/common/cmd_dcr.c +++ b/common/cmd_dcr.c @@ -44,10 +44,8 @@ int do_getdcr ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] ) unsigned long get_dcr (unsigned short); /* Validate arguments */ - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); /* Get a DCR */ dcrn = (unsigned short) simple_strtoul (argv[1], NULL, 16); @@ -73,10 +71,8 @@ int do_setdcr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) extern char console_buffer[]; /* Validate arguments */ - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); /* Set a DCR */ dcrn = (unsigned short) simple_strtoul (argv[1], NULL, 16); @@ -120,10 +116,8 @@ int do_getidcr (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) char buf[80]; /* Validate arguments */ - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); /* Find out whether ther is '.' (dot) symbol in the first parameter. */ strncpy (buf, argv[1], sizeof(buf)-1); @@ -176,10 +170,8 @@ int do_setidcr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) char buf[80]; /* Validate arguments */ - if (argc < 4) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 4) + return cmd_usage(cmdtp); /* Find out whether ther is '.' (dot) symbol in the first parameter. */ strncpy (buf, argv[1], sizeof(buf)-1); diff --git a/common/cmd_df.c b/common/cmd_df.c index 6a08666..9a3c84c 100644 --- a/common/cmd_df.c +++ b/common/cmd_df.c @@ -27,8 +27,7 @@ static int do_df(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } usage: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } U_BOOT_CMD( diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c index 129162c..9f4b22c 100644 --- a/common/cmd_eeprom.c +++ b/common/cmd_eeprom.c @@ -104,8 +104,7 @@ int do_eeprom ( cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) } } - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } #endif diff --git a/common/cmd_ext2.c b/common/cmd_ext2.c index 49021cd..35fb361 100644 --- a/common/cmd_ext2.c +++ b/common/cmd_ext2.c @@ -65,10 +65,9 @@ int do_ext2ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) block_dev_desc_t *dev_desc=NULL; int part_length; - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); + dev = (int)simple_strtoul (argv[2], &ep, 16); dev_desc = get_dev(argv[1],dev); @@ -164,8 +163,7 @@ int do_ext2load (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) break; default: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } if (!filename) { diff --git a/common/cmd_fdc.c b/common/cmd_fdc.c index 486d5d4..831a07f 100644 --- a/common/cmd_fdc.c +++ b/common/cmd_fdc.c @@ -741,8 +741,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: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } /* setup FDC and scan for drives */ if(fdc_setup(boot_drive,pCMD,pFG)==FALSE) { diff --git a/common/cmd_fdos.c b/common/cmd_fdos.c index 00f7e88..a8822d9 100644 --- a/common/cmd_fdos.c +++ b/common/cmd_fdos.c @@ -73,8 +73,7 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) name = argv [2]; break; default: - cmd_usage(cmdtp); - break; + return cmd_usage(cmdtp); } /* Init physical layer */ diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index cd4c6de..3d0c2b7 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -65,14 +65,12 @@ void set_working_fdt_addr(void *addr) */ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) { - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); - /******************************************************************** + /* * Set the address of the fdt - ********************************************************************/ + */ if (argv[1][0] == 'a') { unsigned long addr; /* @@ -116,18 +114,16 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) } } - /******************************************************************** + /* * Move the working_fdt - ********************************************************************/ + */ } else if (strncmp(argv[1], "mo", 2) == 0) { struct fdt_header *newaddr; int len; int err; - if (argc < 4) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 4) + return cmd_usage(cmdtp); /* * Set the address and length of the fdt. @@ -166,9 +162,9 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) } working_fdt = newaddr; - /******************************************************************** + /* * Make a new node - ********************************************************************/ + */ } else if (strncmp(argv[1], "mk", 2) == 0) { char *pathp; /* path */ char *nodep; /* new node to add */ @@ -178,10 +174,8 @@ 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) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 4) + return cmd_usage(cmdtp); pathp = argv[2]; nodep = argv[3]; @@ -202,9 +196,9 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) return 1; } - /******************************************************************** + /* * Set the value of a property in the working_fdt. - ********************************************************************/ + */ } else if (argv[1][0] == 's') { char *pathp; /* path */ char *prop; /* property */ @@ -216,10 +210,8 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) /* * Parameters: Node path, property, optional value. */ - if (argc < 4) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 4) + return cmd_usage(cmdtp); pathp = argv[2]; prop = argv[3]; @@ -247,9 +239,9 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) return 1; } - /******************************************************************** + /* * Print (recursive) / List (single level) - ********************************************************************/ + */ } else if ((argv[1][0] == 'p') || (argv[1][0] == 'l')) { int depth = MAX_LEVEL; /* how deep to print */ char *pathp; /* path */ @@ -281,9 +273,9 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) if (ret != 0) return ret; - /******************************************************************** + /* * Remove a property/node - ********************************************************************/ + */ } else if (strncmp(argv[1], "rm", 2) == 0) { int nodeoffset; /* node offset from libfdt */ int err; @@ -321,9 +313,9 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) } } - /******************************************************************** + /* * Display header info - ********************************************************************/ + */ } else if (argv[1][0] == 'h') { u32 version = fdt_version(working_fdt); printf("magic:\t\t\t0x%x\n", fdt_magic(working_fdt)); @@ -351,16 +343,16 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) fdt_num_mem_rsv(working_fdt)); printf("\n"); - /******************************************************************** + /* * Set boot cpu id - ********************************************************************/ + */ } else if (strncmp(argv[1], "boo", 3) == 0) { unsigned long tmp = simple_strtoul(argv[2], NULL, 16); fdt_set_boot_cpuid_phys(working_fdt, tmp); - /******************************************************************** + /* * memory command - ********************************************************************/ + */ } else if (strncmp(argv[1], "me", 2) == 0) { uint64_t addr, size; int err; @@ -370,9 +362,9 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) if (err < 0) return err; - /******************************************************************** + /* * mem reserve commands - ********************************************************************/ + */ } else if (strncmp(argv[1], "rs", 2) == 0) { if (argv[2][0] == 'p') { uint64_t addr, size; @@ -417,8 +409,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) } } else { /* Unrecognized command */ - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } } #ifdef CONFIG_OF_BOARD_SETUP @@ -430,10 +421,8 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) else if (argv[1][0] == 'c') { unsigned long initrd_start = 0, initrd_end = 0; - if ((argc != 2) && (argc != 4)) { - cmd_usage(cmdtp); - return 1; - } + if ((argc != 2) && (argc != 4)) + return cmd_usage(cmdtp); if (argc == 4) { initrd_start = simple_strtoul(argv[2], NULL, 16); @@ -449,8 +438,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) } else { /* Unrecognized command */ - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } return 0; diff --git a/common/cmd_flash.c b/common/cmd_flash.c index 5d8fb7a..ff43965 100644 --- a/common/cmd_flash.c +++ b/common/cmd_flash.c @@ -332,10 +332,8 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #endif int rcode = 0; - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); if (strcmp(argv[1], "all") == 0) { for (bank=1; bank<=CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { @@ -383,10 +381,8 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } #endif - if (argc != 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc != 3) + return cmd_usage(cmdtp); if (strcmp(argv[1], "bank") == 0) { bank = simple_strtoul(argv[2], NULL, 16); @@ -406,10 +402,8 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; } - if (addr_first >= addr_last) { - cmd_usage(cmdtp); - return 1; - } + if (addr_first >= addr_last) + return cmd_usage(cmdtp); rcode = flash_sect_erase(addr_first, addr_last); return rcode; @@ -482,19 +476,15 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int p; int rcode = 0; - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); - if (strcmp(argv[1], "off") == 0) { + if (strcmp(argv[1], "off") == 0) p = 0; - } else if (strcmp(argv[1], "on") == 0) { + else if (strcmp(argv[1], "on") == 0) p = 1; - } else { - cmd_usage(cmdtp); - return 1; - } + else + return cmd_usage(cmdtp); #ifdef CONFIG_HAS_DATAFLASH if ((strcmp(argv[2], "all") != 0) && (strcmp(argv[2], "bank") != 0)) { @@ -592,10 +582,8 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } #endif - if (argc != 4) { - cmd_usage(cmdtp); - return 1; - } + if (argc != 4) + return cmd_usage(cmdtp); if (strcmp(argv[2], "bank") == 0) { bank = simple_strtoul(argv[3], NULL, 16); @@ -634,10 +622,9 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; } - if (addr_first >= addr_last) { - cmd_usage(cmdtp); - return 1; - } + if (addr_first >= addr_last) + return cmd_usage(cmdtp); + rcode = flash_sect_protect (p, addr_first, addr_last); #endif /* CONFIG_SYS_NO_FLASH */ return rcode; diff --git a/common/cmd_fpga.c b/common/cmd_fpga.c index ddc7a05..e50c9de 100644 --- a/common/cmd_fpga.c +++ b/common/cmd_fpga.c @@ -44,7 +44,6 @@ #endif /* Local functions */ -static void fpga_usage (cmd_tbl_t * cmdtp); static int fpga_get_op (char *opstr); /* Local defines */ @@ -232,8 +231,7 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) switch (op) { case FPGA_NONE: - fpga_usage (cmdtp); - break; + return cmd_usage(cmdtp); case FPGA_INFO: rc = fpga_info (dev); @@ -312,17 +310,11 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) default: printf ("Unknown operation\n"); - fpga_usage (cmdtp); - break; + return cmd_usage(cmdtp); } return (rc); } -static void fpga_usage (cmd_tbl_t * cmdtp) -{ - cmd_usage(cmdtp); -} - /* * Map op to supported operations. We don't use a table since we * would just have to relocate it from flash anyway. diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index fb9d3b0..371e022 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -184,10 +184,8 @@ static int do_i2c_read ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv uint devaddr, alen, length; u_char *memaddr; - if (argc != 5) { - cmd_usage(cmdtp); - return 1; - } + if (argc != 5) + return cmd_usage(cmdtp); /* * I2C chip address @@ -200,10 +198,8 @@ 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 == 0) { - cmd_usage(cmdtp); - return 1; - } + if (alen == 0) + return cmd_usage(cmdtp); /* * Length is the number of objects, not number of bytes. @@ -240,10 +236,8 @@ static int do_i2c_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] alen = i2c_dp_last_alen; length = i2c_dp_last_length; - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); if ((flag & CMD_FLAG_REPEAT) == 0) { /* @@ -261,10 +255,8 @@ 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 == 0) { - cmd_usage(cmdtp); - return 1; - } + if (alen == 0) + return cmd_usage(cmdtp); /* * If another parameter, it is the length to display. @@ -332,10 +324,8 @@ static int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] uchar byte; int count; - if ((argc < 4) || (argc > 5)) { - cmd_usage(cmdtp); - return 1; - } + if ((argc < 4) || (argc > 5)) + return cmd_usage(cmdtp); /* * Chip is always specified. @@ -347,10 +337,8 @@ 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 == 0) { - cmd_usage(cmdtp); - return 1; - } + if (alen == 0) + return cmd_usage(cmdtp); /* * Value to write is always specified. @@ -398,10 +386,8 @@ static int do_i2c_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] ulong crc; ulong err; - if (argc < 4) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 4) + return cmd_usage(cmdtp); /* * Chip is always specified. @@ -413,10 +399,8 @@ 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 == 0) { - cmd_usage(cmdtp); - return 1; - } + if (alen == 0) + return cmd_usage(cmdtp); /* * Count is always specified @@ -462,10 +446,8 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg int nbytes; extern char console_buffer[]; - if (argc != 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc != 3) + return cmd_usage(cmdtp); #ifdef CONFIG_BOOT_RETRY_TIME reset_cmd_timeout(); /* got a good command to get here */ @@ -495,10 +477,8 @@ 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 == 0) { - cmd_usage(cmdtp); - return 1; - } + if (alen == 0) + return cmd_usage(cmdtp); } /* @@ -628,10 +608,8 @@ static int do_i2c_loop(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] u_char bytes[16]; int delay; - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); /* * Chip is always specified. @@ -643,10 +621,8 @@ 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 == 0) { - cmd_usage(cmdtp); - return 1; - } + if (alen == 0) + return cmd_usage(cmdtp); /* * Length is the number of objects, not number of bytes. @@ -784,10 +760,9 @@ static int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) "32 MiB", "16 MiB", "8 MiB", "4 MiB" }; - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); + /* * Chip is always specified. */ @@ -1322,12 +1297,10 @@ 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) { + if (c) return c->cmd(cmdtp, flag, argc, argv); - } else { - cmd_usage(cmdtp); - return 1; - } + else + return cmd_usage(cmdtp); } /***************************************************/ diff --git a/common/cmd_ide.c b/common/cmd_ide.c index d486697..c0fb88d 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -179,8 +179,7 @@ int do_ide (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) switch (argc) { case 0: case 1: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); case 2: if (strncmp(argv[1],"res",3) == 0) { puts ("\nReset IDE" @@ -229,8 +228,7 @@ int do_ide (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } return rcode; } - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); case 3: if (strncmp(argv[1],"dev",3) == 0) { int dev = (int)simple_strtoul(argv[2], NULL, 10); @@ -278,8 +276,7 @@ int do_ide (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #endif } - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); default: /* at least 4 args */ @@ -332,14 +329,12 @@ int do_ide (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) printf ("%ld blocks written: %s\n", n, (n==cnt) ? "OK" : "ERROR"); - if (n==cnt) { + if (n==cnt) return 0; - } else { + else return 1; - } } else { - cmd_usage(cmdtp); - rcode = 1; + return cmd_usage(cmdtp); } return rcode; @@ -374,9 +369,8 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) boot_device = argv[2]; break; default: - cmd_usage(cmdtp); show_boot_progress (-42); - return 1; + return cmd_usage(cmdtp); } show_boot_progress (42); diff --git a/common/cmd_irq.c b/common/cmd_irq.c index 4888328..d35a43f 100644 --- a/common/cmd_irq.c +++ b/common/cmd_irq.c @@ -27,17 +27,14 @@ int do_interrupts(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - if (argc != 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc != 2) + return cmd_usage(cmdtp); /* on */ - if (strncmp(argv[1], "on", 2) == 0) { + if (strncmp(argv[1], "on", 2) == 0) enable_interrupts(); - } else { + else disable_interrupts(); - } return 0; } diff --git a/common/cmd_itest.c b/common/cmd_itest.c index e88d6e0..8dd8927 100644 --- a/common/cmd_itest.c +++ b/common/cmd_itest.c @@ -165,10 +165,8 @@ int do_itest ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] ) int value, w; /* Validate arguments */ - if ((argc != 4)){ - cmd_usage(cmdtp); - return 1; - } + if ((argc != 4)) + return cmd_usage(cmdtp); /* Check for a data width specification. * Defaults to long (4) if no specification. diff --git a/common/cmd_load.c b/common/cmd_load.c index 52ed1fa..dad0303 100644 --- a/common/cmd_load.c +++ b/common/cmd_load.c @@ -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 - cmd_usage(cmdtp); + return cmd_usage(cmdtp); } printf("RTS/CTS hardware flow control: %s\n", hwflow_onoff(0) ? "on" : "off"); return 0; diff --git a/common/cmd_log.c b/common/cmd_log.c index 49deddd..0e89357 100644 --- a/common/cmd_log.c +++ b/common/cmd_log.c @@ -241,12 +241,10 @@ int do_log (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } return 0; } - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); default: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } } diff --git a/common/cmd_mem.c b/common/cmd_mem.c index bcea399..44834ea 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -76,10 +76,8 @@ int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) size = dp_last_size; length = dp_last_length; - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); if ((flag & CMD_FLAG_REPEAT) == 0) { /* New command specified. Check for a size specification. @@ -172,10 +170,8 @@ int do_mem_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ulong addr, writeval, count; int size; - if ((argc < 3) || (argc > 4)) { - cmd_usage(cmdtp); - return 1; - } + if ((argc < 3) || (argc > 4)) + return cmd_usage(cmdtp); /* Check for size specification. */ @@ -216,10 +212,8 @@ int do_mem_mdc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int i; ulong count; - if (argc < 4) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 4) + return cmd_usage(cmdtp); count = simple_strtoul(argv[3], NULL, 10); @@ -245,10 +239,8 @@ int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int i; ulong count; - if (argc < 4) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 4) + return cmd_usage(cmdtp); count = simple_strtoul(argv[3], NULL, 10); @@ -276,10 +268,8 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int size; int rcode = 0; - if (argc != 4) { - cmd_usage(cmdtp); - return 1; - } + if (argc != 4) + return cmd_usage(cmdtp); /* Check for size specification. */ @@ -360,10 +350,8 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ulong addr, dest, count; int size; - if (argc != 4) { - cmd_usage(cmdtp); - return 1; - } + if (argc != 4) + return cmd_usage(cmdtp); /* Check for size specification. */ @@ -484,10 +472,8 @@ int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) volatile ushort *shortp; volatile u_char *cp; - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); /* Check for a size spefication. * Defaults to long if no or incorrect specification. @@ -555,10 +541,8 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) volatile ushort *shortp; volatile u_char *cp; - if (argc < 4) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 4) + return cmd_usage(cmdtp); /* Check for a size spefication. * Defaults to long if no or incorrect specification. @@ -990,10 +974,8 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[]) int nbytes, size; extern char console_buffer[]; - if (argc != 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc != 2) + return cmd_usage(cmdtp); #ifdef CONFIG_BOOT_RETRY_TIME reset_cmd_timeout(); /* got a good command to get here */ @@ -1095,10 +1077,8 @@ int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ulong crc; ulong *ptr; - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); addr = simple_strtoul (argv[1], NULL, 16); addr += base_address; @@ -1131,9 +1111,8 @@ int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) char * const *av; if (argc < 3) { - usage: - cmd_usage(cmdtp); - return 1; +usage: + return cmd_usage(cmdtp); } av = argv + 1; @@ -1181,10 +1160,8 @@ int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) unsigned int i; u8 output[16]; - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); addr = simple_strtoul(argv[1], NULL, 16); len = simple_strtoul(argv[2], NULL, 16); @@ -1206,10 +1183,8 @@ int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) unsigned int i; u8 output[20]; - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); addr = simple_strtoul(argv[1], NULL, 16); len = simple_strtoul(argv[2], NULL, 16); @@ -1239,8 +1214,7 @@ int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) dst = simple_strtoul(argv[2], NULL, 16); break; default: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } return !!gunzip((void *) dst, dst_len, (void *) src, &src_len); diff --git a/common/cmd_mfsl.c b/common/cmd_mfsl.c index eeef2cd..00180b0 100644 --- a/common/cmd_mfsl.c +++ b/common/cmd_mfsl.c @@ -37,17 +37,14 @@ int do_frd (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) unsigned int num; unsigned int blocking; - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); 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"); - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } switch (fslnum) { @@ -195,18 +192,14 @@ int do_fwr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) unsigned int num; unsigned int blocking; - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); 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) { - cmd_usage(cmdtp); - return 1; - } + if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) + return cmd_usage(cmdtp); switch (fslnum) { #if (XILINX_FSL_NUMBER > 0) @@ -353,10 +346,9 @@ int do_rspr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) unsigned int reg = 0; unsigned int val = 0; - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); + reg = (unsigned int)simple_strtoul (argv[1], NULL, 16); val = (unsigned int)simple_strtoul (argv[2], NULL, 16); switch (reg) { diff --git a/common/cmd_mii.c b/common/cmd_mii.c index 1619a25..bb94186 100644 --- a/common/cmd_mii.c +++ b/common/cmd_mii.c @@ -301,10 +301,8 @@ int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) int rcode = 0; char *devname; - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); #if defined(CONFIG_MII_INIT) mii_init (); @@ -431,8 +429,7 @@ int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) else miiphy_set_current_dev (argv[2]); } else { - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } /* diff --git a/common/cmd_misc.c b/common/cmd_misc.c index 8439da2..061b1bb 100644 --- a/common/cmd_misc.c +++ b/common/cmd_misc.c @@ -32,17 +32,15 @@ int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ulong start = get_timer(0); ulong delay; - if (argc != 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc != 2) + return cmd_usage(cmdtp); delay = simple_strtoul(argv[1], NULL, 10) * CONFIG_SYS_HZ; while (get_timer(start) < delay) { - if (ctrlc ()) { + if (ctrlc ()) return (-1); - } + udelay (100); } diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c index 698157f..e5f5e94 100644 --- a/common/cmd_mmc.c +++ b/common/cmd_mmc.c @@ -32,10 +32,8 @@ int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { int dev; - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); if (strcmp(argv[1], "init") == 0) { if (argc == 2) { @@ -46,8 +44,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 { - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } if (mmc_legacy_init(dev) != 0) { @@ -72,14 +69,12 @@ int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #endif curr_device = dev; } else { - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } printf("mmc%d is current device\n", curr_device); } else { - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } return 0; diff --git a/common/cmd_mp.c b/common/cmd_mp.c index 4d7b871..f19bf41 100644 --- a/common/cmd_mp.c +++ b/common/cmd_mp.c @@ -28,10 +28,8 @@ cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { unsigned long cpuid; - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); cpuid = simple_strtoul(argv[1], NULL, 10); if (cpuid >= cpu_numcores()) { @@ -42,29 +40,24 @@ cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (argc == 3) { - if (strncmp(argv[2], "reset", 5) == 0) { + if (strncmp(argv[2], "reset", 5) == 0) cpu_reset(cpuid); - } else if (strncmp(argv[2], "status", 6) == 0) { + else if (strncmp(argv[2], "status", 6) == 0) cpu_status(cpuid); - } else if (strncmp(argv[2], "disable", 7) == 0) { + else if (strncmp(argv[2], "disable", 7) == 0) return cpu_disable(cpuid); - } else { - cmd_usage(cmdtp); - return 1; - } + else + return cmd_usage(cmdtp); + return 0; } /* 4 or greater, make sure its release */ - if (strncmp(argv[2], "release", 7) != 0) { - cmd_usage(cmdtp); - return 1; - } + if (strncmp(argv[2], "release", 7) != 0) + return cmd_usage(cmdtp); - if (cpu_release(cpuid, argc - 3, argv + 3)) { - cmd_usage(cmdtp); - return 1; - } + if (cpu_release(cpuid, argc - 3, argv + 3)) + return cmd_usage(cmdtp); return 0; } diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c index 447486b..ceec5a9 100644 --- a/common/cmd_mtdparts.c +++ b/common/cmd_mtdparts.c @@ -1845,8 +1845,7 @@ int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return delete_partition(argv[2]); } - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } /***************************************************/ diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 84b6272..0f47a25 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -275,8 +275,7 @@ int do_nand_env_oob(cmd_tbl_t *cmdtp, nand_info_t *nand, return ret; usage: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } #endif @@ -577,8 +576,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) #endif usage: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } U_BOOT_CMD(nand, CONFIG_SYS_MAXARGS, 1, do_nand, @@ -759,9 +757,8 @@ int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) #if defined(CONFIG_CMD_MTDPARTS) usage: #endif - cmd_usage(cmdtp); show_boot_progress(-53); - return 1; + return cmd_usage(cmdtp); } show_boot_progress(53); diff --git a/common/cmd_net.c b/common/cmd_net.c index 3cdb07f..3ffb9df 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -186,9 +186,9 @@ netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char * const argv[]) break; - default: cmd_usage(cmdtp); + default: show_boot_progress (-80); - return 1; + return cmd_usage(cmdtp); } show_boot_progress (80); @@ -236,10 +236,8 @@ int do_ping (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return -1; NetPingIP = string_to_ip(argv[1]); - if (NetPingIP == 0) { - cmd_usage(cmdtp); - return -1; - } + if (NetPingIP == 0) + return cmd_usage(cmdtp); if (NetLoop(PING) < 0) { printf("ping failed; host %s is not alive\n", argv[1]); @@ -342,10 +340,8 @@ U_BOOT_CMD( #if defined(CONFIG_CMD_DNS) int do_dns(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - if (argc == 1) { - cmd_usage(cmdtp); - return -1; - } + if (argc == 1) + return cmd_usage(cmdtp); /* * We should check for a valid hostname: diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 13325bc..1198954 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -407,10 +407,8 @@ void forceenv (char *varname, char *varvalue) int do_setenv (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); return _do_setenv (flag, argc, argv); } @@ -433,15 +431,13 @@ int do_askenv ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) local_args[2] = NULL; local_args[3] = NULL; - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); + /* Check the syntax */ switch (argc) { case 1: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); case 2: /* askenv envname */ sprintf (message, "Please enter '%s':", argv[1]); @@ -503,10 +499,8 @@ int do_editenv(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) char *init_val; int len; - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); /* Set read buffer to initial value or empty sting */ init_val = getenv(argv[1]); diff --git a/common/cmd_onenand.c b/common/cmd_onenand.c index a3e46a3..83d967b 100644 --- a/common/cmd_onenand.c +++ b/common/cmd_onenand.c @@ -361,10 +361,7 @@ static int do_onenand_read(cmd_tbl_t * cmdtp, int flag, int argc, char * const a size_t retlen = 0; if (argc < 3) - { - cmd_usage(cmdtp); - return 1; - } + return cmd_usage(cmdtp); s = strchr(argv[0], '.'); if ((s != NULL) && (!strcmp(s, ".oob"))) @@ -391,10 +388,7 @@ static int do_onenand_write(cmd_tbl_t * cmdtp, int flag, int argc, char * const size_t retlen = 0; if (argc < 3) - { - cmd_usage(cmdtp); - return 1; - } + return cmd_usage(cmdtp); addr = (ulong)simple_strtoul(argv[1], NULL, 16); @@ -477,10 +471,7 @@ static int do_onenand_dump(cmd_tbl_t * cmdtp, int flag, int argc, char * const a char *s; if (argc < 2) - { - cmd_usage(cmdtp); - return 1; - } + return cmd_usage(cmdtp); s = strchr(argv[0], '.'); ofs = (int)simple_strtoul(argv[1], NULL, 16); @@ -502,10 +493,7 @@ static int do_onenand_markbad(cmd_tbl_t * cmdtp, int flag, int argc, char * cons argv += 2; if (argc <= 0) - { - cmd_usage(cmdtp); - return 1; - } + return cmd_usage(cmdtp); while (argc > 0) { addr = simple_strtoul(*argv, NULL, 16); @@ -549,12 +537,10 @@ static int do_onenand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[] c = find_cmd_tbl(argv[0], &cmd_onenand_sub[0], ARRAY_SIZE(cmd_onenand_sub)); - if (c) { - return c->cmd(cmdtp, flag, argc, argv); - } else { - cmd_usage(cmdtp); - return 1; - } + if (c) + return c->cmd(cmdtp, flag, argc, argv); + else + return cmd_usage(cmdtp); } U_BOOT_CMD( diff --git a/common/cmd_otp.c b/common/cmd_otp.c index a8c73b5..43f7c69 100644 --- a/common/cmd_otp.c +++ b/common/cmd_otp.c @@ -88,8 +88,7 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (argc < 4) { usage: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } prompt_user = false; diff --git a/common/cmd_pci.c b/common/cmd_pci.c index 358ca60..4bde059 100644 --- a/common/cmd_pci.c +++ b/common/cmd_pci.c @@ -534,8 +534,7 @@ int do_pci (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; usage: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } /***************************************************/ diff --git a/common/cmd_portio.c b/common/cmd_portio.c index 92d61d2..4f2f499 100644 --- a/common/cmd_portio.c +++ b/common/cmd_portio.c @@ -43,13 +43,12 @@ int do_portio_out (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) uint size = out_last_size; uint value = out_last_value; - if (argc != 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc != 3) + return cmd_usage(cmdtp); if ((flag & CMD_FLAG_REPEAT) == 0) { - /* New command specified. Check for a size specification. + /* + * New command specified. Check for a size specification. * Defaults to long if no or incorrect specification. */ size = cmd_get_data_size (argv[0], 1); @@ -102,13 +101,12 @@ int do_portio_in (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) uint addr = in_last_addr; uint size = in_last_size; - if (argc != 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc != 2) + return cmd_usage(cmdtp); if ((flag & CMD_FLAG_REPEAT) == 0) { - /* New command specified. Check for a size specification. + /* + * New command specified. Check for a size specification. * Defaults to long if no or incorrect specification. */ size = cmd_get_data_size (argv[0], 1); diff --git a/common/cmd_reiser.c b/common/cmd_reiser.c index 2133a1f..ced1d40 100644 --- a/common/cmd_reiser.c +++ b/common/cmd_reiser.c @@ -56,10 +56,9 @@ int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) block_dev_desc_t *dev_desc=NULL; int part_length; - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); + dev = (int)simple_strtoul (argv[2], &ep, 16); dev_desc = get_dev(argv[1],dev); @@ -150,8 +149,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) break; default: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } if (!filename) { diff --git a/common/cmd_sata.c b/common/cmd_sata.c index 7be58e5..7efa859 100644 --- a/common/cmd_sata.c +++ b/common/cmd_sata.c @@ -77,8 +77,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) switch (argc) { case 0: case 1: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); case 2: if (strncmp(argv[1],"inf", 3) == 0) { int i; @@ -115,8 +114,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } return rc; } - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); case 3: if (strncmp(argv[1], "dev", 3) == 0) { int dev = (int)simple_strtoul(argv[2], NULL, 10); @@ -147,8 +145,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } return rc; } - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); default: /* at least 4 args */ if (strcmp(argv[1], "read") == 0) { @@ -184,8 +181,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 { - cmd_usage(cmdtp); - rc = 1; + return cmd_usage(cmdtp); } return rc; diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c index 5b2df28..6b937f9 100644 --- a/common/cmd_scsi.c +++ b/common/cmd_scsi.c @@ -229,8 +229,7 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) boot_device = argv[2]; break; default: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } if (!boot_device) { @@ -346,7 +345,8 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { switch (argc) { case 0: - case 1: cmd_usage(cmdtp); return 1; + case 1: return cmd_usage(cmdtp); + case 2: if (strncmp(argv[1],"res",3) == 0) { printf("\nReset SCSI\n"); @@ -392,8 +392,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) printf("\nno SCSI devices available\n"); return 1; } - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); case 3: if (strncmp(argv[1],"dev",3) == 0) { int dev = (int)simple_strtoul(argv[2], NULL, 10); @@ -421,8 +420,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } return 1; } - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); default: /* at least 4 args */ if (strcmp(argv[1],"read") == 0) { @@ -437,8 +435,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; } } /* switch */ - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } /**************************************************************************************** diff --git a/common/cmd_setexpr.c b/common/cmd_setexpr.c index b3e489f..1ff1232 100644 --- a/common/cmd_setexpr.c +++ b/common/cmd_setexpr.c @@ -57,10 +57,8 @@ int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int w; /* Validate arguments */ - if ((argc != 5) || (strlen(argv[3]) != 1)) { - cmd_usage(cmdtp); - return 1; - } + if ((argc != 5) || (strlen(argv[3]) != 1)) + return cmd_usage(cmdtp); w = cmd_get_data_size(argv[0], 4); diff --git a/common/cmd_sf.c b/common/cmd_sf.c index 4826e9f..6e7be81 100644 --- a/common/cmd_sf.c +++ b/common/cmd_sf.c @@ -177,8 +177,7 @@ static int do_spi_flash(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[ return do_spi_flash_erase(argc - 1, argv + 1); usage: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } U_BOOT_CMD( diff --git a/common/cmd_strings.c b/common/cmd_strings.c index bbbb6b4..144a6c1 100644 --- a/common/cmd_strings.c +++ b/common/cmd_strings.c @@ -14,10 +14,8 @@ static char *start_addr, *last_addr; int do_strings(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - if (argc == 1) { - cmd_usage(cmdtp); - return 1; - } + if (argc == 1) + return cmd_usage(cmdtp); if ((flag & CMD_FLAG_REPEAT) == 0) { start_addr = (char *)simple_strtoul(argv[1], NULL, 16); diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c index 2faf8d8..77ca0a5 100644 --- a/common/cmd_ubi.c +++ b/common/cmd_ubi.c @@ -442,10 +442,8 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) ulong addr = 0; int err = 0; - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); if (mtdparts_init() != 0) { printf("Error initializing mtdparts!\n"); @@ -471,10 +469,8 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) return 0; } - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); /* todo: get dev number for NAND... */ ubi_dev.nr = 0; diff --git a/common/cmd_ubifs.c b/common/cmd_ubifs.c index 9017041..2cab793 100644 --- a/common/cmd_ubifs.c +++ b/common/cmd_ubifs.c @@ -47,10 +47,9 @@ int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) char *vol_name; int ret; - if (argc != 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc != 2) + return cmd_usage(cmdtp); + vol_name = argv[1]; debug("Using volume %s\n", vol_name); @@ -102,25 +101,19 @@ int do_ubifs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return -1; } - if (argc < 3) { - cmd_usage(cmdtp); - return -1; - } + if (argc < 3) + return cmd_usage(cmdtp); addr = simple_strtoul(argv[1], &endp, 16); - if (endp == argv[1]) { - cmd_usage(cmdtp); - return 1; - } + if (endp == argv[1]) + return cmd_usage(cmdtp); filename = argv[2]; if (argc == 4) { size = simple_strtoul(argv[3], &endp, 16); - if (endp == argv[3]) { - cmd_usage(cmdtp); - return 1; - } + if (endp == argv[3]) + return cmd_usage(cmdtp); } debug("Loading file '%s' to address 0x%08x (size %d)\n", filename, addr, size); diff --git a/common/cmd_usb.c b/common/cmd_usb.c index 73d74ac..dc63f24 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -376,8 +376,7 @@ int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) boot_device = argv[2]; break; default: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } if (!boot_device) { @@ -516,10 +515,8 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) block_dev_desc_t *stor_dev; #endif - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); if ((strncmp(argv[1], "reset", 5) == 0) || (strncmp(argv[1], "start", 5) == 0)) { @@ -699,8 +696,7 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; } #endif /* CONFIG_USB_STORAGE */ - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } #ifdef CONFIG_USB_STORAGE diff --git a/common/cmd_vfd.c b/common/cmd_vfd.c index 1429d31..18c14d1 100644 --- a/common/cmd_vfd.c +++ b/common/cmd_vfd.c @@ -49,10 +49,8 @@ int do_vfd (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { ulong bitmap; - if (argc != 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc != 2) + return cmd_usage(cmdtp); if (argv[1][0] == '/') { /* select bitmap by number */ bitmap = simple_strtoul(argv[1]+1, NULL, 10); diff --git a/common/command.c b/common/command.c index a1fc592..30a9801 100644 --- a/common/command.c +++ b/common/command.c @@ -153,7 +153,7 @@ int cmd_usage(cmd_tbl_t *cmdtp) puts (cmdtp->help); putc ('\n'); #endif /* CONFIG_SYS_LONGHELP */ - return 0; + return 1; } #ifdef CONFIG_AUTO_COMPLETE diff --git a/common/hush.c b/common/hush.c index 8a74d22..4dd9513 100644 --- a/common/hush.c +++ b/common/hush.c @@ -1694,10 +1694,8 @@ static int run_pipe_real(struct pipe *pi) } #endif /* found - check max args */ - if ((child->argc - i) > cmdtp->maxargs) { - cmd_usage(cmdtp); - return -1; - } + if ((child->argc - i) > cmdtp->maxargs) + return cmd_usage(cmdtp); #endif child->argv+=i; /* XXX horrible hack */ #ifndef __U_BOOT__ diff --git a/common/main.c b/common/main.c index 20090ee..54ef79e 100644 --- a/common/main.c +++ b/common/main.c @@ -1418,10 +1418,8 @@ int do_run (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) { int i; - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); for (i=1; i<argc; ++i) { char *arg; |