[PATCH] yaffs2: changes to make yaffs work with the layout-based NAND

Vitaly Wool vwool at ru.mvista.com
Tue Nov 29 10:09:57 EST 2005


Hi Charles,

below is the patch that does two things:

- compacts the structures (theyare still way too big IMHO)
- adapts the yaffs2-mtd layer for the changes in OOB area treatment (see earlier patches to linux-mtd list).

Any feedback is very appreciated.

Vitaly

diff -uNr linux-2.6.10.orig/fs/yaffs2/yaffs_ecc.h linux-2.6.10.nand/fs/yaffs2/yaffs_ecc.h
--- linux-2.6.10.orig/fs/yaffs2/yaffs_ecc.h	2005-11-24 16:51:17.000000000 +0300
+++ linux-2.6.10.nand/fs/yaffs2/yaffs_ecc.h	2005-11-23 17:30:21.000000000 +0300
@@ -30,7 +30,7 @@
 	unsigned char colParity;
 	unsigned lineParity;
 	unsigned lineParityPrime;
-} yaffs_ECCOther;
+} __attribute__ ((__packed__)) yaffs_ECCOther;
 
 void yaffs_ECCCalculate(const unsigned char *data, unsigned char *ecc);
 int yaffs_ECCCorrect(unsigned char *data, unsigned char *read_ecc,
diff -uNr linux-2.6.10.orig/fs/yaffs2/yaffs_mtdif2.c linux-2.6.10.nand/fs/yaffs2/yaffs_mtdif2.c
--- linux-2.6.10.orig/fs/yaffs2/yaffs_mtdif2.c	2005-11-24 16:51:17.000000000 +0300
+++ linux-2.6.10.nand/fs/yaffs2/yaffs_mtdif2.c	2005-11-29 16:55:22.000000000 +0300
@@ -66,7 +66,7 @@
 				       data);
 		if (tags)
 			retval =
-			    mtd->write_oob(mtd, addr, mtd->oobsize, &dummy,
+			    mtd->write_oob(mtd, addr, mtd->oobavail, &dummy,
 					   (__u8 *) & pt);
 
 	}
@@ -112,11 +112,11 @@
 				      data);
 		if (tags)
 			retval =
-			    mtd->read_oob(mtd, addr, mtd->oobsize, &dummy,
+			    mtd->read_oob(mtd, addr, mtd->oobavail, &dummy,
 					  dev->spareBuffer);
 	}
-
-	memcpy(&pt, dev->spareBuffer, sizeof(pt));
+	memcpy(&pt, dev->spareBuffer, mtd->oobavail < sizeof(pt) ? 
+			mtd->oobavail : sizeof(pt));
 
 	if (tags)
 		yaffs_UnpackTags2(tags, &pt);
diff -uNr linux-2.6.10.orig/fs/yaffs2/yaffs_packedtags2.h linux-2.6.10.nand/fs/yaffs2/yaffs_packedtags2.h
--- linux-2.6.10.orig/fs/yaffs2/yaffs_packedtags2.h	2005-11-24 16:51:17.000000000 +0300
+++ linux-2.6.10.nand/fs/yaffs2/yaffs_packedtags2.h	2005-11-23 17:30:21.000000000 +0300
@@ -11,12 +11,12 @@
 	unsigned objectId;
 	unsigned chunkId;
 	unsigned byteCount;
-} yaffs_PackedTags2TagsPart;
+} __attribute__((__packed__)) yaffs_PackedTags2TagsPart;
 
 typedef struct {
 	yaffs_PackedTags2TagsPart t;
 	yaffs_ECCOther ecc;
-} yaffs_PackedTags2;
+} __attribute__((__packed__)) yaffs_PackedTags2;
 
 void yaffs_PackTags2(yaffs_PackedTags2 * pt, const yaffs_ExtendedTags * t);
 void yaffs_UnpackTags2(yaffs_ExtendedTags * t, yaffs_PackedTags2 * pt);





More information about the linux-mtd mailing list