mtd/fs/jffs2 wbuf.c,1.16,1.17
gleixner at infradead.org
gleixner at infradead.org
Thu Aug 29 17:45:57 EDT 2002
Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv16579
Modified Files:
wbuf.c
Log Message:
fit the changes in nand.c
Index: wbuf.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/wbuf.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- wbuf.c 20 Aug 2002 21:37:28 -0000 1.16
+++ wbuf.c 29 Aug 2002 21:45:54 -0000 1.17
@@ -158,7 +158,7 @@
/* else jffs2_flash_writev has actually filled in the rest of the
buffer for us, and will deal with the node refs etc. later. */
- ret = c->mtd->write(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen, c->wbuf);
+ ret = c->mtd->write_ecc(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen, c->wbuf, NULL, NAND_JFFS2_OOB);
if (ret || retlen != c->wbuf_pagesize) {
if (ret)
@@ -374,7 +374,7 @@
outvecs[splitvec].iov_len = split_ofs;
/* We did cross a page boundary, so we write some now */
- ret = jffs2_flash_direct_writev(c, outvecs, splitvec+1, outvec_to, &wbuf_retlen);
+ ret = c->mtd->writev_ecc(c->mtd, outvecs, splitvec+1, outvec_to, &wbuf_retlen, NULL, NAND_JFFS2_OOB);
if (ret < 0 || wbuf_retlen != PAGE_DIV(totlen)) {
/* At this point we have no problem,
c->wbuf is empty.
@@ -438,28 +438,30 @@
int ret;
/* Read flash */
- ret = c->mtd->read(c->mtd, ofs, len, retlen, buf);
+ if (!jffs2_can_mark_obsolete(c)) {
+ ret = c->mtd->read_ecc(c->mtd, ofs, len, retlen, buf, NULL, NAND_JFFS2_OOB);
- if (!jffs2_can_mark_obsolete(c) && (ret == -EIO) && (*retlen == len) ) {
- printk(KERN_WARNING "mtd->read(0x%x bytes from 0x%llx) returned ECC error\n", len, ofs);
- /*
- * We have the raw data without ECC correction in the buffer, maybe
- * we are lucky and all data or parts are correct. We check the node.
- * If data are corrupted node check will sort it out.
- * We keep this block, it will fail on write or erase and the we
- * mark it bad. Or should we do that now? But we should give him a chance.
- * Maybe we had a system crash or power loss before the ecc write or
- * a erase was completed.
- * So we return success. :)
- */
- ret = 0;
- }
+ if ( (ret == -EIO) && (*retlen == len) ) {
+ printk(KERN_WARNING "mtd->read(0x%x bytes from 0x%llx) returned ECC error\n", len, ofs);
+ /*
+ * We have the raw data without ECC correction in the buffer, maybe
+ * we are lucky and all data or parts are correct. We check the node.
+ * If data are corrupted node check will sort it out.
+ * We keep this block, it will fail on write or erase and the we
+ * mark it bad. Or should we do that now? But we should give him a chance.
+ * Maybe we had a system crash or power loss before the ecc write or
+ * a erase was completed.
+ * So we return success. :)
+ */
+ ret = 0;
+ }
+ } else
+ return c->mtd->read(c->mtd, ofs, len, retlen, buf);
/* if no writebuffer available or write buffer empty, return */
if (!c->wbuf_pagesize || !c->wbuf_len)
return ret;
-
/* if we read in a different block, return */
if ( (ofs & ~(c->sector_size-1)) != (c->wbuf_ofs & ~(c->sector_size-1)) )
return ret;
@@ -501,7 +503,7 @@
switch(c->mtd->ecctype) {
case MTD_ECC_SW:
fsdata_pos = (c->wbuf_pagesize == 256) ? NAND_JFFS2_OOB8_FSDAPOS : NAND_JFFS2_OOB16_FSDAPOS;
- badblock_pos = NAND_JFFS2_OOB_BADBPOS;
+ badblock_pos = NAND_BADBLOCK_POS;
break;
default:
D1(printk(KERN_WARNING "jffs2_write_oob_empty(): Invalid ECC type\n"));
@@ -586,7 +588,7 @@
case MTD_ECC_SW:
fsdata_pos = (c->wbuf_pagesize == 256) ? NAND_JFFS2_OOB8_FSDAPOS : NAND_JFFS2_OOB16_FSDAPOS;
fsdata_len = (c->wbuf_pagesize == 256) ? NAND_JFFS2_OOB8_FSDALEN : NAND_JFFS2_OOB16_FSDALEN;
- badblock_pos = NAND_JFFS2_OOB_BADBPOS;
+ badblock_pos = NAND_BADBLOCK_POS;
break;
default:
D1(printk(KERN_WARNING "jffs2_write_nand_cleanmarker(): Invalid ECC type\n"));
@@ -684,7 +686,7 @@
switch(c->mtd->ecctype) {
case MTD_ECC_SW:
- badblock_pos = NAND_JFFS2_OOB_BADBPOS;
+ badblock_pos = NAND_BADBLOCK_POS;
break;
default:
D1(printk(KERN_WARNING "jffs2_nand_read_failcnt(): Invalid ECC type\n"));
@@ -725,7 +727,7 @@
switch(c->mtd->ecctype) {
case MTD_ECC_SW:
- pos = NAND_JFFS2_OOB_BADBPOS;
+ pos = NAND_BADBLOCK_POS;
break;
default:
D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Invalid ECC type\n"));
More information about the linux-mtd-cvs
mailing list