All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] flash_erase: check the nand type
@ 2013-10-24 10:59 Huang Shijie
  2013-10-24 18:29 ` Brian Norris
  0 siblings, 1 reply; 2+ messages in thread
From: Huang Shijie @ 2013-10-24 10:59 UTC (permalink / raw)
  To: dwmw2; +Cc: Huang Shijie, computersforpeace, linux-mtd, dedekind1

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>
---
 flash_erase.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/flash_erase.c b/flash_erase.c
index 1421cf9..933373a 100644
--- a/flash_erase.c
+++ b/flash_erase.c
@@ -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);
-- 
1.7.2.rc3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] flash_erase: check the nand type
  2013-10-24 10:59 [PATCH v2] flash_erase: check the nand type Huang Shijie
@ 2013-10-24 18:29 ` Brian Norris
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Norris @ 2013-10-24 18:29 UTC (permalink / raw)
  To: Huang Shijie; +Cc: linux-mtd, dwmw2, dedekind1

On Thu, Oct 24, 2013 at 06:59:51PM +0800, Huang Shijie wrote:
> 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>

Thanks for the update. Pushed to mtd-utils.git.

BTW, this is not a problem with your patch, but MLC typically have large
OOB sizes which have outgrown the outdated ioctl(MEMGETOOBSEL), so
--jffs2 would have broken for them anyway. I just tested this on my
system. On an old kernel (where MLC is still detected as MTD_NANDFLASH)
I get:

  # flash_erase -j /dev/mtd1 0 1 
  flash_erase: error!: /dev/mtd1: unable to get NAND oobinfo
               error 22 (Invalid argument)

There's not much we can do about this.

Brian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-10-24 18:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-24 10:59 [PATCH v2] flash_erase: check the nand type Huang Shijie
2013-10-24 18:29 ` Brian Norris

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.