]> git.sur5r.net Git - u-boot/blobdiff - common/cmd_flash.c
Minor cleanup
[u-boot] / common / cmd_flash.c
index 5ad4226b8b4e4d57f213271c7c280e6415335d2b..cb1c5bb432be9fb231078ad2175b27e9de8ae646 100644 (file)
@@ -125,13 +125,16 @@ abbrev_spec (char *str, flash_info_t ** pinfo, int *psf, int *psl)
 static int
 addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last)
 {
-       char len_used = 0; /* indicates if the "start +length" form used */
        char *ep;
+       char len_used; /* indicates if the "start +length" form used */
+       char found;
+       ulong bank;
 
        *addr_first = simple_strtoul(arg1, &ep, 16);
        if (ep == arg1 || *ep != '\0')
                return -1;
 
+       len_used = 0;
        if (arg2 && *arg2 == '+'){
                len_used = 1;
                ++arg2;
@@ -142,9 +145,6 @@ addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last)
                return -1;
 
        if (len_used){
-               char found = 0;
-               ulong bank;
-
                /*
                 * *addr_last has the length, compute correct *addr_last
                 * XXX watch out for the integer overflow! Right now it is
@@ -159,6 +159,7 @@ addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last)
                 */
 
                /* find the end addr of the sector where the *addr_last is */
+               found = 0;
                for (bank = 0; bank < CFG_MAX_FLASH_BANKS && !found; ++bank){
                        int i;
                        flash_info_t *info = &flash_info[bank];
@@ -404,7 +405,11 @@ int flash_sect_erase (ulong addr_first, ulong addr_last)
 {
        flash_info_t *info;
        ulong bank;
+#ifdef CFG_MAX_FLASH_BANKS_DETECT
+       int s_first[CFG_MAX_FLASH_BANKS_DETECT], s_last[CFG_MAX_FLASH_BANKS_DETECT];
+#else
        int s_first[CFG_MAX_FLASH_BANKS], s_last[CFG_MAX_FLASH_BANKS];
+#endif
        int erased = 0;
        int planned;
        int rcode = 0;
@@ -451,6 +456,7 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 #ifdef CONFIG_HAS_DATAFLASH
        int status;
 #endif
+
        if (argc < 3) {
                printf ("Usage:\n%s\n", cmdtp->usage);
                return 1;
@@ -501,12 +507,10 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                                info->protect[i] = p;
 #endif /* CFG_FLASH_PROTECTION */
                        }
-               }
-
 #if defined(CFG_FLASH_PROTECTION)
-               if (!rcode) puts (" done\n");
+                       if (!rcode) puts (" done\n");
 #endif /* CFG_FLASH_PROTECTION */
-
+               }
                return rcode;
        }
 
@@ -534,7 +538,7 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
                return rcode;
        }
-       
+
 #if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
        /* protect on/off <part-id> */
        if ((argc == 3) && (id_parse(argv[2], NULL, &dev_type, &dev_num) == 0)) {
@@ -617,7 +621,11 @@ int flash_sect_protect (int p, ulong addr_first, ulong addr_last)
 {
        flash_info_t *info;
        ulong bank;
+#ifdef CFG_MAX_FLASH_BANKS_DETECT
+       int s_first[CFG_MAX_FLASH_BANKS_DETECT], s_last[CFG_MAX_FLASH_BANKS_DETECT];
+#else
        int s_first[CFG_MAX_FLASH_BANKS], s_last[CFG_MAX_FLASH_BANKS];
+#endif
        int protected, i;
        int planned;
        int rcode;
@@ -647,10 +655,10 @@ int flash_sect_protect (int p, ulong addr_first, ulong addr_last)
 #endif /* CFG_FLASH_PROTECTION */
                                }
                        }
+               }
 #if defined(CFG_FLASH_PROTECTION)
-                       if (!rcode) putc ('\n');
+               puts (" done\n");
 #endif /* CFG_FLASH_PROTECTION */
-               }
 
                printf ("%sProtected %d sectors\n",
                        p ? "" : "Un-", protected);