Skip to content

Commit 5fa4339

Browse files
author
Joern Engel
committed
[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 <[email protected]>
1 parent c8b229d commit 5fa4339

File tree

6 files changed

+9
-13
lines changed

6 files changed

+9
-13
lines changed

drivers/mtd/chips/cfi_cmdset_0001.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
548548
mtd->writesize = cfi->interleave << prinfo->ProgRegShift;
549549
MTD_PROGREGION_CTRLMODE_VALID(mtd) = cfi->interleave * prinfo->ControlValid;
550550
MTD_PROGREGION_CTRLMODE_INVALID(mtd) = cfi->interleave * prinfo->ControlInvalid;
551-
mtd->flags |= MTD_PROGRAM_REGIONS;
551+
mtd->flags &= ~MTD_BIT_WRITEABLE;
552552
printk(KERN_DEBUG "%s: program region size/ctrl_valid/ctrl_inval = %d/%d/%d\n",
553553
map->name, mtd->writesize,
554554
MTD_PROGREGION_CTRLMODE_VALID(mtd),

drivers/mtd/chips/cfi_cmdset_0020.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,7 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
238238
mtd->unlock = cfi_staa_unlock;
239239
mtd->suspend = cfi_staa_suspend;
240240
mtd->resume = cfi_staa_resume;
241-
mtd->flags = MTD_CAP_NORFLASH;
242-
mtd->flags |= MTD_PROGRAM_REGIONS; /* FIXME: Not all STMicro flashes have this */
241+
mtd->flags = MTD_CAP_NORFLASH & ~MTD_BIT_WRITEABLE;
243242
mtd->writesize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */
244243
map->fldrv = &cfi_staa_chipdrv;
245244
__module_get(THIS_MODULE);

drivers/mtd/nand/nand_base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2668,7 +2668,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
26682668

26692669
/* Fill in remaining MTD driver data */
26702670
mtd->type = MTD_NANDFLASH;
2671-
mtd->flags = MTD_CAP_NANDFLASH | MTD_ECC;
2671+
mtd->flags = MTD_CAP_NANDFLASH;
26722672
mtd->ecctype = MTD_ECC_SW;
26732673
mtd->erase = nand_erase;
26742674
mtd->point = NULL;

drivers/mtd/onenand/onenand_base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1943,7 +1943,7 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
19431943

19441944
/* Fill in remaining MTD driver data */
19451945
mtd->type = MTD_NANDFLASH;
1946-
mtd->flags = MTD_CAP_NANDFLASH | MTD_ECC;
1946+
mtd->flags = MTD_CAP_NANDFLASH;
19471947
mtd->ecctype = MTD_ECC_SW;
19481948
mtd->erase = onenand_erase;
19491949
mtd->point = NULL;

fs/jffs2/os-linux.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
105105
#ifdef CONFIG_JFFS2_SUMMARY
106106
#define jffs2_can_mark_obsolete(c) (0)
107107
#else
108-
#define jffs2_can_mark_obsolete(c) \
109-
((c->mtd->type == MTD_NORFLASH && !(c->mtd->flags & (MTD_PROGRAM_REGIONS))) || \
110-
c->mtd->type == MTD_RAM)
108+
#define jffs2_can_mark_obsolete(c) (c->mtd->flags & (MTD_BIT_WRITEABLE))
111109
#endif
112110

113111
#define jffs2_cleanmarker_oob(c) (c->mtd->type == MTD_NANDFLASH)
@@ -135,7 +133,7 @@ void jffs2_nand_flash_cleanup(struct jffs2_sb_info *c);
135133
int jffs2_dataflash_setup(struct jffs2_sb_info *c);
136134
void jffs2_dataflash_cleanup(struct jffs2_sb_info *c);
137135

138-
#define jffs2_nor_wbuf_flash(c) (c->mtd->type == MTD_NORFLASH && (c->mtd->flags & MTD_PROGRAM_REGIONS))
136+
#define jffs2_nor_wbuf_flash(c) (c->mtd->type == MTD_NORFLASH && ! (c->mtd->flags & MTD_BIT_WRITEABLE))
139137
int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c);
140138
void jffs2_nor_wbuf_flash_cleanup(struct jffs2_sb_info *c);
141139

include/mtd/mtd-abi.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@ struct mtd_oob_buf {
3030
#define MTD_NANDFLASH 4
3131
#define MTD_DATAFLASH 6
3232

33-
#define MTD_ECC 128 // Device capable of automatic ECC
34-
#define MTD_PROGRAM_REGIONS 512 // Configurable Programming Regions
3533
#define MTD_WRITEABLE 0x400 /* Device is writeable */
34+
#define MTD_BIT_WRITEABLE 0x800 /* Single bits can be flipped */
3635

3736
// Some common devices / combinations of capabilities
3837
#define MTD_CAP_ROM 0
39-
#define MTD_CAP_RAM (MTD_WRITEABLE)
40-
#define MTD_CAP_NORFLASH (MTD_WRITEABLE)
38+
#define MTD_CAP_RAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
39+
#define MTD_CAP_NORFLASH (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
4140
#define MTD_CAP_NANDFLASH (MTD_WRITEABLE)
4241

4342

0 commit comments

Comments
 (0)