mtd: nand: fix the wrong mtd->type for nand chip

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Wed Nov 13 13:59:03 EST 2013


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=963d1c285fdf3b9ce93b575b879c1cba4a23d958
Commit:     963d1c285fdf3b9ce93b575b879c1cba4a23d958
Parent:     e104f1e9dab6726187810f5d9e06cadb946d4a61
Author:     Huang Shijie <b32955 at freescale.com>
AuthorDate: Wed Sep 25 14:58:21 2013 +0800
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Sun Oct 27 16:27:07 2013 -0700

    mtd: nand: fix the wrong mtd->type for nand chip
    
    Current code sets the mtd->type with MTD_NANDFLASH for both
    SLC and MLC. So the jffs2 may supports the MLC nand, but in actually,
    the jffs2 should not support the MLC.
    
    This patch uses the nand_is_slc() to check the nand cell type,
    and set the mtd->type with the right nand type.
    
    After this patch, the jffs2 only supports the SLC nand.
    
    The side-effect of this patch:
      Before this patch, the ioctl(MEMGETINFO) can only return with the
      MTD_NANDFLASH; but after this patch, the ioctl(MEMGETINFO) will
      return with the MTD_NANDFLASH for SLC, and MTD_MLCNANDFLASH for MLC.
    
      So the user applictions(such as mtd-utils) should also changes a little
      for this.
    
    Signed-off-by: Huang Shijie <b32955 at freescale.com>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/nand/nand_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 55c80ef..8488844 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3785,7 +3785,7 @@ int nand_scan_tail(struct mtd_info *mtd)
 		chip->options |= NAND_SUBPAGE_READ;
 
 	/* Fill in remaining MTD driver data */
-	mtd->type = MTD_NANDFLASH;
+	mtd->type = nand_is_slc(chip) ? MTD_NANDFLASH : MTD_MLCNANDFLASH;
 	mtd->flags = (chip->options & NAND_ROM) ? MTD_CAP_ROM :
 						MTD_CAP_NANDFLASH;
 	mtd->_erase = nand_erase;



More information about the linux-mtd-cvs mailing list