Skip to content

Commit c8b229d

Browse files
author
Joern Engel
committed
[MTD] Merge STMicro NOR_ECC code with Intel Sibley code
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>
1 parent 2831877 commit c8b229d

4 files changed

Lines changed: 6 additions & 56 deletions

File tree

‎drivers/mtd/chips/cfi_cmdset_0020.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
239239
mtd->suspend = cfi_staa_suspend;
240240
mtd->resume = cfi_staa_resume;
241241
mtd->flags = MTD_CAP_NORFLASH;
242-
mtd->flags |= MTD_ECC; /* FIXME: Not all STMicro flashes have this */
243-
mtd->eccsize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */
242+
mtd->flags |= MTD_PROGRAM_REGIONS; /* FIXME: Not all STMicro flashes have this */
243+
mtd->writesize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */
244244
map->fldrv = &cfi_staa_chipdrv;
245245
__module_get(THIS_MODULE);
246246
mtd->name = map->name;

‎fs/jffs2/fs.c‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -664,13 +664,6 @@ static int jffs2_flash_setup(struct jffs2_sb_info *c) {
664664
return ret;
665665
}
666666

667-
/* add setups for other bizarre flashes here... */
668-
if (jffs2_nor_ecc(c)) {
669-
ret = jffs2_nor_ecc_flash_setup(c);
670-
if (ret)
671-
return ret;
672-
}
673-
674667
/* and Dataflash */
675668
if (jffs2_dataflash(c)) {
676669
ret = jffs2_dataflash_setup(c);
@@ -694,11 +687,6 @@ void jffs2_flash_cleanup(struct jffs2_sb_info *c) {
694687
jffs2_nand_flash_cleanup(c);
695688
}
696689

697-
/* add cleanups for other bizarre flashes here... */
698-
if (jffs2_nor_ecc(c)) {
699-
jffs2_nor_ecc_flash_cleanup(c);
700-
}
701-
702690
/* and DataFlash */
703691
if (jffs2_dataflash(c)) {
704692
jffs2_dataflash_cleanup(c);

‎fs/jffs2/os-linux.h‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
9292
#define jffs2_flash_writev(a,b,c,d,e,f) jffs2_flash_direct_writev(a,b,c,d,e)
9393
#define jffs2_wbuf_timeout NULL
9494
#define jffs2_wbuf_process NULL
95-
#define jffs2_nor_ecc(c) (0)
9695
#define jffs2_dataflash(c) (0)
97-
#define jffs2_nor_wbuf_flash(c) (0)
98-
#define jffs2_nor_ecc_flash_setup(c) (0)
99-
#define jffs2_nor_ecc_flash_cleanup(c) do {} while (0)
10096
#define jffs2_dataflash_setup(c) (0)
10197
#define jffs2_dataflash_cleanup(c) do {} while (0)
10298
#define jffs2_nor_wbuf_flash_setup(c) (0)
@@ -110,7 +106,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
110106
#define jffs2_can_mark_obsolete(c) (0)
111107
#else
112108
#define jffs2_can_mark_obsolete(c) \
113-
((c->mtd->type == MTD_NORFLASH && !(c->mtd->flags & (MTD_ECC|MTD_PROGRAM_REGIONS))) || \
109+
((c->mtd->type == MTD_NORFLASH && !(c->mtd->flags & (MTD_PROGRAM_REGIONS))) || \
114110
c->mtd->type == MTD_RAM)
115111
#endif
116112

@@ -135,10 +131,6 @@ int jffs2_flush_wbuf_pad(struct jffs2_sb_info *c);
135131
int jffs2_nand_flash_setup(struct jffs2_sb_info *c);
136132
void jffs2_nand_flash_cleanup(struct jffs2_sb_info *c);
137133

138-
#define jffs2_nor_ecc(c) (c->mtd->type == MTD_NORFLASH && (c->mtd->flags & MTD_ECC))
139-
int jffs2_nor_ecc_flash_setup(struct jffs2_sb_info *c);
140-
void jffs2_nor_ecc_flash_cleanup(struct jffs2_sb_info *c);
141-
142134
#define jffs2_dataflash(c) (c->mtd->type == MTD_DATAFLASH)
143135
int jffs2_dataflash_setup(struct jffs2_sb_info *c);
144136
void jffs2_dataflash_cleanup(struct jffs2_sb_info *c);

‎fs/jffs2/wbuf.c‎

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -637,17 +637,6 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig
637637
memset(c->wbuf,0xff,c->wbuf_pagesize);
638638
}
639639

640-
/* Fixup the wbuf if we are moving to a new eraseblock. The checks below
641-
fail for ECC'd NOR because cleanmarker == 16, so a block starts at
642-
xxx0010. */
643-
if (jffs2_nor_ecc(c)) {
644-
if (((c->wbuf_ofs % c->sector_size) == 0) && !c->wbuf_len) {
645-
c->wbuf_ofs = PAGE_DIV(to);
646-
c->wbuf_len = PAGE_MOD(to);
647-
memset(c->wbuf,0xff,c->wbuf_pagesize);
648-
}
649-
}
650-
651640
/* Sanity checks on target address.
652641
It's permitted to write at PAD(c->wbuf_len+c->wbuf_ofs),
653642
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) {
12441233
kfree(c->wbuf);
12451234
}
12461235

1247-
int jffs2_nor_ecc_flash_setup(struct jffs2_sb_info *c) {
1248-
/* Cleanmarker is actually larger on the flashes */
1249-
c->cleanmarker_size = 16;
1250-
1251-
/* Initialize write buffer */
1252-
init_rwsem(&c->wbuf_sem);
1253-
c->wbuf_pagesize = c->mtd->eccsize;
1254-
c->wbuf_ofs = 0xFFFFFFFF;
1255-
1256-
c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
1257-
if (!c->wbuf)
1258-
return -ENOMEM;
1259-
1260-
return 0;
1261-
}
1262-
1263-
void jffs2_nor_ecc_flash_cleanup(struct jffs2_sb_info *c) {
1264-
kfree(c->wbuf);
1265-
}
1266-
12671236
int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c) {
1268-
/* Cleanmarker currently occupies a whole programming region */
1269-
c->cleanmarker_size = c->mtd->writesize;
1237+
/* Cleanmarker currently occupies whole programming regions,
1238+
* either one or 2 for 8Byte STMicro flashes. */
1239+
c->cleanmarker_size = max(16u, c->mtd->writesize);
12701240

12711241
/* Initialize write buffer */
12721242
init_rwsem(&c->wbuf_sem);

0 commit comments

Comments
 (0)