[MTD] Introduce MTD_BIT_WRITEABLE

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon May 22 17:59:02 EDT 2006


Commit:     5fa433942ba4e399f7e28764c9db4ade89e91d40
Parent:     c8b229de2b05c2b3e8d282ce260935a88ac030ca
Author:     Joern Engel <joern at wh.fh-wedel.de>
AuthorDate: Mon May 22 23:18:29 2006 +0200
Commit:     Joern Engel <joern at wh.fh-wedel.de>
CommitDate: Mon May 22 23:18:29 2006 +0200

    [MTD] Introduce MTD_BIT_WRITEABLE
    
    o Add a flag MTD_BIT_WRITEABLE for devices that allow single bits to be
      cleared.
    o Replace MTD_PROGRAM_REGIONS with a cleared MTD_BIT_WRITEABLE flag for
      STMicro and Intel Sibley flashes with internal ECC.  Those flashes
      disallow clearing of single bits, unlike regular NOR flashes, so the
      new flag models their behaviour better.
    o Remove MTD_ECC.  After the STMicro/Sibley merge, this flag is only set
      and never checked.
    
    Signed-off-by: Joern Engel <joern at wh.fh-wedel.de>

 drivers/mtd/chips/cfi_cmdset_0001.c |    2 +-
 drivers/mtd/chips/cfi_cmdset_0020.c |    3 +--
 drivers/mtd/nand/nand_base.c        |    2 +-
 drivers/mtd/onenand/onenand_base.c  |    2 +-
 fs/jffs2/os-linux.h                 |    6 ++----
 include/mtd/mtd-abi.h               |    7 +++----
 6 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 35c3689..0d43581 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -548,7 +548,7 @@ static int cfi_intelext_partition_fixup(
 			mtd->writesize = cfi->interleave << prinfo->ProgRegShift;
 			MTD_PROGREGION_CTRLMODE_VALID(mtd) = cfi->interleave * prinfo->ControlValid;
 			MTD_PROGREGION_CTRLMODE_INVALID(mtd) = cfi->interleave * prinfo->ControlInvalid;
-			mtd->flags |= MTD_PROGRAM_REGIONS;
+			mtd->flags &= ~MTD_BIT_WRITEABLE;
 			printk(KERN_DEBUG "%s: program region size/ctrl_valid/ctrl_inval = %d/%d/%d\n",
 			       map->name, mtd->writesize,
 			       MTD_PROGREGION_CTRLMODE_VALID(mtd),
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
index d745285..fae70a5 100644
--- a/drivers/mtd/chips/cfi_cmdset_0020.c
+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
@@ -238,8 +238,7 @@ static struct mtd_info *cfi_staa_setup(s
 	mtd->unlock = cfi_staa_unlock;
 	mtd->suspend = cfi_staa_suspend;
 	mtd->resume = cfi_staa_resume;
-	mtd->flags = MTD_CAP_NORFLASH;
-	mtd->flags |= MTD_PROGRAM_REGIONS; /* FIXME: Not all STMicro flashes have this */
+	mtd->flags = MTD_CAP_NORFLASH & ~MTD_BIT_WRITEABLE;
 	mtd->writesize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */
 	map->fldrv = &cfi_staa_chipdrv;
 	__module_get(THIS_MODULE);
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 055f660..cd90a46 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2668,7 +2668,7 @@ int nand_scan(struct mtd_info *mtd, int 
 
 	/* Fill in remaining MTD driver data */
 	mtd->type = MTD_NANDFLASH;
-	mtd->flags = MTD_CAP_NANDFLASH | MTD_ECC;
+	mtd->flags = MTD_CAP_NANDFLASH;
 	mtd->ecctype = MTD_ECC_SW;
 	mtd->erase = nand_erase;
 	mtd->point = NULL;
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 198bb85..4c2c61d 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -1943,7 +1943,7 @@ int onenand_scan(struct mtd_info *mtd, i
 
 	/* Fill in remaining MTD driver data */
 	mtd->type = MTD_NANDFLASH;
-	mtd->flags = MTD_CAP_NANDFLASH | MTD_ECC;
+	mtd->flags = MTD_CAP_NANDFLASH;
 	mtd->ecctype = MTD_ECC_SW;
 	mtd->erase = onenand_erase;
 	mtd->point = NULL;
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
index 1a6eb95..743c9e5 100644
--- a/fs/jffs2/os-linux.h
+++ b/fs/jffs2/os-linux.h
@@ -105,9 +105,7 @@ #define jffs2_is_writebuffered(c) (c->wb
 #ifdef CONFIG_JFFS2_SUMMARY
 #define jffs2_can_mark_obsolete(c) (0)
 #else
-#define jffs2_can_mark_obsolete(c) \
-  ((c->mtd->type == MTD_NORFLASH && !(c->mtd->flags & (MTD_PROGRAM_REGIONS))) || \
-   c->mtd->type == MTD_RAM)
+#define jffs2_can_mark_obsolete(c) (c->mtd->flags & (MTD_BIT_WRITEABLE))
 #endif
 
 #define jffs2_cleanmarker_oob(c) (c->mtd->type == MTD_NANDFLASH)
@@ -135,7 +133,7 @@ #define jffs2_dataflash(c) (c->mtd->type
 int jffs2_dataflash_setup(struct jffs2_sb_info *c);
 void jffs2_dataflash_cleanup(struct jffs2_sb_info *c);
 
-#define jffs2_nor_wbuf_flash(c) (c->mtd->type == MTD_NORFLASH && (c->mtd->flags & MTD_PROGRAM_REGIONS))
+#define jffs2_nor_wbuf_flash(c) (c->mtd->type == MTD_NORFLASH && ! (c->mtd->flags & MTD_BIT_WRITEABLE))
 int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c);
 void jffs2_nor_wbuf_flash_cleanup(struct jffs2_sb_info *c);
 
diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h
index 520a3b4..1e09e4c 100644
--- a/include/mtd/mtd-abi.h
+++ b/include/mtd/mtd-abi.h
@@ -30,14 +30,13 @@ #define MTD_NORFLASH		3
 #define MTD_NANDFLASH		4
 #define MTD_DATAFLASH		6
 
-#define MTD_ECC			128	// Device capable of automatic ECC
-#define MTD_PROGRAM_REGIONS	512	// Configurable Programming Regions
 #define MTD_WRITEABLE		0x400	/* Device is writeable */
+#define MTD_BIT_WRITEABLE	0x800	/* Single bits can be flipped */
 
 // Some common devices / combinations of capabilities
 #define MTD_CAP_ROM		0
-#define MTD_CAP_RAM		(MTD_WRITEABLE)
-#define MTD_CAP_NORFLASH	(MTD_WRITEABLE)
+#define MTD_CAP_RAM		(MTD_WRITEABLE | MTD_BIT_WRITEABLE)
+#define MTD_CAP_NORFLASH	(MTD_WRITEABLE | MTD_BIT_WRITEABLE)
 #define MTD_CAP_NANDFLASH	(MTD_WRITEABLE)
 
 



More information about the linux-mtd-cvs mailing list