]> www.infradead.org Git - mtd-utils.git/commitdiff
flash_erase: check the nand type
authorHuang Shijie <b32955@freescale.com>
Thu, 24 Oct 2013 10:59:51 +0000 (18:59 +0800)
committerBrian Norris <computersforpeace@gmail.com>
Thu, 24 Oct 2013 17:51:21 +0000 (10:51 -0700)
Now, the MTD_NANDFLASH stands for SLC nand, and the MTD_MLCNANDFLASH
stands for the MLC nand.

This patch includes the stdbool.h, and changes the "isNAND" to boolean type,
and checks the right nand type for the MLC and SLC nand.

If the user wants to format a MLC nand for JFFS2, we will print out a message
to warn him, and exit right now.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
flash_erase.c

index 1421cf9246ca7c5f4941ee6138f9404d8ba7bbff..933373a2a380131a2ca548b83890feb1a1fa7b3a 100644 (file)
@@ -21,6 +21,7 @@
 #define PROGRAM_NAME "flash_erase"
 
 #include <inttypes.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -95,7 +96,7 @@ int main(int argc, char *argv[])
        int fd, clmpos = 0, clmlen = 8;
        unsigned long long start;
        unsigned int eb, eb_start, eb_cnt;
-       int isNAND;
+       bool isNAND;
        int error = 0;
        off_t offset = 0;
 
@@ -182,9 +183,12 @@ int main(int argc, char *argv[])
        if (mtd_get_dev_info(mtd_desc, mtd_device, &mtd) < 0)
                return errmsg("mtd_get_dev_info failed");
 
+       if (jffs2 && mtd.type == MTD_MLCNANDFLASH)
+               return errmsg("JFFS2 cannot support MLC NAND.");
+
        eb_start = start / mtd.eb_size;
 
-       isNAND = mtd.type == MTD_NANDFLASH ? 1 : 0;
+       isNAND = mtd.type == MTD_NANDFLASH || mtd.type == MTD_MLCNANDFLASH;
 
        if (jffs2) {
                cleanmarker.magic = cpu_to_je16 (JFFS2_MAGIC_BITMASK);