Commit 47e26b1b authored by Wolfgang Denk's avatar Wolfgang Denk

cmd_usage(): simplify return code handling

Lots of code use this construct:

	cmd_usage(cmdtp);
	return 1;

Change cmd_usage() let it return 1 - then we can replace all these
ocurrances by

	return cmd_usage(cmdtp);

This fixes a few places with incorrect return code handling, too.
Signed-off-by: default avatarWolfgang Denk <wd@denx.de>
parent debb6299
......@@ -111,10 +111,8 @@ int mpc5121diu_init_show_bmp(cmd_tbl_t *cmdtp,
{
unsigned int addr;
if (argc < 2) {
cmd_usage(cmdtp);
return 1;
}
if (argc < 2)
return cmd_usage(cmdtp);
if (!strncmp(argv[1], "init", 4)) {
#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
......
......@@ -71,10 +71,7 @@ void bedbug603e_do_break (cmd_tbl_t *cmdtp, int flag, int argc,
/* -------------------------------------------------- */
if (argc < 2)
{
cmd_usage(cmdtp);
return;
}
return cmd_usage(cmdtp);
/* Turn off a breakpoint */
......@@ -118,10 +115,7 @@ void bedbug603e_do_break (cmd_tbl_t *cmdtp, int flag, int argc,
if(!(( isdigit( argv[ 1 ][ 0 ] )) ||
(( argv[ 1 ][ 0 ] >= 'a' ) && ( argv[ 1 ][ 0 ] <= 'f' )) ||
(( argv[ 1 ][ 0 ] >= 'A' ) && ( argv[ 1 ][ 0 ] <= 'F' ))))
{
cmd_usage(cmdtp);
return;
}
return cmd_usage(cmdtp);
addr = simple_strtoul( argv[ 1 ], NULL, 16 );
......
......@@ -118,10 +118,8 @@ int do_ecc(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
writeback[0] = 0x01234567UL;
writeback[1] = 0x89abcdefUL;
if (argc > 4) {
cmd_usage(cmdtp);
return 1;
}
if (argc > 4)
return cmd_usage(cmdtp);
if (argc == 2) {
if (strcmp(argv[1], "status") == 0) {
......@@ -350,8 +348,7 @@ int do_ecc(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
return 0;
}
}
cmd_usage(cmdtp);
return 1;
return cmd_usage(cmdtp);
}
U_BOOT_CMD(ecc, 4, 0, do_ecc,
......
......@@ -70,10 +70,7 @@ void bedbug860_do_break (cmd_tbl_t *cmdtp, int flag, int argc,
/* -------------------------------------------------- */
if (argc < 2)
{
cmd_usage(cmdtp);
return;
}
return cmd_usage(cmdtp);
/* Turn off a breakpoint */
......@@ -121,10 +118,7 @@ void bedbug860_do_break (cmd_tbl_t *cmdtp, int flag, int argc,
/* Set a breakpoint at the address */
if( !isdigit( argv[ 1 ][ 0 ]))
{
cmd_usage(cmdtp);
return;
}
return cmd_usage(cmdtp);
addr = simple_strtoul( argv[ 1 ], NULL, 16 ) & 0xfffffffc;
......
......@@ -44,10 +44,8 @@ static int do_bootstrap(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
u8 *buf;
int cpu_freq;
if (argc < 3) {
cmd_usage(cmdtp);
return 1;
}
if (argc < 3)
return cmd_usage(cmdtp);
cpu_freq = simple_strtol(argv[1], NULL, 10);
if (cpu_freq != 267) {
......
......@@ -223,8 +223,7 @@ int do_l2cache( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] )
l2cache_status() ? "ON" : "OFF");
return 0;
default:
cmd_usage(cmdtp);
return 1;
return cmd_usage(cmdtp);
}
return 0;
......
......@@ -182,14 +182,14 @@ do_pll_alter (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
char c = '\0';
pll_freq_t pll_freq;
if (argc < 2) {
cmd_usage(cmdtp);
goto ret;
}
for (pll_freq = PLL_ebc20; pll_freq < PLL_TOTAL; pll_freq++)
if (argc < 2)
return cmd_usage(cmdtp);
for (pll_freq = PLL_ebc20; pll_freq < PLL_TOTAL; pll_freq++) {
if (!strcmp(pll_name[pll_freq], argv[1]))
break;
}
switch (pll_freq) {
case PLL_ebc20:
......@@ -223,8 +223,7 @@ do_pll_alter (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
default:
printf("Invalid options\n\n");
cmd_usage(cmdtp);
goto ret;
return cmd_usage(cmdtp);
}
printf("PLL set to %s, "
......
......@@ -139,10 +139,9 @@ static int do_lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const arg
static int do_lcd_puts (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);
lcd_puts(argv[1]);
return 0;
......@@ -150,10 +149,9 @@ static int do_lcd_puts (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv
static int do_lcd_putc (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);
lcd_putc((char)argv[1][0]);
return 0;
......@@ -165,10 +163,8 @@ static int do_lcd_cur (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[
ulong dir;
char cur_addr;
if (argc < 3) {
cmd_usage(cmdtp);
return 1;
}
if (argc < 3)
return cmd_usage(cmdtp);
count = simple_strtoul(argv[1], NULL, 16);
if (count > 31) {
......
......@@ -101,16 +101,12 @@ static int do_led_ctl(cmd_tbl_t* cmd_tp, int flags, int argc, char * const argv[
{
int led_no;
if (argc != 3) {
cmd_usage(cmd_tp);
return -1;
}
if (argc != 3)
return cmd_usage(cmd_tp);
led_no = simple_strtoul(argv[1], NULL, 16);
if (led_no != 1 && led_no != 2) {
cmd_usage(cmd_tp);
return -1;
}
if (led_no != 1 && led_no != 2)
return cmd_usage(cmd_tp);
if (strcmp(argv[2],"off") == 0x0) {
if (led_no == 1)
......@@ -123,8 +119,7 @@ static int do_led_ctl(cmd_tbl_t* cmd_tp, int flags, int argc, char * const argv[
else
gpio_write_bit(31, 0);
} else {
cmd_usage(cmd_tp);
return -1;
return cmd_usage(cmd_tp);
}
return 0;
......
......@@ -166,19 +166,17 @@ static int do_lcd_clear(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv
}
static int do_lcd_puts(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);
lcd_puts(argv[1]);
return 0;
}
static int do_lcd_putc(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);
lcd_putc((char)argv[1][0]);
return 0;
}
......@@ -188,10 +186,8 @@ static int do_lcd_cur(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]
ulong dir;
char cur_addr;
if (argc < 3) {
cmd_usage(cmdtp);
return 1;
}
if (argc < 3)
return cmd_usage(cmdtp);
count = simple_strtoul(argv[1], NULL, 16);
if (count > 31) {
......
......@@ -58,10 +58,8 @@ static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag, int flag,
char plbClock[4];
char pcixClock[4];
if (argc < 3) {
cmd_usage(cmdtp);
return 1;
}
if (argc < 3)
return cmd_usage(cmdtp);
if (strcmp(argv[2], "prom0") == 0)
chip = IIC0_BOOTPROM_ADDR;
......
......@@ -290,12 +290,6 @@ void barcobcd_boot (void)
int barcobcd_boot_image (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
#if 0
if (argc > 1) {
cmd_usage(cmdtp);
return 1;
}
#endif
barcobcd_boot ();
return 0;
......
......@@ -75,10 +75,8 @@ static int do_mtc_led(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int err;
int i;
if (argc < 2) {
cmd_usage(cmdtp);
return -1;
}
if (argc < 2)
return cmd_usage(cmdtp);
memset(&pcmd, 0, sizeof(pcmd));
memset(&prx, 0, sizeof(prx));
......@@ -149,10 +147,8 @@ static int do_mtc_digout(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
int err;
uchar channel_mask = 0;
if (argc < 3) {
cmd_usage(cmdtp);
return -1;
}
if (argc < 3)
return cmd_usage(cmdtp);
if (strncmp(argv[1], "on", 2) == 0)
channel_mask |= 1;
......@@ -178,10 +174,8 @@ static int do_mtc_digin(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
int err;
uchar channel_num = 0;
if (argc < 2) {
cmd_usage(cmdtp);
return -1;
}
if (argc < 2)
return cmd_usage(cmdtp);
channel_num = simple_strtol(argv[1], NULL, 10);
if ((channel_num != 1) && (channel_num != 2)) {
......@@ -332,8 +326,7 @@ int cmd_mtc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return c->cmd(c, flag, argc, argv);
} else {
/* Unrecognized command */
cmd_usage(cmdtp);
return 1;
return cmd_usage(cmdtp);
}
return err;
......
......@@ -345,10 +345,8 @@ int do_esdbmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#ifdef CONFIG_VIDEO_SM501
char *str;
#endif
if (argc != 2) {
cmd_usage(cmdtp);
return 1;
}
if (argc != 2)
return cmd_usage(cmdtp);
addr = simple_strtoul(argv[1], NULL, 16);
......
......@@ -221,9 +221,7 @@ int do_pci9054 (cmd_tbl_t * cmdtp, int flag, int argc,
return 0;
}
cmd_usage(cmdtp);
return 1;
return cmd_usage(cmdtp);
}
U_BOOT_CMD(
......
......@@ -351,8 +351,7 @@ int do_mac(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
prog_eeprom();
break;
default:
cmd_usage(cmdtp);
break;
return cmd_usage(cmdtp);
}
return 0;
......@@ -388,8 +387,7 @@ int do_mac(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
break;
case 'h': /* help */
default:
cmd_usage(cmdtp);
break;
return cmd_usage(cmdtp);
}
return 0;
......
......@@ -115,10 +115,8 @@ int mpc8610diu_init_show_bmp(cmd_tbl_t *cmdtp,
{
unsigned int addr;
if (argc < 2) {
cmd_usage(cmdtp);
return 1;
}
if (argc < 2)
return cmd_usage(cmdtp);
if (!strncmp(argv[1],"init",4)) {
#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
......
......@@ -272,8 +272,7 @@ do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
break;
}
cmd_usage(cmdtp);
return 1;
return cmd_usage(cmdtp);
}
U_BOOT_CMD(
fpga, 6, 1, do_fpga,
......@@ -324,8 +323,7 @@ do_eecl (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
/* fall through ... */
default:
cmd_usage(cmdtp);
return 1;
return cmd_usage(cmdtp);
}
memset (data, 0, HYMOD_EEPROM_SIZE);
......
......@@ -168,8 +168,7 @@ static int do_inkadiag_io(cmd_tbl_t *cmdtp, int flag, int argc,
printf("exit code: 0x%X\n", val);
return 0;
default:
cmd_usage(cmdtp);
break;
return cmd_usage(cmdtp);
}
return -1;
......@@ -244,10 +243,8 @@ static int do_inkadiag_serial(cmd_tbl_t *cmdtp, int flag, int argc,
int combrd, baudrate, i, j, len;
int address;
if (argc < 5) {
cmd_usage(cmdtp);
return 1;
}
if (argc < 5)
return cmd_usage(cmdtp);
argc--;
argv++;
......@@ -394,10 +391,8 @@ static int do_inkadiag_buzzer(cmd_tbl_t *cmdtp, int flag, int argc,
unsigned int period, freq;
int prev, i;
if (argc != 3) {
cmd_usage(cmdtp);
return 1;
}
if (argc != 3)
return cmd_usage(cmdtp);
argc--;
argv++;
......@@ -474,8 +469,7 @@ static int do_inkadiag(cmd_tbl_t *cmdtp, int flag, int argc,
return c->cmd(c, flag, argc, argv);
} else {
/* Unrecognized command */
cmd_usage(cmdtp);
return 1;
return cmd_usage(cmdtp);
}
}
......
......@@ -186,10 +186,8 @@ int board_init(void)
int do_spi_toggle(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
u32 tmp;
if (argc < 2) {
cmd_usage(cmdtp);
return 1;
}
if (argc < 2)
return cmd_usage(cmdtp);
if ((strcmp(argv[1], "off") == 0)) {
printf("SPI FLASH disabled, NAND enabled\n");
......@@ -214,8 +212,7 @@ int do_spi_toggle(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
tmp = readl(KW_GPIO0_BASE);
writel(tmp & (~FLASH_GPIO_PIN) , KW_GPIO0_BASE);
} else {
cmd_usage(cmdtp);
return 1;
return cmd_usage(cmdtp);
}
return 0;
......
......@@ -845,8 +845,7 @@ int do_pic (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
default:
break;
}
cmd_usage(cmdtp);
return 1;
return cmd_usage(cmdtp);
}
U_BOOT_CMD(
pic, 4, 1, do_pic,
......@@ -975,8 +974,7 @@ int do_lsb (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
default:
break;
}
cmd_usage(cmdtp);
return 1;
return cmd_usage(cmdtp);
}
U_BOOT_CMD(
......
......@@ -306,20 +306,15 @@ void hw_watchdog_reset(void)
int do_eeprom_wp(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);
if ((strcmp(argv[1], "on") == 0)) {
if ((strcmp(argv[1], "on") == 0))
gpio_write_bit(CONFIG_SYS_GPIO_EEPROM_EXT_WP, 1);
} else if ((strcmp(argv[1], "off") == 0)) {
else if ((strcmp(argv[1], "off") == 0))
gpio_write_bit(CONFIG_SYS_GPIO_EEPROM_EXT_WP, 0);
} else {
cmd_usage(cmdtp);
return 1;
}
else
return cmd_usage(cmdtp);
return 0;
}
......
......@@ -528,8 +528,7 @@ int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 0;
}
#endif
cmd_usage(cmdtp);
return 1;
return cmd_usage(cmdtp);
}
......
......@@ -232,8 +232,7 @@ int do_wd (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
default:
break;
}
cmd_usage(cmdtp);
return 1;
return cmd_usage(cmdtp);
}
U_BOOT_CMD(
......
......@@ -616,9 +616,8 @@ int do_sha1 (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int rcode = -1;
if (argc < 2) {
usage:
cmd_usage(cmdtp);
return 1;
usage:
return cmd_usage(cmdtp);
}
if (argc >= 3) {
......
......@@ -635,10 +635,8 @@ static int set_lcd_brightness(char *brightness)
static int cmd_lcd_brightness(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 set_lcd_brightness(argv[1]);
}
......
......@@ -36,20 +36,20 @@ extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
/*
* Command led: controls the various LEDs 0..11 on the PN62 card.
*/
int do_led (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int do_led(cmd_tbl_t * cmdtp, int flag, int argc, char *const argv[])
{
unsigned int number, function;
unsigned int number, function;
if (argc != 3) {
cmd_usage(cmdtp);
return 1;
}
number = simple_strtoul(argv[1], NULL, 10);
if (number > PN62_LED_MAX)
return 1;
function = simple_strtoul(argv[2], NULL, 16);
set_led (number, function);
return 0;
if (argc != 3)
return cmd_usage(cmdtp);
number = simple_strtoul(argv[1], NULL, 10);
if (number > PN62_LED_MAX)
return 1;
function = simple_strtoul(argv[2], NULL, 16);
set_led(number, function);
return 0;
}
U_BOOT_CMD(
led , 3, 1, do_led,
......@@ -83,8 +83,7 @@ int do_loadpci (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);
}
printf ("## Ready for image download ...\n");
......
......@@ -214,10 +214,8 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
ulong addr;
if (argc < 2) {
cmd_usage(cmdtp);
return 1;
}
if (argc < 2)
return cmd_usage(cmdtp);
addr = simple_strtoul(argv[1], NULL, 16);
......
......@@ -304,10 +304,8 @@ int do_set_mac(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
unsigned char mac[6];
char *s, *e;
if (argc != 2) {
cmd_usage(cmdtp);
return 1;
}
if (argc != 2)
return cmd_usage(cmdtp);
s = argv[1];
......@@ -330,10 +328,8 @@ U_BOOT_CMD(
int do_print_mac(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);
mac_read();
......
......@@ -112,10 +112,8 @@ int do_hw_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
char *cmd;
if (argc != 2) {
cmd_usage(cmdtp);
return 1;
}
if (argc != 2)
return cmd_usage(cmdtp);
cmd = argv[1];
switch (cmd[0]) {
......@@ -150,8 +148,7 @@ int do_hw_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
test_net();
break;
default:
cmd_usage(cmdtp);
return 1;
return cmd_usage(cmdtp);
}
return 0;
......
......@@ -286,8 +286,7 @@ int do_fpga (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 0;
failure:
cmd_usage(cmdtp);
return 1;
return cmd_usage(cmdtp);
}
U_BOOT_CMD(
......
......@@ -399,8 +399,7 @@ int do_puma (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
default:
break;
}
cmd_usage(cmdtp);
return 1;
return cmd_usage(cmdtp);
}
U_BOOT_CMD (puma, 4, 1, do_puma,
......
......@@ -215,10 +215,8 @@ int do_chip_config(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
char *s, *e;
char i2c_mac[20];
if ((argc > 3) || (argc < 2)) {
cmd_usage(cmdtp);
return 1;
}
if ((argc > 3) || (argc < 2))
return cmd_usage(cmdtp);