Clear creation counters when deinitialising.
[yaffs2.git] / yaffs_nand.c
index b919da0..0a76ca0 100644 (file)
@@ -9,28 +9,30 @@
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
- *
  */
+
 const char *yaffs_nand_c_version =
-    "$Id: yaffs_nand.c,v 1.6 2007-02-12 16:55:26 wookey Exp $";
+       "$Id: yaffs_nand.c,v 1.11 2009-09-09 03:03:01 charles Exp $";
 
 #include "yaffs_nand.h"
 #include "yaffs_tagscompat.h"
 #include "yaffs_tagsvalidity.h"
 
+#include "yaffs_getblockinfo.h"
 
-int yaffs_ReadChunkWithTagsFromNAND(yaffs_Device * dev, int chunkInNAND,
-                                          __u8 * buffer,
-                                          yaffs_ExtendedTags * tags)
+int yaffs_ReadChunkWithTagsFromNAND(yaffs_Device *dev, int chunkInNAND,
+                                          __u8 *buffer,
+                                          yaffs_ExtendedTags *tags)
 {
        int result;
        yaffs_ExtendedTags localTags;
-       
+
        int realignedChunkInNAND = chunkInNAND - dev->chunkOffset;
-       
+
+       dev->nPageReads++;
+
        /* If there are no tags provided, use local tags to get prioritised gc working */
-       if(!tags)
+       if (!tags)
                tags = &localTags;
 
        if (dev->readChunkWithTagsFromNAND)
@@ -40,25 +42,28 @@ int yaffs_ReadChunkWithTagsFromNAND(yaffs_Device * dev, int chunkInNAND,
                result = yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(dev,
                                                                        realignedChunkInNAND,
                                                                        buffer,
-                                                                       tags);  
-       if(tags && 
-          tags->eccResult > YAFFS_ECC_RESULT_NO_ERROR){
-       
+                                                                       tags);
+       if (tags &&
+          tags->eccResult > YAFFS_ECC_RESULT_NO_ERROR) {
+
                yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev, chunkInNAND/dev->nChunksPerBlock);
-                yaffs_HandleChunkError(dev,bi);
+               yaffs_HandleChunkError(dev, bi);
        }
-                                                               
+
        return result;
 }
 
-int yaffs_WriteChunkWithTagsToNAND(yaffs_Device * dev,
+int yaffs_WriteChunkWithTagsToNAND(yaffs_Device *dev,
                                                   int chunkInNAND,
-                                                  const __u8 * buffer,
-                                                  yaffs_ExtendedTags * tags)
+                                                  const __u8 *buffer,
+                                                  yaffs_ExtendedTags *tags)
 {
+
+       dev->nPageWrites++;
+
        chunkInNAND -= dev->chunkOffset;
 
-       
+
        if (tags) {
                tags->sequenceNumber = dev->sequenceNumber;
                tags->chunkUsed = 1;
@@ -85,21 +90,21 @@ int yaffs_WriteChunkWithTagsToNAND(yaffs_Device * dev,
                                                                       tags);
 }
 
-int yaffs_MarkBlockBad(yaffs_Device * dev, int blockNo)
+int yaffs_MarkBlockBad(yaffs_Device *dev, int blockNo)
 {
        blockNo -= dev->blockOffset;
 
-;
+
        if (dev->markNANDBlockBad)
                return dev->markNANDBlockBad(dev, blockNo);
        else
                return yaffs_TagsCompatabilityMarkNANDBlockBad(dev, blockNo);
 }
 
-int yaffs_QueryInitialBlockState(yaffs_Device * dev,
+int yaffs_QueryInitialBlockState(yaffs_Device *dev,
                                                 int blockNo,
-                                                yaffs_BlockState * state,
-                                                unsigned *sequenceNumber)
+                                                yaffs_BlockState *state,
+                                                __u32 *sequenceNumber)
 {
        blockNo -= dev->blockOffset;
 
@@ -119,8 +124,8 @@ int yaffs_EraseBlockInNAND(struct yaffs_DeviceStruct *dev,
 
        blockInNAND -= dev->blockOffset;
 
-
        dev->nBlockErasures++;
+
        result = dev->eraseBlockInNAND(dev, blockInNAND);
 
        return result;
@@ -132,4 +137,4 @@ int yaffs_InitialiseNAND(struct yaffs_DeviceStruct *dev)
 }
 
 
+