]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[MTD] Merge STMicro NOR_ECC code with Intel Sibley code
authorJoern Engel <joern@wh.fh-wedel.de>
Mon, 22 May 2006 21:18:12 +0000 (23:18 +0200)
committerJoern Engel <joern@wh.fh-wedel.de>
Mon, 22 May 2006 21:18:12 +0000 (23:18 +0200)
In 2002, STMicro started producing NOR flashes with internal ECC protection
for small blocks (8 or 16 bytes).  Support for those flashes was added by me.
In 2005, Intel Sibley flashes copied this strategy and Nico added support for
those.  Merge the code for both.

Signed-off-by: Joern Engel <joern@wh.fh-wedel.de>
drivers/mtd/chips/cfi_cmdset_0020.c
fs/jffs2/fs.c
fs/jffs2/os-linux.h
fs/jffs2/wbuf.c

index 3911c98ba578c8f8de03e7856563cf40f7a039a5..d745285fccf89d27bf2a968f08c319200f42d9c5 100644 (file)
@@ -239,8 +239,8 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
        mtd->suspend = cfi_staa_suspend;
        mtd->resume = cfi_staa_resume;
        mtd->flags = MTD_CAP_NORFLASH;
-       mtd->flags |= MTD_ECC; /* FIXME: Not all STMicro flashes have this */
-       mtd->eccsize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */
+       mtd->flags |= MTD_PROGRAM_REGIONS; /* FIXME: Not all STMicro flashes have this */
+       mtd->writesize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */
        map->fldrv = &cfi_staa_chipdrv;
        __module_get(THIS_MODULE);
        mtd->name = map->name;
index a0f84673ce54c9b6ae7d1f22136836a9e79eb96e..79f70251a4eb953905846ba553a5e30c391393e2 100644 (file)
@@ -664,13 +664,6 @@ static int jffs2_flash_setup(struct jffs2_sb_info *c) {
                        return ret;
        }
 
-       /* add setups for other bizarre flashes here... */
-       if (jffs2_nor_ecc(c)) {
-               ret = jffs2_nor_ecc_flash_setup(c);
-               if (ret)
-                       return ret;
-       }
-
        /* and Dataflash */
        if (jffs2_dataflash(c)) {
                ret = jffs2_dataflash_setup(c);
@@ -694,11 +687,6 @@ void jffs2_flash_cleanup(struct jffs2_sb_info *c) {
                jffs2_nand_flash_cleanup(c);
        }
 
-       /* add cleanups for other bizarre flashes here... */
-       if (jffs2_nor_ecc(c)) {
-               jffs2_nor_ecc_flash_cleanup(c);
-       }
-
        /* and DataFlash */
        if (jffs2_dataflash(c)) {
                jffs2_dataflash_cleanup(c);
index d2ad2a2081d8f3b0ece3d5304ce1628f12f4ffe3..1a6eb955e0bea66309806d915507085b4096ec47 100644 (file)
@@ -92,11 +92,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
 #define jffs2_flash_writev(a,b,c,d,e,f) jffs2_flash_direct_writev(a,b,c,d,e)
 #define jffs2_wbuf_timeout NULL
 #define jffs2_wbuf_process NULL
-#define jffs2_nor_ecc(c) (0)
 #define jffs2_dataflash(c) (0)
-#define jffs2_nor_wbuf_flash(c) (0)
-#define jffs2_nor_ecc_flash_setup(c) (0)
-#define jffs2_nor_ecc_flash_cleanup(c) do {} while (0)
 #define jffs2_dataflash_setup(c) (0)
 #define jffs2_dataflash_cleanup(c) do {} while (0)
 #define jffs2_nor_wbuf_flash_setup(c) (0)
@@ -110,7 +106,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
 #define jffs2_can_mark_obsolete(c) (0)
 #else
 #define jffs2_can_mark_obsolete(c) \
-  ((c->mtd->type == MTD_NORFLASH && !(c->mtd->flags & (MTD_ECC|MTD_PROGRAM_REGIONS))) || \
+  ((c->mtd->type == MTD_NORFLASH && !(c->mtd->flags & (MTD_PROGRAM_REGIONS))) || \
    c->mtd->type == MTD_RAM)
 #endif
 
@@ -135,10 +131,6 @@ int jffs2_flush_wbuf_pad(struct jffs2_sb_info *c);
 int jffs2_nand_flash_setup(struct jffs2_sb_info *c);
 void jffs2_nand_flash_cleanup(struct jffs2_sb_info *c);
 
-#define jffs2_nor_ecc(c) (c->mtd->type == MTD_NORFLASH && (c->mtd->flags & MTD_ECC))
-int jffs2_nor_ecc_flash_setup(struct jffs2_sb_info *c);
-void jffs2_nor_ecc_flash_cleanup(struct jffs2_sb_info *c);
-
 #define jffs2_dataflash(c) (c->mtd->type == MTD_DATAFLASH)
 int jffs2_dataflash_setup(struct jffs2_sb_info *c);
 void jffs2_dataflash_cleanup(struct jffs2_sb_info *c);
index 355226d8ce29987d0b902b333e76e9115e2532c6..087c2e438a6d025a407407ab52ed24def933f062 100644 (file)
@@ -637,17 +637,6 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig
                memset(c->wbuf,0xff,c->wbuf_pagesize);
        }
 
-       /* Fixup the wbuf if we are moving to a new eraseblock.  The checks below
-          fail for ECC'd NOR because cleanmarker == 16, so a block starts at
-          xxx0010.  */
-       if (jffs2_nor_ecc(c)) {
-               if (((c->wbuf_ofs % c->sector_size) == 0) && !c->wbuf_len) {
-                       c->wbuf_ofs = PAGE_DIV(to);
-                       c->wbuf_len = PAGE_MOD(to);
-                       memset(c->wbuf,0xff,c->wbuf_pagesize);
-               }
-       }
-
        /* Sanity checks on target address.
           It's permitted to write at PAD(c->wbuf_len+c->wbuf_ofs),
           and it's permitted to write at the beginning of a new
@@ -1244,29 +1233,10 @@ void jffs2_dataflash_cleanup(struct jffs2_sb_info *c) {
        kfree(c->wbuf);
 }
 
-int jffs2_nor_ecc_flash_setup(struct jffs2_sb_info *c) {
-       /* Cleanmarker is actually larger on the flashes */
-       c->cleanmarker_size = 16;
-
-       /* Initialize write buffer */
-       init_rwsem(&c->wbuf_sem);
-       c->wbuf_pagesize = c->mtd->eccsize;
-       c->wbuf_ofs = 0xFFFFFFFF;
-
-       c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
-       if (!c->wbuf)
-               return -ENOMEM;
-
-       return 0;
-}
-
-void jffs2_nor_ecc_flash_cleanup(struct jffs2_sb_info *c) {
-       kfree(c->wbuf);
-}
-
 int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c) {
-       /* Cleanmarker currently occupies a whole programming region */
-       c->cleanmarker_size = c->mtd->writesize;
+       /* Cleanmarker currently occupies whole programming regions,
+        * either one or 2 for 8Byte STMicro flashes. */
+       c->cleanmarker_size = max(16u, c->mtd->writesize);
 
        /* Initialize write buffer */
        init_rwsem(&c->wbuf_sem);