mtd/drivers/mtd/nand nand_base.c,1.156,1.157

tpoynor at infradead.org tpoynor at infradead.org
Mon Nov 21 17:14:59 EST 2005


Update of /home/cvs/mtd/drivers/mtd/nand
In directory phoenix.infradead.org:/tmp/cvs-serv26220/drivers/mtd/nand

Modified Files:
	nand_base.c 
Log Message:
[MTD] NAND: nand_write_oob_hwecc skip ECC bytes, restore pad to end

nand_write_oob_hwecc corrupts filesystem OOB bytes placed after ECC bytes.
The h/w-generated ecc bytes must be skipped in the caller-supplied buffer and
in the generated OOB buffer.  Also restore ability to pad 0xff bytes to end
of OOB for short writes.

From: Vitaly Wool and Todd Poynor
Signed-off-by: Todd Poynor <tpoynor at mvista.com>


Index: nand_base.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand_base.c,v
retrieving revision 1.156
retrieving revision 1.157
diff -u -r1.156 -r1.157
--- nand_base.c	18 Nov 2005 23:12:31 -0000	1.156
+++ nand_base.c	21 Nov 2005 22:14:55 -0000	1.157
@@ -2093,7 +2093,7 @@
  */
 static int nand_write_oob_hwecc (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * oob_buf)
 {
-	int i, j, column, page, status, ret = -EIO, chipnr, eccsteps, ecclen, ooblen;
+	int column, page, status, ret = -EIO, chipnr, eccsteps, fflen, ooblen;
 	struct nand_chip *this = mtd->priv;
 
 	DEBUG (MTD_DEBUG_LEVEL3, "%s: to = 0x%08x, len = %i\n", __FUNCTION__, (unsigned int) to, (int) len);
@@ -2140,18 +2140,21 @@
 
 	eccsteps = this->eccsteps;
 
-	for (ecclen = 0, ooblen = 0; eccsteps; eccsteps--) {
+	for (fflen = 0, ooblen = 0; eccsteps; eccsteps--)
+		int i, j;
+
 		for (j = 0; this->layout[j].length; j++) {
 			switch (this->layout[j].type) {
 			case ITEM_TYPE_DATA:
 				this->enable_hwecc(mtd, NAND_ECC_WRITE);
 				this->write_buf(mtd, ffchars, this->layout[j].length);
+				fflen += this->layout[j].length;
 				break;
 
 			case ITEM_TYPE_ECC:
 				this->enable_hwecc(mtd, NAND_ECC_WRITESYN);
 				this->write_buf(mtd, ffchars, this->layout[j].length);
-				ecclen += this->layout[j].length;
+				ooblen += this->layout[j].length;
 				break;
 
 			case ITEM_TYPE_OOB:
@@ -2165,8 +2168,12 @@
 				if (i)
 					this->write_buf(mtd, &oob_buf[ooblen], i);
 				ooblen += i;
-				if (ooblen == len)
+				if (ooblen == len) {
+					if (NAND_MUST_PAD(this))
+						this->write_buf(mtd, ffchars,
+								mtd->oobsize + mtd->oobblock - fflen - ooblen);
 					goto finish;
+				}
 				break;
 			}
 		}





More information about the linux-mtd-cvs mailing list