summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2010-08-03 22:45:13 +0200
committerWolfgang Denk <wd@denx.de>2010-08-03 22:45:13 +0200
commitac956293befb265b8958654d08c4ad52e605d46e (patch)
tree4fbfc08b1be8616bc5ee2032b53996ac0c5d64d8 /common
parente9aecdec153ae166739858e6a570432449b979f7 (diff)
parent7385c28e9b5f7d47e6a8f1ad9800e6e70af714e2 (diff)
downloadu-boot-imx-ac956293befb265b8958654d08c4ad52e605d46e.zip
u-boot-imx-ac956293befb265b8958654d08c4ad52e605d46e.tar.gz
u-boot-imx-ac956293befb265b8958654d08c4ad52e605d46e.tar.bz2
Merge branch 'master' of /home/wd/git/u-boot/master
Diffstat (limited to 'common')
-rw-r--r--common/cmd_bedbug.c12
-rw-r--r--common/cmd_bmp.c14
-rw-r--r--common/cmd_boot.c6
-rw-r--r--common/cmd_bootm.c11
-rw-r--r--common/cmd_cache.c14
-rw-r--r--common/cmd_dcr.c24
-rw-r--r--common/cmd_df.c3
-rw-r--r--common/cmd_eeprom.c3
-rw-r--r--common/cmd_ext2.c10
-rw-r--r--common/cmd_fat.c210
-rw-r--r--common/cmd_fdc.c3
-rw-r--r--common/cmd_fdos.c3
-rw-r--r--common/cmd_fdt.c76
-rw-r--r--common/cmd_flash.c47
-rw-r--r--common/cmd_fpga.c12
-rw-r--r--common/cmd_i2c.c87
-rw-r--r--common/cmd_ide.c20
-rw-r--r--common/cmd_irq.c11
-rw-r--r--common/cmd_itest.c6
-rw-r--r--common/cmd_load.c2
-rw-r--r--common/cmd_log.c6
-rw-r--r--common/cmd_mem.c80
-rw-r--r--common/cmd_mfsl.c28
-rw-r--r--common/cmd_mii.c9
-rw-r--r--common/cmd_misc.c10
-rw-r--r--common/cmd_mmc.c15
-rw-r--r--common/cmd_mp.c31
-rw-r--r--common/cmd_mtdparts.c3
-rw-r--r--common/cmd_nand.c9
-rw-r--r--common/cmd_net.c16
-rw-r--r--common/cmd_nvedit.c22
-rw-r--r--common/cmd_onenand.c30
-rw-r--r--common/cmd_otp.c3
-rw-r--r--common/cmd_pci.c3
-rw-r--r--common/cmd_portio.c18
-rw-r--r--common/cmd_reiser.c10
-rw-r--r--common/cmd_sata.c12
-rw-r--r--common/cmd_scsi.c15
-rw-r--r--common/cmd_setexpr.c6
-rw-r--r--common/cmd_sf.c3
-rw-r--r--common/cmd_strings.c6
-rw-r--r--common/cmd_ubi.c12
-rw-r--r--common/cmd_ubifs.c25
-rw-r--r--common/cmd_usb.c12
-rw-r--r--common/cmd_vfd.c6
-rw-r--r--common/command.c2
-rw-r--r--common/env_common.c2
-rw-r--r--common/fdt_support.c291
-rw-r--r--common/hush.c6
-rw-r--r--common/main.c6
-rw-r--r--common/usb_storage.c9
51 files changed, 605 insertions, 675 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_fat.c b/common/cmd_fat.c
index ede7308..0220494 100644
--- a/common/cmd_fat.c
+++ b/common/cmd_fat.c
@@ -45,39 +45,43 @@ int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
char *ep;
if (argc < 5) {
- printf ("usage: fatload <interface> <dev[:part]> <addr> <filename> [bytes]\n");
+ printf( "usage: fatload <interface> <dev[:part]> "
+ "<addr> <filename> [bytes]\n");
return 1;
}
- dev = (int)simple_strtoul (argv[2], &ep, 16);
- dev_desc=get_dev(argv[1],dev);
- if (dev_desc==NULL) {
- puts ("\n** Invalid boot device **\n");
+
+ dev = (int)simple_strtoul(argv[2], &ep, 16);
+ dev_desc = get_dev(argv[1],dev);
+ if (dev_desc == NULL) {
+ puts("\n** Invalid boot device **\n");
return 1;
}
if (*ep) {
if (*ep != ':') {
- puts ("\n** Invalid boot device, use `dev[:part]' **\n");
+ puts("\n** Invalid boot device, use `dev[:part]' **\n");
return 1;
}
part = (int)simple_strtoul(++ep, NULL, 16);
}
if (fat_register_device(dev_desc,part)!=0) {
- printf ("\n** Unable to use %s %d:%d for fatload **\n",argv[1],dev,part);
+ printf("\n** Unable to use %s %d:%d for fatload **\n",
+ argv[1], dev, part);
return 1;
}
- offset = simple_strtoul (argv[3], NULL, 16);
+ offset = simple_strtoul(argv[3], NULL, 16);
if (argc == 6)
- count = simple_strtoul (argv[5], NULL, 16);
+ count = simple_strtoul(argv[5], NULL, 16);
else
count = 0;
- size = file_fat_read (argv[4], (unsigned char *) offset, count);
+ size = file_fat_read(argv[4], (unsigned char *)offset, count);
if(size==-1) {
- printf("\n** Unable to read \"%s\" from %s %d:%d **\n",argv[4],argv[1],dev,part);
+ printf("\n** Unable to read \"%s\" from %s %d:%d **\n",
+ argv[4], argv[1], dev, part);
return 1;
}
- printf ("\n%ld bytes read\n", size);
+ printf("\n%ld bytes read\n", size);
sprintf(buf, "%lX", size);
setenv("filesize", buf);
@@ -104,34 +108,35 @@ int do_fat_ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
block_dev_desc_t *dev_desc=NULL;
if (argc < 3) {
- printf ("usage: fatls <interface> <dev[:part]> [directory]\n");
- return (0);
+ printf("usage: fatls <interface> <dev[:part]> [directory]\n");
+ return 0;
}
- dev = (int)simple_strtoul (argv[2], &ep, 16);
- dev_desc=get_dev(argv[1],dev);
- if (dev_desc==NULL) {
- puts ("\n** Invalid boot device **\n");
+ dev = (int)simple_strtoul(argv[2], &ep, 16);
+ dev_desc = get_dev(argv[1],dev);
+ if (dev_desc == NULL) {
+ puts("\n** Invalid boot device **\n");
return 1;
}
if (*ep) {
if (*ep != ':') {
- puts ("\n** Invalid boot device, use `dev[:part]' **\n");
+ puts("\n** Invalid boot device, use `dev[:part]' **\n");
return 1;
}
part = (int)simple_strtoul(++ep, NULL, 16);
}
if (fat_register_device(dev_desc,part)!=0) {
- printf ("\n** Unable to use %s %d:%d for fatls **\n",argv[1],dev,part);
+ printf("\n** Unable to use %s %d:%d for fatls **\n",
+ argv[1], dev, part);
return 1;
}
if (argc == 4)
- ret = file_fat_ls (argv[3]);
+ ret = file_fat_ls(argv[3]);
else
- ret = file_fat_ls (filename);
+ ret = file_fat_ls(filename);
if(ret!=0)
printf("No Fat FS detected\n");
- return (ret);
+ return ret;
}
U_BOOT_CMD(
@@ -149,27 +154,28 @@ int do_fat_fsinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
block_dev_desc_t *dev_desc=NULL;
if (argc < 2) {
- printf ("usage: fatinfo <interface> <dev[:part]>\n");
- return (0);
+ printf("usage: fatinfo <interface> <dev[:part]>\n");
+ return 0;
}
- dev = (int)simple_strtoul (argv[2], &ep, 16);
- dev_desc=get_dev(argv[1],dev);
- if (dev_desc==NULL) {
- puts ("\n** Invalid boot device **\n");
+ dev = (int)simple_strtoul(argv[2], &ep, 16);
+ dev_desc = get_dev(argv[1],dev);
+ if (dev_desc == NULL) {
+ puts("\n** Invalid boot device **\n");
return 1;
}
if (*ep) {
if (*ep != ':') {
- puts ("\n** Invalid boot device, use `dev[:part]' **\n");
+ puts("\n** Invalid boot device, use `dev[:part]' **\n");
return 1;
}
part = (int)simple_strtoul(++ep, NULL, 16);
}
if (fat_register_device(dev_desc,part)!=0) {
- printf ("\n** Unable to use %s %d:%d for fatinfo **\n",argv[1],dev,part);
+ printf("\n** Unable to use %s %d:%d for fatinfo **\n",
+ argv[1], dev, part);
return 1;
}
- return (file_fat_detectfs ());
+ return file_fat_detectfs();
}
U_BOOT_CMD(
@@ -178,143 +184,3 @@ U_BOOT_CMD(
"<interface> <dev[:part]>\n"
" - print information about filesystem from 'dev' on 'interface'"
);
-
-#ifdef NOT_IMPLEMENTED_YET
-/* find first device whose first partition is a DOS filesystem */
-int find_fat_partition (void)
-{
- int i, j;
- block_dev_desc_t *dev_desc;
- unsigned char *part_table;
- unsigned char buffer[ATA_BLOCKSIZE];
-
- for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; i++) {
- dev_desc = ide_get_dev (i);
- if (!dev_desc) {
- debug ("couldn't get ide device!\n");
- return (-1);
- }
- if (dev_desc->part_type == PART_TYPE_DOS) {
- if (dev_desc->
- block_read (dev_desc->dev, 0, 1, (ulong *) buffer) != 1) {
- debug ("can't perform block_read!\n");
- return (-1);
- }
- part_table = &buffer[0x1be]; /* start with partition #4 */
- for (j = 0; j < 4; j++) {
- if ((part_table[4] == 1 || /* 12-bit FAT */
- part_table[4] == 4 || /* 16-bit FAT */
- part_table[4] == 6) && /* > 32Meg part */
- part_table[0] == 0x80) { /* bootable? */
- curr_dev = i;
- part_offset = part_table[11];
- part_offset <<= 8;
- part_offset |= part_table[10];
- part_offset <<= 8;
- part_offset |= part_table[9];
- part_offset <<= 8;
- part_offset |= part_table[8];
- debug ("found partition start at %ld\n", part_offset);
- return (0);
- }
- part_table += 16;
- }
- }
- }
-
- debug ("no valid devices found!\n");
- return (-1);
-}
-
-int
-do_fat_dump (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char * const argv[])
-{
- __u8 block[1024];
- int ret;
- int bknum;
-
- ret = 0;
-
- if (argc != 2) {
- printf ("needs an argument!\n");
- return (0);
- }
-
- bknum = simple_strtoul (argv[1], NULL, 10);
-
- if (disk_read (0, bknum, block) != 0) {
- printf ("Error: reading block\n");
- return -1;
- }
- printf ("FAT dump: %d\n", bknum);
- hexdump (512, block);
-
- return (ret);
-}
-
-int disk_read (__u32 startblock, __u32 getsize, __u8 *bufptr)
-{
- ulong tot;
- block_dev_desc_t *dev_desc;
-
- if (curr_dev < 0) {
- if (find_fat_partition () != 0)
- return (-1);
- }
-
- dev_desc = ide_get_dev (curr_dev);
- if (!dev_desc) {
- debug ("couldn't get ide device\n");
- return (-1);
- }
-
- tot = dev_desc->block_read (0, startblock + part_offset,
- getsize, (ulong *) bufptr);
-
- /* should we do this here?
- flush_cache ((ulong)buf, cnt*ide_dev_desc[device].blksz);
- */
-
- if (tot == getsize)
- return (0);
-
- debug ("unable to read from device!\n");
-
- return (-1);
-}
-
-
-static int isprint (unsigned char ch)
-{
- if (ch >= 32 && ch < 127)
- return (1);
-
- return (0);
-}
-
-
-void hexdump (int cnt, unsigned char *data)
-{
- int i;
- int run;
- int offset;
-
- offset = 0;
- while (cnt) {
- printf ("%04X : ", offset);
- if (cnt >= 16)
- run = 16;
- else
- run = cnt;
- cnt -= run;
- for (i = 0; i < run; i++)
- printf ("%02X ", (unsigned int) data[i]);
- printf (": ");
- for (i = 0; i < run; i++)
- printf ("%c", isprint (data[i]) ? data[i] : '.');
- printf ("\n");
- data = &data[16];
- offset += run;
- }
-}
-#endif /* NOT_IMPLEMENTED_YET */
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/env_common.c b/common/env_common.c
index 82e4936..460309b 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -227,7 +227,7 @@ void env_relocate (void)
#endif
if (gd->env_valid == 0) {
-#if defined(CONFIG_GTH) || defined(CONFIG_ENV_IS_NOWHERE) /* Environment not changable */
+#if defined(CONFIG_ENV_IS_NOWHERE) /* Environment not changable */
puts ("Using default environment\n\n");
#else
puts ("*** Warning - bad CRC, using default environment\n\n");
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 4d87135..718b635 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -2,6 +2,8 @@
* (C) Copyright 2007
* Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com
*
+ * Copyright 2010 Freescale Semiconductor, Inc.
+ *
* See file CREDITS for list of people who contributed to this
* project.
*
@@ -861,3 +863,292 @@ void fdt_del_node_and_alias(void *blob, const char *alias)
off = fdt_path_offset(blob, "/aliases");
fdt_delprop(blob, off, alias);
}
+
+/* Helper to read a big number; size is in cells (not bytes) */
+static inline u64 of_read_number(const __be32 *cell, int size)
+{
+ u64 r = 0;
+ while (size--)
+ r = (r << 32) | be32_to_cpu(*(cell++));
+ return r;
+}
+
+static int of_n_cells(const void *blob, int nodeoffset, const char *name)
+{
+ int np;
+ const int *ip;
+
+ do {
+ np = fdt_parent_offset(blob, nodeoffset);
+
+ if (np >= 0)
+ nodeoffset = np;
+ ip = (int *)fdt_getprop(blob, nodeoffset, name, NULL);
+ if (ip)
+ return be32_to_cpup(ip);
+ } while (np >= 0);
+
+ /* No #<NAME>-cells property for the root node */
+ return 1;
+}
+
+int of_n_addr_cells(const void *blob, int nodeoffset)
+{
+ return of_n_cells(blob, nodeoffset, "#address-cells");
+}
+
+int of_n_size_cells(const void *blob, int nodeoffset)
+{
+ return of_n_cells(blob, nodeoffset, "#size-cells");
+}
+
+#define PRu64 "%llx"
+
+/* Max address size we deal with */
+#define OF_MAX_ADDR_CELLS 4
+#define OF_BAD_ADDR ((u64)-1)
+#define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \
+ (ns) > 0)
+
+/* Debug utility */
+#ifdef DEBUG
+static void of_dump_addr(const char *s, const u32 *addr, int na)
+{
+ printf("%s", s);
+ while(na--)
+ printf(" %08x", *(addr++));
+ printf("\n");
+}
+#else
+static void of_dump_addr(const char *s, const u32 *addr, int na) { }
+#endif
+
+/* Callbacks for bus specific translators */
+struct of_bus {
+ const char *name;
+ const char *addresses;
+ void (*count_cells)(void *blob, int offset,
+ int *addrc, int *sizec);
+ u64 (*map)(u32 *addr, const u32 *range,
+ int na, int ns, int pna);
+ int (*translate)(u32 *addr, u64 offset, int na);
+};
+
+/* Default translator (generic bus) */
+static void of_bus_default_count_cells(void *blob, int offset,
+ int *addrc, int *sizec)
+{
+ if (addrc)
+ *addrc = of_n_addr_cells(blob, offset);
+ if (sizec)
+ *sizec = of_n_size_cells(blob, offset);
+}
+
+static u64 of_bus_default_map(u32 *addr, const u32 *range,
+ int na, int ns, int pna)
+{
+ u64 cp, s, da;
+
+ cp = of_read_number(range, na);
+ s = of_read_number(range + na + pna, ns);
+ da = of_read_number(addr, na);
+
+ debug("OF: default map, cp="PRu64", s="PRu64", da="PRu64"\n",
+ cp, s, da);
+
+ if (da < cp || da >= (cp + s))
+ return OF_BAD_ADDR;
+ return da - cp;
+}
+
+static int of_bus_default_translate(u32 *addr, u64 offset, int na)
+{
+ u64 a = of_read_number(addr, na);
+ memset(addr, 0, na * 4);
+ a += offset;
+ if (na > 1)
+ addr[na - 2] = a >> 32;
+ addr[na - 1] = a & 0xffffffffu;
+
+ return 0;
+}
+
+/* Array of bus specific translators */
+static struct of_bus of_busses[] = {
+ /* Default */
+ {
+ .name = "default",
+ .addresses = "reg",
+ .count_cells = of_bus_default_count_cells,
+ .map = of_bus_default_map,
+ .translate = of_bus_default_translate,
+ },
+};
+
+static int of_translate_one(void * blob, int parent, struct of_bus *bus,
+ struct of_bus *pbus, u32 *addr,
+ int na, int ns, int pna, const char *rprop)
+{
+ const u32 *ranges;
+ int rlen;
+ int rone;
+ u64 offset = OF_BAD_ADDR;
+
+ /* Normally, an absence of a "ranges" property means we are
+ * crossing a non-translatable boundary, and thus the addresses
+ * below the current not cannot be converted to CPU physical ones.
+ * Unfortunately, while this is very clear in the spec, it's not
+ * what Apple understood, and they do have things like /uni-n or
+ * /ht nodes with no "ranges" property and a lot of perfectly
+ * useable mapped devices below them. Thus we treat the absence of
+ * "ranges" as equivalent to an empty "ranges" property which means
+ * a 1:1 translation at that level. It's up to the caller not to try
+ * to translate addresses that aren't supposed to be translated in
+ * the first place. --BenH.
+ */
+ ranges = (u32 *)fdt_getprop(blob, parent, rprop, &rlen);
+ if (ranges == NULL || rlen == 0) {
+ offset = of_read_number(addr, na);
+ memset(addr, 0, pna * 4);
+ debug("OF: no ranges, 1:1 translation\n");
+ goto finish;
+ }
+
+ debug("OF: walking ranges...\n");
+
+ /* Now walk through the ranges */
+ rlen /= 4;
+ rone = na + pna + ns;
+ for (; rlen >= rone; rlen -= rone, ranges += rone) {
+ offset = bus->map(addr, ranges, na, ns, pna);
+ if (offset != OF_BAD_ADDR)
+ break;
+ }
+ if (offset == OF_BAD_ADDR) {
+ debug("OF: not found !\n");
+ return 1;
+ }
+ memcpy(addr, ranges + na, 4 * pna);
+
+ finish:
+ of_dump_addr("OF: parent translation for:", addr, pna);
+ debug("OF: with offset: "PRu64"\n", offset);
+
+ /* Translate it into parent bus space */
+ return pbus->translate(addr, offset, pna);
+}
+
+/*
+ * Translate an address from the device-tree into a CPU physical address,
+ * this walks up the tree and applies the various bus mappings on the
+ * way.
+ *
+ * Note: We consider that crossing any level with #size-cells == 0 to mean
+ * that translation is impossible (that is we are not dealing with a value
+ * that can be mapped to a cpu physical address). This is not really specified
+ * that way, but this is traditionally the way IBM at least do things
+ */
+u64 __of_translate_address(void *blob, int node_offset, const u32 *in_addr,
+ const char *rprop)
+{
+ int parent;
+ struct of_bus *bus, *pbus;
+ u32 addr[OF_MAX_ADDR_CELLS];
+ int na, ns, pna, pns;
+ u64 result = OF_BAD_ADDR;
+
+ debug("OF: ** translation for device %s **\n",
+ fdt_get_name(blob, node_offset, NULL));
+
+ /* Get parent & match bus type */
+ parent = fdt_parent_offset(blob, node_offset);
+ if (parent < 0)
+ goto bail;
+ bus = &of_busses[0];
+
+ /* Cound address cells & copy address locally */
+ bus->count_cells(blob, node_offset, &na, &ns);
+ if (!OF_CHECK_COUNTS(na, ns)) {
+ printf("%s: Bad cell count for %s\n", __FUNCTION__,
+ fdt_get_name(blob, node_offset, NULL));
+ goto bail;
+ }
+ memcpy(addr, in_addr, na * 4);
+
+ debug("OF: bus is %s (na=%d, ns=%d) on %s\n",
+ bus->name, na, ns, fdt_get_name(blob, parent, NULL));
+ of_dump_addr("OF: translating address:", addr, na);
+
+ /* Translate */
+ for (;;) {
+ /* Switch to parent bus */
+ node_offset = parent;
+ parent = fdt_parent_offset(blob, node_offset);
+
+ /* If root, we have finished */
+ if (parent < 0) {
+ debug("OF: reached root node\n");
+ result = of_read_number(addr, na);
+ break;
+ }
+
+ /* Get new parent bus and counts */
+ pbus = &of_busses[0];
+ pbus->count_cells(blob, node_offset, &pna, &pns);
+ if (!OF_CHECK_COUNTS(pna, pns)) {
+ printf("%s: Bad cell count for %s\n", __FUNCTION__,
+ fdt_get_name(blob, node_offset, NULL));
+ break;
+ }
+
+ debug("OF: parent bus is %s (na=%d, ns=%d) on %s\n",
+ pbus->name, pna, pns, fdt_get_name(blob, parent, NULL));
+
+ /* Apply bus translation */
+ if (of_translate_one(blob, node_offset, bus, pbus,
+ addr, na, ns, pna, rprop))
+ break;
+
+ /* Complete the move up one level */
+ na = pna;
+ ns = pns;
+ bus = pbus;
+
+ of_dump_addr("OF: one level translation:", addr, na);
+ }
+ bail:
+
+ return result;
+}
+
+u64 fdt_translate_address(void *blob, int node_offset, const u32 *in_addr)
+{
+ return __of_translate_address(blob, node_offset, in_addr, "ranges");
+}
+
+/**
+ * fdt_node_offset_by_compat_reg: Find a node that matches compatiable and
+ * who's reg property matches a physical cpu address
+ *
+ * @blob: ptr to device tree
+ * @compat: compatiable string to match
+ * @compat_off: property name
+ *
+ */
+int fdt_node_offset_by_compat_reg(void *blob, const char *compat,
+ phys_addr_t compat_off)
+{
+ int len, off = fdt_node_offset_by_compatible(blob, -1, compat);
+ while (off != -FDT_ERR_NOTFOUND) {
+ u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", &len);
+ if (reg) {
+ if (compat_off == fdt_translate_address(blob, off, reg))
+ return off;
+ }
+ off = fdt_node_offset_by_compatible(blob, off, compat);
+ }
+
+ return -FDT_ERR_NOTFOUND;
+}
+
+
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;
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 4fc01a2..76949b8 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -181,7 +181,7 @@ block_dev_desc_t *usb_stor_get_dev(int index)
void usb_show_progress(void)
{
- printf(".");
+ debug(".");
}
/*******************************************************************************
@@ -224,10 +224,11 @@ int usb_stor_scan(int mode)
for (i = 0; i < USB_MAX_STOR_DEV; i++) {
memset(&usb_dev_desc[i], 0, sizeof(block_dev_desc_t));
- usb_dev_desc[i].target = 0xff;
usb_dev_desc[i].if_type = IF_TYPE_USB;
usb_dev_desc[i].dev = i;
usb_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
+ usb_dev_desc[i].target = 0xff;
+ usb_dev_desc[i].type = DEV_TYPE_UNKNOWN;
usb_dev_desc[i].block_read = usb_stor_read;
usb_dev_desc[i].block_write = usb_stor_write;
}
@@ -1080,7 +1081,7 @@ retry_it:
usb_disable_asynch(0); /* asynch transfer allowed */
if (blkcnt >= USB_MAX_READ_BLK)
- printf("\n");
+ debug("\n");
return blkcnt;
}
@@ -1160,7 +1161,7 @@ retry_it:
usb_disable_asynch(0); /* asynch transfer allowed */
if (blkcnt >= USB_MAX_WRITE_BLK)
- printf("\n");
+ debug("\n");
return blkcnt;
}