From 47e26b1bf91ddef69f4a3892815c857db094cef9 Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Sat, 17 Jul 2010 01:06:04 +0200 Subject: 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: Wolfgang Denk --- tools/updater/cmd_flash.c | 49 +++++++++++++++++------------------------------ 1 file changed, 18 insertions(+), 31 deletions(-) (limited to 'tools/updater/cmd_flash.c') diff --git a/tools/updater/cmd_flash.c b/tools/updater/cmd_flash.c index 5ce45baeb4..957a7c4f68 100644 --- a/tools/updater/cmd_flash.c +++ b/tools/updater/cmd_flash.c @@ -121,10 +121,8 @@ int do_flerase(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) int n, sect_first, sect_last; 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) { @@ -146,10 +144,8 @@ int do_flerase(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) return rcode; } - 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); @@ -167,10 +163,8 @@ int do_flerase(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) addr_first = simple_strtoul(argv[1], NULL, 16); addr_last = simple_strtoul(argv[2], NULL, 16); - if (addr_first >= addr_last) { - cmd_usage(cmdtp); - return 1; - } + if (addr_first >= addr_last) + return cmd_usage(cmdtp); printf ("Erase Flash from 0x%08lx to 0x%08lx ", addr_first, addr_last); rcode = flash_sect_erase(addr_first, addr_last); @@ -243,19 +237,15 @@ int do_protect(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) int i, p, n, sect_first, sect_last; int rcode = 0; - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); if (strcmp(argv[1], "off") == 0) p = 0; else if (strcmp(argv[1], "on") == 0) p = 1; - else { - cmd_usage(cmdtp); - return 1; - } + else + return cmd_usage(cmdtp); if (strcmp(argv[2], "all") == 0) { for (bank=1; bank<=CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { @@ -309,10 +299,8 @@ int do_protect(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) return rcode; } - 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); @@ -340,7 +328,8 @@ int do_protect(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) } #if defined(CONFIG_SYS_FLASH_PROTECTION) - if (!rcode) puts (" done\n"); + if (!rcode) + puts(" done\n"); #endif /* CONFIG_SYS_FLASH_PROTECTION */ return rcode; @@ -349,12 +338,10 @@ int do_protect(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) addr_first = simple_strtoul(argv[2], NULL, 16); addr_last = simple_strtoul(argv[3], NULL, 16); - if (addr_first >= addr_last) { - cmd_usage(cmdtp); - return 1; - } - rcode = flash_sect_protect (p, addr_first, addr_last); - return rcode; + if (addr_first >= addr_last) + return cmd_usage(cmdtp); + + return flash_sect_protect (p, addr_first, addr_last); } int flash_sect_protect (int p, ulong addr_first, ulong addr_last) { -- cgit