Check the return value of mtd->write_ecc() calls.
[yaffs2.git] / yaffs_tagscompat.c
index d7c0fd1144540320fef6ce62418fa885267c9d89..b9970eda0b82d88a407c02e929309e7f884519ec 100644 (file)
@@ -10,7 +10,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- * $Id: yaffs_tagscompat.c,v 1.1 2004-11-03 08:14:07 charles Exp $
+ * $Id: yaffs_tagscompat.c,v 1.3 2005-07-31 06:47:12 marty Exp $
  */
 
 #include "yaffs_guts.h"
 #include "yaffs_ecc.h"
 
 static void yaffs_HandleReadDataError(yaffs_Device *dev,int chunkInNAND);
+#ifdef NOTYET
 static void yaffs_CheckWrittenBlock(yaffs_Device *dev,int chunkInNAND);
 static void yaffs_HandleWriteChunkOk(yaffs_Device *dev,int chunkInNAND,const __u8 *data, const yaffs_Spare *spare);
 static void yaffs_HandleUpdateChunk(yaffs_Device *dev,int chunkInNAND, const yaffs_Spare *spare);
 static void yaffs_HandleWriteChunkError(yaffs_Device *dev,int chunkInNAND);
-
+#endif
 
 
 static const char yaffs_countBitsTable[256] =
@@ -305,8 +306,7 @@ static int yaffs_ReadChunkFromNAND(struct yaffs_DeviceStruct *dev,
        return retVal;
 }
 
-
-
+#ifdef NOTYET
 static int yaffs_CheckChunkErased(struct yaffs_DeviceStruct *dev,int chunkInNAND)
 {
 
@@ -331,7 +331,7 @@ static int yaffs_CheckChunkErased(struct yaffs_DeviceStruct *dev,int chunkInNAND
        return YAFFS_OK;
 
 }
-
+#endif
 
 #if 0
 int yaffs_EraseBlockInNAND(struct yaffs_DeviceStruct *dev,int blockInNAND)
@@ -480,6 +480,7 @@ static void yaffs_HandleReadDataError(yaffs_Device *dev,int chunkInNAND)
 }
 
 
+#ifdef NOTYET
 static void yaffs_CheckWrittenBlock(yaffs_Device *dev,int chunkInNAND)
 {
 }
@@ -530,6 +531,7 @@ static int yaffs_VerifyCompare(const __u8 *d0, const __u8 * d1, const yaffs_Spar
 
        return 1;
 }
+#endif /* NOTYET */
 
 #if 0
 typedef struct
@@ -587,6 +589,13 @@ int yaffs_TagsCompatabilityWriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkI
                tags.byteCount = eTags->byteCount;
                tags.serialNumber = eTags->serialNumber;
                
+// NCB
+               if (!dev->useNANDECC && data)
+               {
+                   yaffs_CalcECC(data,&spare);
+               }
+
+// /NCB
                 yaffs_LoadTagsIntoSpare(&spare,&tags);
                
        }
@@ -602,8 +611,21 @@ int yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunk
        yaffs_Tags tags;
        yaffs_ECCResult eccResult;
        
+// NCB
+     static yaffs_Spare spareFF;
+     static int init;
+     
+     if(!init)
+     {
+            memset(&spareFF,0xFF,sizeof(spareFF));
+            init = 1;
+     }
+// /NCB
        if(yaffs_ReadChunkFromNAND(dev,chunkInNAND,data,&spare,&eccResult,1))
        {
+// added NCB - eTags may be NULL
+               if (eTags) {
+
                 int deleted = (yaffs_CountBits(spare.pageStatus) < 7) ? 1 : 0;
                        
                 yaffs_GetTagsFromSpare(dev,&spare,&tags);
@@ -616,6 +638,10 @@ int yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunk
                 eTags->eccResult = eccResult;
                 eTags->blockBad = 0; // We're reading it therefore it is not a bad block
                 
+// NCB added 18/2/2005
+                eTags->chunkUsed = (memcmp(&spareFF,&spare,sizeof(spareFF)) != 0) ? 1:0;
+               }
+                
                 return YAFFS_OK;
        }
        else