]> git.sur5r.net Git - u-boot/blobdiff - common/cmd_flash.c
mx31 litekit support
[u-boot] / common / cmd_flash.c
index 201f4e33d44178a4ef169f3d0c9c2f8ffb842d2c..f56443e25e3a80ef03b0a46a17369d55a1c0665f 100644 (file)
@@ -31,9 +31,7 @@
 #include <dataflash.h>
 #endif
 
-#if (CONFIG_COMMANDS & CFG_CMD_FLASH)
-
-#if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
 #include <jffs2/jffs2.h>
 
 /* parition handling routines */
@@ -125,13 +123,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 +143,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 +157,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];
@@ -310,7 +309,7 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        flash_info_t *info;
        ulong bank, addr_first, addr_last;
        int n, sect_first, sect_last;
-#if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
        struct mtd_device *dev;
        struct part_info *part;
        u8 dev_type, dev_num, pnum;
@@ -342,7 +341,7 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                return rcode;
        }
 
-#if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
        /* erase <part-id> - erase partition */
        if ((argc == 2) && (id_parse(argv[1], NULL, &dev_type, &dev_num) == 0)) {
                mtdparts_init();
@@ -446,7 +445,7 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        flash_info_t *info;
        ulong bank, addr_first, addr_last;
        int i, p, n, sect_first, sect_last;
-#if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
        struct mtd_device *dev;
        struct part_info *part;
        u8 dev_type, dev_num, pnum;
@@ -506,12 +505,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;
        }
 
@@ -540,7 +537,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)
+#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
        /* protect on/off <part-id> */
        if ((argc == 3) && (id_parse(argv[2], NULL, &dev_type, &dev_num) == 0)) {
                mtdparts_init();
@@ -673,7 +670,7 @@ int flash_sect_protect (int p, ulong addr_first, ulong addr_last)
 
 
 /**************************************************/
-#if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
 # define TMP_ERASE     "erase <part-id>\n    - erase partition\n"
 # define TMP_PROT_ON   "protect on <part-id>\n    - protect partition\n"
 # define TMP_PROT_OFF  "protect off <part-id>\n    - make partition writable\n"
@@ -691,7 +688,7 @@ U_BOOT_CMD(
 );
 
 U_BOOT_CMD(
-       erase,   3,   1,  do_flerase,
+       erase,   3,   0,  do_flerase,
        "erase   - erase FLASH memory\n",
        "start end\n"
        "    - erase FLASH from addr 'start' to addr 'end'\n"
@@ -705,7 +702,7 @@ U_BOOT_CMD(
 );
 
 U_BOOT_CMD(
-       protect,  4,  1,   do_protect,
+       protect,  4,  0,   do_protect,
        "protect - enable or disable FLASH write protection\n",
        "on  start end\n"
        "    - protect FLASH from addr 'start' to addr 'end'\n"
@@ -732,5 +729,3 @@ U_BOOT_CMD(
 #undef TMP_ERASE
 #undef TMP_PROT_ON
 #undef TMP_PROT_OFF
-
-#endif /* CFG_CMD_FLASH */