Some fixes and add NOR integrity code
[yaffs2.git] / yaffs_tagscompat.c
index aed101e45be5aa7421396f2d57ae54326d49c5d9..f6c40535088c05a9317c19a8324980ef6d5fa028 100644 (file)
@@ -418,7 +418,16 @@ int yaffs_TagsCompatabilityWriteChunkWithTagsToNAND(yaffs_Device * dev,
        } else {
                tags.objectId = eTags->objectId;
                tags.chunkId = eTags->chunkId;
-               tags.byteCount = eTags->byteCount;
+
+               tags.byteCountLSB = eTags->byteCount & 0x3ff;
+               
+               if(dev->nDataBytesPerChunk >= 1024){
+                       tags.byteCountMSB = (eTags->byteCount >> 10) & 3;
+               } else {
+                       tags.byteCountMSB = 3;
+               }
+               
+
                tags.serialNumber = eTags->serialNumber;
 
                if (!dev->useNANDECC && data) {
@@ -439,7 +448,7 @@ int yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(yaffs_Device * dev,
 
        yaffs_Spare spare;
        yaffs_Tags tags;
-       yaffs_ECCResult eccResult;
+       yaffs_ECCResult eccResult = YAFFS_ECC_RESULT_UNKNOWN;
 
        static yaffs_Spare spareFF;
        static int init = 0;
@@ -470,7 +479,11 @@ int yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(yaffs_Device * dev,
 
                                eTags->objectId = tags.objectId;
                                eTags->chunkId = tags.chunkId;
-                               eTags->byteCount = tags.byteCount;
+                               eTags->byteCount = tags.byteCountLSB;
+
+                               if(dev->nDataBytesPerChunk >= 1024)
+                                       eTags->byteCount |= (((unsigned) tags.byteCountMSB) << 10);
+
                                eTags->serialNumber = tags.serialNumber;
                        }
                }