Major whitespace/style changes to match Linux checkpatch.pl code style
authorwookey <wookey>
Fri, 6 Mar 2009 17:20:49 +0000 (17:20 +0000)
committerwookey <wookey>
Fri, 6 Mar 2009 17:20:49 +0000 (17:20 +0000)
30 files changed:
devextras.h
moduleconfig.h
yaffs_checkptrw.c
yaffs_checkptrw.h
yaffs_ecc.c
yaffs_ecc.h
yaffs_fs.c
yaffs_getblockinfo.h
yaffs_guts.c
yaffs_guts.h
yaffs_mtdif.c
yaffs_mtdif.h
yaffs_mtdif1.c
yaffs_mtdif1.h
yaffs_mtdif2.c
yaffs_mtdif2.h
yaffs_nand.c
yaffs_nand.h
yaffs_nandemul2k.h
yaffs_packedtags1.c
yaffs_packedtags1.h
yaffs_packedtags2.c
yaffs_packedtags2.h
yaffs_qsort.c
yaffs_qsort.h
yaffs_tagscompat.c
yaffs_tagscompat.h
yaffs_tagsvalidity.c
yaffs_tagsvalidity.h
yportenv.h

index a9366fd..35c3446 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
  *
  * Copyright (C) 2002-2007 Aleph One Ltd.
  *   for Toby Churchill Ltd and Brightstar Engineering
@@ -24,7 +24,7 @@
 #define __EXTRAS_H__
 
 
-#if !(defined __KERNEL__) 
+#if !(defined __KERNEL__)
 
 /* Definition of types */
 typedef unsigned char __u8;
@@ -34,7 +34,7 @@ typedef unsigned __u32;
 #endif
 
 /*
- * This is a simple doubly linked list implementation that matches the 
+ * This is a simple doubly linked list implementation that matches the
  * way the Linux kernel doubly linked list implementation works.
  */
 
@@ -46,7 +46,7 @@ struct ylist_head {
 
 /* Initialise a static list */
 #define YLIST_HEAD(name) \
-struct ylist_head name = { &(name),&(name)}
+struct ylist_head name = { &(name), &(name)}
 
 
 
@@ -55,32 +55,32 @@ struct ylist_head name = { &(name),&(name)}
 do { \
  (p)->next = (p);\
  (p)->prev = (p); \
-} while(0)
+} while (0)
 
 
 /* Add an element to a list */
-static __inline__ void ylist_add(struct ylist_head *newEntry, 
-                                 struct ylist_head *list)
+static __inline__ void ylist_add(struct ylist_head *newEntry,
+                               struct ylist_head *list)
 {
-        struct ylist_head *listNext = list->next;
-        
-        list->next = newEntry;
-        newEntry->prev = list;
+       struct ylist_head *listNext = list->next;
+
+       list->next = newEntry;
+       newEntry->prev = list;
        newEntry->next = listNext;
        listNext->prev = newEntry;
-       
+
 }
 
-static __inline__ void ylist_add_tail(struct ylist_head *newEntry, 
+static __inline__ void ylist_add_tail(struct ylist_head *newEntry,
                                 struct ylist_head *list)
 {
        struct ylist_head *listPrev = list->prev;
-       
+
        list->prev = newEntry;
        newEntry->next = list;
        newEntry->prev = listPrev;
        listPrev->next = newEntry;
-       
+
 }
 
 
@@ -88,35 +88,35 @@ static __inline__ void ylist_add_tail(struct ylist_head *newEntry,
  * reinitialising the links.of the entry*/
 static __inline__ void ylist_del(struct ylist_head *entry)
 {
-        struct ylist_head *listNext = entry->next;
-        struct ylist_head *listPrev = entry->prev;
-        
-        listNext->prev = listPrev;
-        listPrev->next = listNext;
-        
+       struct ylist_head *listNext = entry->next;
+       struct ylist_head *listPrev = entry->prev;
+
+       listNext->prev = listPrev;
+       listPrev->next = listNext;
+
 }
 
 static __inline__ void ylist_del_init(struct ylist_head *entry)
 {
-        ylist_del(entry);
-        entry->next = entry->prev = entry;
+       ylist_del(entry);
+       entry->next = entry->prev = entry;
 }
 
 
 /* Test if the list is empty */
 static __inline__ int ylist_empty(struct ylist_head *entry)
 {
-        return (entry->next == entry);
+       return (entry->next == entry);
 }
 
 
 /* ylist_entry takes a pointer to a list entry and offsets it to that
  * we can find a pointer to the object it is embedded in.
  */
+
+
 #define ylist_entry(entry, type, member) \
-        ((type *)((char *)(entry)-(unsigned long)(&((type *)NULL)->member)))
+       ((type *)((char *)(entry)-(unsigned long)(&((type *)NULL)->member)))
 
 
 /* ylist_for_each and list_for_each_safe  iterate over lists.
@@ -124,11 +124,11 @@ static __inline__ int ylist_empty(struct ylist_head *entry)
  */
 
 #define ylist_for_each(itervar, list) \
-        for (itervar = (list)->next; itervar != (list); itervar = itervar->next )
+       for (itervar = (list)->next; itervar != (list); itervar = itervar->next)
 
-#define ylist_for_each_safe(itervar,saveVar, list) \
-        for (itervar = (list)->next, saveVar = (list)->next->next; itervar != (list); \
-         itervar = saveVar, saveVar = saveVar->next)
+#define ylist_for_each_safe(itervar, saveVar, list) \
+       for (itervar = (list)->next, saveVar = (list)->next->next; \
+               itervar != (list); itervar = saveVar, saveVar = saveVar->next)
 
 
 #if !(defined __KERNEL__)
@@ -143,15 +143,15 @@ static __inline__ int ylist_empty(struct ylist_head *entry)
 /* File types */
 
 
-#define DT_UNKNOWN      0
-#define DT_FIFO         1
-#define DT_CHR          2
+#define DT_UNKNOWN     0
+#define DT_FIFO                1
+#define DT_CHR         2
 #define DT_DIR         4
 #define DT_BLK         6
-#define DT_REG          8
-#define DT_LNK          10
-#define DT_SOCK         12
-#define DT_WHT          14
+#define DT_REG         8
+#define DT_LNK         10
+#define DT_SOCK                12
+#define DT_WHT         14
 
 
 #ifndef WIN32
@@ -162,8 +162,8 @@ static __inline__ int ylist_empty(struct ylist_head *entry)
  * Attribute flags.  These should be or-ed together to figure out what
  * has been changed!
  */
-#define ATTR_MODE       1
-#define ATTR_UID        2
+#define ATTR_MODE      1
+#define ATTR_UID       2
 #define ATTR_GID       4
 #define ATTR_SIZE      8
 #define ATTR_ATIME     16
@@ -179,7 +179,7 @@ struct iattr {
        unsigned ia_atime;
        unsigned ia_mtime;
        unsigned ia_ctime;
-        unsigned int ia_attr_flags;
+       unsigned int ia_attr_flags;
 };
 
 #endif
index ac5af6f..a344baf 100644 (file)
 
 /* Default: Not selected */
 /* Meaning: Yaffs does its own ECC, rather than using MTD ECC */
-//#define CONFIG_YAFFS_DOES_ECC
+/* #define CONFIG_YAFFS_DOES_ECC */
 
 /* Default: Not selected */
 /* Meaning: ECC byte order is 'wrong'.  Only meaningful if */
 /*          CONFIG_YAFFS_DOES_ECC is set */
-//#define CONFIG_YAFFS_ECC_WRONG_ORDER
+/* #define CONFIG_YAFFS_ECC_WRONG_ORDER */
 
 /* Default: Selected */
 /* Meaning: Disables testing whether chunks are erased before writing to them*/
@@ -58,7 +58,7 @@ MTD versions in yaffs_mtdif1.c.
 */
 /* Default: Not selected */
 /* Meaning: Use older-style on-NAND data format with pageStatus byte */
-//#define CONFIG_YAFFS_9BYTE_TAGS
+/* #define CONFIG_YAFFS_9BYTE_TAGS */
 
 #endif /* YAFFS_OUT_OF_TREE */
 
index 7ed37a0..40d7923 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 const char *yaffs_checkptrw_c_version =
-    "$Id: yaffs_checkptrw.c,v 1.17 2008-08-12 22:51:57 charles Exp $";
+       "$Id: yaffs_checkptrw.c,v 1.18 2009-03-06 17:20:49 wookey Exp $";
 
 
 #include "yaffs_checkptrw.h"
@@ -20,40 +20,35 @@ const char *yaffs_checkptrw_c_version =
 
 static int yaffs_CheckpointSpaceOk(yaffs_Device *dev)
 {
-
        int blocksAvailable = dev->nErasedBlocks - dev->nReservedBlocks;
 
        T(YAFFS_TRACE_CHECKPOINT,
                (TSTR("checkpt blocks available = %d" TENDSTR),
                blocksAvailable));
 
-
        return (blocksAvailable <= 0) ? 0 : 1;
 }
 
 
 static int yaffs_CheckpointErase(yaffs_Device *dev)
 {
-
        int i;
 
-
-       if(!dev->eraseBlockInNAND)
+       if (!dev->eraseBlockInNAND)
                return 0;
-       T(YAFFS_TRACE_CHECKPOINT,(TSTR("checking blocks %d to %d"TENDSTR),
-               dev->internalStartBlock,dev->internalEndBlock));
-
-       for(i = dev->internalStartBlock; i <= dev->internalEndBlock; i++) {
-               yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev,i);
-               if(bi->blockState == YAFFS_BLOCK_STATE_CHECKPOINT){
-                       T(YAFFS_TRACE_CHECKPOINT,(TSTR("erasing checkpt block %d"TENDSTR),i));
-                       if(dev->eraseBlockInNAND(dev,i- dev->blockOffset /* realign */)){
+       T(YAFFS_TRACE_CHECKPOINT, (TSTR("checking blocks %d to %d"TENDSTR),
+               dev->internalStartBlock, dev->internalEndBlock));
+
+       for (i = dev->internalStartBlock; i <= dev->internalEndBlock; i++) {
+               yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev, i);
+               if (bi->blockState == YAFFS_BLOCK_STATE_CHECKPOINT) {
+                       T(YAFFS_TRACE_CHECKPOINT, (TSTR("erasing checkpt block %d"TENDSTR), i));
+                       if (dev->eraseBlockInNAND(dev, i - dev->blockOffset /* realign */)) {
                                bi->blockState = YAFFS_BLOCK_STATE_EMPTY;
                                dev->nErasedBlocks++;
                                dev->nFreeChunks += dev->nChunksPerBlock;
-                       }
-                       else {
-                               dev->markNANDBlockBad(dev,i);
+                       } else {
+                               dev->markNANDBlockBad(dev, i);
                                bi->blockState = YAFFS_BLOCK_STATE_DEAD;
                        }
                }
@@ -71,23 +66,23 @@ static void yaffs_CheckpointFindNextErasedBlock(yaffs_Device *dev)
        int blocksAvailable = dev->nErasedBlocks - dev->nReservedBlocks;
        T(YAFFS_TRACE_CHECKPOINT,
                (TSTR("allocating checkpt block: erased %d reserved %d avail %d next %d "TENDSTR),
-               dev->nErasedBlocks,dev->nReservedBlocks,blocksAvailable,dev->checkpointNextBlock));
+               dev->nErasedBlocks, dev->nReservedBlocks, blocksAvailable, dev->checkpointNextBlock));
 
-       if(dev->checkpointNextBlock >= 0 &&
-          dev->checkpointNextBlock <= dev->internalEndBlock &&
-          blocksAvailable > 0){
+       if (dev->checkpointNextBlock >= 0 &&
+                       dev->checkpointNextBlock <= dev->internalEndBlock &&
+                       blocksAvailable > 0) {
 
-               for(i = dev->checkpointNextBlock; i <= dev->internalEndBlock; i++){
-                       yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev,i);
-                       if(bi->blockState == YAFFS_BLOCK_STATE_EMPTY){
+               for (i = dev->checkpointNextBlock; i <= dev->internalEndBlock; i++) {
+                       yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev, i);
+                       if (bi->blockState == YAFFS_BLOCK_STATE_EMPTY) {
                                dev->checkpointNextBlock = i + 1;
                                dev->checkpointCurrentBlock = i;
-                               T(YAFFS_TRACE_CHECKPOINT,(TSTR("allocating checkpt block %d"TENDSTR),i));
+                               T(YAFFS_TRACE_CHECKPOINT, (TSTR("allocating checkpt block %d"TENDSTR), i));
                                return;
                        }
                }
        }
-       T(YAFFS_TRACE_CHECKPOINT,(TSTR("out of checkpt blocks"TENDSTR)));
+       T(YAFFS_TRACE_CHECKPOINT, (TSTR("out of checkpt blocks"TENDSTR)));
 
        dev->checkpointNextBlock = -1;
        dev->checkpointCurrentBlock = -1;
@@ -98,30 +93,31 @@ static void yaffs_CheckpointFindNextCheckpointBlock(yaffs_Device *dev)
        int  i;
        yaffs_ExtendedTags tags;
 
-       T(YAFFS_TRACE_CHECKPOINT,(TSTR("find next checkpt block: start:  blocks %d next %d" TENDSTR),
+       T(YAFFS_TRACE_CHECKPOINT, (TSTR("find next checkpt block: start:  blocks %d next %d" TENDSTR),
                dev->blocksInCheckpoint, dev->checkpointNextBlock));
 
-       if(dev->blocksInCheckpoint < dev->checkpointMaxBlocks)
-               for(i = dev->checkpointNextBlock; i <= dev->internalEndBlock; i++){
+       if (dev->blocksInCheckpoint < dev->checkpointMaxBlocks)
+               for (i = dev->checkpointNextBlock; i <= dev->internalEndBlock; i++) {
                        int chunk = i * dev->nChunksPerBlock;
                        int realignedChunk = chunk - dev->chunkOffset;
 
-                       dev->readChunkWithTagsFromNAND(dev,realignedChunk,NULL,&tags);
-                       T(YAFFS_TRACE_CHECKPOINT,(TSTR("find next checkpt block: search: block %d oid %d seq %d eccr %d" TENDSTR),
-                               i, tags.objectId,tags.sequenceNumber,tags.eccResult));
+                       dev->readChunkWithTagsFromNAND(dev, realignedChunk,
+                                       NULL, &tags);
+                       T(YAFFS_TRACE_CHECKPOINT, (TSTR("find next checkpt block: search: block %d oid %d seq %d eccr %d" TENDSTR),
+                               i, tags.objectId, tags.sequenceNumber, tags.eccResult));
 
-                       if(tags.sequenceNumber == YAFFS_SEQUENCE_CHECKPOINT_DATA){
+                       if (tags.sequenceNumber == YAFFS_SEQUENCE_CHECKPOINT_DATA) {
                                /* Right kind of block */
                                dev->checkpointNextBlock = tags.objectId;
                                dev->checkpointCurrentBlock = i;
                                dev->checkpointBlockList[dev->blocksInCheckpoint] = i;
                                dev->blocksInCheckpoint++;
-                               T(YAFFS_TRACE_CHECKPOINT,(TSTR("found checkpt block %d"TENDSTR),i));
+                               T(YAFFS_TRACE_CHECKPOINT, (TSTR("found checkpt block %d"TENDSTR), i));
                                return;
                        }
                }
 
-       T(YAFFS_TRACE_CHECKPOINT,(TSTR("found no more checkpt blocks"TENDSTR)));
+       T(YAFFS_TRACE_CHECKPOINT, (TSTR("found no more checkpt blocks"TENDSTR)));
 
        dev->checkpointNextBlock = -1;
        dev->checkpointCurrentBlock = -1;
@@ -133,17 +129,17 @@ int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
 
        /* Got the functions we need? */
        if (!dev->writeChunkWithTagsToNAND ||
-           !dev->readChunkWithTagsFromNAND ||
-           !dev->eraseBlockInNAND ||
-           !dev->markNANDBlockBad)
+                       !dev->readChunkWithTagsFromNAND ||
+                       !dev->eraseBlockInNAND ||
+                       !dev->markNANDBlockBad)
                return 0;
 
-       if(forWriting && !yaffs_CheckpointSpaceOk(dev))
+       if (forWriting && !yaffs_CheckpointSpaceOk(dev))
                return 0;
 
-       if(!dev->checkpointBuffer)
+       if (!dev->checkpointBuffer)
                dev->checkpointBuffer = YMALLOC_DMA(dev->totalBytesPerChunk);
-       if(!dev->checkpointBuffer)
+       if (!dev->checkpointBuffer)
                return 0;
 
 
@@ -159,12 +155,10 @@ int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
        dev->checkpointNextBlock = dev->internalStartBlock;
 
        /* Erase all the blocks in the checkpoint area */
-       if(forWriting){
-               memset(dev->checkpointBuffer,0,dev->nDataBytesPerChunk);
+       if (forWriting) {
+               memset(dev->checkpointBuffer, 0, dev->nDataBytesPerChunk);
                dev->checkpointByteOffset = 0;
                return yaffs_CheckpointErase(dev);
-
-
        } else {
                int i;
                /* Set to a value that will kick off a read */
@@ -174,7 +168,7 @@ int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
                dev->blocksInCheckpoint = 0;
                dev->checkpointMaxBlocks = (dev->internalEndBlock - dev->internalStartBlock)/16 + 2;
                dev->checkpointBlockList = YMALLOC(sizeof(int) * dev->checkpointMaxBlocks);
-               for(i = 0; i < dev->checkpointMaxBlocks; i++)
+               for (i = 0; i < dev->checkpointMaxBlocks; i++)
                        dev->checkpointBlockList[i] = -1;
        }
 
@@ -191,18 +185,17 @@ int yaffs_GetCheckpointSum(yaffs_Device *dev, __u32 *sum)
 
 static int yaffs_CheckpointFlushBuffer(yaffs_Device *dev)
 {
-
        int chunk;
        int realignedChunk;
 
        yaffs_ExtendedTags tags;
 
-       if(dev->checkpointCurrentBlock < 0){
+       if (dev->checkpointCurrentBlock < 0) {
                yaffs_CheckpointFindNextErasedBlock(dev);
                dev->checkpointCurrentChunk = 0;
        }
 
-       if(dev->checkpointCurrentBlock < 0)
+       if (dev->checkpointCurrentBlock < 0)
                return 0;
 
        tags.chunkDeleted = 0;
@@ -210,10 +203,10 @@ static int yaffs_CheckpointFlushBuffer(yaffs_Device *dev)
        tags.chunkId = dev->checkpointPageSequence + 1;
        tags.sequenceNumber =  YAFFS_SEQUENCE_CHECKPOINT_DATA;
        tags.byteCount = dev->nDataBytesPerChunk;
-       if(dev->checkpointCurrentChunk == 0){
+       if (dev->checkpointCurrentChunk == 0) {
                /* First chunk we write for the block? Set block state to
                   checkpoint */
-               yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev,dev->checkpointCurrentBlock);
+               yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev, dev->checkpointCurrentBlock);
                bi->blockState = YAFFS_BLOCK_STATE_CHECKPOINT;
                dev->blocksInCheckpoint++;
        }
@@ -221,28 +214,29 @@ static int yaffs_CheckpointFlushBuffer(yaffs_Device *dev)
        chunk = dev->checkpointCurrentBlock * dev->nChunksPerBlock + dev->checkpointCurrentChunk;
 
 
-       T(YAFFS_TRACE_CHECKPOINT,(TSTR("checkpoint wite buffer nand %d(%d:%d) objid %d chId %d" TENDSTR),
-               chunk, dev->checkpointCurrentBlock, dev->checkpointCurrentChunk,tags.objectId,tags.chunkId));
+       T(YAFFS_TRACE_CHECKPOINT, (TSTR("checkpoint wite buffer nand %d(%d:%d) objid %d chId %d" TENDSTR),
+               chunk, dev->checkpointCurrentBlock, dev->checkpointCurrentChunk, tags.objectId, tags.chunkId));
 
        realignedChunk = chunk - dev->chunkOffset;
 
-       dev->writeChunkWithTagsToNAND(dev,realignedChunk,dev->checkpointBuffer,&tags);
+       dev->writeChunkWithTagsToNAND(dev, realignedChunk,
+                       dev->checkpointBuffer, &tags);
        dev->checkpointByteOffset = 0;
        dev->checkpointPageSequence++;
        dev->checkpointCurrentChunk++;
-       if(dev->checkpointCurrentChunk >= dev->nChunksPerBlock){
+       if (dev->checkpointCurrentChunk >= dev->nChunksPerBlock) {
                dev->checkpointCurrentChunk = 0;
                dev->checkpointCurrentBlock = -1;
        }
-       memset(dev->checkpointBuffer,0,dev->nDataBytesPerChunk);
+       memset(dev->checkpointBuffer, 0, dev->nDataBytesPerChunk);
 
        return 1;
 }
 
 
-int yaffs_CheckpointWrite(yaffs_Device *dev,const void *data, int nBytes)
+int yaffs_CheckpointWrite(yaffs_Device *dev, const void *data, int nBytes)
 {
-       int i=0;
+       int i = 0;
        int ok = 1;
 
 
@@ -250,17 +244,14 @@ int yaffs_CheckpointWrite(yaffs_Device *dev,const void *data, int nBytes)
 
 
 
-       if(!dev->checkpointBuffer)
+       if (!dev->checkpointBuffer)
                return 0;
 
-       if(!dev->checkpointOpenForWrite)
+       if (!dev->checkpointOpenForWrite)
                return -1;
 
-       while(i < nBytes && ok) {
-
-
-
-               dev->checkpointBuffer[dev->checkpointByteOffset] = *dataBytes ;
+       while (i < nBytes && ok) {
+               dev->checkpointBuffer[dev->checkpointByteOffset] = *dataBytes;
                dev->checkpointSum += *dataBytes;
                dev->checkpointXor ^= *dataBytes;
 
@@ -270,18 +261,17 @@ int yaffs_CheckpointWrite(yaffs_Device *dev,const void *data, int nBytes)
                dev->checkpointByteCount++;
 
 
-               if(dev->checkpointByteOffset < 0 ||
+               if (dev->checkpointByteOffset < 0 ||
                   dev->checkpointByteOffset >= dev->nDataBytesPerChunk)
                        ok = yaffs_CheckpointFlushBuffer(dev);
-
        }
 
-       return  i;
+       return i;
 }
 
 int yaffs_CheckpointRead(yaffs_Device *dev, void *data, int nBytes)
 {
-       int i=0;
+       int i = 0;
        int ok = 1;
        yaffs_ExtendedTags tags;
 
@@ -291,53 +281,54 @@ int yaffs_CheckpointRead(yaffs_Device *dev, void *data, int nBytes)
 
        __u8 *dataBytes = (__u8 *)data;
 
-       if(!dev->checkpointBuffer)
+       if (!dev->checkpointBuffer)
                return 0;
 
-       if(dev->checkpointOpenForWrite)
+       if (dev->checkpointOpenForWrite)
                return -1;
 
-       while(i < nBytes && ok) {
+       while (i < nBytes && ok) {
 
 
-               if(dev->checkpointByteOffset < 0 ||
-                  dev->checkpointByteOffset >= dev->nDataBytesPerChunk) {
+               if (dev->checkpointByteOffset < 0 ||
+                       dev->checkpointByteOffset >= dev->nDataBytesPerChunk) {
 
-                       if(dev->checkpointCurrentBlock < 0){
+                       if (dev->checkpointCurrentBlock < 0) {
                                yaffs_CheckpointFindNextCheckpointBlock(dev);
                                dev->checkpointCurrentChunk = 0;
                        }
 
-                       if(dev->checkpointCurrentBlock < 0)
+                       if (dev->checkpointCurrentBlock < 0)
                                ok = 0;
                        else {
-
-                               chunk = dev->checkpointCurrentBlock * dev->nChunksPerBlock +
-                                         dev->checkpointCurrentChunk;
+                               chunk = dev->checkpointCurrentBlock *
+                                       dev->nChunksPerBlock +
+                                       dev->checkpointCurrentChunk;
 
                                realignedChunk = chunk - dev->chunkOffset;
 
-                               /* read in the next chunk */
-                               /* printf("read checkpoint page %d\n",dev->checkpointPage); */
-                               dev->readChunkWithTagsFromNAND(dev, realignedChunk,
-                                                              dev->checkpointBuffer,
-                                                             &tags);
+                               /* read in the next chunk */
+                               /* printf("read checkpoint page %d\n",dev->checkpointPage); */
+                               dev->readChunkWithTagsFromNAND(dev,
+                                               realignedChunk,
+                                               dev->checkpointBuffer,
+                                               &tags);
 
-                               if(tags.chunkId != (dev->checkpointPageSequence + 1) ||
-                                  tags.eccResult > YAFFS_ECC_RESULT_FIXED ||
-                                  tags.sequenceNumber != YAFFS_SEQUENCE_CHECKPOINT_DATA)
-                                  ok = 0;
+                               if (tags.chunkId != (dev->checkpointPageSequence + 1) ||
+                                       tags.eccResult > YAFFS_ECC_RESULT_FIXED ||
+                                       tags.sequenceNumber != YAFFS_SEQUENCE_CHECKPOINT_DATA)
+                                       ok = 0;
 
                                dev->checkpointByteOffset = 0;
                                dev->checkpointPageSequence++;
                                dev->checkpointCurrentChunk++;
 
-                               if(dev->checkpointCurrentChunk >= dev->nChunksPerBlock)
+                               if (dev->checkpointCurrentChunk >= dev->nChunksPerBlock)
                                        dev->checkpointCurrentBlock = -1;
                        }
                }
 
-               if(ok){
+               if (ok) {
                        *dataBytes = dev->checkpointBuffer[dev->checkpointByteOffset];
                        dev->checkpointSum += *dataBytes;
                        dev->checkpointXor ^= *dataBytes;
@@ -354,17 +345,17 @@ int yaffs_CheckpointRead(yaffs_Device *dev, void *data, int nBytes)
 int yaffs_CheckpointClose(yaffs_Device *dev)
 {
 
-       if(dev->checkpointOpenForWrite){
-               if(dev->checkpointByteOffset != 0)
+       if (dev->checkpointOpenForWrite) {
+               if (dev->checkpointByteOffset != 0)
                        yaffs_CheckpointFlushBuffer(dev);
        } else {
                int i;
-               for(i = 0; i < dev->blocksInCheckpoint && dev->checkpointBlockList[i] >= 0; i++){
-                       yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev,dev->checkpointBlockList[i]);
-                       if(bi->blockState == YAFFS_BLOCK_STATE_EMPTY)
+               for (i = 0; i < dev->blocksInCheckpoint && dev->checkpointBlockList[i] >= 0; i++) {
+                       yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev, dev->checkpointBlockList[i]);
+                       if (bi->blockState == YAFFS_BLOCK_STATE_EMPTY)
                                bi->blockState = YAFFS_BLOCK_STATE_CHECKPOINT;
                        else {
-                               // Todo this looks odd...
+                               /* Todo this looks odd... */
                        }
                }
                YFREE(dev->checkpointBlockList);
@@ -375,27 +366,25 @@ int yaffs_CheckpointClose(yaffs_Device *dev)
        dev->nErasedBlocks -= dev->blocksInCheckpoint;
 
 
-       T(YAFFS_TRACE_CHECKPOINT,(TSTR("checkpoint byte count %d" TENDSTR),
+       T(YAFFS_TRACE_CHECKPOINT, (TSTR("checkpoint byte count %d" TENDSTR),
                        dev->checkpointByteCount));
 
-       if(dev->checkpointBuffer){
+       if (dev->checkpointBuffer) {
                /* free the buffer */
                YFREE(dev->checkpointBuffer);
                dev->checkpointBuffer = NULL;
                return 1;
-       }
-       else
+       } else
                return 0;
-
 }
 
 int yaffs_CheckpointInvalidateStream(yaffs_Device *dev)
 {
        /* Erase the first checksum block */
 
-       T(YAFFS_TRACE_CHECKPOINT,(TSTR("checkpoint invalidate"TENDSTR)));
+       T(YAFFS_TRACE_CHECKPOINT, (TSTR("checkpoint invalidate"TENDSTR)));
 
-       if(!yaffs_CheckpointSpaceOk(dev))
+       if (!yaffs_CheckpointSpaceOk(dev))
                return 0;
 
        return yaffs_CheckpointErase(dev);
index d3ff174..5d426ea 100644 (file)
@@ -20,9 +20,9 @@
 
 int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting);
 
-int yaffs_CheckpointWrite(yaffs_Device *dev,const void *data, int nBytes);
+int yaffs_CheckpointWrite(yaffs_Device *dev, const void *data, int nBytes);
 
-int yaffs_CheckpointRead(yaffs_Device *dev,void *data, int nBytes);
+int yaffs_CheckpointRead(yaffs_Device *dev, void *data, int nBytes);
 
 int yaffs_GetCheckpointSum(yaffs_Device *dev, __u32 *sum);
 
index 9f5973a..d037e90 100644 (file)
@@ -29,7 +29,7 @@
  */
 
 const char *yaffs_ecc_c_version =
-    "$Id: yaffs_ecc.c,v 1.10 2007-12-13 15:35:17 wookey Exp $";
+       "$Id: yaffs_ecc.c,v 1.11 2009-03-06 17:20:50 wookey Exp $";
 
 #include "yportenv.h"
 
@@ -109,12 +109,10 @@ void yaffs_ECCCalculate(const unsigned char *data, unsigned char *ecc)
                b = column_parity_table[*data++];
                col_parity ^= b;
 
-               if (b & 0x01)   // odd number of bits in the byte
-               {
+               if (b & 0x01) {         /* odd number of bits in the byte */
                        line_parity ^= i;
                        line_parity_prime ^= ~i;
                }
-
        }
 
        ecc[2] = (~col_parity) | 0x03;
@@ -158,7 +156,7 @@ void yaffs_ECCCalculate(const unsigned char *data, unsigned char *ecc)
        ecc[0] = ~t;
 
 #ifdef CONFIG_YAFFS_ECC_WRONG_ORDER
-       // Swap the bytes into the wrong order
+       /* Swap the bytes into the wrong order */
        t = ecc[0];
        ecc[0] = ecc[1];
        ecc[1] = t;
@@ -189,7 +187,7 @@ int yaffs_ECCCorrect(unsigned char *data, unsigned char *read_ecc,
                unsigned bit;
 
 #ifdef CONFIG_YAFFS_ECC_WRONG_ORDER
-               // swap the bytes to correct for the wrong order
+               /* swap the bytes to correct for the wrong order */
                unsigned char t;
 
                t = d0;
@@ -251,7 +249,7 @@ int yaffs_ECCCorrect(unsigned char *data, unsigned char *read_ecc,
  * ECCxxxOther does ECC calcs on arbitrary n bytes of data
  */
 void yaffs_ECCCalculateOther(const unsigned char *data, unsigned nBytes,
-                            yaffs_ECCOther * eccOther)
+                               yaffs_ECCOther *eccOther)
 {
        unsigned int i;
 
@@ -278,8 +276,8 @@ void yaffs_ECCCalculateOther(const unsigned char *data, unsigned nBytes,
 }
 
 int yaffs_ECCCorrectOther(unsigned char *data, unsigned nBytes,
-                         yaffs_ECCOther * read_ecc,
-                         const yaffs_ECCOther * test_ecc)
+                       yaffs_ECCOther *read_ecc,
+                       const yaffs_ECCOther *test_ecc)
 {
        unsigned char cDelta;   /* column parity delta */
        unsigned lDelta;        /* line parity delta */
@@ -294,8 +292,7 @@ int yaffs_ECCCorrectOther(unsigned char *data, unsigned nBytes,
                return 0; /* no error */
 
        if (lDelta == ~lDeltaPrime &&
-           (((cDelta ^ (cDelta >> 1)) & 0x15) == 0x15))
-       {
+           (((cDelta ^ (cDelta >> 1)) & 0x15) == 0x15)) {
                /* Single bit (recoverable) error in data */
 
                bit = 0;
@@ -307,7 +304,7 @@ int yaffs_ECCCorrectOther(unsigned char *data, unsigned nBytes,
                if (cDelta & 0x02)
                        bit |= 0x01;
 
-               if(lDelta >= nBytes)
+               if (lDelta >= nBytes)
                        return -1;
 
                data[lDelta] ^= (1 << bit);
@@ -316,7 +313,7 @@ int yaffs_ECCCorrectOther(unsigned char *data, unsigned nBytes,
        }
 
        if ((yaffs_CountBits32(lDelta) + yaffs_CountBits32(lDeltaPrime) +
-            yaffs_CountBits(cDelta)) == 1) {
+                       yaffs_CountBits(cDelta)) == 1) {
                /* Reccoverable error in ecc */
 
                *read_ecc = *test_ecc;
@@ -326,6 +323,4 @@ int yaffs_ECCCorrectOther(unsigned char *data, unsigned nBytes,
        /* Unrecoverable error */
 
        return -1;
-
 }
-
index 79bc3d1..6076517 100644 (file)
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  */
 
- /*
 * This code implements the ECC algorithm used in SmartMedia.
 *
 * The ECC comprises 22 bits of parity information and is stuffed into 3 bytes.
 * The two unused bit are set to 1.
 * The ECC can correct single bit errors in a 256-byte page of data. Thus, two such ECC
 * blocks are used on a 512-byte NAND page.
 *
 */
+/*
+ * This code implements the ECC algorithm used in SmartMedia.
+ *
+ * The ECC comprises 22 bits of parity information and is stuffed into 3 bytes.
+ * The two unused bit are set to 1.
+ * The ECC can correct single bit errors in a 256-byte page of data. Thus, two such ECC
+ * blocks are used on a 512-byte NAND page.
+ *
+ */
 
 #ifndef __YAFFS_ECC_H__
 #define __YAFFS_ECC_H__
@@ -34,11 +34,11 @@ typedef struct {
 
 void yaffs_ECCCalculate(const unsigned char *data, unsigned char *ecc);
 int yaffs_ECCCorrect(unsigned char *data, unsigned char *read_ecc,
-                    const unsigned char *test_ecc);
+               const unsigned char *test_ecc);
 
 void yaffs_ECCCalculateOther(const unsigned char *data, unsigned nBytes,
-                            yaffs_ECCOther * ecc);
+                       yaffs_ECCOther *ecc);
 int yaffs_ECCCorrectOther(unsigned char *data, unsigned nBytes,
-                         yaffs_ECCOther * read_ecc,
-                         const yaffs_ECCOther * test_ecc);
+                       yaffs_ECCOther *read_ecc,
+                       const yaffs_ECCOther *test_ecc);
 #endif
index 5f0c7b2..376dbdf 100644 (file)
  */
 
 const char *yaffs_fs_c_version =
-    "$Id: yaffs_fs.c,v 1.75 2009-03-05 01:45:28 charles Exp $";
+    "$Id: yaffs_fs.c,v 1.76 2009-03-06 17:20:51 wookey Exp $";
 extern const char *yaffs_guts_c_version;
 
 #include <linux/version.h>
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19))
 #include <linux/config.h>
 #endif
 #include <linux/kernel.h>
@@ -54,7 +54,7 @@ extern const char *yaffs_guts_c_version;
 
 #include "asm/div64.h"
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
 
 #include <linux/statfs.h>      /* Added NCB 15-8-2003 */
 #include <asm/statfs.h>
@@ -70,42 +70,42 @@ extern const char *yaffs_guts_c_version;
 #define        BDEVNAME_SIZE           0
 #define        yaffs_devname(sb, buf)  kdevname(sb->s_dev)
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0))
 /* added NCB 26/5/2006 for 2.4.25-vrs2-tcl1 kernel */
 #define __user
 #endif
 
 #endif
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
-#define YPROC_ROOT  &proc_root
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26))
+#define YPROC_ROOT  (&proc_root)
 #else
 #define YPROC_ROOT  NULL
 #endif
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
 #define WRITE_SIZE_STR "writesize"
-#define WRITE_SIZE(mtd) (mtd)->writesize
+#define WRITE_SIZE(mtd) ((mtd)->writesize)
 #else
 #define WRITE_SIZE_STR "oobblock"
-#define WRITE_SIZE(mtd) (mtd)->oobblock
+#define WRITE_SIZE(mtd) ((mtd)->oobblock)
 #endif
 
-#if(LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 27))
 #define YAFFS_USE_WRITE_BEGIN_END 1
 #else
 #define YAFFS_USE_WRITE_BEGIN_END 0
 #endif
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 28))
 static uint32_t YCALCBLOCKS(uint64_t partition_size, uint32_t block_size)
 {
        uint64_t result = partition_size;
-       do_div(result,block_size);
+       do_div(result, block_size);
        return (uint32_t)result;
 }
 #else
-#define YCALCBLOCKS(s,b) ((s)/(b))
+#define YCALCBLOCKS(s, b) ((s)/(b))
 #endif
 
 #include <asm/uaccess.h>
@@ -123,41 +123,41 @@ unsigned int yaffs_wr_attempts = YAFFS_WR_ATTEMPTS;
 unsigned int yaffs_auto_checkpoint = 1;
 
 /* Module Parameters */
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
-module_param(yaffs_traceMask,uint,0644);
-module_param(yaffs_wr_attempts,uint,0644);
-module_param(yaffs_auto_checkpoint,uint,0644);
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
+module_param(yaffs_traceMask, uint, 0644);
+module_param(yaffs_wr_attempts, uint, 0644);
+module_param(yaffs_auto_checkpoint, uint, 0644);
 #else
-MODULE_PARM(yaffs_traceMask,"i");
-MODULE_PARM(yaffs_wr_attempts,"i");
-MODULE_PARM(yaffs_auto_checkpoint,"i");
+MODULE_PARM(yaffs_traceMask, "i");
+MODULE_PARM(yaffs_wr_attempts, "i");
+MODULE_PARM(yaffs_auto_checkpoint, "i");
 #endif
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25))
 /* use iget and read_inode */
-#define Y_IGET(sb,inum) iget((sb),(inum))
+#define Y_IGET(sb, inum) iget((sb), (inum))
 static void yaffs_read_inode(struct inode *inode);
 
 #else
 /* Call local equivalent */
 #define YAFFS_USE_OWN_IGET
-#define Y_IGET(sb,inum) yaffs_iget((sb),(inum))
+#define Y_IGET(sb, inum) yaffs_iget((sb), (inum))
 
-static struct inode * yaffs_iget(struct super_block *sb, unsigned long ino);
+static struct inode *yaffs_iget(struct super_block *sb, unsigned long ino);
 #endif
 
 /*#define T(x) printk x */
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18))
-#define yaffs_InodeToObjectLV(iptr) (iptr)->i_private
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18))
+#define yaffs_InodeToObjectLV(iptr) ((iptr)->i_private)
 #else
-#define yaffs_InodeToObjectLV(iptr) (iptr)->u.generic_ip
+#define yaffs_InodeToObjectLV(iptr) ((iptr)->u.generic_ip)
 #endif
 
 #define yaffs_InodeToObject(iptr) ((yaffs_Object *)(yaffs_InodeToObjectLV(iptr)))
 #define yaffs_DentryToObject(dptr) yaffs_InodeToObject((dptr)->d_inode)
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
 #define yaffs_SuperToDevice(sb)        ((yaffs_Device *)sb->s_fs_info)
 #else
 #define yaffs_SuperToDevice(sb)        ((yaffs_Device *)sb->u.generic_sbp)
@@ -166,49 +166,49 @@ static struct inode * yaffs_iget(struct super_block *sb, unsigned long ino);
 static void yaffs_put_super(struct super_block *sb);
 
 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
-                               loff_t * pos);
+                               loff_t *pos);
 static ssize_t yaffs_hold_space(struct file *f);
 static void yaffs_release_space(struct file *f);
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
 static int yaffs_file_flush(struct file *file, fl_owner_t id);
 #else
 static int yaffs_file_flush(struct file *file);
 #endif
 
 static int yaffs_sync_object(struct file *file, struct dentry *dentry,
-                            int datasync);
+                               int datasync);
 
 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir);
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode,
                        struct nameidata *n);
 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry,
-                                  struct nameidata *n);
+                                       struct nameidata *n);
 #else
 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode);
 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry);
 #endif
 static int yaffs_link(struct dentry *old_dentry, struct inode *dir,
-                     struct dentry *dentry);
+                       struct dentry *dentry);
 static int yaffs_unlink(struct inode *dir, struct dentry *dentry);
 static int yaffs_symlink(struct inode *dir, struct dentry *dentry,
-                        const char *symname);
+                       const char *symname);
 static int yaffs_mkdir(struct inode *dir, struct dentry *dentry, int mode);
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
-                      dev_t dev);
+                       dev_t dev);
 #else
 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
-                      int dev);
+                       int dev);
 #endif
 static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry,
                        struct inode *new_dir, struct dentry *new_dentry);
 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr);
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
 static int yaffs_sync_fs(struct super_block *sb, int wait);
 static void yaffs_write_super(struct super_block *sb);
 #else
@@ -216,9 +216,9 @@ static int yaffs_sync_fs(struct super_block *sb);
 static int yaffs_write_super(struct super_block *sb);
 #endif
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
 static int yaffs_statfs(struct dentry *dentry, struct kstatfs *buf);
-#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf);
 #else
 static int yaffs_statfs(struct super_block *sb, struct statfs *buf);
@@ -232,7 +232,7 @@ static void yaffs_delete_inode(struct inode *);
 static void yaffs_clear_inode(struct inode *);
 
 static int yaffs_readpage(struct file *file, struct page *page);
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
 static int yaffs_writepage(struct page *page, struct writeback_control *wbc);
 #else
 static int yaffs_writepage(struct page *page);
@@ -241,22 +241,22 @@ static int yaffs_writepage(struct page *page);
 
 #if (YAFFS_USE_WRITE_BEGIN_END != 0)
 static int yaffs_write_begin(struct file *filp, struct address_space *mapping,
-                             loff_t pos, unsigned len, unsigned flags,
-                          struct page **pagep, void **fsdata);
+                               loff_t pos, unsigned len, unsigned flags,
+                               struct page **pagep, void **fsdata);
 static int yaffs_write_end(struct file *filp, struct address_space *mapping,
-                          loff_t pos, unsigned len, unsigned copied,
-                          struct page *pg, void *fsdadata);
+                               loff_t pos, unsigned len, unsigned copied,
+                               struct page *pg, void *fsdadata);
 #else
 static int yaffs_prepare_write(struct file *f, struct page *pg,
-                              unsigned offset, unsigned to);
+                               unsigned offset, unsigned to);
 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset,
-                             unsigned to);
-                                                                                                
+                               unsigned to);
+
 #endif
 
-static int yaffs_readlink(struct dentry *dentry, char __user * buffer,
-                         int buflen);
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13))
+static int yaffs_readlink(struct dentry *dentry, char __user *buffer,
+                               int buflen);
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 13))
 static void *yaffs_follow_link(struct dentry *dentry, struct nameidata *nd);
 #else
 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd);
@@ -274,7 +274,7 @@ static struct address_space_operations yaffs_file_address_operations = {
 #endif
 };
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22))
 static struct file_operations yaffs_file_operations = {
        .read = do_sync_read,
        .write = do_sync_write,
@@ -288,7 +288,7 @@ static struct file_operations yaffs_file_operations = {
        .llseek = generic_file_llseek,
 };
 
-#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18))
+#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18))
 
 static struct file_operations yaffs_file_operations = {
        .read = do_sync_read,
@@ -309,7 +309,7 @@ static struct file_operations yaffs_file_operations = {
        .mmap = generic_file_mmap,
        .flush = yaffs_file_flush,
        .fsync = yaffs_sync_object,
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
        .sendfile = generic_file_sendfile,
 #endif
 };
@@ -360,24 +360,21 @@ static struct super_operations yaffs_super_ops = {
        .write_super = yaffs_write_super,
 };
 
-static void yaffs_GrossLock(yaffs_Device * dev)
+static void yaffs_GrossLock(yaffs_Device *dev)
 {
-       T(YAFFS_TRACE_OS, ( "yaffs locking %p\n",current));
-
+       T(YAFFS_TRACE_OS, ("yaffs locking %p\n", current));
        down(&dev->grossLock);
-        T(YAFFS_TRACE_OS, ( "yaffs locked %p\n",current));
-       
+       T(YAFFS_TRACE_OS, ("yaffs locked %p\n", current));
 }
 
-static void yaffs_GrossUnlock(yaffs_Device * dev)
+static void yaffs_GrossUnlock(yaffs_Device *dev)
 {
-       T(YAFFS_TRACE_OS, ( "yaffs unlocking %p\n",current));
+       T(YAFFS_TRACE_OS, ("yaffs unlocking %p\n", current));
        up(&dev->grossLock);
-
 }
 
-static int yaffs_readlink(struct dentry *dentry, char __user * buffer,
-                         int buflen)
+static int yaffs_readlink(struct dentry *dentry, char __user *buffer,
+                       int buflen)
 {
        unsigned char *alias;
        int ret;
@@ -398,7 +395,7 @@ static int yaffs_readlink(struct dentry *dentry, char __user * buffer,
        return ret;
 }
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 13))
 static void *yaffs_follow_link(struct dentry *dentry, struct nameidata *nd)
 #else
 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd)
@@ -414,16 +411,15 @@ static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd)
 
        yaffs_GrossUnlock(dev);
 
-       if (!alias)
-        {
+       if (!alias) {
                ret = -ENOMEM;
                goto out;
-        }
+       }
 
        ret = vfs_follow_link(nd, alias);
        kfree(alias);
 out:
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 13))
        return ERR_PTR (ret);
 #else
        return ret;
@@ -431,15 +427,15 @@ out:
 }
 
 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,
-                             yaffs_Object * obj);
+                               yaffs_Object *obj);
 
 /*
  * Lookup is used to find objects in the fs
  */
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
 
 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry,
-                                  struct nameidata *n)
+                               struct nameidata *n)
 #else
 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry)
 #endif
@@ -452,12 +448,11 @@ static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry)
        yaffs_GrossLock(dev);
 
        T(YAFFS_TRACE_OS,
-         "yaffs_lookup for %d:%s\n",
-          yaffs_InodeToObject(dir)->objectId, dentry->d_name.name));
+               ("yaffs_lookup for %d:%s\n",
+               yaffs_InodeToObject(dir)->objectId, dentry->d_name.name));
 
-       obj =
-           yaffs_FindObjectByName(yaffs_InodeToObject(dir),
-                                  dentry->d_name.name);
+       obj = yaffs_FindObjectByName(yaffs_InodeToObject(dir),
+                                       dentry->d_name.name);
 
        obj = yaffs_GetEquivalentObject(obj);   /* in case it was a hardlink */
 
@@ -466,13 +461,13 @@ static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry)
 
        if (obj) {
                T(YAFFS_TRACE_OS,
-                 "yaffs_lookup found %d\n", obj->objectId));
+                       ("yaffs_lookup found %d\n", obj->objectId));
 
                inode = yaffs_get_inode(dir->i_sb, obj->yst_mode, 0, obj);
 
                if (inode) {
                        T(YAFFS_TRACE_OS,
-                         "yaffs_loookup dentry \n"));
+                               ("yaffs_loookup dentry \n"));
 /* #if 0 asserted by NCB for 2.5/6 compatability - falls through to
  * d_add even if NULL inode */
 #if 0
@@ -485,7 +480,7 @@ static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry)
                }
 
        } else {
-               T(YAFFS_TRACE_OS, ( "yaffs_lookup not found\n"));
+               T(YAFFS_TRACE_OS, ("yaffs_lookup not found\n"));
 
        }
 
@@ -507,8 +502,8 @@ static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry)
 static void yaffs_put_inode(struct inode *inode)
 {
        T(YAFFS_TRACE_OS,
-         ("yaffs_put_inode: ino %d, count %d\n", (int)inode->i_ino,
-          atomic_read(&inode->i_count)));
+               ("yaffs_put_inode: ino %d, count %d\n", (int)inode->i_ino,
+               atomic_read(&inode->i_count)));
 
 }
 #endif
@@ -522,9 +517,9 @@ static void yaffs_clear_inode(struct inode *inode)
        obj = yaffs_InodeToObject(inode);
 
        T(YAFFS_TRACE_OS,
-         ("yaffs_clear_inode: ino %d, count %d %s\n", (int)inode->i_ino,
-          atomic_read(&inode->i_count),
-          obj ? "object exists" : "null object"));
+               ("yaffs_clear_inode: ino %d, count %d %s\n", (int)inode->i_ino,
+               atomic_read(&inode->i_count),
+               obj ? "object exists" : "null object"));
 
        if (obj) {
                dev = obj->myDev;
@@ -559,9 +554,9 @@ static void yaffs_delete_inode(struct inode *inode)
        yaffs_Device *dev;
 
        T(YAFFS_TRACE_OS,
-         ("yaffs_delete_inode: ino %d, count %d %s\n", (int)inode->i_ino,
-          atomic_read(&inode->i_count),
-          obj ? "object exists" : "null object"));
+               ("yaffs_delete_inode: ino %d, count %d %s\n", (int)inode->i_ino,
+               atomic_read(&inode->i_count),
+               obj ? "object exists" : "null object"));
 
        if (obj) {
                dev = obj->myDev;
@@ -569,13 +564,13 @@ static void yaffs_delete_inode(struct inode *inode)
                yaffs_DeleteObject(obj);
                yaffs_GrossUnlock(dev);
        }
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13))
-        truncate_inode_pages (&inode->i_data, 0);
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 13))
+       truncate_inode_pages (&inode->i_data, 0);
 #endif
        clear_inode(inode);
 }
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
 static int yaffs_file_flush(struct file *file, fl_owner_t id)
 #else
 static int yaffs_file_flush(struct file *file)
@@ -586,8 +581,8 @@ static int yaffs_file_flush(struct file *file)
        yaffs_Device *dev = obj->myDev;
 
        T(YAFFS_TRACE_OS,
-         "yaffs_file_flush object %d (%s)\n", obj->objectId,
-          obj->dirty ? "dirty" : "clean"));
+               ("yaffs_file_flush object %d (%s)\n", obj->objectId,
+               obj->dirty ? "dirty" : "clean"));
 
        yaffs_GrossLock(dev);
 
@@ -608,15 +603,15 @@ static int yaffs_readpage_nolock(struct file *f, struct page *pg)
 
        yaffs_Device *dev;
 
-       T(YAFFS_TRACE_OS, ( "yaffs_readpage at %08x, size %08x\n",
-                          (unsigned)(pg->index << PAGE_CACHE_SHIFT),
-                          (unsigned)PAGE_CACHE_SIZE));
+       T(YAFFS_TRACE_OS, ("yaffs_readpage at %08x, size %08x\n",
+                       (unsigned)(pg->index << PAGE_CACHE_SHIFT),
+                       (unsigned)PAGE_CACHE_SIZE));
 
        obj = yaffs_DentryToObject(f->f_dentry);
 
        dev = obj->myDev;
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
        BUG_ON(!PageLocked(pg));
 #else
        if (!PageLocked(pg))
@@ -629,8 +624,9 @@ static int yaffs_readpage_nolock(struct file *f, struct page *pg)
        yaffs_GrossLock(dev);
 
        ret =
-           yaffs_ReadDataFromFile(obj, pg_buf, pg->index << PAGE_CACHE_SHIFT,
-                                  PAGE_CACHE_SIZE);
+               yaffs_ReadDataFromFile(obj, pg_buf,
+                               pg->index << PAGE_CACHE_SHIFT,
+                               PAGE_CACHE_SIZE);
 
        yaffs_GrossUnlock(dev);
 
@@ -648,7 +644,7 @@ static int yaffs_readpage_nolock(struct file *f, struct page *pg)
        flush_dcache_page(pg);
        kunmap(pg);
 
-       T(YAFFS_TRACE_OS, ( "yaffs_readpage done\n"));
+       T(YAFFS_TRACE_OS, ("yaffs_readpage done\n"));
        return ret;
 }
 
@@ -666,7 +662,7 @@ static int yaffs_readpage(struct file *f, struct page *pg)
 
 /* writepage inspired by/stolen from smbfs */
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
 static int yaffs_writepage(struct page *page, struct writeback_control *wbc)
 #else
 static int yaffs_writepage(struct page *page)
@@ -689,12 +685,11 @@ static int yaffs_writepage(struct page *page)
 
        if (offset > inode->i_size) {
                T(YAFFS_TRACE_OS,
-                 (
-                  "yaffs_writepage at %08x, inode size = %08x!!!\n",
-                  (unsigned)(page->index << PAGE_CACHE_SHIFT),
-                  (unsigned)inode->i_size));
+                       ("yaffs_writepage at %08x, inode size = %08x!!!\n",
+                       (unsigned)(page->index << PAGE_CACHE_SHIFT),
+                       (unsigned)inode->i_size));
                T(YAFFS_TRACE_OS,
-                 "                -> don't care!!\n"));
+                       ("                -> don't care!!\n"));
                unlock_page(page);
                return 0;
        }
@@ -716,19 +711,18 @@ static int yaffs_writepage(struct page *page)
        yaffs_GrossLock(obj->myDev);
 
        T(YAFFS_TRACE_OS,
-         "yaffs_writepage at %08x, size %08x\n",
-          (unsigned)(page->index << PAGE_CACHE_SHIFT), nBytes));
+               ("yaffs_writepage at %08x, size %08x\n",
+               (unsigned)(page->index << PAGE_CACHE_SHIFT), nBytes));
        T(YAFFS_TRACE_OS,
-         "writepag0: obj = %05x, ino = %05x\n",
-          (int)obj->variant.fileVariant.fileSize, (int)inode->i_size));
+               ("writepag0: obj = %05x, ino = %05x\n",
+               (int)obj->variant.fileVariant.fileSize, (int)inode->i_size));
 
-       nWritten =
-           yaffs_WriteDataToFile(obj, buffer, page->index << PAGE_CACHE_SHIFT,
-                                 nBytes, 0);
+       nWritten = yaffs_WriteDataToFile(obj, buffer,
+                       page->index << PAGE_CACHE_SHIFT, nBytes, 0);
 
        T(YAFFS_TRACE_OS,
-         "writepag1: obj = %05x, ino = %05x\n",
-          (int)obj->variant.fileVariant.fileSize, (int)inode->i_size));
+               ("writepag1: obj = %05x, ino = %05x\n",
+               (int)obj->variant.fileVariant.fileSize, (int)inode->i_size));
 
        yaffs_GrossUnlock(obj->myDev);
 
@@ -743,58 +737,57 @@ static int yaffs_writepage(struct page *page)
 
 #if (YAFFS_USE_WRITE_BEGIN_END > 0)
 static int yaffs_write_begin(struct file *filp, struct address_space *mapping,
-                             loff_t pos, unsigned len, unsigned flags,
-                          struct page **pagep, void **fsdata)
-
+                               loff_t pos, unsigned len, unsigned flags,
+                               struct page **pagep, void **fsdata)
 {
        struct page *pg = NULL;
-        pgoff_t index = pos >> PAGE_CACHE_SHIFT;
-        uint32_t offset = pos & (PAGE_CACHE_SIZE - 1);
-        uint32_t to = offset + len;
-        
-        int ret = 0;
-        int space_held = 0;
-        
-       T(YAFFS_TRACE_OS, ( "start yaffs_write_begin\n"));
+       pgoff_t index = pos >> PAGE_CACHE_SHIFT;
+       uint32_t offset = pos & (PAGE_CACHE_SIZE - 1);
+       uint32_t to = offset + len;
+
+       int ret = 0;
+       int space_held = 0;
+
+       T(YAFFS_TRACE_OS, ("start yaffs_write_begin\n"));
        /* Get a page */
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28)
-       pg = grab_cache_page_write_begin(mapping,index,flags);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 28)
+       pg = grab_cache_page_write_begin(mapping, index, flags);
 #else
-       pg = __grab_cache_page(mapping,index);
+       pg = __grab_cache_page(mapping, index);
 #endif
 
-       *pagep = pg;    
-       if(!pg){
+       *pagep = pg;
+       if (!pg) {
                ret =  -ENOMEM;
                goto out;
        }
        /* Get fs space */
        space_held = yaffs_hold_space(filp);
-       
-       if(!space_held){
+
+       if (!space_held) {
                ret = -ENOSPC;
                goto out;
        }
-               
+
        /* Update page if required */
-       
+
        if (!Page_Uptodate(pg) && (offset || to < PAGE_CACHE_SIZE))
                ret = yaffs_readpage_nolock(filp, pg);
-       
-       if(ret)
+
+       if (ret)
                goto out;
 
        /* Happy path return */
-       T(YAFFS_TRACE_OS, ( "end yaffs_write_begin - ok\n"));
-               
+       T(YAFFS_TRACE_OS, ("end yaffs_write_begin - ok\n"));
+
        return 0;
-               
+
 out:
-       T(YAFFS_TRACE_OS, ( "end yaffs_write_begin fail returning %d\n",ret));
-       if(space_held){
+       T(YAFFS_TRACE_OS, ("end yaffs_write_begin fail returning %d\n", ret));
+       if (space_held) {
                yaffs_release_space(filp);
        }
-       if(pg) {
+       if (pg) {
                unlock_page(pg);
                page_cache_release(pg);
        }
@@ -804,42 +797,39 @@ out:
 #else
 
 static int yaffs_prepare_write(struct file *f, struct page *pg,
-                              unsigned offset, unsigned to)
+                               unsigned offset, unsigned to)
 {
+       T(YAFFS_TRACE_OS, ("yaffs_prepair_write\n"));
 
-       T(YAFFS_TRACE_OS, ( "yaffs_prepair_write\n"));
        if (!Page_Uptodate(pg) && (offset || to < PAGE_CACHE_SIZE))
                return yaffs_readpage_nolock(f, pg);
        return 0;
-
 }
 #endif
 
 #if (YAFFS_USE_WRITE_BEGIN_END > 0)
 static int yaffs_write_end(struct file *filp, struct address_space *mapping,
-                          loff_t pos, unsigned len, unsigned copied,
-                          struct page *pg, void *fsdadata)
+                               loff_t pos, unsigned len, unsigned copied,
+                               struct page *pg, void *fsdadata)
 {
        int ret = 0;
        void *addr, *kva;
-        uint32_t offset_into_page = pos & (PAGE_CACHE_SIZE -1); 
-
+       uint32_t offset_into_page = pos & (PAGE_CACHE_SIZE - 1);
 
-       
-       kva=kmap(pg);
+       kva = kmap(pg);
        addr = kva + offset_into_page;
 
        T(YAFFS_TRACE_OS,
-         ( "yaffs_write_end addr %x pos %x nBytes %d\n", (unsigned) addr,
-          (int)pos, copied));
+               ("yaffs_write_end addr %x pos %x nBytes %d\n",
+               (unsigned) addr,
+               (int)pos, copied));
 
        ret = yaffs_file_write(filp, addr, copied, &pos);
 
        if (ret != copied) {
                T(YAFFS_TRACE_OS,
-                 (
-                  "yaffs_write_end not same size ret %d  copied %d\n",
-                  ret, copied ));
+                       ("yaffs_write_end not same size ret %d  copied %d\n",
+                       ret, copied));
                SetPageError(pg);
                ClearPageUptodate(pg);
        } else {
@@ -856,34 +846,32 @@ static int yaffs_write_end(struct file *filp, struct address_space *mapping,
 #else
 
 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset,
-                             unsigned to)
+                               unsigned to)
 {
-
        void *addr, *kva;
-       
+
        loff_t pos = (((loff_t) pg->index) << PAGE_CACHE_SHIFT) + offset;
        int nBytes = to - offset;
        int nWritten;
 
        unsigned spos = pos;
        unsigned saddr;
-       
-       kva=kmap(pg);
+
+       kva = kmap(pg);
        addr = kva + offset;
 
        saddr = (unsigned) addr;
 
        T(YAFFS_TRACE_OS,
-         ( "yaffs_commit_write addr %x pos %x nBytes %d\n", saddr,
-          spos, nBytes));
+               ("yaffs_commit_write addr %x pos %x nBytes %d\n",
+               saddr, spos, nBytes));
 
        nWritten = yaffs_file_write(f, addr, nBytes, &pos);
 
        if (nWritten != nBytes) {
                T(YAFFS_TRACE_OS,
-                 (
-                  "yaffs_commit_write not same size nWritten %d  nBytes %d\n",
-                  nWritten, nBytes));
+                       ("yaffs_commit_write not same size nWritten %d  nBytes %d\n",
+                       nWritten, nBytes));
                SetPageError(pg);
                ClearPageUptodate(pg);
        } else {
@@ -893,62 +881,61 @@ static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset,
        kunmap(pg);
 
        T(YAFFS_TRACE_OS,
-         "yaffs_commit_write returning %d\n",
-          nWritten == nBytes ? 0 : nWritten));
+               ("yaffs_commit_write returning %d\n",
+               nWritten == nBytes ? 0 : nWritten));
 
        return nWritten == nBytes ? 0 : nWritten;
-
 }
 #endif
 
 
-static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object * obj)
+static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object *obj)
 {
        if (inode && obj) {
 
 
                /* Check mode against the variant type and attempt to repair if broken. */
-               __u32 mode = obj->yst_mode;
-               switch( obj->variantType ){
-               case YAFFS_OBJECT_TYPE_FILE :
-                       if( ! S_ISREG(mode) ){
-                               obj->yst_mode &= ~S_IFMT;
-                               obj->yst_mode |= S_IFREG;
-                       }
-
-                       break;
-               case YAFFS_OBJECT_TYPE_SYMLINK :
-                       if( ! S_ISLNK(mode) ){
-                               obj->yst_mode &= ~S_IFMT;
-                               obj->yst_mode |= S_IFLNK;
-                       }
-
-                       break;
-               case YAFFS_OBJECT_TYPE_DIRECTORY :
-                       if( ! S_ISDIR(mode) ){
-                               obj->yst_mode &= ~S_IFMT;
-                               obj->yst_mode |= S_IFDIR;
-                       }
-
-                       break;
-               case YAFFS_OBJECT_TYPE_UNKNOWN :
-               case YAFFS_OBJECT_TYPE_HARDLINK :
-               case YAFFS_OBJECT_TYPE_SPECIAL :
-               default:
-                       /* TODO? */
-                       break;
-               }
-
-               inode->i_flags |= S_NOATIME;
-               
+               __u32 mode = obj->yst_mode;
+               switch (obj->variantType) {
+               case YAFFS_OBJECT_TYPE_FILE:
+                       if (!S_ISREG(mode)) {
+                               obj->yst_mode &= ~S_IFMT;
+                               obj->yst_mode |= S_IFREG;
+                       }
+
+                       break;
+               case YAFFS_OBJECT_TYPE_SYMLINK:
+                       if (!S_ISLNK(mode)) {
+                               obj->yst_mode &= ~S_IFMT;
+                               obj->yst_mode |= S_IFLNK;
+                       }
+
+                       break;
+               case YAFFS_OBJECT_TYPE_DIRECTORY:
+                       if (!S_ISDIR(mode)) {
+                               obj->yst_mode &= ~S_IFMT;
+                               obj->yst_mode |= S_IFDIR;
+                       }
+
+                       break;
+               case YAFFS_OBJECT_TYPE_UNKNOWN:
+               case YAFFS_OBJECT_TYPE_HARDLINK:
+               case YAFFS_OBJECT_TYPE_SPECIAL:
+               default:
+                       /* TODO? */
+                       break;
+               }
+
+               inode->i_flags |= S_NOATIME;
+
                inode->i_ino = obj->objectId;
                inode->i_mode = obj->yst_mode;
                inode->i_uid = obj->yst_uid;
                inode->i_gid = obj->yst_gid;
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19))
                inode->i_blksize = inode->i_sb->s_blocksize;
 #endif
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
 
                inode->i_rdev = old_decode_dev(obj->yst_rdev);
                inode->i_atime.tv_sec = (time_t) (obj->yst_atime);
@@ -969,26 +956,25 @@ static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object * obj)
                inode->i_nlink = yaffs_GetObjectLinkCount(obj);
 
                T(YAFFS_TRACE_OS,
-                 (
-                  "yaffs_FillInode mode %x uid %d gid %d size %d count %d\n",
-                  inode->i_mode, inode->i_uid, inode->i_gid,
-                  (int)inode->i_size, atomic_read(&inode->i_count)));
+                       ("yaffs_FillInode mode %x uid %d gid %d size %d count %d\n",
+                       inode->i_mode, inode->i_uid, inode->i_gid,
+                       (int)inode->i_size, atomic_read(&inode->i_count)));
 
                switch (obj->yst_mode & S_IFMT) {
                default:        /* fifo, device or socket */
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
                        init_special_inode(inode, obj->yst_mode,
-                                          old_decode_dev(obj->yst_rdev));
+                                       old_decode_dev(obj->yst_rdev));
 #else
                        init_special_inode(inode, obj->yst_mode,
-                                          (dev_t) (obj->yst_rdev));
+                                       (dev_t) (obj->yst_rdev));
 #endif
                        break;
                case S_IFREG:   /* file */
                        inode->i_op = &yaffs_file_inode_operations;
                        inode->i_fop = &yaffs_file_operations;
                        inode->i_mapping->a_ops =
-                           &yaffs_file_address_operations;
+                               &yaffs_file_address_operations;
                        break;
                case S_IFDIR:   /* directory */
                        inode->i_op = &yaffs_dir_inode_operations;
@@ -1005,36 +991,36 @@ static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object * obj)
 
        } else {
                T(YAFFS_TRACE_OS,
-                 "yaffs_FileInode invalid parameters\n"));
+                       ("yaffs_FileInode invalid parameters\n"));
        }
 
 }
 
 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,
-                             yaffs_Object * obj)
+                               yaffs_Object *obj)
 {
        struct inode *inode;
 
        if (!sb) {
                T(YAFFS_TRACE_OS,
-                 "yaffs_get_inode for NULL super_block!!\n"));
+                       ("yaffs_get_inode for NULL super_block!!\n"));
                return NULL;
 
        }
 
        if (!obj) {
                T(YAFFS_TRACE_OS,
-                 "yaffs_get_inode for NULL object!!\n"));
+                       ("yaffs_get_inode for NULL object!!\n"));
                return NULL;
 
        }
 
        T(YAFFS_TRACE_OS,
-         "yaffs_get_inode for object %d\n", obj->objectId));
+               ("yaffs_get_inode for object %d\n", obj->objectId));
 
        inode = Y_IGET(sb, obj->objectId);
-       if(IS_ERR(inode))
-         return NULL;
+       if (IS_ERR(inode))
+               return NULL;
 
        /* NB Side effect: iget calls back to yaffs_read_inode(). */
        /* iget also increments the inode's i_count */
@@ -1044,7 +1030,7 @@ struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,
 }
 
 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
-                               loff_t * pos)
+                               loff_t *pos)
 {
        yaffs_Object *obj;
        int nWritten, ipos;
@@ -1067,20 +1053,19 @@ static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
 
        if (!obj) {
                T(YAFFS_TRACE_OS,
-                 "yaffs_file_write: hey obj is null!\n"));
+                       ("yaffs_file_write: hey obj is null!\n"));
        } else {
                T(YAFFS_TRACE_OS,
-                 (
-                  "yaffs_file_write about to write writing %zu bytes"
-                  "to object %d at %d\n",
-                  n, obj->objectId, ipos));
+                       ("yaffs_file_write about to write writing %zu bytes"
+                       "to object %d at %d\n",
+                       n, obj->objectId, ipos));
        }
 
        nWritten = yaffs_WriteDataToFile(obj, buf, ipos, n, 0);
 
        T(YAFFS_TRACE_OS,
-         "yaffs_file_write writing %zu bytes, %d written at %d\n",
-          n, nWritten, ipos));
+               ("yaffs_file_write writing %zu bytes, %d written at %d\n",
+               n, nWritten, ipos));
        if (nWritten > 0) {
                ipos += nWritten;
                *pos = ipos;
@@ -1089,10 +1074,9 @@ static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
                        inode->i_blocks = (ipos + 511) >> 9;
 
                        T(YAFFS_TRACE_OS,
-                         (
-                          "yaffs_file_write size updated to %d bytes, "
-                          "%d blocks\n",
-                          ipos, (int)(inode->i_blocks)));
+                               ("yaffs_file_write size updated to %d bytes, "
+                               "%d blocks\n",
+                               ipos, (int)(inode->i_blocks)));
                }
 
        }
@@ -1108,10 +1092,10 @@ static ssize_t yaffs_hold_space(struct file *f)
 {
        yaffs_Object *obj;
        yaffs_Device *dev;
-       
+
        int nFreeChunks;
 
-       
+
        obj = yaffs_DentryToObject(f->f_dentry);
 
        dev = obj->myDev;
@@ -1119,7 +1103,7 @@ static ssize_t yaffs_hold_space(struct file *f)
        yaffs_GrossLock(dev);
 
        nFreeChunks = yaffs_GetNumberOfFreeChunks(dev);
-       
+
        yaffs_GrossUnlock(dev);
 
        return (nFreeChunks > 20) ? 1 : 0;
@@ -1129,17 +1113,16 @@ static void yaffs_release_space(struct file *f)
 {
        yaffs_Object *obj;
        yaffs_Device *dev;
-       
-       
+
+
        obj = yaffs_DentryToObject(f->f_dentry);
 
        dev = obj->myDev;
 
        yaffs_GrossLock(dev);
 
-       
-       yaffs_GrossUnlock(dev);
 
+       yaffs_GrossUnlock(dev);
 }
 
 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
@@ -1164,10 +1147,9 @@ static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
 
        if (offset == 0) {
                T(YAFFS_TRACE_OS,
-                 ( "yaffs_readdir: entry . ino %d \n",
-                  (int)inode->i_ino));
-               if (filldir(dirent, ".", 1, offset, inode->i_ino, DT_DIR)
-                   < 0) {
+                       ("yaffs_readdir: entry . ino %d \n",
+                       (int)inode->i_ino));
+               if (filldir(dirent, ".", 1, offset, inode->i_ino, DT_DIR) < 0) {
                        goto out;
                }
                offset++;
@@ -1175,11 +1157,10 @@ static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
        }
        if (offset == 1) {
                T(YAFFS_TRACE_OS,
-                 ( "yaffs_readdir: entry .. ino %d \n",
-                  (int)f->f_dentry->d_parent->d_inode->i_ino));
-               if (filldir
-                   (dirent, "..", 2, offset,
-                    f->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) {
+                       ("yaffs_readdir: entry .. ino %d \n",
+                       (int)f->f_dentry->d_parent->d_inode->i_ino));
+               if (filldir(dirent, "..", 2, offset,
+                       f->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) {
                        goto out;
                }
                offset++;
@@ -1205,16 +1186,15 @@ static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
                        yaffs_GetObjectName(l, name,
                                            YAFFS_MAX_NAME_LENGTH + 1);
                        T(YAFFS_TRACE_OS,
-                         ( "yaffs_readdir: %s inode %d\n", name,
+                         ("yaffs_readdir: %s inode %d\n", name,
                           yaffs_GetObjectInode(l)));
 
                        if (filldir(dirent,
-                                   name,
-                                   strlen(name),
-                                   offset,
-                                   yaffs_GetObjectInode(l),
-                                   yaffs_GetObjectType(l))
-                           < 0) {
+                                       name,
+                                       strlen(name),
+                                       offset,
+                                       yaffs_GetObjectInode(l),
+                                       yaffs_GetObjectType(l)) < 0) {
                                goto up_and_out;
                        }
 
@@ -1223,9 +1203,8 @@ static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
                }
        }
 
-      up_and_out:
-      out:
-
+up_and_out:
+out:
        yaffs_GrossUnlock(dev);
 
        return 0;
@@ -1234,19 +1213,19 @@ static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
 /*
  * File creation. Allocate an inode, and we're done..
  */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
 #define YCRED(x) x
 #else
-#define YCRED(x) x->cred
+#define YCRED(x) (x->cred)
 #endif
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
-                      dev_t rdev)
+                       dev_t rdev)
 #else
 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
-                      int rdev)
+                       int rdev)
 #endif
 {
        struct inode *inode;
@@ -1260,22 +1239,22 @@ static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
        uid_t uid = YCRED(current)->fsuid;
        gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : YCRED(current)->fsgid;
 
-       if((dir->i_mode & S_ISGID) && S_ISDIR(mode))
+       if ((dir->i_mode & S_ISGID) && S_ISDIR(mode))
                mode |= S_ISGID;
 
        if (parent) {
                T(YAFFS_TRACE_OS,
-                 "yaffs_mknod: parent object %d type %d\n",
-                  parent->objectId, parent->variantType));
+                       ("yaffs_mknod: parent object %d type %d\n",
+                       parent->objectId, parent->variantType));
        } else {
                T(YAFFS_TRACE_OS,
-                 "yaffs_mknod: could not get parent object\n"));
+                       ("yaffs_mknod: could not get parent object\n"));
                return -EPERM;
        }
 
        T(YAFFS_TRACE_OS, ("yaffs_mknod: making oject for %s, "
-                          "mode %x dev %x\n",
-                          dentry->d_name.name, mode, rdev));
+                       "mode %x dev %x\n",
+                       dentry->d_name.name, mode, rdev));
 
        dev = parent->myDev;
 
@@ -1284,33 +1263,28 @@ static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
        switch (mode & S_IFMT) {
        default:
                /* Special (socket, fifo, device...) */
-               T(YAFFS_TRACE_OS, (
-                                  "yaffs_mknod: making special\n"));
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
-               obj =
-                   yaffs_MknodSpecial(parent, dentry->d_name.name, mode, uid,
-                                      gid, old_encode_dev(rdev));
+               T(YAFFS_TRACE_OS, ("yaffs_mknod: making special\n"));
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
+               obj = yaffs_MknodSpecial(parent, dentry->d_name.name, mode, uid,
+                               gid, old_encode_dev(rdev));
 #else
-               obj =
-                   yaffs_MknodSpecial(parent, dentry->d_name.name, mode, uid,
-                                      gid, rdev);
+               obj = yaffs_MknodSpecial(parent, dentry->d_name.name, mode, uid,
+                               gid, rdev);
 #endif
                break;
        case S_IFREG:           /* file          */
-               T(YAFFS_TRACE_OS, ( "yaffs_mknod: making file\n"));
-               obj =
-                   yaffs_MknodFile(parent, dentry->d_name.name, mode, uid,
-                                   gid);
+               T(YAFFS_TRACE_OS, ("yaffs_mknod: making file\n"));
+               obj = yaffs_MknodFile(parent, dentry->d_name.name, mode, uid,
+                               gid);
                break;
        case S_IFDIR:           /* directory */
                T(YAFFS_TRACE_OS,
-                 ( "yaffs_mknod: making directory\n"));
-               obj =
-                   yaffs_MknodDirectory(parent, dentry->d_name.name, mode,
-                                        uid, gid);
+                       ("yaffs_mknod: making directory\n"));
+               obj = yaffs_MknodDirectory(parent, dentry->d_name.name, mode,
+                                       uid, gid);
                break;
        case S_IFLNK:           /* symlink */
-               T(YAFFS_TRACE_OS, ( "yaffs_mknod: making symlink\n"));
+               T(YAFFS_TRACE_OS, ("yaffs_mknod: making symlink\n"));
                obj = NULL;     /* Do we ever get here? */
                break;
        }
@@ -1322,12 +1296,12 @@ static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
                inode = yaffs_get_inode(dir->i_sb, mode, rdev, obj);
                d_instantiate(dentry, inode);
                T(YAFFS_TRACE_OS,
-                 "yaffs_mknod created object %d count = %d\n",
-                  obj->objectId, atomic_read(&inode->i_count)));
+                       ("yaffs_mknod created object %d count = %d\n",
+                       obj->objectId, atomic_read(&inode->i_count)));
                error = 0;
        } else {
                T(YAFFS_TRACE_OS,
-                 "yaffs_mknod failed making object\n"));
+                       ("yaffs_mknod failed making object\n"));
                error = -ENOMEM;
        }
 
@@ -1337,7 +1311,7 @@ static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
 static int yaffs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 {
        int retVal;
-       T(YAFFS_TRACE_OS, ( "yaffs_mkdir\n"));
+       T(YAFFS_TRACE_OS, ("yaffs_mkdir\n"));
        retVal = yaffs_mknod(dir, dentry, mode | S_IFDIR, 0);
 #if 0
        /* attempt to fix dir bug - didn't work */
@@ -1348,14 +1322,14 @@ static int yaffs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
        return retVal;
 }
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode,
                        struct nameidata *n)
 #else
 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode)
 #endif
 {
-       T(YAFFS_TRACE_OS, ( "yaffs_create\n"));
+       T(YAFFS_TRACE_OS, ("yaffs_create\n"));
        return yaffs_mknod(dir, dentry, mode | S_IFREG, 0);
 }
 
@@ -1366,8 +1340,8 @@ static int yaffs_unlink(struct inode *dir, struct dentry *dentry)
        yaffs_Device *dev;
 
        T(YAFFS_TRACE_OS,
-         "yaffs_unlink %d:%s\n", (int)(dir->i_ino),
-          dentry->d_name.name));
+               ("yaffs_unlink %d:%s\n", (int)(dir->i_ino),
+               dentry->d_name.name));
 
        dev = yaffs_InodeToObject(dir)->myDev;
 
@@ -1390,25 +1364,23 @@ static int yaffs_unlink(struct inode *dir, struct dentry *dentry)
  * Create a link...
  */
 static int yaffs_link(struct dentry *old_dentry, struct inode *dir,
-                     struct dentry *dentry)
+                       struct dentry *dentry)
 {
        struct inode *inode = old_dentry->d_inode;
        yaffs_Object *obj = NULL;
        yaffs_Object *link = NULL;
        yaffs_Device *dev;
 
-       T(YAFFS_TRACE_OS, ( "yaffs_link\n"));
+       T(YAFFS_TRACE_OS, ("yaffs_link\n"));
 
        obj = yaffs_InodeToObject(inode);
        dev = obj->myDev;
 
        yaffs_GrossLock(dev);
 
-       if (!S_ISDIR(inode->i_mode))    /* Don't link directories */
-       {
-               link =
-                   yaffs_Link(yaffs_InodeToObject(dir), dentry->d_name.name,
-                              obj);
+       if (!S_ISDIR(inode->i_mode)) {          /* Don't link directories */
+               link = yaffs_Link(yaffs_InodeToObject(dir), dentry->d_name.name,
+                       obj);
        }
 
        if (link) {
@@ -1416,16 +1388,14 @@ static int yaffs_link(struct dentry *old_dentry, struct inode *dir,
                d_instantiate(dentry, old_dentry->d_inode);
                atomic_inc(&old_dentry->d_inode->i_count);
                T(YAFFS_TRACE_OS,
-                 ( "yaffs_link link count %d i_count %d\n",
-                  old_dentry->d_inode->i_nlink,
-                  atomic_read(&old_dentry->d_inode->i_count)));
-
+                       ("yaffs_link link count %d i_count %d\n",
+                       old_dentry->d_inode->i_nlink,
+                       atomic_read(&old_dentry->d_inode->i_count)));
        }
 
        yaffs_GrossUnlock(dev);
 
        if (link) {
-
                return 0;
        }
 
@@ -1433,39 +1403,37 @@ static int yaffs_link(struct dentry *old_dentry, struct inode *dir,
 }
 
 static int yaffs_symlink(struct inode *dir, struct dentry *dentry,
-                        const char *symname)
+                               const char *symname)
 {
        yaffs_Object *obj;
        yaffs_Device *dev;
        uid_t uid = YCRED(current)->fsuid;
        gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : YCRED(current)->fsgid;
 
-       T(YAFFS_TRACE_OS, ( "yaffs_symlink\n"));
+       T(YAFFS_TRACE_OS, ("yaffs_symlink\n"));
 
        dev = yaffs_InodeToObject(dir)->myDev;
        yaffs_GrossLock(dev);
        obj = yaffs_MknodSymLink(yaffs_InodeToObject(dir), dentry->d_name.name,
-                                S_IFLNK | S_IRWXUGO, uid, gid, symname);
+                               S_IFLNK | S_IRWXUGO, uid, gid, symname);
        yaffs_GrossUnlock(dev);
 
        if (obj) {
-
                struct inode *inode;
 
                inode = yaffs_get_inode(dir->i_sb, obj->yst_mode, 0, obj);
                d_instantiate(dentry, inode);
-               T(YAFFS_TRACE_OS, ( "symlink created OK\n"));
+               T(YAFFS_TRACE_OS, ("symlink created OK\n"));
                return 0;
        } else {
-               T(YAFFS_TRACE_OS, ( "symlink not created\n"));
-
+               T(YAFFS_TRACE_OS, ("symlink not created\n"));
        }
 
        return -ENOMEM;
 }
 
 static int yaffs_sync_object(struct file *file, struct dentry *dentry,
-                            int datasync)
+                               int datasync)
 {
 
        yaffs_Object *obj;
@@ -1475,7 +1443,7 @@ static int yaffs_sync_object(struct file *file, struct dentry *dentry,
 
        dev = obj->myDev;
 
-       T(YAFFS_TRACE_OS, ( "yaffs_sync_object\n"));
+       T(YAFFS_TRACE_OS, ("yaffs_sync_object\n"));
        yaffs_GrossLock(dev);
        yaffs_FlushFile(obj, 1);
        yaffs_GrossUnlock(dev);
@@ -1494,41 +1462,36 @@ static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry,
        int retVal = YAFFS_FAIL;
        yaffs_Object *target;
 
-        T(YAFFS_TRACE_OS, ( "yaffs_rename\n"));
+       T(YAFFS_TRACE_OS, ("yaffs_rename\n"));
        dev = yaffs_InodeToObject(old_dir)->myDev;
 
        yaffs_GrossLock(dev);
 
        /* Check if the target is an existing directory that is not empty. */
-       target =
-           yaffs_FindObjectByName(yaffs_InodeToObject(new_dir),
-                                  new_dentry->d_name.name);
+       target = yaffs_FindObjectByName(yaffs_InodeToObject(new_dir),
+                               new_dentry->d_name.name);
 
 
 
-       if (target &&
-           target->variantType == YAFFS_OBJECT_TYPE_DIRECTORY &&
-           !ylist_empty(&target->variant.directoryVariant.children)) {
+       if (target && target->variantType == YAFFS_OBJECT_TYPE_DIRECTORY &&
+               !ylist_empty(&target->variant.directoryVariant.children)) {
 
-               T(YAFFS_TRACE_OS, ( "target is non-empty dir\n"));
+               T(YAFFS_TRACE_OS, ("target is non-empty dir\n"));
 
                retVal = YAFFS_FAIL;
        } else {
-
                /* Now does unlinking internally using shadowing mechanism */
-               T(YAFFS_TRACE_OS, ( "calling yaffs_RenameObject\n"));
-
-               retVal =
-                   yaffs_RenameObject(yaffs_InodeToObject(old_dir),
-                                      old_dentry->d_name.name,
-                                      yaffs_InodeToObject(new_dir),
-                                      new_dentry->d_name.name);
+               T(YAFFS_TRACE_OS, ("calling yaffs_RenameObject\n"));
 
+               retVal = yaffs_RenameObject(yaffs_InodeToObject(old_dir),
+                               old_dentry->d_name.name,
+                               yaffs_InodeToObject(new_dir),
+                               new_dentry->d_name.name);
        }
        yaffs_GrossUnlock(dev);
 
        if (retVal == YAFFS_OK) {
-               if(target) {
+               if (target) {
                        new_dentry->d_inode->i_nlink--;
                        mark_inode_dirty(new_dentry->d_inode);
                }
@@ -1537,7 +1500,6 @@ static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry,
        } else {
                return -ENOTEMPTY;
        }
-
 }
 
 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr)
@@ -1547,15 +1509,15 @@ static int yaffs_setattr(struct dentry *dentry, struct iattr *attr)
        yaffs_Device *dev;
 
        T(YAFFS_TRACE_OS,
-         ( "yaffs_setattr of object %d\n",
-          yaffs_InodeToObject(inode)->objectId));
-
-       if ((error = inode_change_ok(inode, attr)) == 0) {
+               ("yaffs_setattr of object %d\n",
+               yaffs_InodeToObject(inode)->objectId));
 
+       error = inode_change_ok(inode, attr);
+       if (error == 0) {
                dev = yaffs_InodeToObject(inode)->myDev;
                yaffs_GrossLock(dev);
                if (yaffs_SetAttributes(yaffs_InodeToObject(inode), attr) ==
-                   YAFFS_OK) {
+                               YAFFS_OK) {
                        error = 0;
                } else {
                        error = -EPERM;
@@ -1567,12 +1529,12 @@ static int yaffs_setattr(struct dentry *dentry, struct iattr *attr)
        return error;
 }
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
 static int yaffs_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
        yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev;
        struct super_block *sb = dentry->d_sb;
-#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf)
 {
        yaffs_Device *dev = yaffs_SuperToDevice(sb);
@@ -1582,54 +1544,53 @@ static int yaffs_statfs(struct super_block *sb, struct statfs *buf)
        yaffs_Device *dev = yaffs_SuperToDevice(sb);
 #endif
 
-       T(YAFFS_TRACE_OS, ( "yaffs_statfs\n"));
+       T(YAFFS_TRACE_OS, ("yaffs_statfs\n"));
 
        yaffs_GrossLock(dev);
 
        buf->f_type = YAFFS_MAGIC;
        buf->f_bsize = sb->s_blocksize;
        buf->f_namelen = 255;
-       
-       if(dev->nDataBytesPerChunk & (dev->nDataBytesPerChunk - 1)){
+
+       if (dev->nDataBytesPerChunk & (dev->nDataBytesPerChunk - 1)) {
                /* Do this if chunk size is not a power of 2 */
-               
+
                uint64_t bytesInDev;
                uint64_t bytesFree;
 
-               bytesInDev = ((uint64_t)((dev->endBlock - dev->startBlock +1))) *
-                            ((uint64_t)(dev->nChunksPerBlock * dev->nDataBytesPerChunk));
-       
-               do_div(bytesInDev,sb->s_blocksize); /* bytesInDev becomes the number of blocks */
+               bytesInDev = ((uint64_t)((dev->endBlock - dev->startBlock + 1))) *
+                       ((uint64_t)(dev->nChunksPerBlock * dev->nDataBytesPerChunk));
+
+               do_div(bytesInDev, sb->s_blocksize); /* bytesInDev becomes the number of blocks */
                buf->f_blocks = bytesInDev;
 
                bytesFree  = ((uint64_t)(yaffs_GetNumberOfFreeChunks(dev))) *
-                            ((uint64_t)(dev->nDataBytesPerChunk));
-       
-               do_div(bytesFree,sb->s_blocksize);
-       
+                       ((uint64_t)(dev->nDataBytesPerChunk));
+
+               do_div(bytesFree, sb->s_blocksize);
+
                buf->f_bfree = bytesFree;
-       
+
        } else if (sb->s_blocksize > dev->nDataBytesPerChunk) {
-       
+
                buf->f_blocks =
-                          (dev->endBlock - dev->startBlock + 1) * 
-                           dev->nChunksPerBlock / 
-                           (sb->s_blocksize / dev->nDataBytesPerChunk);
-               buf->f_bfree =
-                          yaffs_GetNumberOfFreeChunks(dev) / 
-                          (sb->s_blocksize / dev->nDataBytesPerChunk);
+                       (dev->endBlock - dev->startBlock + 1) *
+                       dev->nChunksPerBlock /
+                       (sb->s_blocksize / dev->nDataBytesPerChunk);
+               buf->f_bfree =
+                       yaffs_GetNumberOfFreeChunks(dev) /
+                       (sb->s_blocksize / dev->nDataBytesPerChunk);
        } else {
-              buf->f_blocks =
-                          (dev->endBlock - dev->startBlock + 1) * 
-                          dev->nChunksPerBlock * 
-                          (dev->nDataBytesPerChunk / sb->s_blocksize);
-                          
-                      buf->f_bfree =
-                          yaffs_GetNumberOfFreeChunks(dev) * 
-                          (dev->nDataBytesPerChunk / sb->s_blocksize);
+               buf->f_blocks =
+                       (dev->endBlock - dev->startBlock + 1) *
+                       dev->nChunksPerBlock *
+                       (dev->nDataBytesPerChunk / sb->s_blocksize);
+
+               buf->f_bfree =
+                       yaffs_GetNumberOfFreeChunks(dev) *
+                       (dev->nDataBytesPerChunk / sb->s_blocksize);
        }
-       
-       
+
        buf->f_files = 0;
        buf->f_ffree = 0;
        buf->f_bavail = buf->f_bfree;
@@ -1643,12 +1604,12 @@ static int yaffs_do_sync_fs(struct super_block *sb)
 {
 
        yaffs_Device *dev = yaffs_SuperToDevice(sb);
-       T(YAFFS_TRACE_OS, ( "yaffs_do_sync_fs\n"));
+       T(YAFFS_TRACE_OS, ("yaffs_do_sync_fs\n"));
 
-       if(sb->s_dirt) {
+       if (sb->s_dirt) {
                yaffs_GrossLock(dev);
 
-               if(dev){
+               if (dev) {
                        yaffs_FlushEntireDeviceCache(dev);
                        yaffs_CheckpointSave(dev);
                }
@@ -1661,48 +1622,46 @@ static int yaffs_do_sync_fs(struct super_block *sb)
 }
 
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
 static void yaffs_write_super(struct super_block *sb)
 #else
 static int yaffs_write_super(struct super_block *sb)
 #endif
 {
 
-       T(YAFFS_TRACE_OS, ( "yaffs_write_super\n"));
+       T(YAFFS_TRACE_OS, ("yaffs_write_super\n"));
        if (yaffs_auto_checkpoint >= 2)
                yaffs_do_sync_fs(sb);
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18))
-       return 0; 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18))
+       return 0;
 #endif
 }
 
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
 static int yaffs_sync_fs(struct super_block *sb, int wait)
 #else
 static int yaffs_sync_fs(struct super_block *sb)
 #endif
 {
-
-       T(YAFFS_TRACE_OS, ( "yaffs_sync_fs\n"));
+       T(YAFFS_TRACE_OS, ("yaffs_sync_fs\n"));
 
        if (yaffs_auto_checkpoint >= 1)
                yaffs_do_sync_fs(sb);
-       
-       return 0; 
 
+       return 0;
 }
 
 #ifdef YAFFS_USE_OWN_IGET
 
-static struct inode * yaffs_iget(struct super_block *sb, unsigned long ino)
+static struct inode *yaffs_iget(struct super_block *sb, unsigned long ino)
 {
        struct inode *inode;
        yaffs_Object *obj;
        yaffs_Device *dev = yaffs_SuperToDevice(sb);
 
        T(YAFFS_TRACE_OS,
-         "yaffs_iget for %lu\n", ino));
+               ("yaffs_iget for %lu\n", ino));
 
        inode = iget_locked(sb, ino);
        if (!inode)
@@ -1710,11 +1669,11 @@ static struct inode * yaffs_iget(struct super_block *sb, unsigned long ino)
        if (!(inode->i_state & I_NEW))
                return inode;
 
-       /* NB This is called as a side effect of other functions, but
-       * we had to release the lock to prevent deadlocks, so
-       * need to lock again.
-       */
-    
+       /* NB This is called as a side effect of other functions, but
+        * we had to release the lock to prevent deadlocks, so
+        * need to lock again.
+        */
+
        yaffs_GrossLock(dev);
 
        obj = yaffs_FindObjectByNumber(dev, inode->i_ino);
@@ -1722,7 +1681,7 @@ static struct inode * yaffs_iget(struct super_block *sb, unsigned long ino)
        yaffs_FillInodeFromObject(inode, obj);
 
        yaffs_GrossUnlock(dev);
-       
+
        unlock_new_inode(inode);
        return inode;
 }
@@ -1740,7 +1699,7 @@ static void yaffs_read_inode(struct inode *inode)
        yaffs_Device *dev = yaffs_SuperToDevice(inode->i_sb);
 
        T(YAFFS_TRACE_OS,
-         "yaffs_read_inode for %d\n", (int)inode->i_ino));
+               ("yaffs_read_inode for %d\n", (int)inode->i_ino));
 
        yaffs_GrossLock(dev);
 
@@ -1755,16 +1714,16 @@ static void yaffs_read_inode(struct inode *inode)
 
 static YLIST_HEAD(yaffs_dev_list);
 
-#if 0 // not used
+#if 0 /* not used */
 static int yaffs_remount_fs(struct super_block *sb, int *flags, char *data)
 {
        yaffs_Device    *dev = yaffs_SuperToDevice(sb);
 
-       if( *flags & MS_RDONLY ) {
+       if (*flags & MS_RDONLY) {
                struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice;
 
                T(YAFFS_TRACE_OS,
-                       ( "yaffs_remount_fs: %s: RO\n", dev->name ));
+                       ("yaffs_remount_fs: %s: RO\n", dev->name));
 
                yaffs_GrossLock(dev);
 
@@ -1776,10 +1735,9 @@ static int yaffs_remount_fs(struct super_block *sb, int *flags, char *data)
                        mtd->sync(mtd);
 
                yaffs_GrossUnlock(dev);
-       }
-       else {
+       } else {
                T(YAFFS_TRACE_OS,
-                       ( "yaffs_remount_fs: %s: RW\n", dev->name ));
+                       ("yaffs_remount_fs: %s: RW\n", dev->name));
        }
 
        return 0;
@@ -1790,7 +1748,7 @@ static void yaffs_put_super(struct super_block *sb)
 {
        yaffs_Device *dev = yaffs_SuperToDevice(sb);
 
-       T(YAFFS_TRACE_OS, ( "yaffs_put_super\n"));
+       T(YAFFS_TRACE_OS, ("yaffs_put_super\n"));
 
        yaffs_GrossLock(dev);
 
@@ -1798,9 +1756,8 @@ static void yaffs_put_super(struct super_block *sb)
 
        yaffs_CheckpointSave(dev);
 
-       if (dev->putSuperFunc) {
+       if (dev->putSuperFunc)
                dev->putSuperFunc(sb);
-       }
 
        yaffs_Deinitialise(dev);
 
@@ -1809,7 +1766,7 @@ static void yaffs_put_super(struct super_block *sb)
        /* we assume this is protected by lock_kernel() in mount/umount */
        ylist_del(&dev->devList);
 
-       if(dev->spareBuffer){
+       if (dev->spareBuffer) {
                YFREE(dev->spareBuffer);
                dev->spareBuffer = NULL;
        }
@@ -1820,12 +1777,10 @@ static void yaffs_put_super(struct super_block *sb)
 
 static void yaffs_MTDPutSuper(struct super_block *sb)
 {
-
        struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice;
 
-       if (mtd->sync) {
+       if (mtd->sync)
                mtd->sync(mtd);
-       }
 
        put_mtd_device(mtd);
 }
@@ -1835,8 +1790,8 @@ static void yaffs_MarkSuperBlockDirty(void *vsb)
 {
        struct super_block *sb = (struct super_block *)vsb;
 
-       T(YAFFS_TRACE_OS, ( "yaffs_MarkSuperBlockDirty() sb = %p\n",sb));
-       if(sb)
+       T(YAFFS_TRACE_OS, ("yaffs_MarkSuperBlockDirty() sb = %p\n", sb));
+       if (sb)
                sb->s_dirt = 1;
 }
 
@@ -1850,48 +1805,48 @@ typedef struct {
 #define MAX_OPT_LEN 20
 static int yaffs_parse_options(yaffs_options *options, const char *options_str)
 {
-       char cur_opt[MAX_OPT_LEN+1];
+       char cur_opt[MAX_OPT_LEN + 1];
        int p;
        int error = 0;
 
        /* Parse through the options which is a comma seperated list */
 
-       while(options_str && *options_str && !error){
-               memset(cur_opt,0,MAX_OPT_LEN+1);
+       while (options_str && *options_str && !error) {
+               memset(cur_opt, 0, MAX_OPT_LEN + 1);
                p = 0;
 
-               while(*options_str && *options_str != ','){
-                       if(p < MAX_OPT_LEN){
+               while (*options_str && *options_str != ',') {
+                       if (p < MAX_OPT_LEN) {
                                cur_opt[p] = *options_str;
                                p++;
                        }
                        options_str++;
                }
 
-               if(!strcmp(cur_opt,"inband-tags"))
+               if (!strcmp(cur_opt, "inband-tags"))
                        options->inband_tags = 1;
-               else if(!strcmp(cur_opt,"no-cache"))
+               else if (!strcmp(cur_opt, "no-cache"))
                        options->no_cache = 1;
-               else if(!strcmp(cur_opt,"no-checkpoint-read"))
+               else if (!strcmp(cur_opt, "no-checkpoint-read"))
                        options->skip_checkpoint_read = 1;
-               else if(!strcmp(cur_opt,"no-checkpoint-write"))
+               else if (!strcmp(cur_opt, "no-checkpoint-write"))
                        options->skip_checkpoint_write = 1;
-               else if(!strcmp(cur_opt,"no-checkpoint")){
+               else if (!strcmp(cur_opt, "no-checkpoint")) {
                        options->skip_checkpoint_read = 1;
                        options->skip_checkpoint_write = 1;
                } else {
-                       printk(KERN_INFO "yaffs: Bad mount option \"%s\"\n",cur_opt);
+                       printk(KERN_INFO "yaffs: Bad mount option \"%s\"\n",
+                                       cur_opt);
                        error = 1;
                }
-
        }
 
        return error;
 }
 
 static struct super_block *yaffs_internal_read_super(int yaffsVersion,
-                                                    struct super_block *sb,
-                                                    void *data, int silent)
+                                               struct super_block *sb,
+                                               void *data, int silent)
 {
        int nBlocks;
        struct inode *inode = NULL;
@@ -1919,14 +1874,14 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
                       sb->s_dev,
                       yaffs_devname(sb, devname_buf));
 
-       if(!data_str)
+       if (!data_str)
                data_str = "";
 
-       printk(KERN_INFO "yaffs: passed flags \"%s\"\n",data_str);
+       printk(KERN_INFO "yaffs: passed flags \"%s\"\n", data_str);
 
-       memset(&options,0,sizeof(options));
+       memset(&options, 0, sizeof(options));
 
-       if(yaffs_parse_options(&options,data_str)){
+       if (yaffs_parse_options(&options, data_str)) {
                /* Option parsing failed */
                return NULL;
        }
@@ -1978,7 +1933,7 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
        T(YAFFS_TRACE_OS, (" %s %d\n", WRITE_SIZE_STR, WRITE_SIZE(mtd)));
        T(YAFFS_TRACE_OS, (" oobsize %d\n", mtd->oobsize));
        T(YAFFS_TRACE_OS, (" erasesize %d\n", mtd->erasesize));
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
        T(YAFFS_TRACE_OS, (" size %u\n", mtd->size));
 #else
        T(YAFFS_TRACE_OS, (" size %lld\n", mtd->size));
@@ -1988,15 +1943,15 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
 
        if (yaffsVersion == 1 &&
            WRITE_SIZE(mtd) >= 2048) {
-           T(YAFFS_TRACE_ALWAYS,("yaffs: auto selecting yaffs2\n"));
+           T(YAFFS_TRACE_ALWAYS, ("yaffs: auto selecting yaffs2\n"));
            yaffsVersion = 2;
        }
 
        /* Added NCB 26/5/2006 for completeness */
-       if (yaffsVersion == 2 && 
+       if (yaffsVersion == 2 &&
            !options.inband_tags &&
-           WRITE_SIZE(mtd) == 512){
-           T(YAFFS_TRACE_ALWAYS,("yaffs: auto selecting yaffs1\n"));
+           WRITE_SIZE(mtd) == 512) {
+           T(YAFFS_TRACE_ALWAYS, ("yaffs: auto selecting yaffs1\n"));
            yaffsVersion = 1;
        }
 
@@ -2009,7 +1964,7 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
                    !mtd->block_markbad ||
                    !mtd->read ||
                    !mtd->write ||
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
                    !mtd->read_oob || !mtd->write_oob) {
 #else
                    !mtd->write_ecc ||
@@ -2034,7 +1989,7 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
                if (!mtd->erase ||
                    !mtd->read ||
                    !mtd->write ||
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
                    !mtd->read_oob || !mtd->write_oob) {
 #else
                    !mtd->write_ecc ||
@@ -2060,7 +2015,7 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
         * Set the yaffs_Device up for mtd
         */
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
        sb->s_fs_info = dev = kmalloc(sizeof(yaffs_Device), GFP_KERNEL);
 #else
        sb->u.generic_sbp = dev = kmalloc(sizeof(yaffs_Device), GFP_KERNEL);
@@ -2079,7 +2034,7 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
 
        /* Set up the memory size parameters.... */
 
-       nBlocks = YCALCBLOCKS(mtd->size ,(YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK));
+       nBlocks = YCALCBLOCKS(mtd->size(YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK));
 
        dev->startBlock = 0;
        dev->endBlock = nBlocks - 1;
@@ -2099,19 +2054,19 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
                dev->queryNANDBlock = nandmtd2_QueryNANDBlock;
                dev->spareBuffer = YMALLOC(mtd->oobsize);
                dev->isYaffs2 = 1;
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
                dev->totalBytesPerChunk = mtd->writesize;
                dev->nChunksPerBlock = mtd->erasesize / mtd->writesize;
 #else
                dev->totalBytesPerChunk = mtd->oobblock;
                dev->nChunksPerBlock = mtd->erasesize / mtd->oobblock;
 #endif
-               nBlocks = YCALCBLOCKS(mtd->size,mtd->erasesize);
+               nBlocks = YCALCBLOCKS(mtd->size, mtd->erasesize);
 
                dev->startBlock = 0;
                dev->endBlock = nBlocks - 1;
        } else {
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
                /* use the MTD interface in yaffs_mtdif1.c */
                dev->writeChunkWithTagsToNAND =
                        nandmtd1_WriteChunkWithTagsToNAND;
@@ -2193,14 +2148,14 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
 }
 
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
 static int yaffs_internal_read_super_mtd(struct super_block *sb, void *data,
                                         int silent)
 {
        return yaffs_internal_read_super(1, sb, data, silent) ? 0 : -EINVAL;
 }
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
 static int yaffs_read_super(struct file_system_type *fs,
                            int flags, const char *dev_name,
                            void *data, struct vfsmount *mnt)
@@ -2241,14 +2196,14 @@ static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super,
 
 #ifdef CONFIG_YAFFS_YAFFS2
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
 static int yaffs2_internal_read_super_mtd(struct super_block *sb, void *data,
                                          int silent)
 {
        return yaffs_internal_read_super(2, sb, data, silent) ? 0 : -EINVAL;
 }
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
 static int yaffs2_read_super(struct file_system_type *fs,
                        int flags, const char *dev_name, void *data,
                        struct vfsmount *mnt)
@@ -2421,7 +2376,7 @@ static int yaffs_proc_write(struct file *file, const char *buf,
        char *end;
        char *mask_name;
        const char *x;
-       char substring[MAX_MASK_NAME_LENGTH+1];
+       char substring[MAX_MASK_NAME_LENGTH + 1];
        int i;
        int done = 0;
        int add, len = 0;
@@ -2456,14 +2411,14 @@ static int yaffs_proc_write(struct file *file, const char *buf,
                        pos += len;
                        done = 0;
                } else {
-                       for(x = buf + pos, i = 0;
-                           (*x == '_' || (*x >='a' && *x <= 'z')) &&
-                           i <MAX_MASK_NAME_LENGTH; x++, i++, pos++)
-                           substring[i] = *x;
+                       for (x = buf + pos, i = 0;
+                           (*x == '_' || (*x >= 'a' && *x <= 'z')) &&
+                           i < MAX_MASK_NAME_LENGTH; x++, i++, pos++)
+                               substring[i] = *x;
                        substring[i] = '\0';
 
                        for (i = 0; mask_flags[i].mask_name != NULL; i++) {
-                               if(strcmp(substring,mask_flags[i].mask_name) == 0){
+                               if (strcmp(substring, mask_flags[i].mask_name) == 0) {
                                        mask_name = mask_flags[i].mask_name;
                                        mask_bitfield = mask_flags[i].mask_bitfield;
                                        done = 0;
@@ -2474,7 +2429,7 @@ static int yaffs_proc_write(struct file *file, const char *buf,
 
                if (mask_name != NULL) {
                        done = 0;
-                       switch(add) {
+                       switch (add) {
                        case '-':
                                rg &= ~mask_bitfield;
                                break;
@@ -2493,13 +2448,13 @@ static int yaffs_proc_write(struct file *file, const char *buf,
 
        yaffs_traceMask = rg | YAFFS_TRACE_ALWAYS;
 
-       printk("new trace = 0x%08X\n",yaffs_traceMask);
+       printk(KERN_DEBUG "new trace = 0x%08X\n", yaffs_traceMask);
 
        if (rg & YAFFS_TRACE_ALWAYS) {
                for (i = 0; mask_flags[i].mask_name != NULL; i++) {
                        char flag;
                        flag = ((rg & mask_flags[i].mask_bitfield) == mask_flags[i].mask_bitfield) ? '+' : '-';
-                       printk("%c%s\n", flag, mask_flags[i].mask_name);
+                       printk(KERN_DEBUG "%c%s\n", flag, mask_flags[i].mask_name);
                }
        }
 
@@ -2513,12 +2468,8 @@ struct file_system_to_install {
 };
 
 static struct file_system_to_install fs_to_install[] = {
-//#ifdef CONFIG_YAFFS_YAFFS1
        {&yaffs_fs_type, 0},
-//#endif
-//#ifdef CONFIG_YAFFS_YAFFS2
        {&yaffs2_fs_type, 0},
-//#endif
        {NULL, 0}
 };
 
@@ -2590,7 +2541,6 @@ static void __exit exit_yaffs_fs(void)
                }
                fsinst++;
        }
-
 }
 
 module_init(init_yaffs_fs)
index b9742ac..5b0a1ac 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
  *
  * Copyright (C) 2002-2007 Aleph One Ltd.
  *   for Toby Churchill Ltd and Brightstar Engineering
index ea1ffc2..4359db2 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 const char *yaffs_guts_c_version =
-    "$Id: yaffs_guts.c,v 1.80 2009-03-05 21:46:46 charles Exp $";
+    "$Id: yaffs_guts.c,v 1.81 2009-03-06 17:20:51 wookey Exp $";
 
 #include "yportenv.h"
 
@@ -22,7 +22,7 @@ const char *yaffs_guts_c_version =
 #include "yaffs_getblockinfo.h"
 
 #include "yaffs_tagscompat.h"
-#ifndef  CONFIG_YAFFS_USE_OWN_SORT
+#ifndef CONFIG_YAFFS_USE_OWN_SORT
 #include "yaffs_qsort.h"
 #endif
 #include "yaffs_nand.h"
@@ -39,101 +39,102 @@ const char *yaffs_guts_c_version =
 
 
 /* Robustification (if it ever comes about...) */
-static void yaffs_RetireBlock(yaffs_Device * dev, int blockInNAND);
-static void yaffs_HandleWriteChunkError(yaffs_Device * dev, int chunkInNAND, int erasedOk);
-static void yaffs_HandleWriteChunkOk(yaffs_Device * dev, int chunkInNAND,
-                                    const __u8 * data,
-                                    const yaffs_ExtendedTags * tags);
-static void yaffs_HandleUpdateChunk(yaffs_Device * dev, int chunkInNAND,
-                                   const yaffs_ExtendedTags * tags);
+static void yaffs_RetireBlock(yaffs_Device *dev, int blockInNAND);
+static void yaffs_HandleWriteChunkError(yaffs_Device *dev, int chunkInNAND,
+               int erasedOk);
+static void yaffs_HandleWriteChunkOk(yaffs_Device *dev, int chunkInNAND,
+                               const __u8 *data,
+                               const yaffs_ExtendedTags *tags);
+static void yaffs_HandleUpdateChunk(yaffs_Device *dev, int chunkInNAND,
+                               const yaffs_ExtendedTags *tags);
 
 /* Other local prototypes */
-static int yaffs_UnlinkObject( yaffs_Object *obj);
+static int yaffs_UnlinkObject(yaffs_Object *obj);
 static int yaffs_ObjectHasCachedWriteData(yaffs_Object *obj);
 
 static void yaffs_HardlinkFixup(yaffs_Device *dev, yaffs_Object *hardList);
 
-static int yaffs_WriteNewChunkWithTagsToNAND(yaffs_Device * dev,
-                                            const __u8 * buffer,
-                                            yaffs_ExtendedTags * tags,
-                                            int useReserve);
-static int yaffs_PutChunkIntoFile(yaffs_Object * in, int chunkInInode,
-                                 int chunkInNAND, int inScan);
-
-static yaffs_Object *yaffs_CreateNewObject(yaffs_Device * dev, int number,
-                                          yaffs_ObjectType type);
-static void yaffs_AddObjectToDirectory(yaffs_Object * directory,
-                                      yaffs_Object * obj);
-static int yaffs_UpdateObjectHeader(yaffs_Object * in, const YCHAR * name,
-                                   int force, int isShrink, int shadows);
-static void yaffs_RemoveObjectFromDirectory(yaffs_Object * obj);
+static int yaffs_WriteNewChunkWithTagsToNAND(yaffs_Device *dev,
+                                       const __u8 *buffer,
+                                       yaffs_ExtendedTags *tags,
+                                       int useReserve);
+static int yaffs_PutChunkIntoFile(yaffs_Object *in, int chunkInInode,
+                               int chunkInNAND, int inScan);
+
+static yaffs_Object *yaffs_CreateNewObject(yaffs_Device *dev, int number,
+                                       yaffs_ObjectType type);
+static void yaffs_AddObjectToDirectory(yaffs_Object *directory,
+                               yaffs_Object *obj);
+static int yaffs_UpdateObjectHeader(yaffs_Object *in, const YCHAR *name,
+                               int force, int isShrink, int shadows);
+static void yaffs_RemoveObjectFromDirectory(yaffs_Object *obj);
 static int yaffs_CheckStructures(void);
-static int yaffs_DeleteWorker(yaffs_Object * in, yaffs_Tnode * tn, __u32 level,
-                             int chunkOffset, int *limit);
-static int yaffs_DoGenericObjectDeletion(yaffs_Object * in);
+static int yaffs_DeleteWorker(yaffs_Object *in, yaffs_Tnode *tn, __u32 level,
+                       int chunkOffset, int *limit);
+static int yaffs_DoGenericObjectDeletion(yaffs_Object *in);
 
-static yaffs_BlockInfo *yaffs_GetBlockInfo(yaffs_Device * dev, int blockNo);
+static yaffs_BlockInfo *yaffs_GetBlockInfo(yaffs_Device *dev, int blockNo);
 
 
 static int yaffs_CheckChunkErased(struct yaffs_DeviceStruct *dev,
-                                 int chunkInNAND);
+                               int chunkInNAND);
 
-static int yaffs_UnlinkWorker(yaffs_Object * obj);
+static int yaffs_UnlinkWorker(yaffs_Object *obj);
 
-static int yaffs_TagsMatch(const yaffs_ExtendedTags * tags, int objectId,
-                          int chunkInObject);
+static int yaffs_TagsMatch(const yaffs_ExtendedTags *tags, int objectId,
+                       int chunkInObject);
 
-loff_t yaffs_GetFileSize(yaffs_Object * obj);
+loff_t yaffs_GetFileSize(yaffs_Object *obj);
 
-static int yaffs_AllocateChunk(yaffs_Device * dev, int useReserve, yaffs_BlockInfo **blockUsedPtr);
+static int yaffs_AllocateChunk(yaffs_Device *dev, int useReserve,
+                               yaffs_BlockInfo **blockUsedPtr);
 
-static void yaffs_VerifyFreeChunks(yaffs_Device * dev);
+static void yaffs_VerifyFreeChunks(yaffs_Device *dev);
 
 static void yaffs_CheckObjectDetailsLoaded(yaffs_Object *in);
 
 static void yaffs_VerifyDirectory(yaffs_Object *directory);
 #ifdef YAFFS_PARANOID
-static int yaffs_CheckFileSanity(yaffs_Object * in);
+static int yaffs_CheckFileSanity(yaffs_Object *in);
 #else
 #define yaffs_CheckFileSanity(in)
 #endif
 
-static void yaffs_InvalidateWholeChunkCache(yaffs_Object * in);
-static void yaffs_InvalidateChunkCache(yaffs_Object * object, int chunkId);
+static void yaffs_InvalidateWholeChunkCache(yaffs_Object *in);
+static void yaffs_InvalidateChunkCache(yaffs_Object *object, int chunkId);
 
 static void yaffs_InvalidateCheckpoint(yaffs_Device *dev);
 
-static int yaffs_FindChunkInFile(yaffs_Object * in, int chunkInInode,
-                                yaffs_ExtendedTags * tags);
+static int yaffs_FindChunkInFile(yaffs_Object *in, int chunkInInode,
+                               yaffs_ExtendedTags *tags);
 
-static __u32 yaffs_GetChunkGroupBase(yaffs_Device *dev, yaffs_Tnode *tn, unsigned pos);
-static yaffs_Tnode *yaffs_FindLevel0Tnode(yaffs_Device * dev,
-                                         yaffs_FileStructure * fStruct,
-                                         __u32 chunkId);
+static __u32 yaffs_GetChunkGroupBase(yaffs_Device *dev, yaffs_Tnode *tn,
+               unsigned pos);
+static yaffs_Tnode *yaffs_FindLevel0Tnode(yaffs_Device *dev,
+                                       yaffs_FileStructure *fStruct,
+                                       __u32 chunkId);
 
 
 /* Function to calculate chunk and offset */
 
-static void yaffs_AddrToChunk(yaffs_Device *dev, loff_t addr, int *chunkOut, __u32 *offsetOut)
+static void yaffs_AddrToChunk(yaffs_Device *dev, loff_t addr, int *chunkOut,
+               __u32 *offsetOut)
 {
        int chunk;
        __u32 offset;
-       
+
        chunk  = (__u32)(addr >> dev->chunkShift);
-               
-       if(dev->chunkDiv == 1)
-       {
+
+       if (dev->chunkDiv == 1) {
                /* easy power of 2 case */
                offset = (__u32)(addr & dev->chunkMask);
-       }
-       else
-       {
+       } else {
                /* Non power-of-2 case */
-               
+
                loff_t chunkBase;
-               
+
                chunk /= dev->chunkDiv;
-               
+
                chunkBase = ((loff_t)chunk) * dev->nDataBytesPerChunk;
                offset = (__u32)(addr - chunkBase);
        }
@@ -142,79 +143,80 @@ static void yaffs_AddrToChunk(yaffs_Device *dev, loff_t addr, int *chunkOut, __u
        *offsetOut = offset;
 }
 
-/* Function to return the number of shifts for a power of 2 greater than or equal 
- * to the given number
+/* Function to return the number of shifts for a power of 2 greater than or
+ * equal to the given number
  * Note we don't try to cater for all possible numbers and this does not have to
  * be hellishly efficient.
  */
+
 static __u32 ShiftsGE(__u32 x)
 {
        int extraBits;
        int nShifts;
-       
+
        nShifts = extraBits = 0;
-       
-       while(x>1){
-               if(x & 1) extraBits++;
-               x>>=1;
+
+       while (x > 1) {
+               if (x & 1)
+                       extraBits++;
+               x >>= 1;
                nShifts++;
        }
 
-       if(extraBits) 
+       if (extraBits)
                nShifts++;
-               
+
        return nShifts;
 }
 
 /* Function to return the number of shifts to get a 1 in bit 0
  */
+
 static __u32 Shifts(__u32 x)
 {
        int nShifts;
-       
+
        nShifts =  0;
-       
-       if(!x) return 0;
-       
-       while( !(x&1)){
-               x>>=1;
+
+       if (!x)
+               return 0;
+
+       while (!(x&1)) {
+               x >>= 1;
                nShifts++;
        }
-               
+
        return nShifts;
 }
 
 
 
-/* 
+/*
  * Temporary buffer manipulations.
  */
 
-static int yaffs_InitialiseTempBuffers(yaffs_Device *dev)      
+static int yaffs_InitialiseTempBuffers(yaffs_Device *dev)
 {
        int i;
        __u8 *buf = (__u8 *)1;
-               
-       memset(dev->tempBuffer,0,sizeof(dev->tempBuffer));
-               
+
+       memset(dev->tempBuffer, 0, sizeof(dev->tempBuffer));
+
        for (i = 0; buf && i < YAFFS_N_TEMP_BUFFERS; i++) {
                dev->tempBuffer[i].line = 0;    /* not in use */
                dev->tempBuffer[i].buffer = buf =
                    YMALLOC_DMA(dev->totalBytesPerChunk);
        }
-               
+
        return buf ? YAFFS_OK : YAFFS_FAIL;
-       
 }
 
-__u8 *yaffs_GetTempBuffer(yaffs_Device * dev, int lineNo)
+__u8 *yaffs_GetTempBuffer(yaffs_Device *dev, int lineNo)
 {
        int i, j;
 
        dev->tempInUse++;
-       if(dev->tempInUse > dev->maxTemp)
+       if (dev->tempInUse > dev->maxTemp)
                dev->maxTemp = dev->tempInUse;
 
        for (i = 0; i < YAFFS_N_TEMP_BUFFERS; i++) {
@@ -249,13 +251,13 @@ __u8 *yaffs_GetTempBuffer(yaffs_Device * dev, int lineNo)
 
 }
 
-void yaffs_ReleaseTempBuffer(yaffs_Device * dev, __u8 * buffer,
+void yaffs_ReleaseTempBuffer(yaffs_Device *dev, __u8 *buffer,
                                    int lineNo)
 {
        int i;
-       
+
        dev->tempInUse--;
-       
+
        for (i = 0; i < YAFFS_N_TEMP_BUFFERS; i++) {
                if (dev->tempBuffer[i].buffer == buffer) {
                        dev->tempBuffer[i].line = 0;
@@ -277,27 +279,26 @@ void yaffs_ReleaseTempBuffer(yaffs_Device * dev, __u8 * buffer,
 /*
  * Determine if we have a managed buffer.
  */
-int yaffs_IsManagedTempBuffer(yaffs_Device * dev, const __u8 * buffer)
+int yaffs_IsManagedTempBuffer(yaffs_Device *dev, const __u8 *buffer)
 {
        int i;
+
        for (i = 0; i < YAFFS_N_TEMP_BUFFERS; i++) {
                if (dev->tempBuffer[i].buffer == buffer)
                        return 1;
-
        }
 
-    for (i = 0; i < dev->nShortOpCaches; i++) {
-        if( dev->srCache[i].data == buffer )
-            return 1;
-
-    }
+       for (i = 0; i < dev->nShortOpCaches; i++) {
+               if (dev->srCache[i].data == buffer)
+                       return 1;
+       }
 
-    if (buffer == dev->checkpointBuffer)
-      return 1;
+       if (buffer == dev->checkpointBuffer)
+               return 1;
 
-    T(YAFFS_TRACE_ALWAYS,
-         (TSTR("yaffs: unmaged buffer detected.\n" TENDSTR)));
-    return 0;
+       T(YAFFS_TRACE_ALWAYS,
+               (TSTR("yaffs: unmaged buffer detected.\n" TENDSTR)));
+       return 0;
 }
 
 
@@ -306,62 +307,63 @@ int yaffs_IsManagedTempBuffer(yaffs_Device * dev, const __u8 * buffer)
  * Chunk bitmap manipulations
  */
 
-static Y_INLINE __u8 *yaffs_BlockBits(yaffs_Device * dev, int blk)
+static Y_INLINE __u8 *yaffs_BlockBits(yaffs_Device *dev, int blk)
 {
        if (blk < dev->internalStartBlock || blk > dev->internalEndBlock) {
                T(YAFFS_TRACE_ERROR,
-                 (TSTR("**>> yaffs: BlockBits block %d is not valid" TENDSTR),
-                  blk));
+                       (TSTR("**>> yaffs: BlockBits block %d is not valid" TENDSTR),
+                       blk));
                YBUG();
        }
        return dev->chunkBits +
-           (dev->chunkBitmapStride * (blk - dev->internalStartBlock));
+               (dev->chunkBitmapStride * (blk - dev->internalStartBlock));
 }
 
 static Y_INLINE void yaffs_VerifyChunkBitId(yaffs_Device *dev, int blk, int chunk)
 {
-       if(blk < dev->internalStartBlock || blk > dev->internalEndBlock ||
-          chunk < 0 || chunk >= dev->nChunksPerBlock) {
-          T(YAFFS_TRACE_ERROR,
-           (TSTR("**>> yaffs: Chunk Id (%d:%d) invalid"TENDSTR),blk,chunk));
-           YBUG();
+       if (blk < dev->internalStartBlock || blk > dev->internalEndBlock ||
+                       chunk < 0 || chunk >= dev->nChunksPerBlock) {
+               T(YAFFS_TRACE_ERROR,
+               (TSTR("**>> yaffs: Chunk Id (%d:%d) invalid"TENDSTR),
+                       blk, chunk));
+               YBUG();
        }
 }
 
-static Y_INLINE void yaffs_ClearChunkBits(yaffs_Device * dev, int blk)
+static Y_INLINE void yaffs_ClearChunkBits(yaffs_Device *dev, int blk)
 {
        __u8 *blkBits = yaffs_BlockBits(dev, blk);
 
        memset(blkBits, 0, dev->chunkBitmapStride);
 }
 
-static Y_INLINE void yaffs_ClearChunkBit(yaffs_Device * dev, int blk, int chunk)
+static Y_INLINE void yaffs_ClearChunkBit(yaffs_Device *dev, int blk, int chunk)
 {
        __u8 *blkBits = yaffs_BlockBits(dev, blk);
 
-       yaffs_VerifyChunkBitId(dev,blk,chunk);
+       yaffs_VerifyChunkBitId(dev, blk, chunk);
 
        blkBits[chunk / 8] &= ~(1 << (chunk & 7));
 }
 
-static Y_INLINE void yaffs_SetChunkBit(yaffs_Device * dev, int blk, int chunk)
+static Y_INLINE void yaffs_SetChunkBit(yaffs_Device *dev, int blk, int chunk)
 {
        __u8 *blkBits = yaffs_BlockBits(dev, blk);
-       
-       yaffs_VerifyChunkBitId(dev,blk,chunk);
+
+       yaffs_VerifyChunkBitId(dev, blk, chunk);
 
        blkBits[chunk / 8] |= (1 << (chunk & 7));
 }
 
-static Y_INLINE int yaffs_CheckChunkBit(yaffs_Device * dev, int blk, int chunk)
+static Y_INLINE int yaffs_CheckChunkBit(yaffs_Device *dev, int blk, int chunk)
 {
        __u8 *blkBits = yaffs_BlockBits(dev, blk);
-       yaffs_VerifyChunkBitId(dev,blk,chunk);
+       yaffs_VerifyChunkBitId(dev, blk, chunk);
 
        return (blkBits[chunk / 8] & (1 << (chunk & 7))) ? 1 : 0;
 }
 
-static Y_INLINE int yaffs_StillSomeChunkBits(yaffs_Device * dev, int blk)
+static Y_INLINE int yaffs_StillSomeChunkBits(yaffs_Device *dev, int blk)
 {
        __u8 *blkBits = yaffs_BlockBits(dev, blk);
        int i;
@@ -373,28 +375,28 @@ static Y_INLINE int yaffs_StillSomeChunkBits(yaffs_Device * dev, int blk)
        return 0;
 }
 
-static int yaffs_CountChunkBits(yaffs_Device * dev, int blk)
+static int yaffs_CountChunkBits(yaffs_Device *dev, int blk)
 {
        __u8 *blkBits = yaffs_BlockBits(dev, blk);
        int i;
        int n = 0;
        for (i = 0; i < dev->chunkBitmapStride; i++) {
                __u8 x = *blkBits;
-               while(x){
-                       if(x & 1)
+               while (x) {
+                       if (x & 1)
                                n++;
-                       x >>=1;
+                       x >>= 1;
                }
-                       
+
                blkBits++;
        }
        return n;
 }
 
-/* 
+/*
  * Verification code
  */
+
 static int yaffs_SkipVerification(yaffs_Device *dev)
 {
        return !(yaffs_traceMask & (YAFFS_TRACE_VERIFY | YAFFS_TRACE_VERIFY_FULL));
@@ -410,7 +412,7 @@ static int yaffs_SkipNANDVerification(yaffs_Device *dev)
        return !(yaffs_traceMask & (YAFFS_TRACE_VERIFY_NAND));
 }
 
-static const char * blockStateName[] = {
+static const char *blockStateName[] = {
 "Unknown",
 "Needs scanning",
 "Scanning",
@@ -423,65 +425,65 @@ static const char * blockStateName[] = {
 "Dead"
 };
 
-static void yaffs_VerifyBlock(yaffs_Device *dev,yaffs_BlockInfo *bi,int n)
+static void yaffs_VerifyBlock(yaffs_Device *dev, yaffs_BlockInfo *bi, int n)
 {
        int actuallyUsed;
        int inUse;
-       
-       if(yaffs_SkipVerification(dev))
+
+       if (yaffs_SkipVerification(dev))
                return;
-               
+
        /* Report illegal runtime states */
-       if(bi->blockState >= YAFFS_NUMBER_OF_BLOCK_STATES)
-               T(YAFFS_TRACE_VERIFY,(TSTR("Block %d has undefined state %d"TENDSTR),n,bi->blockState));
-               
-       switch(bi->blockState){
-        case YAFFS_BLOCK_STATE_UNKNOWN:
-        case YAFFS_BLOCK_STATE_SCANNING:
-        case YAFFS_BLOCK_STATE_NEEDS_SCANNING:
-               T(YAFFS_TRACE_VERIFY,(TSTR("Block %d has bad run-state %s"TENDSTR),
-               n,blockStateName[bi->blockState]));
+       if (bi->blockState >= YAFFS_NUMBER_OF_BLOCK_STATES)
+               T(YAFFS_TRACE_VERIFY, (TSTR("Block %d has undefined state %d"TENDSTR), n, bi->blockState));
+
+       switch (bi->blockState) {
+       case YAFFS_BLOCK_STATE_UNKNOWN:
+       case YAFFS_BLOCK_STATE_SCANNING:
+       case YAFFS_BLOCK_STATE_NEEDS_SCANNING:
+               T(YAFFS_TRACE_VERIFY, (TSTR("Block %d has bad run-state %s"TENDSTR),
+               n, blockStateName[bi->blockState]));
        }
-       
+
        /* Check pages in use and soft deletions are legal */
-       
+
        actuallyUsed = bi->pagesInUse - bi->softDeletions;
-       
-       if(bi->pagesInUse < 0 || bi->pagesInUse > dev->nChunksPerBlock ||
+
+       if (bi->pagesInUse < 0 || bi->pagesInUse > dev->nChunksPerBlock ||
           bi->softDeletions < 0 || bi->softDeletions > dev->nChunksPerBlock ||
           actuallyUsed < 0 || actuallyUsed > dev->nChunksPerBlock)
-               T(YAFFS_TRACE_VERIFY,(TSTR("Block %d has illegal values pagesInUsed %d softDeletions %d"TENDSTR),
-               n,bi->pagesInUse,bi->softDeletions));
-       
-               
+               T(YAFFS_TRACE_VERIFY, (TSTR("Block %d has illegal values pagesInUsed %d softDeletions %d"TENDSTR),
+               n, bi->pagesInUse, bi->softDeletions));
+
+
        /* Check chunk bitmap legal */
-       inUse = yaffs_CountChunkBits(dev,n);
-       if(inUse != bi->pagesInUse)
-               T(YAFFS_TRACE_VERIFY,(TSTR("Block %d has inconsistent values pagesInUse %d counted chunk bits %d"TENDSTR),
-                       n,bi->pagesInUse,inUse));
-       
+       inUse = yaffs_CountChunkBits(dev, n);
+       if (inUse != bi->pagesInUse)
+               T(YAFFS_TRACE_VERIFY, (TSTR("Block %d has inconsistent values pagesInUse %d counted chunk bits %d"TENDSTR),
+                       n, bi->pagesInUse, inUse));
+
        /* Check that the sequence number is valid.
-        * Ten million is legal, but is very unlikely 
+        * Ten million is legal, but is very unlikely
         */
-       if(dev->isYaffs2 && 
+       if (dev->isYaffs2 &&
           (bi->blockState == YAFFS_BLOCK_STATE_ALLOCATING || bi->blockState == YAFFS_BLOCK_STATE_FULL) &&
-          (bi->sequenceNumber < YAFFS_LOWEST_SEQUENCE_NUMBER || bi->sequenceNumber > 10000000 ))
-               T(YAFFS_TRACE_VERIFY,(TSTR("Block %d has suspect sequence number of %d"TENDSTR),
-               n,bi->sequenceNumber));
-               
+          (bi->sequenceNumber < YAFFS_LOWEST_SEQUENCE_NUMBER || bi->sequenceNumber > 10000000))
+               T(YAFFS_TRACE_VERIFY, (TSTR("Block %d has suspect sequence number of %d"TENDSTR),
+               n, bi->sequenceNumber));
 }
 
-static void yaffs_VerifyCollectedBlock(yaffs_Device *dev,yaffs_BlockInfo *bi,int n)
+static void yaffs_VerifyCollectedBlock(yaffs_Device *dev, yaffs_BlockInfo *bi,
+               int n)
 {
-       yaffs_VerifyBlock(dev,bi,n);
-       
+       yaffs_VerifyBlock(dev, bi, n);
+
        /* After collection the block should be in the erased state */
        /* This will need to change if we do partial gc */
-       
-       if(bi->blockState != YAFFS_BLOCK_STATE_COLLECTING &&
-          bi->blockState != YAFFS_BLOCK_STATE_EMPTY){
-               T(YAFFS_TRACE_ERROR,(TSTR("Block %d is in state %d after gc, should be erased"TENDSTR),
-                       n,bi->blockState));
+
+       if (bi->blockState != YAFFS_BLOCK_STATE_COLLECTING &&
+                       bi->blockState != YAFFS_BLOCK_STATE_EMPTY) {
+               T(YAFFS_TRACE_ERROR, (TSTR("Block %d is in state %d after gc, should be erased"TENDSTR),
+                       n, bi->blockState));
        }
 }
 
@@ -490,53 +492,50 @@ static void yaffs_VerifyBlocks(yaffs_Device *dev)
        int i;
        int nBlocksPerState[YAFFS_NUMBER_OF_BLOCK_STATES];
        int nIllegalBlockStates = 0;
-       
 
-       if(yaffs_SkipVerification(dev))
+       if (yaffs_SkipVerification(dev))
                return;
 
-       memset(nBlocksPerState,0,sizeof(nBlocksPerState));
+       memset(nBlocksPerState, 0, sizeof(nBlocksPerState));
 
-               
-       for(i = dev->internalStartBlock; i <= dev->internalEndBlock; i++){
-               yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev,i);
-               yaffs_VerifyBlock(dev,bi,i);
+       for (i = dev->internalStartBlock; i <= dev->internalEndBlock; i++) {
+               yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev, i);
+               yaffs_VerifyBlock(dev, bi, i);
 
-               if(bi->blockState < YAFFS_NUMBER_OF_BLOCK_STATES)
+               if (bi->blockState < YAFFS_NUMBER_OF_BLOCK_STATES)
                        nBlocksPerState[bi->blockState]++;
                else
                        nIllegalBlockStates++;
-                                       
        }
-       
-       T(YAFFS_TRACE_VERIFY,(TSTR(""TENDSTR)));
-       T(YAFFS_TRACE_VERIFY,(TSTR("Block summary"TENDSTR)));
-       
-       T(YAFFS_TRACE_VERIFY,(TSTR("%d blocks have illegal states"TENDSTR),nIllegalBlockStates));
-       if(nBlocksPerState[YAFFS_BLOCK_STATE_ALLOCATING] > 1)
-               T(YAFFS_TRACE_VERIFY,(TSTR("Too many allocating blocks"TENDSTR)));
 
-       for(i = 0; i < YAFFS_NUMBER_OF_BLOCK_STATES; i++)
+       T(YAFFS_TRACE_VERIFY, (TSTR(""TENDSTR)));
+       T(YAFFS_TRACE_VERIFY, (TSTR("Block summary"TENDSTR)));
+
+       T(YAFFS_TRACE_VERIFY, (TSTR("%d blocks have illegal states"TENDSTR), nIllegalBlockStates));
+       if (nBlocksPerState[YAFFS_BLOCK_STATE_ALLOCATING] > 1)
+               T(YAFFS_TRACE_VERIFY, (TSTR("Too many allocating blocks"TENDSTR)));
+
+       for (i = 0; i < YAFFS_NUMBER_OF_BLOCK_STATES; i++)
                T(YAFFS_TRACE_VERIFY,
                  (TSTR("%s %d blocks"TENDSTR),
-                 blockStateName[i],nBlocksPerState[i]));
-       
-       if(dev->blocksInCheckpoint != nBlocksPerState[YAFFS_BLOCK_STATE_CHECKPOINT])
+                 blockStateName[i], nBlocksPerState[i]));
+
+       if (dev->blocksInCheckpoint != nBlocksPerState[YAFFS_BLOCK_STATE_CHECKPOINT])
                T(YAFFS_TRACE_VERIFY,
                 (TSTR("Checkpoint block count wrong dev %d count %d"TENDSTR),
                 dev->blocksInCheckpoint, nBlocksPerState[YAFFS_BLOCK_STATE_CHECKPOINT]));
-                
-       if(dev->nErasedBlocks != nBlocksPerState[YAFFS_BLOCK_STATE_EMPTY])
+
+       if (dev->nErasedBlocks != nBlocksPerState[YAFFS_BLOCK_STATE_EMPTY])
                T(YAFFS_TRACE_VERIFY,
                 (TSTR("Erased block count wrong dev %d count %d"TENDSTR),
                 dev->nErasedBlocks, nBlocksPerState[YAFFS_BLOCK_STATE_EMPTY]));
-                
-       if(nBlocksPerState[YAFFS_BLOCK_STATE_COLLECTING] > 1)
+
+       if (nBlocksPerState[YAFFS_BLOCK_STATE_COLLECTING] > 1)
                T(YAFFS_TRACE_VERIFY,
                 (TSTR("Too many collecting blocks %d (max is 1)"TENDSTR),
                 nBlocksPerState[YAFFS_BLOCK_STATE_COLLECTING]));
 
-       T(YAFFS_TRACE_VERIFY,(TSTR(""TENDSTR)));
+       T(YAFFS_TRACE_VERIFY, (TSTR(""TENDSTR)));
 
 }
 
@@ -546,64 +545,62 @@ static void yaffs_VerifyBlocks(yaffs_Device *dev)
  */
 static void yaffs_VerifyObjectHeader(yaffs_Object *obj, yaffs_ObjectHeader *oh, yaffs_ExtendedTags *tags, int parentCheck)
 {
-       if(obj && yaffs_SkipVerification(obj->myDev))
+       if (obj && yaffs_SkipVerification(obj->myDev))
                return;
-               
-       if(!(tags && obj && oh)){
-               T(YAFFS_TRACE_VERIFY,
-                               (TSTR("Verifying object header tags %x obj %x oh %x"TENDSTR),
-                               (__u32)tags,(__u32)obj,(__u32)oh));
+
+       if (!(tags && obj && oh)) {
+               T(YAFFS_TRACE_VERIFY,
+                               (TSTR("Verifying object header tags %x obj %x oh %x"TENDSTR),
+                               (__u32)tags, (__u32)obj, (__u32)oh));
                return;
        }
-       
-       if(oh->type <= YAFFS_OBJECT_TYPE_UNKNOWN ||
-          oh->type > YAFFS_OBJECT_TYPE_MAX)
-               T(YAFFS_TRACE_VERIFY,
-                (TSTR("Obj %d header type is illegal value 0x%x"TENDSTR),
-                tags->objectId, oh->type));
 
-       if(tags->objectId != obj->objectId)
-               T(YAFFS_TRACE_VERIFY,
-                (TSTR("Obj %d header mismatch objectId %d"TENDSTR),
-                tags->objectId, obj->objectId));
+       if (oh->type <= YAFFS_OBJECT_TYPE_UNKNOWN ||
+                       oh->type > YAFFS_OBJECT_TYPE_MAX)
+               T(YAFFS_TRACE_VERIFY,
+                       (TSTR("Obj %d header type is illegal value 0x%x"TENDSTR),
+                       tags->objectId, oh->type));
+
+       if (tags->objectId != obj->objectId)
+               T(YAFFS_TRACE_VERIFY,
+                       (TSTR("Obj %d header mismatch objectId %d"TENDSTR),
+                       tags->objectId, obj->objectId));
 
 
        /*
         * Check that the object's parent ids match if parentCheck requested.
-        * 
+        *
         * Tests do not apply to the root object.
         */
-       
-       if(parentCheck && tags->objectId > 1 && !obj->parent)
-               T(YAFFS_TRACE_VERIFY,
-                (TSTR("Obj %d header mismatch parentId %d obj->parent is NULL"TENDSTR),
-                tags->objectId, oh->parentObjectId));
-               
-       
-       if(parentCheck && obj->parent &&
-          oh->parentObjectId != obj->parent->objectId && 
-          (oh->parentObjectId != YAFFS_OBJECTID_UNLINKED ||
-           obj->parent->objectId != YAFFS_OBJECTID_DELETED))
-               T(YAFFS_TRACE_VERIFY,
-                (TSTR("Obj %d header mismatch parentId %d parentObjectId %d"TENDSTR),
-                tags->objectId, oh->parentObjectId, obj->parent->objectId));
-               
-       
-       if(tags->objectId > 1 && oh->name[0] == 0) /* Null name */
+
+       if (parentCheck && tags->objectId > 1 && !obj->parent)
+               T(YAFFS_TRACE_VERIFY,
+                       (TSTR("Obj %d header mismatch parentId %d obj->parent is NULL"TENDSTR),
+                       tags->objectId, oh->parentObjectId));
+
+       if (parentCheck && obj->parent &&
+                       oh->parentObjectId != obj->parent->objectId &&
+                       (oh->parentObjectId != YAFFS_OBJECTID_UNLINKED ||
+                       obj->parent->objectId != YAFFS_OBJECTID_DELETED))
+               T(YAFFS_TRACE_VERIFY,
+                       (TSTR("Obj %d header mismatch parentId %d parentObjectId %d"TENDSTR),
+                       tags->objectId, oh->parentObjectId, obj->parent->objectId));
+
+       if (tags->objectId > 1 && oh->name[0] == 0) /* Null name */
                T(YAFFS_TRACE_VERIFY,
-               (TSTR("Obj %d header name is NULL"TENDSTR),
-                obj->objectId));
+                       (TSTR("Obj %d header name is NULL"TENDSTR),
+                       obj->objectId));
 
-       if(tags->objectId > 1 && ((__u8)(oh->name[0])) == 0xff) /* Trashed name */
+       if (tags->objectId > 1 && ((__u8)(oh->name[0])) == 0xff) /* Trashed name */
                T(YAFFS_TRACE_VERIFY,
-               (TSTR("Obj %d header name is 0xFF"TENDSTR),
-                obj->objectId));
+                       (TSTR("Obj %d header name is 0xFF"TENDSTR),
+                       obj->objectId));
 }
 
 
 
-static int yaffs_VerifyTnodeWorker(yaffs_Object * obj, yaffs_Tnode * tn,
-                                       __u32 level, int chunkOffset)
+static int yaffs_VerifyTnodeWorker(yaffs_Object *obj, yaffs_Tnode *tn,
+                                       __u32 level, int chunkOffset)
 {
        int i;
        yaffs_Device *dev = obj->myDev;
@@ -612,7 +609,7 @@ static int yaffs_VerifyTnodeWorker(yaffs_Object * obj, yaffs_Tnode * tn,
        if (tn) {
                if (level > 0) {
 
-                       for (i = 0; i < YAFFS_NTNODES_INTERNAL && ok; i++){
+                       for (i = 0; i < YAFFS_NTNODES_INTERNAL && ok; i++) {
                                if (tn->internal[i]) {
                                        ok = yaffs_VerifyTnodeWorker(obj,
                                                        tn->internal[i],
@@ -623,17 +620,17 @@ static int yaffs_VerifyTnodeWorker(yaffs_Object * obj, yaffs_Tnode * tn,
                } else if (level == 0) {
                        yaffs_ExtendedTags tags;
                        __u32 objectId = obj->objectId;
-                       
+
                        chunkOffset <<=  YAFFS_TNODES_LEVEL0_BITS;
-                       
-                       for(i = 0; i < YAFFS_NTNODES_LEVEL0; i++){
-                               __u32 theChunk = yaffs_GetChunkGroupBase(dev,tn,i);
-                               
-                               if(theChunk > 0){
+
+                       for (i = 0; i < YAFFS_NTNODES_LEVEL0; i++) {
+                               __u32 theChunk = yaffs_GetChunkGroupBase(dev, tn, i);
+
+                               if (theChunk > 0) {
                                        /* T(~0,(TSTR("verifying (%d:%d) %d"TENDSTR),tags.objectId,tags.chunkId,theChunk)); */
-                                       yaffs_ReadChunkWithTagsFromNAND(dev,theChunk,NULL, &tags);
-                                       if(tags.objectId != objectId || tags.chunkId != chunkOffset){
-                                               T(~0,(TSTR("Object %d chunkId %d NAND mismatch chunk %d tags (%d:%d)"TENDSTR),
+                                       yaffs_ReadChunkWithTagsFromNAND(dev, theChunk, NULL, &tags);
+                                       if (tags.objectId != objectId || tags.chunkId != chunkOffset) {
+                                               T(~0, (TSTR("Object %d chunkId %d NAND mismatch chunk %d tags (%d:%d)"TENDSTR),
                                                        objectId, chunkOffset, theChunk,
                                                        tags.objectId, tags.chunkId));
                                        }
@@ -659,107 +656,105 @@ static void yaffs_VerifyFile(yaffs_Object *obj)
        yaffs_ExtendedTags tags;
        yaffs_Tnode *tn;
        __u32 objectId;
-       
-       if(!obj)
+
+       if (!obj)
                return;
 
-       if(yaffs_SkipVerification(obj->myDev))
+       if (yaffs_SkipVerification(obj->myDev))
                return;
-       
+
        dev = obj->myDev;
        objectId = obj->objectId;
-       
+
        /* Check file size is consistent with tnode depth */
        lastChunk =  obj->variant.fileVariant.fileSize / dev->nDataBytesPerChunk + 1;
        x = lastChunk >> YAFFS_TNODES_LEVEL0_BITS;
        requiredTallness = 0;
-       while (x> 0) {
+       while (x > 0) {
                x >>= YAFFS_TNODES_INTERNAL_BITS;
                requiredTallness++;
        }
-       
+
        actualTallness = obj->variant.fileVariant.topLevel;
-       
-       if(requiredTallness > actualTallness )
+
+       if (requiredTallness > actualTallness)
                T(YAFFS_TRACE_VERIFY,
                (TSTR("Obj %d had tnode tallness %d, needs to be %d"TENDSTR),
-                obj->objectId,actualTallness, requiredTallness));
-       
-       
-       /* Check that the chunks in the tnode tree are all correct. 
+                obj->objectId, actualTallness, requiredTallness));
+
+
+       /* Check that the chunks in the tnode tree are all correct.
         * We do this by scanning through the tnode tree and
         * checking the tags for every chunk match.
         */
 
-       if(yaffs_SkipNANDVerification(dev))
+       if (yaffs_SkipNANDVerification(dev))
                return;
-               
-       for(i = 1; i <= lastChunk; i++){
-               tn = yaffs_FindLevel0Tnode(dev, &obj->variant.fileVariant,i);
+
+       for (i = 1; i <= lastChunk; i++) {
+               tn = yaffs_FindLevel0Tnode(dev, &obj->variant.fileVariant, i);
 
                if (tn) {
-                       __u32 theChunk = yaffs_GetChunkGroupBase(dev,tn,i);
-                       if(theChunk > 0){
+                       __u32 theChunk = yaffs_GetChunkGroupBase(dev, tn, i);
+                       if (theChunk > 0) {
                                /* T(~0,(TSTR("verifying (%d:%d) %d"TENDSTR),objectId,i,theChunk)); */
-                               yaffs_ReadChunkWithTagsFromNAND(dev,theChunk,NULL, &tags);
-                               if(tags.objectId != objectId || tags.chunkId != i){
-                                       T(~0,(TSTR("Object %d chunkId %d NAND mismatch chunk %d tags (%d:%d)"TENDSTR),
+                               yaffs_ReadChunkWithTagsFromNAND(dev, theChunk, NULL, &tags);
+                               if (tags.objectId != objectId || tags.chunkId != i) {
+                                       T(~0, (TSTR("Object %d chunkId %d NAND mismatch chunk %d tags (%d:%d)"TENDSTR),
                                                objectId, i, theChunk,
                                                tags.objectId, tags.chunkId));
                                }
                        }
                }
-
        }
-
 }
 
 
 static void yaffs_VerifyHardLink(yaffs_Object *obj)
 {
-       if(obj && yaffs_SkipVerification(obj->myDev))
+       if (obj && yaffs_SkipVerification(obj->myDev))
                return;
-               
+
        /* Verify sane equivalent object */
 }
 
 static void yaffs_VerifySymlink(yaffs_Object *obj)
 {
-       if(obj && yaffs_SkipVerification(obj->myDev))
+       if (obj && yaffs_SkipVerification(obj->myDev))
                return;
-               
+
        /* Verify symlink string */
 }
 
 static void yaffs_VerifySpecial(yaffs_Object *obj)
 {
-       if(obj && yaffs_SkipVerification(obj->myDev))
+       if (obj && yaffs_SkipVerification(obj->myDev))
                return;
 }
 
 static void yaffs_VerifyObject(yaffs_Object *obj)
 {
        yaffs_Device *dev;
-       
+
        __u32 chunkMin;
        __u32 chunkMax;
-       
+
        __u32 chunkIdOk;
        __u32 chunkInRange;
        __u32 chunkShouldNotBeDeleted;
-       __u32 chunkValid; 
-       
-       if(!obj)
+       __u32 chunkValid;
+
+       if (!obj)
                return;
-               
-       if(obj->beingCreated)
+
+       if (obj->beingCreated)
                return;
-       
+
        dev = obj->myDev;
-       
-       if(yaffs_SkipVerification(dev))
+
+       if (yaffs_SkipVerification(dev))
                return;
-               
+
        /* Check sane object header chunk */
 
        chunkMin = dev->internalStartBlock * dev->nChunksPerBlock;
@@ -767,51 +762,52 @@ static void yaffs_VerifyObject(yaffs_Object *obj)
 
        chunkInRange = (((unsigned)(obj->hdrChunk)) >= chunkMin && ((unsigned)(obj->hdrChunk)) <= chunkMax);
        chunkIdOk = chunkInRange || obj->hdrChunk == 0;
-       chunkValid  =  chunkInRange &&
+       chunkValid = chunkInRange &&
                        yaffs_CheckChunkBit(dev,
-                                           obj->hdrChunk / dev->nChunksPerBlock,
-                                           obj->hdrChunk % dev->nChunksPerBlock);
+                                       obj->hdrChunk / dev->nChunksPerBlock,
+                                       obj->hdrChunk % dev->nChunksPerBlock);
        chunkShouldNotBeDeleted = chunkInRange && !chunkValid;
 
-       if(!obj->fake &&
-           (!chunkIdOk || chunkShouldNotBeDeleted)) {
-          T(YAFFS_TRACE_VERIFY,
-          (TSTR("Obj %d has chunkId %d %s %s"TENDSTR),
-          obj->objectId,obj->hdrChunk,
-          chunkIdOk ? "" : ",out of range",
-          chunkShouldNotBeDeleted ? ",marked as deleted" : ""));
+       if (!obj->fake &&
+                       (!chunkIdOk || chunkShouldNotBeDeleted)) {
+               T(YAFFS_TRACE_VERIFY,
+                       (TSTR("Obj %d has chunkId %d %s %s"TENDSTR),
+                       obj->objectId, obj->hdrChunk,
+                       chunkIdOk ? "" : ",out of range",
+                       chunkShouldNotBeDeleted ? ",marked as deleted" : ""));
        }
-       
-       if(chunkValid &&!yaffs_SkipNANDVerification(dev)) {
+
+       if (chunkValid && !yaffs_SkipNANDVerification(dev)) {
                yaffs_ExtendedTags tags;
                yaffs_ObjectHeader *oh;
-               __u8 *buffer = yaffs_GetTempBuffer(dev,__LINE__);
-               
+               __u8 *buffer = yaffs_GetTempBuffer(dev, __LINE__);
+
                oh = (yaffs_ObjectHeader *)buffer;
 
-               yaffs_ReadChunkWithTagsFromNAND(dev, obj->hdrChunk,buffer, &tags);
+               yaffs_ReadChunkWithTagsFromNAND(dev, obj->hdrChunk, buffer,
+                               &tags);
+
+               yaffs_VerifyObjectHeader(obj, oh, &tags, 1);
 
-               yaffs_VerifyObjectHeader(obj,oh,&tags,1);
-               
-               yaffs_ReleaseTempBuffer(dev,buffer,__LINE__);
+               yaffs_ReleaseTempBuffer(dev, buffer, __LINE__);
        }
-       
+
        /* Verify it has a parent */
-       if(obj && !obj->fake &&
-          (!obj->parent || obj->parent->myDev != dev)){
-          T(YAFFS_TRACE_VERIFY,
-          (TSTR("Obj %d has parent pointer %p which does not look like an object"TENDSTR),
-          obj->objectId,obj->parent));    
+       if (obj && !obj->fake &&
+                       (!obj->parent || obj->parent->myDev != dev)) {
+               T(YAFFS_TRACE_VERIFY,
+                       (TSTR("Obj %d has parent pointer %p which does not look like an object"TENDSTR),
+                       obj->objectId, obj->parent));
        }
-       
+
        /* Verify parent is a directory */
-       if(obj->parent && obj->parent->variantType != YAFFS_OBJECT_TYPE_DIRECTORY){
-          T(YAFFS_TRACE_VERIFY,
-          (TSTR("Obj %d's parent is not a directory (type %d)"TENDSTR),
-          obj->objectId,obj->parent->variantType));       
+       if (obj->parent && obj->parent->variantType != YAFFS_OBJECT_TYPE_DIRECTORY) {
+               T(YAFFS_TRACE_VERIFY,
+                       (TSTR("Obj %d's parent is not a directory (type %d)"TENDSTR),
+                       obj->objectId, obj->parent->variantType));
        }
-       
-       switch(obj->variantType){
+
+       switch (obj->variantType) {
        case YAFFS_OBJECT_TYPE_FILE:
                yaffs_VerifyFile(obj);
                break;
@@ -831,57 +827,54 @@ static void yaffs_VerifyObject(yaffs_Object *obj)
        default:
                T(YAFFS_TRACE_VERIFY,
                (TSTR("Obj %d has illegaltype %d"TENDSTR),
-               obj->objectId,obj->variantType));          
+               obj->objectId, obj->variantType));
                break;
        }
-       
-       
 }
 
 static void yaffs_VerifyObjects(yaffs_Device *dev)
 {
-        yaffs_Object *obj;
-        int i;
-        struct ylist_head *lh;
+       yaffs_Object *obj;
+       int i;
+       struct ylist_head *lh;
 
-        if(yaffs_SkipVerification(dev))
-                return;
-       
-        /* Iterate through the objects in each hash entry */
-         
-         for(i = 0; i <  YAFFS_NOBJECT_BUCKETS; i++){
-                ylist_for_each(lh, &dev->objectBucket[i].list) {
-                        if (lh) {
-                                obj = ylist_entry(lh, yaffs_Object, hashLink);
-                                yaffs_VerifyObject(obj);
-                        }
-                }
-        }
+       if (yaffs_SkipVerification(dev))
+               return;
+
+       /* Iterate through the objects in each hash entry */
 
+       for (i = 0; i <  YAFFS_NOBJECT_BUCKETS; i++) {
+               ylist_for_each(lh, &dev->objectBucket[i].list) {
+                       if (lh) {
+                               obj = ylist_entry(lh, yaffs_Object, hashLink);
+                               yaffs_VerifyObject(obj);
+                       }
+               }
+       }
 }
 
 
 /*
  *  Simple hash function. Needs to have a reasonable spread
  */
+
 static Y_INLINE int yaffs_HashFunction(int n)
 {
        n = abs(n);
-       return (n % YAFFS_NOBJECT_BUCKETS);
+       return n % YAFFS_NOBJECT_BUCKETS;
 }
 
 /*
  * Access functions to useful fake objects.
  * Note that root might have a presence in NAND if permissions are set.
  */
-yaffs_Object *yaffs_Root(yaffs_Device * dev)
+
+yaffs_Object *yaffs_Root(yaffs_Device *dev)
 {
        return dev->rootDir;
 }
 
-yaffs_Object *yaffs_LostNFound(yaffs_Device * dev)
+yaffs_Object *yaffs_LostNFound(yaffs_Device *dev)
 {
        return dev->lostNFoundDir;
 }
@@ -890,8 +883,8 @@ yaffs_Object *yaffs_LostNFound(yaffs_Device * dev)
 /*
  *  Erased NAND checking functions
  */
-int yaffs_CheckFF(__u8 * buffer, int nBytes)
+
+int yaffs_CheckFF(__u8 *buffer, int nBytes)
 {
        /* Horrible, slow implementation */
        while (nBytes--) {
@@ -903,19 +896,17 @@ int yaffs_CheckFF(__u8 * buffer, int nBytes)
 }
 
 static int yaffs_CheckChunkErased(struct yaffs_DeviceStruct *dev,
-                                 int chunkInNAND)
+                               int chunkInNAND)
 {
-
        int retval = YAFFS_OK;
        __u8 *data = yaffs_GetTempBuffer(dev, __LINE__);
        yaffs_ExtendedTags tags;
        int result;
 
        result = yaffs_ReadChunkWithTagsFromNAND(dev, chunkInNAND, data, &tags);
-       
-       if(tags.eccResult > YAFFS_ECC_RESULT_NO_ERROR)
+
+       if (tags.eccResult > YAFFS_ECC_RESULT_NO_ERROR)
                retval = YAFFS_FAIL;
-               
 
        if (!yaffs_CheckFF(data, dev->nDataBytesPerChunk) || tags.chunkUsed) {
                T(YAFFS_TRACE_NANDACCESS,
@@ -930,9 +921,9 @@ static int yaffs_CheckChunkErased(struct yaffs_DeviceStruct *dev,
 }
 
 static int yaffs_WriteNewChunkWithTagsToNAND(struct yaffs_DeviceStruct *dev,
-                                            const __u8 * data,
-                                            yaffs_ExtendedTags * tags,
-                                            int useReserve)
+                                       const __u8 *data,
+                                       yaffs_ExtendedTags *tags,
+                                       int useReserve)
 {
        int attempts = 0;
        int writeOk = 0;
@@ -1005,10 +996,10 @@ static int yaffs_WriteNewChunkWithTagsToNAND(struct yaffs_DeviceStruct *dev,
                /* Copy the data into the robustification buffer */
                yaffs_HandleWriteChunkOk(dev, chunk, data, tags);
 
-       } while (writeOk != YAFFS_OK && 
-               (yaffs_wr_attempts <= 0 || attempts <= yaffs_wr_attempts));
-       
-       if(!writeOk)
+       } while (writeOk != YAFFS_OK &&
+               (yaffs_wr_attempts <= 0 || attempts <= yaffs_wr_attempts));
+
+       if (!writeOk)
                chunk = -1;
 
        if (attempts > 1) {
@@ -1025,20 +1016,19 @@ static int yaffs_WriteNewChunkWithTagsToNAND(struct yaffs_DeviceStruct *dev,
 /*
  * Block retiring for handling a broken block.
  */
-static void yaffs_RetireBlock(yaffs_Device * dev, int blockInNAND)
+
+static void yaffs_RetireBlock(yaffs_Device *dev, int blockInNAND)
 {
        yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev, blockInNAND);
 
        yaffs_InvalidateCheckpoint(dev);
-       
+
        if (yaffs_MarkBlockBad(dev, blockInNAND) != YAFFS_OK) {
                if (yaffs_EraseBlockInNAND(dev, blockInNAND) != YAFFS_OK) {
                        T(YAFFS_TRACE_ALWAYS, (TSTR(
                                "yaffs: Failed to mark bad and erase block %d"
                                TENDSTR), blockInNAND));
-               }
-               else {
+               } else {
                        yaffs_ExtendedTags tags;
                        int chunkId = blockInNAND * dev->nChunksPerBlock;
 
@@ -1048,7 +1038,7 @@ static void yaffs_RetireBlock(yaffs_Device * dev, int blockInNAND)
                        yaffs_InitialiseTags(&tags);
                        tags.sequenceNumber = YAFFS_SEQUENCE_BAD_BLOCK;
                        if (dev->writeChunkWithTagsToNAND(dev, chunkId -
-                           dev->chunkOffset, buffer, &tags) != YAFFS_OK)
+                               dev->chunkOffset, buffer, &tags) != YAFFS_OK)
                                T(YAFFS_TRACE_ALWAYS, (TSTR("yaffs: Failed to "
                                        TCONT("write bad block marker to block %d")
                                        TENDSTR), blockInNAND));
@@ -1068,60 +1058,56 @@ static void yaffs_RetireBlock(yaffs_Device * dev, int blockInNAND)
  * Functions for robustisizing TODO
  *
  */
-static void yaffs_HandleWriteChunkOk(yaffs_Device * dev, int chunkInNAND,
-                                    const __u8 * data,
-                                    const yaffs_ExtendedTags * tags)
+
+static void yaffs_HandleWriteChunkOk(yaffs_Device *dev, int chunkInNAND,
+                               const __u8 *data,
+                               const yaffs_ExtendedTags *tags)
 {
 }
 
-static void yaffs_HandleUpdateChunk(yaffs_Device * dev, int chunkInNAND,
-                                   const yaffs_ExtendedTags * tags)
+static void yaffs_HandleUpdateChunk(yaffs_Device *dev, int chunkInNAND,
+                               const yaffs_ExtendedTags *tags)
 {
 }
 
 void yaffs_HandleChunkError(yaffs_Device *dev, yaffs_BlockInfo *bi)
 {
-       if(!bi->gcPrioritise){
+       if (!bi->gcPrioritise) {
                bi->gcPrioritise = 1;
                dev->hasPendingPrioritisedGCs = 1;
-               bi->chunkErrorStrikes ++;
-               
-               if(bi->chunkErrorStrikes > 3){
+               bi->chunkErrorStrikes++;
+
+               if (bi->chunkErrorStrikes > 3) {
                        bi->needsRetiring = 1; /* Too many stikes, so retire this */
                        T(YAFFS_TRACE_ALWAYS, (TSTR("yaffs: Block struck out" TENDSTR)));
 
                }
-               
        }
 }
 
-static void yaffs_HandleWriteChunkError(yaffs_Device * dev, int chunkInNAND, int erasedOk)
+static void yaffs_HandleWriteChunkError(yaffs_Device *dev, int chunkInNAND,
+               int erasedOk)
 {
-
        int blockInNAND = chunkInNAND / dev->nChunksPerBlock;
        yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev, blockInNAND);
 
-       yaffs_HandleChunkError(dev,bi);
-               
-       
-       if(erasedOk ) {
+       yaffs_HandleChunkError(dev, bi);
+
+       if (erasedOk) {
                /* Was an actual write failure, so mark the block for retirement  */
                bi->needsRetiring = 1;
                T(YAFFS_TRACE_ERROR | YAFFS_TRACE_BAD_BLOCKS,
                  (TSTR("**>> Block %d needs retiring" TENDSTR), blockInNAND));
-
-               
        }
-       
+
        /* Delete the chunk */
        yaffs_DeleteChunk(dev, chunkInNAND, 1, __LINE__);
 }
 
 
-/*---------------- Name handling functions ------------*/ 
+/*---------------- Name handling functions ------------*/
 
-static __u16 yaffs_CalcNameSum(const YCHAR * name)
+static __u16 yaffs_CalcNameSum(const YCHAR *name)
 {
        __u16 sum = 0;
        __u16 i = 1;
@@ -1142,10 +1128,10 @@ static __u16 yaffs_CalcNameSum(const YCHAR * name)
        return sum;
 }
 
-static void yaffs_SetObjectName(yaffs_Object * obj, const YCHAR * name)
+static void yaffs_SetObjectName(yaffs_Object *obj, const YCHAR *name)
 {
 #ifdef CONFIG_YAFFS_SHORT_NAMES_IN_RAM
-       memset(obj->shortName,0,sizeof (YCHAR) * (YAFFS_SHORT_NAME_LENGTH+1)); 
+       memset(obj->shortName, 0, sizeof (YCHAR) * (YAFFS_SHORT_NAME_LENGTH+1));
        if (name && yaffs_strlen(name) <= YAFFS_SHORT_NAME_LENGTH) {
                yaffs_strcpy(obj->shortName, name);
        } else {
@@ -1161,13 +1147,13 @@ static void yaffs_SetObjectName(yaffs_Object * obj, const YCHAR * name)
  * The list is hooked together using the first pointer
  * in the tnode.
  */
+
 /* yaffs_CreateTnodes creates a bunch more tnodes and
  * adds them to the tnode free list.
  * Don't use this function directly
  */
 
-static int yaffs_CreateTnodes(yaffs_Device * dev, int nTnodes)
+static int yaffs_CreateTnodes(yaffs_Device *dev, int nTnodes)
 {
        int i;
        int tnodeSize;
@@ -1179,14 +1165,13 @@ static int yaffs_CreateTnodes(yaffs_Device * dev, int nTnodes)
 
        if (nTnodes < 1)
                return YAFFS_OK;
-               
+
        /* Calculate the tnode size in bytes for variable width tnode support.
         * Must be a multiple of 32-bits  */
        tnodeSize = (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8;
 
-       if(tnodeSize < sizeof(yaffs_Tnode))
+       if (tnodeSize < sizeof(yaffs_Tnode))
                tnodeSize = sizeof(yaffs_Tnode);
-               
 
        /* make these things */
 
@@ -1195,7 +1180,7 @@ static int yaffs_CreateTnodes(yaffs_Device * dev, int nTnodes)
 
        if (!newTnodes) {
                T(YAFFS_TRACE_ERROR,
-                 (TSTR("yaffs: Could not allocate Tnodes" TENDSTR)));
+                       (TSTR("yaffs: Could not allocate Tnodes" TENDSTR)));
                return YAFFS_FAIL;
        }
 
@@ -1215,12 +1200,12 @@ static int yaffs_CreateTnodes(yaffs_Device * dev, int nTnodes)
        dev->freeTnodes = newTnodes;
 #else
        /* New hookup for wide tnodes */
-       for(i = 0; i < nTnodes -1; i++) {
+       for (i = 0; i < nTnodes - 1; i++) {
                curr = (yaffs_Tnode *) &mem[i * tnodeSize];
                next = (yaffs_Tnode *) &mem[(i+1) * tnodeSize];
                curr->internal[0] = next;
        }
-       
+
        curr = (yaffs_Tnode *) &mem[(nTnodes - 1) * tnodeSize];
        curr->internal[0] = dev->freeTnodes;
        dev->freeTnodes = (yaffs_Tnode *)mem;
@@ -1235,14 +1220,13 @@ static int yaffs_CreateTnodes(yaffs_Device * dev, int nTnodes)
         * NB If we can't add this to the management list it isn't fatal
         * but it just means we can't free this bunch of tnodes later.
         */
-        
+
        tnl = YMALLOC(sizeof(yaffs_TnodeList));
        if (!tnl) {
                T(YAFFS_TRACE_ERROR,
                  (TSTR
                   ("yaffs: Could not add tnodes to management list" TENDSTR)));
                   return YAFFS_FAIL;
-
        } else {
                tnl->tnodes = newTnodes;
                tnl->next = dev->allocatedTnodeList;
@@ -1256,7 +1240,7 @@ static int yaffs_CreateTnodes(yaffs_Device * dev, int nTnodes)
 
 /* GetTnode gets us a clean tnode. Tries to make allocate more if we run out */
 
-static yaffs_Tnode *yaffs_GetTnodeRaw(yaffs_Device * dev)
+static yaffs_Tnode *yaffs_GetTnodeRaw(yaffs_Device *dev)
 {
        yaffs_Tnode *tn = NULL;
 
@@ -1283,22 +1267,22 @@ static yaffs_Tnode *yaffs_GetTnodeRaw(yaffs_Device * dev)
        return tn;
 }
 
-static yaffs_Tnode *yaffs_GetTnode(yaffs_Device * dev)
+static yaffs_Tnode *yaffs_GetTnode(yaffs_Device *dev)
 {
        yaffs_Tnode *tn = yaffs_GetTnodeRaw(dev);
        int tnodeSize = (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8;
 
-       if(tnodeSize < sizeof(yaffs_Tnode))
+       if (tnodeSize < sizeof(yaffs_Tnode))
                tnodeSize = sizeof(yaffs_Tnode);
-       
-       if(tn)
+
+       if (tn)
                memset(tn, 0, tnodeSize);
 
-       return tn;      
+       return tn;
 }
 
 /* FreeTnode frees up a tnode and puts it back on the free list */
-static void yaffs_FreeTnode(yaffs_Device * dev, yaffs_Tnode * tn)
+static void yaffs_FreeTnode(yaffs_Device *dev, yaffs_Tnode *tn)
 {
        if (tn) {
 #ifdef CONFIG_YAFFS_TNODE_LIST_DEBUG
@@ -1314,10 +1298,9 @@ static void yaffs_FreeTnode(yaffs_Device * dev, yaffs_Tnode * tn)
                dev->nFreeTnodes++;
        }
        dev->nCheckpointBlocksRequired = 0; /* force recalculation*/
-       
 }
 
-static void yaffs_DeinitialiseTnodes(yaffs_Device * dev)
+static void yaffs_DeinitialiseTnodes(yaffs_Device *dev)
 {
        /* Free the list of allocated tnodes */
        yaffs_TnodeList *tmp;
@@ -1335,71 +1318,72 @@ static void yaffs_DeinitialiseTnodes(yaffs_Device * dev)
        dev->nFreeTnodes = 0;
 }
 
-static void yaffs_InitialiseTnodes(yaffs_Device * dev)
+static void yaffs_InitialiseTnodes(yaffs_Device *dev)
 {
        dev->allocatedTnodeList = NULL;
        dev->freeTnodes = NULL;
        dev->nFreeTnodes = 0;
        dev->nTnodesCreated = 0;
+}
+
+
+void yaffs_PutLevel0Tnode(yaffs_Device *dev, yaffs_Tnode *tn, unsigned pos,
+               unsigned val)
+{
+       __u32 *map = (__u32 *)tn;
+       __u32 bitInMap;
+       __u32 bitInWord;
+       __u32 wordInMap;
+       __u32 mask;
+
+       pos &= YAFFS_TNODES_LEVEL0_MASK;
+       val >>= dev->chunkGroupBits;
+
+       bitInMap = pos * dev->tnodeWidth;
+       wordInMap = bitInMap / 32;
+       bitInWord = bitInMap & (32 - 1);
 
+       mask = dev->tnodeMask << bitInWord;
+
+       map[wordInMap] &= ~mask;
+       map[wordInMap] |= (mask & (val << bitInWord));
+
+       if (dev->tnodeWidth > (32 - bitInWord)) {
+               bitInWord = (32 - bitInWord);
+               wordInMap++;;
+               mask = dev->tnodeMask >> (/*dev->tnodeWidth -*/ bitInWord);
+               map[wordInMap] &= ~mask;
+               map[wordInMap] |= (mask & (val >> bitInWord));
+       }
 }
 
+static __u32 yaffs_GetChunkGroupBase(yaffs_Device *dev, yaffs_Tnode *tn,
+               unsigned pos)
+{
+       __u32 *map = (__u32 *)tn;
+       __u32 bitInMap;
+       __u32 bitInWord;
+       __u32 wordInMap;
+       __u32 val;
+
+       pos &= YAFFS_TNODES_LEVEL0_MASK;
+
+       bitInMap = pos * dev->tnodeWidth;
+       wordInMap = bitInMap / 32;
+       bitInWord = bitInMap & (32 - 1);
 
-void yaffs_PutLevel0Tnode(yaffs_Device *dev, yaffs_Tnode *tn, unsigned pos, unsigned val)
-{
-  __u32 *map = (__u32 *)tn;
-  __u32 bitInMap;
-  __u32 bitInWord;
-  __u32 wordInMap;
-  __u32 mask;
-  
-  pos &= YAFFS_TNODES_LEVEL0_MASK;
-  val >>= dev->chunkGroupBits;
-  
-  bitInMap = pos * dev->tnodeWidth;
-  wordInMap = bitInMap /32;
-  bitInWord = bitInMap & (32 -1);
-  
-  mask = dev->tnodeMask << bitInWord;
-  
-  map[wordInMap] &= ~mask;
-  map[wordInMap] |= (mask & (val << bitInWord));
-  
-  if(dev->tnodeWidth > (32-bitInWord)) {
-    bitInWord = (32 - bitInWord);
-    wordInMap++;;
-    mask = dev->tnodeMask >> (/*dev->tnodeWidth -*/ bitInWord);
-    map[wordInMap] &= ~mask;
-    map[wordInMap] |= (mask & (val >> bitInWord));
-  }
-}
-
-static __u32 yaffs_GetChunkGroupBase(yaffs_Device *dev, yaffs_Tnode *tn, unsigned pos)
-{
-  __u32 *map = (__u32 *)tn;
-  __u32 bitInMap;
-  __u32 bitInWord;
-  __u32 wordInMap;
-  __u32 val;
-  
-  pos &= YAFFS_TNODES_LEVEL0_MASK;
-  
-  bitInMap = pos * dev->tnodeWidth;
-  wordInMap = bitInMap /32;
-  bitInWord = bitInMap & (32 -1);
-  
-  val = map[wordInMap] >> bitInWord;
-  
-  if(dev->tnodeWidth > (32-bitInWord)) {
-    bitInWord = (32 - bitInWord);
-    wordInMap++;;
-    val |= (map[wordInMap] << bitInWord);
-  }
-  
-  val &= dev->tnodeMask;
-  val <<= dev->chunkGroupBits;
-  
-  return val;
+       val = map[wordInMap] >> bitInWord;
+
+       if      (dev->tnodeWidth > (32 - bitInWord)) {
+               bitInWord = (32 - bitInWord);
+               wordInMap++;;
+               val |= (map[wordInMap] << bitInWord);
+       }
+
+       val &= dev->tnodeMask;
+       val <<= dev->chunkGroupBits;
+
+       return val;
 }
 
 /* ------------------- End of individual tnode manipulation -----------------*/
@@ -1410,11 +1394,10 @@ static __u32 yaffs_GetChunkGroupBase(yaffs_Device *dev, yaffs_Tnode *tn, unsigne
  */
 
 /* FindLevel0Tnode finds the level 0 tnode, if one exists. */
-static yaffs_Tnode *yaffs_FindLevel0Tnode(yaffs_Device * dev,
-                                         yaffs_FileStructure * fStruct,
-                                         __u32 chunkId)
+static yaffs_Tnode *yaffs_FindLevel0Tnode(yaffs_Device *dev,
+                                       yaffs_FileStructure *fStruct,
+                                       __u32 chunkId)
 {
-
        yaffs_Tnode *tn = fStruct->top;
        __u32 i;
        int requiredTallness;
@@ -1445,15 +1428,12 @@ static yaffs_Tnode *yaffs_FindLevel0Tnode(yaffs_Device * dev,
 
        /* Traverse down to level 0 */
        while (level > 0 && tn) {
-               tn = tn->
-                   internal[(chunkId >>
-                              ( YAFFS_TNODES_LEVEL0_BITS + 
-                                (level - 1) *
-                                YAFFS_TNODES_INTERNAL_BITS)
-                             ) &
-                            YAFFS_TNODES_INTERNAL_MASK];
+               tn = tn->internal[(chunkId >>
+                       (YAFFS_TNODES_LEVEL0_BITS +
+                               (level - 1) *
+                               YAFFS_TNODES_INTERNAL_BITS)) &
+                       YAFFS_TNODES_INTERNAL_MASK];
                level--;
-
        }
 
        return tn;
@@ -1469,13 +1449,12 @@ static yaffs_Tnode *yaffs_FindLevel0Tnode(yaffs_Device * dev,
  *  If the tn argument is NULL, then a fresh tnode will be added otherwise the specified tn will
  *  be plugged into the ttree.
  */
-static yaffs_Tnode *yaffs_AddOrFindLevel0Tnode(yaffs_Device * dev,
-                                              yaffs_FileStructure * fStruct,
-                                              __u32 chunkId,
-                                              yaffs_Tnode *passedTn)
-{
 
+static yaffs_Tnode *yaffs_AddOrFindLevel0Tnode(yaffs_Device *dev,
+                                       yaffs_FileStructure *fStruct,
+                                       __u32 chunkId,
+                                       yaffs_Tnode *passedTn)
+{
        int requiredTallness;
        int i;
        int l;
@@ -1504,9 +1483,9 @@ static yaffs_Tnode *yaffs_AddOrFindLevel0Tnode(yaffs_Device * dev,
 
 
        if (requiredTallness > fStruct->topLevel) {
-               /* Not tall enough,gotta make the tree taller */
+               /* Not tall enough, gotta make the tree taller */
                for (i = fStruct->topLevel; i < requiredTallness; i++) {
-               
+
                        tn = yaffs_GetTnode(dev);
 
                        if (tn) {
@@ -1525,63 +1504,61 @@ static yaffs_Tnode *yaffs_AddOrFindLevel0Tnode(yaffs_Device * dev,
 
        l = fStruct->topLevel;
        tn = fStruct->top;
-       
-       if(l > 0) {
+
+       if (l > 0) {
                while (l > 0 && tn) {
                        x = (chunkId >>
-                            ( YAFFS_TNODES_LEVEL0_BITS +
+                            (YAFFS_TNODES_LEVEL0_BITS +
                              (l - 1) * YAFFS_TNODES_INTERNAL_BITS)) &
                            YAFFS_TNODES_INTERNAL_MASK;
 
 
-                       if((l>1) && !tn->internal[x]){
+                       if ((l > 1) && !tn->internal[x]) {
                                /* Add missing non-level-zero tnode */
                                tn->internal[x] = yaffs_GetTnode(dev);
 
-                       } else if(l == 1) {
+                       } else if (l == 1) {
                                /* Looking from level 1 at level 0 */
-                               if (passedTn) {
+                               if (passedTn) {
                                        /* If we already have one, then release it.*/
-                                       if(tn->internal[x])
-                                               yaffs_FreeTnode(dev,tn->internal[x]);
+                                       if (tn->internal[x])
+                                               yaffs_FreeTnode(dev, tn->internal[x]);
                                        tn->internal[x] = passedTn;
-                       
-                               } else if(!tn->internal[x]) {
+
+                               } else if (!tn->internal[x]) {
                                        /* Don't have one, none passed in */
                                        tn->internal[x] = yaffs_GetTnode(dev);
                                }
                        }
-               
+
                        tn = tn->internal[x];
                        l--;
                }
        } else {
                /* top is level 0 */
-               if(passedTn) {
-                       memcpy(tn,passedTn,(dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8);
-                       yaffs_FreeTnode(dev,passedTn);
+               if (passedTn) {
+                       memcpy(tn, passedTn, (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8);
+                       yaffs_FreeTnode(dev, passedTn);
                }
        }
 
        return tn;
 }
 
-static int yaffs_FindChunkInGroup(yaffs_Device * dev, int theChunk,
-                                 yaffs_ExtendedTags * tags, int objectId,
-                                 int chunkInInode)
+static int yaffs_FindChunkInGroup(yaffs_Device *dev, int theChunk,
+                               yaffs_ExtendedTags *tags, int objectId,
+                               int chunkInInode)
 {
        int j;
 
        for (j = 0; theChunk && j < dev->chunkGroupSize; j++) {
-               if (yaffs_CheckChunkBit
-                   (dev, theChunk / dev->nChunksPerBlock,
-                    theChunk % dev->nChunksPerBlock)) {
+               if (yaffs_CheckChunkBit(dev, theChunk / dev->nChunksPerBlock,
+                               theChunk % dev->nChunksPerBlock)) {
                        yaffs_ReadChunkWithTagsFromNAND(dev, theChunk, NULL,
                                                        tags);
                        if (yaffs_TagsMatch(tags, objectId, chunkInInode)) {
                                /* found it; */
                                return theChunk;
-
                        }
                }
                theChunk++;
@@ -1592,11 +1569,11 @@ static int yaffs_FindChunkInGroup(yaffs_Device * dev, int theChunk,
 
 /* DeleteWorker scans backwards through the tnode tree and deletes all the
  * chunks and tnodes in the file
- * Returns 1 if the tree was deleted. 
+ * Returns 1 if the tree was deleted.
  * Returns 0 if it stopped early due to hitting the limit and the delete is incomplete.
  */
 
-static int yaffs_DeleteWorker(yaffs_Object * in, yaffs_Tnode * tn, __u32 level,
+static int yaffs_DeleteWorker(yaffs_Object *in, yaffs_Tnode *tn, __u32 level,
                              int chunkOffset, int *limit)
 {
        int i;
@@ -1610,7 +1587,6 @@ static int yaffs_DeleteWorker(yaffs_Object * in, yaffs_Tnode * tn, __u32 level,
 
        if (tn) {
                if (level > 0) {
-
                        for (i = YAFFS_NTNODES_INTERNAL - 1; allDone && i >= 0;
                             i--) {
                                if (tn->internal[i]) {
@@ -1618,17 +1594,17 @@ static int yaffs_DeleteWorker(yaffs_Object * in, yaffs_Tnode * tn, __u32 level,
                                                allDone = 0;
                                        } else {
                                                allDone =
-                                                   yaffs_DeleteWorker(in,
-                                                                      tn->
-                                                                      internal
-                                                                      [i],
-                                                                      level -
-                                                                      1,
-                                                                      (chunkOffset
+                                                       yaffs_DeleteWorker(in,
+                                                               tn->
+                                                               internal
+                                                               [i],
+                                                               level -
+                                                               1,
+                                                               (chunkOffset
                                                                        <<
                                                                        YAFFS_TNODES_INTERNAL_BITS)
-                                                                      + i,
-                                                                      limit);
+                                                               + i,
+                                                               limit);
                                        }
                                        if (allDone) {
                                                yaffs_FreeTnode(dev,
@@ -1637,27 +1613,25 @@ static int yaffs_DeleteWorker(yaffs_Object * in, yaffs_Tnode * tn, __u32 level,
                                                tn->internal[i] = NULL;
                                        }
                                }
-
                        }
                        return (allDone) ? 1 : 0;
                } else if (level == 0) {
                        int hitLimit = 0;
 
                        for (i = YAFFS_NTNODES_LEVEL0 - 1; i >= 0 && !hitLimit;
-                            i--) {
-                               theChunk = yaffs_GetChunkGroupBase(dev,tn,i);
+                                       i--) {
+                               theChunk = yaffs_GetChunkGroupBase(dev, tn, i);
                                if (theChunk) {
 
-                                       chunkInInode =
-                                           (chunkOffset <<
-                                            YAFFS_TNODES_LEVEL0_BITS) + i;
+                                       chunkInInode = (chunkOffset <<
+                                               YAFFS_TNODES_LEVEL0_BITS) + i;
 
                                        foundChunk =
-                                           yaffs_FindChunkInGroup(dev,
-                                                                  theChunk,
-                                                                  &tags,
-                                                                  in->objectId,
-                                                                  chunkInInode);
+                                               yaffs_FindChunkInGroup(dev,
+                                                               theChunk,
+                                                               &tags,
+                                                               in->objectId,
+                                                               chunkInInode);
 
                                        if (foundChunk > 0) {
                                                yaffs_DeleteChunk(dev,
@@ -1673,7 +1647,7 @@ static int yaffs_DeleteWorker(yaffs_Object * in, yaffs_Tnode * tn, __u32 level,
 
                                        }
 
-                                       yaffs_PutLevel0Tnode(dev,tn,i,0);
+                                       yaffs_PutLevel0Tnode(dev, tn, i, 0);
                                }
 
                        }
@@ -1687,9 +1661,8 @@ static int yaffs_DeleteWorker(yaffs_Object * in, yaffs_Tnode * tn, __u32 level,
 
 }
 
-static void yaffs_SoftDeleteChunk(yaffs_Device * dev, int chunk)
+static void yaffs_SoftDeleteChunk(yaffs_Device *dev, int chunk)
 {
-
        yaffs_BlockInfo *theBlock;
 
        T(YAFFS_TRACE_DELETION, (TSTR("soft delete chunk %d" TENDSTR), chunk));
@@ -1706,8 +1679,8 @@ static void yaffs_SoftDeleteChunk(yaffs_Device * dev, int chunk)
  * of the tnode.
  * Thus, essentially this is the same as DeleteWorker except that the chunks are soft deleted.
  */
-static int yaffs_SoftDeleteWorker(yaffs_Object * in, yaffs_Tnode * tn,
+
+static int yaffs_SoftDeleteWorker(yaffs_Object *in, yaffs_Tnode *tn,
                                  __u32 level, int chunkOffset)
 {
        int i;
@@ -1744,14 +1717,14 @@ static int yaffs_SoftDeleteWorker(yaffs_Object * in, yaffs_Tnode * tn,
                } else if (level == 0) {
 
                        for (i = YAFFS_NTNODES_LEVEL0 - 1; i >= 0; i--) {
-                               theChunk = yaffs_GetChunkGroupBase(dev,tn,i);
+                               theChunk = yaffs_GetChunkGroupBase(dev, tn, i);
                                if (theChunk) {
                                        /* Note this does not find the real chunk, only the chunk group.
-                                        * We make an assumption that a chunk group is not larger than 
+                                        * We make an assumption that a chunk group is not larger than
                                         * a block.
                                         */
                                        yaffs_SoftDeleteChunk(dev, theChunk);
-                                       yaffs_PutLevel0Tnode(dev,tn,i,0);
+                                       yaffs_PutLevel0Tnode(dev, tn, i, 0);
                                }
 
                        }
@@ -1765,7 +1738,7 @@ static int yaffs_SoftDeleteWorker(yaffs_Object * in, yaffs_Tnode * tn,
 
 }
 
-static void yaffs_SoftDeleteFile(yaffs_Object * obj)
+static void yaffs_SoftDeleteFile(yaffs_Object *obj)
 {
        if (obj->deleted &&
            obj->variantType == YAFFS_OBJECT_TYPE_FILE && !obj->softDeleted) {
@@ -1799,8 +1772,8 @@ static void yaffs_SoftDeleteFile(yaffs_Object * obj)
  * by a special case.
  */
 
-static yaffs_Tnode *yaffs_PruneWorker(yaffs_Device * dev, yaffs_Tnode * tn,
-                                     __u32 level, int del0)
+static yaffs_Tnode *yaffs_PruneWorker(yaffs_Device *dev, yaffs_Tnode *tn,
+                               __u32 level, int del0)
 {
        int i;
        int hasData;
@@ -1834,8 +1807,8 @@ static yaffs_Tnode *yaffs_PruneWorker(yaffs_Device * dev, yaffs_Tnode * tn,
 
 }
 
-static int yaffs_PruneFileStructure(yaffs_Device * dev,
-                                   yaffs_FileStructure * fStruct)
+static int yaffs_PruneFileStructure(yaffs_Device *dev,
+                               yaffs_FileStructure *fStruct)
 {
        int i;
        int hasData;
@@ -1849,7 +1822,7 @@ static int yaffs_PruneFileStructure(yaffs_Device * dev,
                /* Now we have a tree with all the non-zero branches NULL but the height
                 * is the same as it was.
                 * Let's see if we can trim internal tnodes to shorten the tree.
-                * We can do this if only the 0th element in the tnode is in use 
+                * We can do this if only the 0th element in the tnode is in use
                 * (ie all the non-zero are NULL)
                 */
 
@@ -1881,7 +1854,7 @@ static int yaffs_PruneFileStructure(yaffs_Device * dev,
 /* yaffs_CreateFreeObjects creates a bunch more objects and
  * adds them to the object free list.
  */
-static int yaffs_CreateFreeObjects(yaffs_Device * dev, int nObjects)
+static int yaffs_CreateFreeObjects(yaffs_Device *dev, int nObjects)
 {
        int i;
        yaffs_Object *newObjects;
@@ -1895,22 +1868,22 @@ static int yaffs_CreateFreeObjects(yaffs_Device * dev, int nObjects)
        list = YMALLOC(sizeof(yaffs_ObjectList));
 
        if (!newObjects || !list) {
-               if(newObjects)
+               if (newObjects)
                        YFREE(newObjects);
-               if(list)
+               if (list)
                        YFREE(list);
                T(YAFFS_TRACE_ALLOCATE,
                  (TSTR("yaffs: Could not allocate more objects" TENDSTR)));
                return YAFFS_FAIL;
        }
-       
-        /* Hook them into the free list */
-        for (i = 0; i < nObjects - 1; i++) {
-                newObjects[i].siblings.next =
-                    (struct ylist_head *)(&newObjects[i + 1]);
-        }
 
-        newObjects[nObjects - 1].siblings.next = (void *)dev->freeObjects;
+       /* Hook them into the free list */
+       for (i = 0; i < nObjects - 1; i++) {
+               newObjects[i].siblings.next =
+                               (struct ylist_head *)(&newObjects[i + 1]);
+       }
+
+       newObjects[nObjects - 1].siblings.next = (void *)dev->freeObjects;
        dev->freeObjects = newObjects;
        dev->nFreeObjects += nObjects;
        dev->nObjectsCreated += nObjects;
@@ -1926,7 +1899,7 @@ static int yaffs_CreateFreeObjects(yaffs_Device * dev, int nObjects)
 
 
 /* AllocateEmptyObject gets us a clean Object. Tries to make allocate more if we run out */
-static yaffs_Object *yaffs_AllocateEmptyObject(yaffs_Device * dev)
+static yaffs_Object *yaffs_AllocateEmptyObject(yaffs_Device *dev)
 {
        yaffs_Object *tn = NULL;
 
@@ -1941,47 +1914,47 @@ static yaffs_Object *yaffs_AllocateEmptyObject(yaffs_Device * dev)
        if (dev->freeObjects) {
                tn = dev->freeObjects;
                dev->freeObjects =
-                   (yaffs_Object *) (dev->freeObjects->siblings.next);
+                       (yaffs_Object *) (dev->freeObjects->siblings.next);
                dev->nFreeObjects--;
        }
 #endif
-       if(tn){
+       if (tn) {
                /* Now sweeten it up... */
 
                memset(tn, 0, sizeof(yaffs_Object));
                tn->beingCreated = 1;
-               
+
                tn->myDev = dev;
                tn->hdrChunk = 0;
                tn->variantType = YAFFS_OBJECT_TYPE_UNKNOWN;
                YINIT_LIST_HEAD(&(tn->hardLinks));
                YINIT_LIST_HEAD(&(tn->hashLink));
                YINIT_LIST_HEAD(&tn->siblings);
-               
+
 
                /* Now make the directory sane */
-               if(dev->rootDir){
+               if (dev->rootDir) {
                        tn->parent = dev->rootDir;
-                       ylist_add(&(tn->siblings),&dev->rootDir->variant.directoryVariant.children);
+                       ylist_add(&(tn->siblings), &dev->rootDir->variant.directoryVariant.children);
                }
 
-                /* Add it to the lost and found directory.
-                 * NB Can't put root or lostNFound in lostNFound so
+               /* Add it to the lost and found directory.
+                * NB Can't put root or lostNFound in lostNFound so
                 * check if lostNFound exists first
                 */
                if (dev->lostNFoundDir) {
                        yaffs_AddObjectToDirectory(dev->lostNFoundDir, tn);
                }
-               
+
                tn->beingCreated = 0;
        }
-       
+
        dev->nCheckpointBlocksRequired = 0; /* force recalculation*/
 
        return tn;
 }
 
-static yaffs_Object *yaffs_CreateFakeDirectory(yaffs_Device * dev, int number,
+static yaffs_Object *yaffs_CreateFakeDirectory(yaffs_Device *dev, int number,
                                               __u32 mode)
 {
 
@@ -2002,24 +1975,22 @@ static yaffs_Object *yaffs_CreateFakeDirectory(yaffs_Device * dev, int number,
 
 }
 
-static void yaffs_UnhashObject(yaffs_Object * tn)
+static void yaffs_UnhashObject(yaffs_Object *tn)
 {
        int bucket;
-        yaffs_Device *dev = tn->myDev;
-
-        /* If it is still linked into the bucket list, free from the list */
-        if (!ylist_empty(&tn->hashLink)) {
-                ylist_del_init(&tn->hashLink);
-                bucket = yaffs_HashFunction(tn->objectId);
-                dev->objectBucket[bucket].count--;
-        }
+       yaffs_Device *dev = tn->myDev;
 
+       /* If it is still linked into the bucket list, free from the list */
+       if (!ylist_empty(&tn->hashLink)) {
+               ylist_del_init(&tn->hashLink);
+               bucket = yaffs_HashFunction(tn->objectId);
+               dev->objectBucket[bucket].count--;
+       }
 }
 
 /*  FreeObject frees up a Object and puts it back on the free list */
-static void yaffs_FreeObject(yaffs_Object * tn)
+static void yaffs_FreeObject(yaffs_Object *tn)
 {
-
        yaffs_Device *dev = tn->myDev;
 
 #ifdef  __KERNEL__
@@ -2028,11 +1999,11 @@ static void yaffs_FreeObject(yaffs_Object * tn)
        
        if(tn->parent)
                YBUG();
-       if(!ylist_empty(&tn->siblings))
+       if (!ylist_empty(&tn->siblings))
                YBUG();
 
 
-#ifdef  __KERNEL__
+#ifdef __KERNEL__
        if (tn->myInode) {
                /* We're still hooked up to a cached inode.
                 * Don't delete now, but mark for later deletion
@@ -2042,23 +2013,22 @@ static void yaffs_FreeObject(yaffs_Object * tn)
        }
 #endif
 
-        yaffs_UnhashObject(tn);
+       yaffs_UnhashObject(tn);
 
 #ifdef VALGRIND_TEST
        YFREE(tn);
 #else
-        /* Link into the free list. */
-        tn->siblings.next = (struct ylist_head *)(dev->freeObjects);
-        dev->freeObjects = tn;
-        dev->nFreeObjects++;
+       /* Link into the free list. */
+       tn->siblings.next = (struct ylist_head *)(dev->freeObjects);
+       dev->freeObjects = tn;
+       dev->nFreeObjects++;
 #endif
        dev->nCheckpointBlocksRequired = 0; /* force recalculation*/
-
 }
 
 #ifdef __KERNEL__
 
-void yaffs_HandleDeferedFree(yaffs_Object * obj)
+void yaffs_HandleDeferedFree(yaffs_Object *obj)
 {
        if (obj->deferedFree) {
                yaffs_FreeObject(obj);
@@ -2067,7 +2037,7 @@ void yaffs_HandleDeferedFree(yaffs_Object * obj)
 
 #endif
 
-static void yaffs_DeinitialiseObjects(yaffs_Device * dev)
+static void yaffs_DeinitialiseObjects(yaffs_Device *dev)
 {
        /* Free the list of allocated Objects */
 
@@ -2085,24 +2055,23 @@ static void yaffs_DeinitialiseObjects(yaffs_Device * dev)
        dev->nFreeObjects = 0;
 }
 
-static void yaffs_InitialiseObjects(yaffs_Device * dev)
+static void yaffs_InitialiseObjects(yaffs_Device *dev)
 {
        int i;
 
        dev->allocatedObjectList = NULL;
        dev->freeObjects = NULL;
-        dev->nFreeObjects = 0;
-
-        for (i = 0; i < YAFFS_NOBJECT_BUCKETS; i++) {
-                YINIT_LIST_HEAD(&dev->objectBucket[i].list);
-                dev->objectBucket[i].count = 0;
-        }
+       dev->nFreeObjects = 0;
 
+       for (i = 0; i < YAFFS_NOBJECT_BUCKETS; i++) {
+               YINIT_LIST_HEAD(&dev->objectBucket[i].list);
+               dev->objectBucket[i].count = 0;
+       }
 }
 
-static int yaffs_FindNiceObjectBucket(yaffs_Device * dev)
+static int yaffs_FindNiceObjectBucket(yaffs_Device *dev)
 {
-       static int x = 0;
+       static int x;
        int i;
        int l = 999;
        int lowest = 999999;
@@ -2136,63 +2105,60 @@ static int yaffs_FindNiceObjectBucket(yaffs_Device * dev)
        return l;
 }
 
-static int yaffs_CreateNewObjectNumber(yaffs_Device * dev)
+static int yaffs_CreateNewObjectNumber(yaffs_Device *dev)
 {
        int bucket = yaffs_FindNiceObjectBucket(dev);
 
        /* Now find an object value that has not already been taken
         * by scanning the list.
-         */
+        */
 
-        int found = 0;
-        struct ylist_head *i;
+       int found = 0;
+       struct ylist_head *i;
 
-        __u32 n = (__u32) bucket;
+       __u32 n = (__u32) bucket;
 
        /* yaffs_CheckObjectHashSanity();  */
 
        while (!found) {
-                found = 1;
-                n += YAFFS_NOBJECT_BUCKETS;
-                if (1 || dev->objectBucket[bucket].count > 0) {
-                        ylist_for_each(i, &dev->objectBucket[bucket].list) {
-                                /* If there is already one in the list */
-                                if (i
-                                    && ylist_entry(i, yaffs_Object,
-                                                  hashLink)->objectId == n) {
-                                        found = 0;
-                                }
+               found = 1;
+               n += YAFFS_NOBJECT_BUCKETS;
+               if (1 || dev->objectBucket[bucket].count > 0) {
+                       ylist_for_each(i, &dev->objectBucket[bucket].list) {
+                               /* If there is already one in the list */
+                               if (i && ylist_entry(i, yaffs_Object,
+                                               hashLink)->objectId == n) {
+                                       found = 0;
+                               }
                        }
                }
        }
 
-
        return n;
 }
 
-static void yaffs_HashObject(yaffs_Object * in)
+static void yaffs_HashObject(yaffs_Object *in)
 {
-        int bucket = yaffs_HashFunction(in->objectId);
-        yaffs_Device *dev = in->myDev;
-
-        ylist_add(&in->hashLink, &dev->objectBucket[bucket].list);
-        dev->objectBucket[bucket].count++;
+       int bucket = yaffs_HashFunction(in->objectId);
+       yaffs_Device *dev = in->myDev;
 
+       ylist_add(&in->hashLink, &dev->objectBucket[bucket].list);
+       dev->objectBucket[bucket].count++;
 }
 
-yaffs_Object *yaffs_FindObjectByNumber(yaffs_Device * dev, __u32 number)
+yaffs_Object *yaffs_FindObjectByNumber(yaffs_Device *dev, __u32 number)
 {
-        int bucket = yaffs_HashFunction(number);
-        struct ylist_head *i;
-        yaffs_Object *in;
+       int bucket = yaffs_HashFunction(number);
+       struct ylist_head *i;
+       yaffs_Object *in;
 
-        ylist_for_each(i, &dev->objectBucket[bucket].list) {
-                /* Look if it is in the list */
-                if (i) {
-                        in = ylist_entry(i, yaffs_Object, hashLink);
-                        if (in->objectId == number) {
+       ylist_for_each(i, &dev->objectBucket[bucket].list) {
+               /* Look if it is in the list */
+               if (i) {
+                       in = ylist_entry(i, yaffs_Object, hashLink);
+                       if (in->objectId == number) {
 #ifdef __KERNEL__
-                                /* Don't tell the VFS about this one if it is defered free */
+                               /* Don't tell the VFS about this one if it is defered free */
                                if (in->deferedFree)
                                        return NULL;
 #endif
@@ -2205,10 +2171,9 @@ yaffs_Object *yaffs_FindObjectByNumber(yaffs_Device * dev, __u32 number)
        return NULL;
 }
 
-yaffs_Object *yaffs_CreateNewObject(yaffs_Device * dev, int number,
+yaffs_Object *yaffs_CreateNewObject(yaffs_Device *dev, int number,
                                    yaffs_ObjectType type)
 {
-
        yaffs_Object *theObject;
        yaffs_Tnode *tn = NULL;
 
@@ -2217,18 +2182,16 @@ yaffs_Object *yaffs_CreateNewObject(yaffs_Device * dev, int number,
        }
 
        theObject = yaffs_AllocateEmptyObject(dev);
-       if(!theObject)
+       if (!theObject)
                return NULL;
-               
-       if(type == YAFFS_OBJECT_TYPE_FILE){
+
+       if (type == YAFFS_OBJECT_TYPE_FILE) {
                tn = yaffs_GetTnode(dev);
-               if(!tn){
+               if (!tn) {
                        yaffs_FreeObject(theObject);
                        return NULL;
                }
        }
-               
-       
 
        if (theObject) {
                theObject->fake = 0;
@@ -2255,13 +2218,13 @@ yaffs_Object *yaffs_CreateNewObject(yaffs_Device * dev, int number,
                        theObject->variant.fileVariant.scannedFileSize = 0;
                        theObject->variant.fileVariant.shrinkSize = 0xFFFFFFFF; /* max __u32 */
                        theObject->variant.fileVariant.topLevel = 0;
-                        theObject->variant.fileVariant.top = tn;
-                        break;
-                case YAFFS_OBJECT_TYPE_DIRECTORY:
-                        YINIT_LIST_HEAD(&theObject->variant.directoryVariant.
-                                       children);
-                        break;
-                case YAFFS_OBJECT_TYPE_SYMLINK:
+                       theObject->variant.fileVariant.top = tn;
+                       break;
+               case YAFFS_OBJECT_TYPE_DIRECTORY:
+                       YINIT_LIST_HEAD(&theObject->variant.directoryVariant.
+                                       children);
+                       break;
+               case YAFFS_OBJECT_TYPE_SYMLINK:
                case YAFFS_OBJECT_TYPE_HARDLINK:
                case YAFFS_OBJECT_TYPE_SPECIAL:
                        /* No action required */
@@ -2275,7 +2238,7 @@ yaffs_Object *yaffs_CreateNewObject(yaffs_Device * dev, int number,
        return theObject;
 }
 
-static yaffs_Object *yaffs_FindOrCreateObjectByNumber(yaffs_Device * dev,
+static yaffs_Object *yaffs_FindOrCreateObjectByNumber(yaffs_Device *dev,
                                                      int number,
                                                      yaffs_ObjectType type)
 {
@@ -2292,15 +2255,15 @@ static yaffs_Object *yaffs_FindOrCreateObjectByNumber(yaffs_Device * dev,
        return theObject;
 
 }
-                       
 
-static YCHAR *yaffs_CloneString(const YCHAR * str)
+
+static YCHAR *yaffs_CloneString(const YCHAR *str)
 {
        YCHAR *newStr = NULL;
 
        if (str && *str) {
                newStr = YMALLOC((yaffs_strlen(str) + 1) * sizeof(YCHAR));
-               if(newStr)
+               if (newStr)
                        yaffs_strcpy(newStr, str);
        }
 
@@ -2314,15 +2277,15 @@ static YCHAR *yaffs_CloneString(const YCHAR * str)
  * aliasString only has meaning for a sumlink.
  * rdev only has meaning for devices (a subset of special objects)
  */
+
 static yaffs_Object *yaffs_MknodObject(yaffs_ObjectType type,
-                                      yaffs_Object * parent,
-                                      const YCHAR * name,
+                                      yaffs_Object *parent,
+                                      const YCHAR *name,
                                       __u32 mode,
                                       __u32 uid,
                                       __u32 gid,
-                                      yaffs_Object * equivalentObject,
-                                      const YCHAR * aliasString, __u32 rdev)
+                                      yaffs_Object *equivalentObject,
+                                      const YCHAR *aliasString, __u32 rdev)
 {
        yaffs_Object *in;
        YCHAR *str = NULL;
@@ -2336,18 +2299,18 @@ static yaffs_Object *yaffs_MknodObject(yaffs_ObjectType type,
 
        in = yaffs_CreateNewObject(dev, -1, type);
 
-       if(!in)
+       if (!in)
                return YAFFS_FAIL;
-       
-       if(type == YAFFS_OBJECT_TYPE_SYMLINK){
+
+       if (type == YAFFS_OBJECT_TYPE_SYMLINK) {
                str = yaffs_CloneString(aliasString);
-               if(!str){
+               if (!str) {
                        yaffs_FreeObject(in);
                        return NULL;
                }
        }
-       
-       
+
+
 
        if (in) {
                in->hdrChunk = 0;
@@ -2383,13 +2346,13 @@ static yaffs_Object *yaffs_MknodObject(yaffs_ObjectType type,
                        break;
                case YAFFS_OBJECT_TYPE_HARDLINK:
                        in->variant.hardLinkVariant.equivalentObject =
-                            equivalentObject;
-                        in->variant.hardLinkVariant.equivalentObjectId =
-                            equivalentObject->objectId;
-                        ylist_add(&in->hardLinks, &equivalentObject->hardLinks);
-                        break;
-                case YAFFS_OBJECT_TYPE_FILE:    
-                case YAFFS_OBJECT_TYPE_DIRECTORY:
+                               equivalentObject;
+                       in->variant.hardLinkVariant.equivalentObjectId =
+                               equivalentObject->objectId;
+                       ylist_add(&in->hardLinks, &equivalentObject->hardLinks);
+                       break;
+               case YAFFS_OBJECT_TYPE_FILE:
+               case YAFFS_OBJECT_TYPE_DIRECTORY:
                case YAFFS_OBJECT_TYPE_SPECIAL:
                case YAFFS_OBJECT_TYPE_UNKNOWN:
                        /* do nothing */
@@ -2407,38 +2370,38 @@ static yaffs_Object *yaffs_MknodObject(yaffs_ObjectType type,
        return in;
 }
 
-yaffs_Object *yaffs_MknodFile(yaffs_Object * parent, const YCHAR * name,
-                             __u32 mode, __u32 uid, __u32 gid)
+yaffs_Object *yaffs_MknodFile(yaffs_Object *parent, const YCHAR *name,
+                       __u32 mode, __u32 uid, __u32 gid)
 {
        return yaffs_MknodObject(YAFFS_OBJECT_TYPE_FILE, parent, name, mode,
-                                uid, gid, NULL, NULL, 0);
+                               uid, gid, NULL, NULL, 0);
 }
 
-yaffs_Object *yaffs_MknodDirectory(yaffs_Object * parent, const YCHAR * name,
-                                  __u32 mode, __u32 uid, __u32 gid)
+yaffs_Object *yaffs_MknodDirectory(yaffs_Object *parent, const YCHAR *name,
+                               __u32 mode, __u32 uid, __u32 gid)
 {
        return yaffs_MknodObject(YAFFS_OBJECT_TYPE_DIRECTORY, parent, name,
                                 mode, uid, gid, NULL, NULL, 0);
 }
 
-yaffs_Object *yaffs_MknodSpecial(yaffs_Object * parent, const YCHAR * name,
-                                __u32 mode, __u32 uid, __u32 gid, __u32 rdev)
+yaffs_Object *yaffs_MknodSpecial(yaffs_Object *parent, const YCHAR *name,
+                               __u32 mode, __u32 uid, __u32 gid, __u32 rdev)
 {
        return yaffs_MknodObject(YAFFS_OBJECT_TYPE_SPECIAL, parent, name, mode,
                                 uid, gid, NULL, NULL, rdev);
 }
 
-yaffs_Object *yaffs_MknodSymLink(yaffs_Object * parent, const YCHAR * name,
-                                __u32 mode, __u32 uid, __u32 gid,
-                                const YCHAR * alias)
+yaffs_Object *yaffs_MknodSymLink(yaffs_Object *parent, const YCHAR *name,
+                               __u32 mode, __u32 uid, __u32 gid,
+                               const YCHAR *alias)
 {
        return yaffs_MknodObject(YAFFS_OBJECT_TYPE_SYMLINK, parent, name, mode,
-                                uid, gid, NULL, alias, 0);
+                               uid, gid, NULL, alias, 0);
 }
 
 /* yaffs_Link returns the object id of the equivalent object.*/
-yaffs_Object *yaffs_Link(yaffs_Object * parent, const YCHAR * name,
-                        yaffs_Object * equivalentObject)
+yaffs_Object *yaffs_Link(yaffs_Object *parent, const YCHAR *name,
+                       yaffs_Object *equivalentObject)
 {
        /* Get the real object in case we were fed a hard link as an equivalent object */
        equivalentObject = yaffs_GetEquivalentObject(equivalentObject);
@@ -2453,8 +2416,8 @@ yaffs_Object *yaffs_Link(yaffs_Object * parent, const YCHAR * name,
 
 }
 
-static int yaffs_ChangeObjectName(yaffs_Object * obj, yaffs_Object * newDir,
-                                 const YCHAR * newName, int force, int shadows)
+static int yaffs_ChangeObjectName(yaffs_Object *obj, yaffs_Object *newDir,
+                               const YCHAR *newName, int force, int shadows)
 {
        int unlinkOp;
        int deleteOp;
@@ -2472,7 +2435,7 @@ static int yaffs_ChangeObjectName(yaffs_Object * obj, yaffs_Object * newDir,
                    TENDSTR)));
                YBUG();
        }
-       
+
        /* TODO: Do we need this different handling for YAFFS2 and YAFFS1?? */
        if (obj->myDev->isYaffs2) {
                unlinkOp = (newDir == obj->myDev->unlinkedDir);
@@ -2485,9 +2448,9 @@ static int yaffs_ChangeObjectName(yaffs_Object * obj, yaffs_Object * newDir,
 
        existingTarget = yaffs_FindObjectByName(newDir, newName);
 
-       /* If the object is a file going into the unlinked directory, 
+       /* If the object is a file going into the unlinked directory,
         *   then it is OK to just stuff it in since duplicate names are allowed.
-        *   else only proceed if the new name does not exist and if we're putting 
+        *   else only proceed if the new name does not exist and if we're putting
         *   it into a directory.
         */
        if ((unlinkOp ||
@@ -2505,24 +2468,24 @@ static int yaffs_ChangeObjectName(yaffs_Object * obj, yaffs_Object * newDir,
                        obj->unlinked = 1;
 
                /* If it is a deletion then we mark it as a shrink for gc purposes. */
-               if (yaffs_UpdateObjectHeader(obj, newName, 0, deleteOp, shadows)>= 0)
+               if (yaffs_UpdateObjectHeader(obj, newName, 0, deleteOp, shadows) >= 0)
                        return YAFFS_OK;
        }
 
        return YAFFS_FAIL;
 }
 
-int yaffs_RenameObject(yaffs_Object * oldDir, const YCHAR * oldName,
-                      yaffs_Object * newDir, const YCHAR * newName)
+int yaffs_RenameObject(yaffs_Object *oldDir, const YCHAR *oldName,
+               yaffs_Object *newDir, const YCHAR *newName)
 {
-       yaffs_Object *obj=NULL;
-       yaffs_Object *existingTarget=NULL;
+       yaffs_Object *obj = NULL;
+       yaffs_Object *existingTarget = NULL;
        int force = 0;
-       
-       
-       if(!oldDir || oldDir->variantType != YAFFS_OBJECT_TYPE_DIRECTORY)
+
+
+       if (!oldDir || oldDir->variantType != YAFFS_OBJECT_TYPE_DIRECTORY)
                YBUG();
-       if(!newDir || newDir->variantType != YAFFS_OBJECT_TYPE_DIRECTORY)
+       if (!newDir || newDir->variantType != YAFFS_OBJECT_TYPE_DIRECTORY)
                YBUG();
 
 #ifdef CONFIG_YAFFS_CASE_INSENSITIVE
@@ -2536,8 +2499,8 @@ int yaffs_RenameObject(yaffs_Object * oldDir, const YCHAR * oldName,
 #endif
 
        else if (yaffs_strlen(newName) > YAFFS_MAX_NAME_LENGTH)
-         /* ENAMETOOLONG */
-         return YAFFS_FAIL;
+               /* ENAMETOOLONG */
+               return YAFFS_FAIL;
 
        obj = yaffs_FindObjectByName(oldDir, oldName);
 
@@ -2545,18 +2508,18 @@ int yaffs_RenameObject(yaffs_Object * oldDir, const YCHAR * oldName,
 
                /* Now do the handling for an existing target, if there is one */
 
-                existingTarget = yaffs_FindObjectByName(newDir, newName);
-                if (existingTarget &&
-                    existingTarget->variantType == YAFFS_OBJECT_TYPE_DIRECTORY &&
-                    !ylist_empty(&existingTarget->variant.directoryVariant.children)) {
-                        /* There is a target that is a non-empty directory, so we fail */
-                        return YAFFS_FAIL;      /* EEXIST or ENOTEMPTY */
-                } else if (existingTarget && existingTarget != obj) {
-                       /* Nuke the target first, using shadowing, 
+               existingTarget = yaffs_FindObjectByName(newDir, newName);
+               if (existingTarget &&
+                       existingTarget->variantType == YAFFS_OBJECT_TYPE_DIRECTORY &&
+                       !ylist_empty(&existingTarget->variant.directoryVariant.children)) {
+                       /* There is a target that is a non-empty directory, so we fail */
+                       return YAFFS_FAIL;      /* EEXIST or ENOTEMPTY */
+               } else if (existingTarget && existingTarget != obj) {
+                       /* Nuke the target first, using shadowing,
                         * but only if it isn't the same object
                         */
                        yaffs_ChangeObjectName(obj, newDir, newName, force,
-                                              existingTarget->objectId);
+                                               existingTarget->objectId);
                        yaffs_UnlinkObject(existingTarget);
                }
 
@@ -2567,37 +2530,34 @@ int yaffs_RenameObject(yaffs_Object * oldDir, const YCHAR * oldName,
 
 /*------------------------- Block Management and Page Allocation ----------------*/
 
-static int yaffs_InitialiseBlocks(yaffs_Device * dev)
+static int yaffs_InitialiseBlocks(yaffs_Device *dev)
 {
        int nBlocks = dev->internalEndBlock - dev->internalStartBlock + 1;
-       
+
        dev->blockInfo = NULL;
        dev->chunkBits = NULL;
-       
+
        dev->allocationBlock = -1;      /* force it to get a new one */
 
        /* If the first allocation strategy fails, thry the alternate one */
        dev->blockInfo = YMALLOC(nBlocks * sizeof(yaffs_BlockInfo));
-       if(!dev->blockInfo){
+       if (!dev->blockInfo) {
                dev->blockInfo = YMALLOC_ALT(nBlocks * sizeof(yaffs_BlockInfo));
                dev->blockInfoAlt = 1;
-       }
-       else
+       } else
                dev->blockInfoAlt = 0;
-               
-       if(dev->blockInfo){
-       
+
+       if (dev->blockInfo) {
                /* Set up dynamic blockinfo stuff. */
                dev->chunkBitmapStride = (dev->nChunksPerBlock + 7) / 8; /* round up bytes */
                dev->chunkBits = YMALLOC(dev->chunkBitmapStride * nBlocks);
-               if(!dev->chunkBits){
+               if (!dev->chunkBits) {
                        dev->chunkBits = YMALLOC_ALT(dev->chunkBitmapStride * nBlocks);
                        dev->chunkBitsAlt = 1;
-               }
-               else
+               } else
                        dev->chunkBitsAlt = 0;
        }
-       
+
        if (dev->blockInfo && dev->chunkBits) {
                memset(dev->blockInfo, 0, nBlocks * sizeof(yaffs_BlockInfo));
                memset(dev->chunkBits, 0, dev->chunkBitmapStride * nBlocks);
@@ -2605,30 +2565,29 @@ static int yaffs_InitialiseBlocks(yaffs_Device * dev)
        }
 
        return YAFFS_FAIL;
-
 }
 
-static void yaffs_DeinitialiseBlocks(yaffs_Device * dev)
+static void yaffs_DeinitialiseBlocks(yaffs_Device *dev)
 {
-       if(dev->blockInfoAlt && dev->blockInfo)
+       if (dev->blockInfoAlt && dev->blockInfo)
                YFREE_ALT(dev->blockInfo);
-       else if(dev->blockInfo)
+       else if (dev->blockInfo)
                YFREE(dev->blockInfo);
 
        dev->blockInfoAlt = 0;
 
        dev->blockInfo = NULL;
-       
-       if(dev->chunkBitsAlt && dev->chunkBits)
+
+       if (dev->chunkBitsAlt && dev->chunkBits)
                YFREE_ALT(dev->chunkBits);
-       else if(dev->chunkBits)
+       else if (dev->chunkBits)
                YFREE(dev->chunkBits);
        dev->chunkBitsAlt = 0;
        dev->chunkBits = NULL;
 }
 
-static int yaffs_BlockNotDisqualifiedFromGC(yaffs_Device * dev,
-                                           yaffs_BlockInfo * bi)
+static int yaffs_BlockNotDisqualifiedFromGC(yaffs_Device *dev,
+                                       yaffs_BlockInfo *bi)
 {
        int i;
        __u32 seq;
@@ -2647,7 +2606,7 @@ static int yaffs_BlockNotDisqualifiedFromGC(yaffs_Device * dev,
                seq = dev->sequenceNumber;
 
                for (i = dev->internalStartBlock; i <= dev->internalEndBlock;
-                    i++) {
+                               i++) {
                        b = yaffs_GetBlockInfo(dev, i);
                        if (b->blockState == YAFFS_BLOCK_STATE_FULL &&
                            (b->pagesInUse - b->softDeletions) <
@@ -2662,38 +2621,36 @@ static int yaffs_BlockNotDisqualifiedFromGC(yaffs_Device * dev,
         * discarded pages.
         */
        return (bi->sequenceNumber <= dev->oldestDirtySequence);
-
 }
 
 /* FindDiretiestBlock is used to select the dirtiest block (or close enough)
  * for garbage collection.
  */
 
-static int yaffs_FindBlockForGarbageCollection(yaffs_Device * dev,
-                                              int aggressive)
+static int yaffs_FindBlockForGarbageCollection(yaffs_Device *dev,
+                                       int aggressive)
 {
-
        int b = dev->currentDirtyChecker;
 
        int i;
        int iterations;
        int dirtiest = -1;
        int pagesInUse = 0;
-       int prioritised=0;
+       int prioritised = 0;
        yaffs_BlockInfo *bi;
        int pendingPrioritisedExist = 0;
-       
+
        /* First let's see if we need to grab a prioritised block */
-       if(dev->hasPendingPrioritisedGCs){
-               for(i = dev->internalStartBlock; i < dev->internalEndBlock && !prioritised; i++){
+       if (dev->hasPendingPrioritisedGCs) {
+               for (i = dev->internalStartBlock; i < dev->internalEndBlock && !prioritised; i++) {
 
                        bi = yaffs_GetBlockInfo(dev, i);
-                       //yaffs_VerifyBlock(dev,bi,i);
-                       
-                       if(bi->gcPrioritise) {
+                       /* yaffs_VerifyBlock(dev,bi,i); */
+
+                       if (bi->gcPrioritise) {
                                pendingPrioritisedExist = 1;
-                               if(bi->blockState == YAFFS_BLOCK_STATE_FULL &&
-                                  yaffs_BlockNotDisqualifiedFromGC(dev, bi)){
+                               if (bi->blockState == YAFFS_BLOCK_STATE_FULL &&
+                                  yaffs_BlockNotDisqualifiedFromGC(dev, bi)) {
                                        pagesInUse = (bi->pagesInUse - bi->softDeletions);
                                        dirtiest = i;
                                        prioritised = 1;
@@ -2701,8 +2658,8 @@ static int yaffs_FindBlockForGarbageCollection(yaffs_Device * dev,
                                }
                        }
                }
-               
-               if(!pendingPrioritisedExist) /* None found, so we can clear this */
+
+               if (!pendingPrioritisedExist) /* None found, so we can clear this */
                        dev->hasPendingPrioritisedGCs = 0;
        }
 
@@ -2718,9 +2675,9 @@ static int yaffs_FindBlockForGarbageCollection(yaffs_Device * dev,
                return -1;
        }
 
-       if(!prioritised)
+       if (!prioritised)
                pagesInUse =
-                       (aggressive) ? dev->nChunksPerBlock : YAFFS_PASSIVE_GC_CHUNKS + 1;
+                       (aggressive) ? dev->nChunksPerBlock : YAFFS_PASSIVE_GC_CHUNKS + 1;
 
        if (aggressive) {
                iterations =
@@ -2752,13 +2709,12 @@ static int yaffs_FindBlockForGarbageCollection(yaffs_Device * dev,
                if (bi->blockState == YAFFS_BLOCK_STATE_CHECKPOINT) {
                        dirtiest = b;
                        pagesInUse = 0;
-               }
-               else 
+               } else
 #endif
 
                if (bi->blockState == YAFFS_BLOCK_STATE_FULL &&
-                      (bi->pagesInUse - bi->softDeletions) < pagesInUse &&
-                       yaffs_BlockNotDisqualifiedFromGC(dev, bi)) {
+                       (bi->pagesInUse - bi->softDeletions) < pagesInUse &&
+                               yaffs_BlockNotDisqualifiedFromGC(dev, bi)) {
                        dirtiest = b;
                        pagesInUse = (bi->pagesInUse - bi->softDeletions);
                }
@@ -2769,19 +2725,18 @@ static int yaffs_FindBlockForGarbageCollection(yaffs_Device * dev,
        if (dirtiest > 0) {
                T(YAFFS_TRACE_GC,
                  (TSTR("GC Selected block %d with %d free, prioritised:%d" TENDSTR), dirtiest,
-                  dev->nChunksPerBlock - pagesInUse,prioritised));
+                  dev->nChunksPerBlock - pagesInUse, prioritised));
        }
 
        dev->oldestDirtySequence = 0;
 
-       if (dirtiest > 0) {
+       if (dirtiest > 0)
                dev->nonAggressiveSkip = 4;
-       }
 
        return dirtiest;
 }
 
-static void yaffs_BlockBecameDirty(yaffs_Device * dev, int blockNo)
+static void yaffs_BlockBecameDirty(yaffs_Device *dev, int blockNo)
 {
        yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev, blockNo);
 
@@ -2790,11 +2745,11 @@ static void yaffs_BlockBecameDirty(yaffs_Device * dev, int blockNo)
        /* If the block is still healthy erase it and mark as clean.
         * If the block has had a data failure, then retire it.
         */
-        
+
        T(YAFFS_TRACE_GC | YAFFS_TRACE_ERASE,
                (TSTR("yaffs_BlockBecameDirty block %d state %d %s"TENDSTR),
                blockNo, bi->blockState, (bi->needsRetiring) ? "needs retiring" : ""));
-               
+
        bi->blockState = YAFFS_BLOCK_STATE_DIRTY;
 
        if (!bi->needsRetiring) {
@@ -2807,7 +2762,7 @@ static void yaffs_BlockBecameDirty(yaffs_Device * dev, int blockNo)
                }
        }
 
-       if (erasedOk && 
+       if (erasedOk &&
            ((yaffs_traceMask & YAFFS_TRACE_ERASE) || !yaffs_SkipVerification(dev))) {
                int i;
                for (i = 0; i < dev->nChunksPerBlock; i++) {
@@ -2843,7 +2798,7 @@ static void yaffs_BlockBecameDirty(yaffs_Device * dev, int blockNo)
        }
 }
 
-static int yaffs_FindBlockForAllocation(yaffs_Device * dev)
+static int yaffs_FindBlockForAllocation(yaffs_Device *dev)
 {
        int i;
 
@@ -2858,7 +2813,7 @@ static int yaffs_FindBlockForAllocation(yaffs_Device * dev)
 
                return -1;
        }
-       
+
        /* Find an empty block. */
 
        for (i = dev->internalStartBlock; i <= dev->internalEndBlock; i++) {
@@ -2895,8 +2850,8 @@ static int yaffs_FindBlockForAllocation(yaffs_Device * dev)
 
 static int yaffs_CalcCheckpointBlocksRequired(yaffs_Device *dev)
 {
-       if(!dev->nCheckpointBlocksRequired &&
-          dev->isYaffs2){
+       if (!dev->nCheckpointBlocksRequired &&
+          dev->isYaffs2) {
                /* Not a valid value so recalculate */
                int nBytes = 0;
                int nBlocks;
@@ -2905,9 +2860,9 @@ static int yaffs_CalcCheckpointBlocksRequired(yaffs_Device *dev)
 
                tnodeSize = (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8;
 
-               if(tnodeSize < sizeof(yaffs_Tnode))
+               if (tnodeSize < sizeof(yaffs_Tnode))
                        tnodeSize = sizeof(yaffs_Tnode);
-               
+
                nBytes += sizeof(yaffs_CheckpointValidity);
                nBytes += sizeof(yaffs_CheckpointDevice);
                nBytes += devBlocks * sizeof(yaffs_BlockInfo);
@@ -2916,40 +2871,43 @@ static int yaffs_CalcCheckpointBlocksRequired(yaffs_Device *dev)
                nBytes += (tnodeSize + sizeof(__u32)) * (dev->nTnodesCreated - dev->nFreeTnodes);
                nBytes += sizeof(yaffs_CheckpointValidity);
                nBytes += sizeof(__u32); /* checksum*/
-       
+
                /* Round up and add 2 blocks to allow for some bad blocks, so add 3 */
-       
+
                nBlocks = (nBytes/(dev->nDataBytesPerChunk * dev->nChunksPerBlock)) + 3;
-       
+
                dev->nCheckpointBlocksRequired = nBlocks;
        }
 
        return dev->nCheckpointBlocksRequired;
 }
 
-// Check if there's space to allocate...
-// Thinks.... do we need top make this ths same as yaffs_GetFreeChunks()?
-static int yaffs_CheckSpaceForAllocation(yaffs_Device * dev)
+/*
+ * Check if there's space to allocate...
+ * Thinks.... do we need top make this ths same as yaffs_GetFreeChunks()?
+ */
+static int yaffs_CheckSpaceForAllocation(yaffs_Device *dev)
 {
        int reservedChunks;
        int reservedBlocks = dev->nReservedBlocks;
        int checkpointBlocks;
-       
-       if(dev->isYaffs2){
-               checkpointBlocks =  yaffs_CalcCheckpointBlocksRequired(dev) - 
+
+       if (dev->isYaffs2) {
+               checkpointBlocks =  yaffs_CalcCheckpointBlocksRequired(dev) -
                                    dev->blocksInCheckpoint;
-               if(checkpointBlocks < 0)
+               if (checkpointBlocks < 0)
                        checkpointBlocks = 0;
        } else {
-               checkpointBlocks =0;
+               checkpointBlocks = 0;
        }
-       
+
        reservedChunks = ((reservedBlocks + checkpointBlocks) * dev->nChunksPerBlock);
-       
+
        return (dev->nFreeChunks > reservedChunks);
 }
 
-static int yaffs_AllocateChunk(yaffs_Device * dev, int useReserve, yaffs_BlockInfo **blockUsedPtr)
+static int yaffs_AllocateChunk(yaffs_Device *dev, int useReserve,
+               yaffs_BlockInfo **blockUsedPtr)
 {
        int retVal;
        yaffs_BlockInfo *bi;
@@ -2966,7 +2924,7 @@ static int yaffs_AllocateChunk(yaffs_Device * dev, int useReserve, yaffs_BlockIn
        }
 
        if (dev->nErasedBlocks < dev->nReservedBlocks
-           && dev->allocationPage == 0) {
+                       && dev->allocationPage == 0) {
                T(YAFFS_TRACE_ALLOCATE, (TSTR("Allocating reserve" TENDSTR)));
        }
 
@@ -2975,10 +2933,10 @@ static int yaffs_AllocateChunk(yaffs_Device * dev, int useReserve, yaffs_BlockIn
                bi = yaffs_GetBlockInfo(dev, dev->allocationBlock);
 
                retVal = (dev->allocationBlock * dev->nChunksPerBlock) +
-                   dev->allocationPage;
+                       dev->allocationPage;
                bi->pagesInUse++;
                yaffs_SetChunkBit(dev, dev->allocationBlock,
-                                 dev->allocationPage);
+                               dev->allocationPage);
 
                dev->allocationPage++;
 
@@ -2990,19 +2948,19 @@ static int yaffs_AllocateChunk(yaffs_Device * dev, int useReserve, yaffs_BlockIn
                        dev->allocationBlock = -1;
                }
 
-               if(blockUsedPtr)
+               if (blockUsedPtr)
                        *blockUsedPtr = bi;
-                       
+
                return retVal;
        }
-       
+
        T(YAFFS_TRACE_ERROR,
-         (TSTR("!!!!!!!!! Allocator out !!!!!!!!!!!!!!!!!" TENDSTR)));
+                       (TSTR("!!!!!!!!! Allocator out !!!!!!!!!!!!!!!!!" TENDSTR)));
 
        return -1;
 }
 
-static int yaffs_GetErasedChunks(yaffs_Device * dev)
+static int yaffs_GetErasedChunks(yaffs_Device *dev)
 {
        int n;
 
@@ -3016,7 +2974,8 @@ static int yaffs_GetErasedChunks(yaffs_Device * dev)
 
 }
 
-static int yaffs_GarbageCollectBlock(yaffs_Device * dev, int block, int wholeBlock)
+static int yaffs_GarbageCollectBlock(yaffs_Device *dev, int block,
+               int wholeBlock)
 {
        int oldChunk;
        int newChunk;
@@ -3038,15 +2997,15 @@ static int yaffs_GarbageCollectBlock(yaffs_Device * dev, int block, int wholeBlo
        yaffs_Object *object;
 
        isCheckpointBlock = (bi->blockState == YAFFS_BLOCK_STATE_CHECKPOINT);
-       
+
        bi->blockState = YAFFS_BLOCK_STATE_COLLECTING;
 
        T(YAFFS_TRACE_TRACING,
-         (TSTR("Collecting block %d, in use %d, shrink %d, wholeBlock %d" TENDSTR), 
-         block,
-         bi->pagesInUse,
-         bi->hasShrinkHeader,
-         wholeBlock));
+                       (TSTR("Collecting block %d, in use %d, shrink %d, wholeBlock %d" TENDSTR),
+                        block,
+                        bi->pagesInUse,
+                        bi->hasShrinkHeader,
+                        wholeBlock));
 
        /*yaffs_VerifyFreeChunks(dev); */
 
@@ -3060,31 +3019,31 @@ static int yaffs_GarbageCollectBlock(yaffs_Device * dev, int block, int wholeBlo
        dev->isDoingGC = 1;
 
        if (isCheckpointBlock ||
-           !yaffs_StillSomeChunkBits(dev, block)) {
+                       !yaffs_StillSomeChunkBits(dev, block)) {
                T(YAFFS_TRACE_TRACING,
-                 (TSTR
-                  ("Collecting block %d that has no chunks in use" TENDSTR),
-                  block));
+                               (TSTR
+                                ("Collecting block %d that has no chunks in use" TENDSTR),
+                                block));
                yaffs_BlockBecameDirty(dev, block);
        } else {
 
                __u8 *buffer = yaffs_GetTempBuffer(dev, __LINE__);
-               
-               yaffs_VerifyBlock(dev,bi,block);
+
+               yaffs_VerifyBlock(dev, bi, block);
 
                maxCopies = (wholeBlock) ? dev->nChunksPerBlock : 10;
                oldChunk = block * dev->nChunksPerBlock + dev->gcChunk;
-               
-               for ( /* init already done */;
+
+               for (/* init already done */;
                     retVal == YAFFS_OK &&
                     dev->gcChunk < dev->nChunksPerBlock &&
-                    (bi->blockState == YAFFS_BLOCK_STATE_COLLECTING)&&
+                    (bi->blockState == YAFFS_BLOCK_STATE_COLLECTING) &&
                     maxCopies > 0;
                     dev->gcChunk++, oldChunk++) {
                        if (yaffs_CheckChunkBit(dev, block, dev->gcChunk)) {
 
                                /* This page is in use and might need to be copied off */
-                               
+
                                maxCopies--;
 
                                markNAND = 1;
@@ -3103,20 +3062,20 @@ static int yaffs_GarbageCollectBlock(yaffs_Device * dev, int block, int wholeBlo
                                   ("Collecting chunk in block %d, %d %d %d " TENDSTR),
                                   dev->gcChunk, tags.objectId, tags.chunkId,
                                   tags.byteCount));
-                                  
-                               if(object && !yaffs_SkipVerification(dev)){
-                                       if(tags.chunkId == 0)
+
+                               if (object && !yaffs_SkipVerification(dev)) {
+                                       if (tags.chunkId == 0)
                                                matchingChunk = object->hdrChunk;
-                                       else if(object->softDeleted)
+                                       else if (object->softDeleted)
                                                matchingChunk = oldChunk; /* Defeat the test */
                                        else
-                                               matchingChunk = yaffs_FindChunkInFile(object,tags.chunkId,NULL);
-                                       
-                                       if(oldChunk != matchingChunk)
+                                               matchingChunk = yaffs_FindChunkInFile(object, tags.chunkId, NULL);
+
+                                       if (oldChunk != matchingChunk)
                                                T(YAFFS_TRACE_ERROR,
                                                  (TSTR("gc: page in gc mismatch: %d %d %d %d"TENDSTR),
-                                                 oldChunk,matchingChunk,tags.objectId, tags.chunkId));
-                                               
+                                                 oldChunk, matchingChunk, tags.objectId, tags.chunkId));
+
                                }
 
                                if (!object) {
@@ -3127,13 +3086,13 @@ static int yaffs_GarbageCollectBlock(yaffs_Device * dev, int block, int wholeBlo
                                            tags.objectId, tags.chunkId, tags.byteCount));
                                }
 
-                               if (object && 
+                               if (object &&
                                    object->deleted &&
                                    object->softDeleted &&
                                    tags.chunkId != 0) {
                                        /* Data chunk in a soft deleted file, throw it away
                                         * It's a soft deleted data chunk,
-                                        * No need to copy this, just forget about it and 
+                                        * No need to copy this, just forget about it and
                                         * fix up the object.
                                         */
 
@@ -3146,9 +3105,8 @@ static int yaffs_GarbageCollectBlock(yaffs_Device * dev, int block, int wholeBlo
                                                cleanups++;
                                        }
                                        markNAND = 0;
-                               } else if (0
-                                          /* Todo object && object->deleted && object->nDataChunks == 0 */
-                                          ) {
+                               } else if (0) {
+                                       /* Todo object && object->deleted && object->nDataChunks == 0 */
                                        /* Deleted object header with no data chunks.
                                         * Can be discarded and the file deleted.
                                         */
@@ -3180,8 +3138,8 @@ static int yaffs_GarbageCollectBlock(yaffs_Device * dev, int block, int wholeBlo
                                                oh = (yaffs_ObjectHeader *)buffer;
                                                oh->isShrink = 0;
                                                tags.extraIsShrinkHeader = 0;
-                                               
-                                               yaffs_VerifyObjectHeader(object,oh,&tags,1);
+
+                                               yaffs_VerifyObjectHeader(object, oh, &tags, 1);
                                        }
 
                                        newChunk =
@@ -3207,7 +3165,7 @@ static int yaffs_GarbageCollectBlock(yaffs_Device * dev, int block, int wholeBlo
                                        }
                                }
 
-                               if(retVal == YAFFS_OK)
+                               if (retVal == YAFFS_OK)
                                        yaffs_DeleteChunk(dev, oldChunk, markNAND, __LINE__);
 
                        }
@@ -3239,9 +3197,10 @@ static int yaffs_GarbageCollectBlock(yaffs_Device * dev, int block, int wholeBlo
 
        }
 
-       yaffs_VerifyCollectedBlock(dev,bi,block);
-         
-       if (chunksBefore >= (chunksAfter = yaffs_GetErasedChunks(dev))) {
+       yaffs_VerifyCollectedBlock(dev, bi, block);
+
+       chunksAfter = yaffs_GetErasedChunks(dev);
+       if (chunksBefore >= chunksAfter) {
                T(YAFFS_TRACE_GC,
                  (TSTR
                   ("gc did not increase free chunks before %d after %d"
@@ -3249,11 +3208,11 @@ static int yaffs_GarbageCollectBlock(yaffs_Device * dev, int block, int wholeBlo
        }
 
        /* If the gc completed then clear the current gcBlock so that we find another. */
-       if(bi->blockState != YAFFS_BLOCK_STATE_COLLECTING){
+       if (bi->blockState != YAFFS_BLOCK_STATE_COLLECTING) {
                dev->gcBlock = -1;
                dev->gcChunk = 0;
        }
-       
+
        dev->isDoingGC = 0;
 
        return retVal;
@@ -3268,29 +3227,29 @@ static int yaffs_GarbageCollectBlock(yaffs_Device * dev, int block, int wholeBlo
  * The idea is to help clear out space in a more spread-out manner.
  * Dunno if it really does anything useful.
  */
-static int yaffs_CheckGarbageCollection(yaffs_Device * dev)
+static int yaffs_CheckGarbageCollection(yaffs_Device *dev)
 {
        int block;
        int aggressive;
        int gcOk = YAFFS_OK;
        int maxTries = 0;
-       
+
        int checkpointBlockAdjust;
 
        if (dev->isDoingGC) {
                /* Bail out so we don't get recursive gc */
                return YAFFS_OK;
        }
-       
+
        /* This loop should pass the first time.
         * We'll only see looping here if the erase of the collected block fails.
         */
 
        do {
                maxTries++;
-               
+
                checkpointBlockAdjust = yaffs_CalcCheckpointBlocksRequired(dev) - dev->blocksInCheckpoint;
-               if(checkpointBlockAdjust < 0)
+               if (checkpointBlockAdjust < 0)
                        checkpointBlockAdjust = 0;
 
                if (dev->nErasedBlocks < (dev->nReservedBlocks + checkpointBlockAdjust + 2)) {
@@ -3301,11 +3260,11 @@ static int yaffs_CheckGarbageCollection(yaffs_Device * dev)
                        aggressive = 0;
                }
 
-               if(dev->gcBlock <= 0){
+               if (dev->gcBlock <= 0) {
                        dev->gcBlock = yaffs_FindBlockForGarbageCollection(dev, aggressive);
                        dev->gcChunk = 0;
                }
-               
+
                block = dev->gcBlock;
 
                if (block > 0) {
@@ -3319,7 +3278,7 @@ static int yaffs_CheckGarbageCollection(yaffs_Device * dev)
                           ("yaffs: GC erasedBlocks %d aggressive %d" TENDSTR),
                           dev->nErasedBlocks, aggressive));
 
-                       gcOk = yaffs_GarbageCollectBlock(dev,block,aggressive);
+                       gcOk = yaffs_GarbageCollectBlock(dev, block, aggressive);
                }
 
                if (dev->nErasedBlocks < (dev->nReservedBlocks) && block > 0) {
@@ -3328,7 +3287,7 @@ static int yaffs_CheckGarbageCollection(yaffs_Device * dev)
                           ("yaffs: GC !!!no reclaim!!! erasedBlocks %d after try %d block %d"
                            TENDSTR), dev->nErasedBlocks, maxTries, block));
                }
-       } while ((dev->nErasedBlocks < dev->nReservedBlocks) && 
+       } while ((dev->nErasedBlocks < dev->nReservedBlocks) &&
                 (block > 0) &&
                 (maxTries < 2));
 
@@ -3337,7 +3296,7 @@ static int yaffs_CheckGarbageCollection(yaffs_Device * dev)
 
 /*-------------------------  TAGS --------------------------------*/
 
-static int yaffs_TagsMatch(const yaffs_ExtendedTags * tags, int objectId,
+static int yaffs_TagsMatch(const yaffs_ExtendedTags *tags, int objectId,
                           int chunkInObject)
 {
        return (tags->chunkId == chunkInObject &&
@@ -3348,8 +3307,8 @@ static int yaffs_TagsMatch(const yaffs_ExtendedTags * tags, int objectId,
 
 /*-------------------- Data file manipulation -----------------*/
 
-static int yaffs_FindChunkInFile(yaffs_Object * in, int chunkInInode,
-                                yaffs_ExtendedTags * tags)
+static int yaffs_FindChunkInFile(yaffs_Object *in, int chunkInInode,
+                                yaffs_ExtendedTags *tags)
 {
        /*Get the Tnode, then get the level 0 offset chunk offset */
        yaffs_Tnode *tn;
@@ -3367,7 +3326,7 @@ static int yaffs_FindChunkInFile(yaffs_Object * in, int chunkInInode,
        tn = yaffs_FindLevel0Tnode(dev, &in->variant.fileVariant, chunkInInode);
 
        if (tn) {
-               theChunk = yaffs_GetChunkGroupBase(dev,tn,chunkInInode);
+               theChunk = yaffs_GetChunkGroupBase(dev, tn, chunkInInode);
 
                retVal =
                    yaffs_FindChunkInGroup(dev, theChunk, tags, in->objectId,
@@ -3376,8 +3335,8 @@ static int yaffs_FindChunkInFile(yaffs_Object * in, int chunkInInode,
        return retVal;
 }
 
-static int yaffs_FindAndDeleteChunkInFile(yaffs_Object * in, int chunkInInode,
-                                         yaffs_ExtendedTags * tags)
+static int yaffs_FindAndDeleteChunkInFile(yaffs_Object *in, int chunkInInode,
+                                         yaffs_ExtendedTags *tags)
 {
        /* Get the Tnode, then get the level 0 offset chunk offset */
        yaffs_Tnode *tn;
@@ -3396,7 +3355,7 @@ static int yaffs_FindAndDeleteChunkInFile(yaffs_Object * in, int chunkInInode,
 
        if (tn) {
 
-               theChunk = yaffs_GetChunkGroupBase(dev,tn,chunkInInode);
+               theChunk = yaffs_GetChunkGroupBase(dev, tn, chunkInInode);
 
                retVal =
                    yaffs_FindChunkInGroup(dev, theChunk, tags, in->objectId,
@@ -3404,7 +3363,7 @@ static int yaffs_FindAndDeleteChunkInFile(yaffs_Object * in, int chunkInInode,
 
                /* Delete the entry in the filestructure (if found) */
                if (retVal != -1) {
-                       yaffs_PutLevel0Tnode(dev,tn,chunkInInode,0);
+                       yaffs_PutLevel0Tnode(dev, tn, chunkInInode, 0);
                }
        } else {
                /*T(("No level 0 found for %d\n", chunkInInode)); */
@@ -3418,7 +3377,7 @@ static int yaffs_FindAndDeleteChunkInFile(yaffs_Object * in, int chunkInInode,
 
 #ifdef YAFFS_PARANOID
 
-static int yaffs_CheckFileSanity(yaffs_Object * in)
+static int yaffs_CheckFileSanity(yaffs_Object *in)
 {
        int chunk;
        int nChunks;
@@ -3447,7 +3406,7 @@ static int yaffs_CheckFileSanity(yaffs_Object * in)
 
                if (tn) {
 
-                       theChunk = yaffs_GetChunkGroupBase(dev,tn,chunk);
+                       theChunk = yaffs_GetChunkGroupBase(dev, tn, chunk);
 
                        if (yaffs_CheckChunkBits
                            (dev, theChunk / dev->nChunksPerBlock,
@@ -3476,14 +3435,14 @@ static int yaffs_CheckFileSanity(yaffs_Object * in)
 
 #endif
 
-static int yaffs_PutChunkIntoFile(yaffs_Object * in, int chunkInInode,
+static int yaffs_PutChunkIntoFile(yaffs_Object *in, int chunkInInode,
                                  int chunkInNAND, int inScan)
 {
-       /* NB inScan is zero unless scanning. 
-        * For forward scanning, inScan is > 0; 
+       /* NB inScan is zero unless scanning.
+        * For forward scanning, inScan is > 0;
         * for backward scanning inScan is < 0
         */
-        
+
        yaffs_Tnode *tn;
        yaffs_Device *dev = in->myDev;
        int existingChunk;
@@ -3507,7 +3466,7 @@ static int yaffs_PutChunkIntoFile(yaffs_Object * in, int chunkInInode,
                return YAFFS_OK;
        }
 
-       tn = yaffs_AddOrFindLevel0Tnode(dev, 
+       tn = yaffs_AddOrFindLevel0Tnode(dev,
                                        &in->variant.fileVariant,
                                        chunkInInode,
                                        NULL);
@@ -3515,11 +3474,11 @@ static int yaffs_PutChunkIntoFile(yaffs_Object * in, int chunkInInode,
                return YAFFS_FAIL;
        }
 
-       existingChunk = yaffs_GetChunkGroupBase(dev,tn,chunkInInode);
+       existingChunk = yaffs_GetChunkGroupBase(dev, tn, chunkInInode);
 
        if (inScan != 0) {
                /* If we're scanning then we need to test for duplicates
-                * NB This does not need to be efficient since it should only ever 
+                * NB This does not need to be efficient since it should only ever
                 * happen when the power fails during a write, then only one
                 * chunk should ever be affected.
                 *
@@ -3560,11 +3519,11 @@ static int yaffs_PutChunkIntoFile(yaffs_Object * in, int chunkInInode,
 
                        }
 
-                       /* NB The deleted flags should be false, otherwise the chunks will 
+                       /* NB The deleted flags should be false, otherwise the chunks will
                         * not be loaded during a scan
                         */
 
-                       if(inScan > 0) {
+                       if (inScan > 0) {
                                newSerial = newTags.serialNumber;
                                existingSerial = existingTags.serialNumber;
                        }
@@ -3573,7 +3532,7 @@ static int yaffs_PutChunkIntoFile(yaffs_Object * in, int chunkInInode,
                            (in->myDev->isYaffs2 ||
                             existingChunk <= 0 ||
                             ((existingSerial + 1) & 3) == newSerial)) {
-                               /* Forward scanning.                            
+                               /* Forward scanning.
                                 * Use new
                                 * Delete the old one and drop through to update the tnode
                                 */
@@ -3596,31 +3555,31 @@ static int yaffs_PutChunkIntoFile(yaffs_Object * in, int chunkInInode,
                in->nDataChunks++;
        }
 
-       yaffs_PutLevel0Tnode(dev,tn,chunkInInode,chunkInNAND);
+       yaffs_PutLevel0Tnode(dev, tn, chunkInInode, chunkInNAND);
 
        return YAFFS_OK;
 }
 
-static int yaffs_ReadChunkDataFromObject(yaffs_Object * in, int chunkInInode,
-                                        __u8 * buffer)
+static int yaffs_ReadChunkDataFromObject(yaffs_Object *in, int chunkInInode,
+                                       __u8 *buffer)
 {
        int chunkInNAND = yaffs_FindChunkInFile(in, chunkInInode, NULL);
 
        if (chunkInNAND >= 0) {
                return yaffs_ReadChunkWithTagsFromNAND(in->myDev, chunkInNAND,
-                                                      buffer,NULL);
+                                               buffer, NULL);
        } else {
                T(YAFFS_TRACE_NANDACCESS,
                  (TSTR("Chunk %d not found zero instead" TENDSTR),
                   chunkInNAND));
                /* get sane (zero) data if you read a hole */
-               memset(buffer, 0, in->myDev->nDataBytesPerChunk);       
+               memset(buffer, 0, in->myDev->nDataBytesPerChunk);
                return 0;
        }
 
 }
 
-void yaffs_DeleteChunk(yaffs_Device * dev, int chunkId, int markNAND, int lyn)
+void yaffs_DeleteChunk(yaffs_Device *dev, int chunkId, int markNAND, int lyn)
 {
        int block;
        int page;
@@ -3629,17 +3588,17 @@ void yaffs_DeleteChunk(yaffs_Device * dev, int chunkId, int markNAND, int lyn)
 
        if (chunkId <= 0)
                return;
-               
+
 
        dev->nDeletions++;
        block = chunkId / dev->nChunksPerBlock;
        page = chunkId % dev->nChunksPerBlock;
 
 
-       if(!yaffs_CheckChunkBit(dev,block,page))
+       if (!yaffs_CheckChunkBit(dev, block, page))
                T(YAFFS_TRACE_VERIFY,
-                       (TSTR("Deleting invalid chunk %d"TENDSTR),
-                        chunkId));
+                       (TSTR("Deleting invalid chunk %d"TENDSTR),
+                        chunkId));
 
        bi = yaffs_GetBlockInfo(dev, block);
 
@@ -3685,8 +3644,8 @@ void yaffs_DeleteChunk(yaffs_Device * dev, int chunkId, int markNAND, int lyn)
 
 }
 
-static int yaffs_WriteChunkDataToObject(yaffs_Object * in, int chunkInInode,
-                                       const __u8 * buffer, int nBytes,
+static int yaffs_WriteChunkDataToObject(yaffs_Object *in, int chunkInInode,
+                                       const __u8 *buffer, int nBytes,
                                        int useReserve)
 {
        /* Find old chunk Need to do this to get serial number
@@ -3715,14 +3674,12 @@ static int yaffs_WriteChunkDataToObject(yaffs_Object * in, int chunkInInode,
        newTags.serialNumber =
            (prevChunkId >= 0) ? prevTags.serialNumber + 1 : 1;
        newTags.byteCount = nBytes;
-       
-       if(nBytes < 1 || nBytes > dev->totalBytesPerChunk){
+
+       if (nBytes < 1 || nBytes > dev->totalBytesPerChunk) {
          T(YAFFS_TRACE_ERROR,
          (TSTR("Writing %d bytes to chunk!!!!!!!!!" TENDSTR), nBytes));
          YBUG();
-     }
-       
-       
+       }
 
        newChunkId =
            yaffs_WriteNewChunkWithTagsToNAND(dev, buffer, &newTags,
@@ -3745,7 +3702,7 @@ static int yaffs_WriteChunkDataToObject(yaffs_Object * in, int chunkInInode,
 /* UpdateObjectHeader updates the header on NAND for an object.
  * If name is not NULL, then that new name is used.
  */
-int yaffs_UpdateObjectHeader(yaffs_Object * in, const YCHAR * name, int force,
+int yaffs_UpdateObjectHeader(yaffs_Object *in, const YCHAR *name, int force,
                             int isShrink, int shadows)
 {
 
@@ -3764,14 +3721,14 @@ int yaffs_UpdateObjectHeader(yaffs_Object * in, const YCHAR * name, int force,
        __u8 *buffer = NULL;
        YCHAR oldName[YAFFS_MAX_NAME_LENGTH + 1];
 
-        yaffs_ObjectHeader *oh = NULL;
-        
-        yaffs_strcpy(oldName,_Y("silly old name"));
+       yaffs_ObjectHeader *oh = NULL;
+
+       yaffs_strcpy(oldName, _Y("silly old name"));
 
 
-       if (!in->fake || 
-           in == dev->rootDir || /* The rootDir should also be saved */
-           force) {
+       if (!in->fake ||
+               in == dev->rootDir || /* The rootDir should also be saved */
+               force) {
 
                yaffs_CheckGarbageCollection(dev);
                yaffs_CheckObjectDetailsLoaded(in);
@@ -3784,9 +3741,9 @@ int yaffs_UpdateObjectHeader(yaffs_Object * in, const YCHAR * name, int force,
                if (prevChunkId > 0) {
                        result = yaffs_ReadChunkWithTagsFromNAND(dev, prevChunkId,
                                                        buffer, &oldTags);
-                       
-                       yaffs_VerifyObjectHeader(in,oh,&oldTags,0);
-                                                                               
+
+                       yaffs_VerifyObjectHeader(in, oh, &oldTags, 0);
+
                        memcpy(oldName, oh->name, sizeof(oh->name));
                }
 
@@ -3820,7 +3777,7 @@ int yaffs_UpdateObjectHeader(yaffs_Object * in, const YCHAR * name, int force,
                if (name && *name) {
                        memset(oh->name, 0, sizeof(oh->name));
                        yaffs_strncpy(oh->name, name, YAFFS_MAX_NAME_LENGTH);
-               } else if (prevChunkId>=0) {
+               } else if (prevChunkId >= 0) {
                        memcpy(oh->name, oldName, sizeof(oh->name));
                } else {
                        memset(oh->name, 0, sizeof(oh->name));
@@ -3874,7 +3831,7 @@ int yaffs_UpdateObjectHeader(yaffs_Object * in, const YCHAR * name, int force,
                newTags.extraShadows = (oh->shadowsObject > 0) ? 1 : 0;
                newTags.extraObjectType = in->variantType;
 
-               yaffs_VerifyObjectHeader(in,oh,&newTags,1);
+               yaffs_VerifyObjectHeader(in, oh, &newTags, 1);
 
                /* Create new chunk in NAND */
                newChunkId =
@@ -3890,13 +3847,13 @@ int yaffs_UpdateObjectHeader(yaffs_Object * in, const YCHAR * name, int force,
                                                  __LINE__);
                        }
 
-                       if(!yaffs_ObjectHasCachedWriteData(in))
+                       if (!yaffs_ObjectHasCachedWriteData(in))
                                in->dirty = 0;
 
                        /* If this was a shrink, then mark the block that the chunk lives on */
                        if (isShrink) {
                                bi = yaffs_GetBlockInfo(in->myDev,
-                                                       newChunkId /in->myDev-> nChunksPerBlock);
+                                       newChunkId / in->myDev->nChunksPerBlock);
                                bi->hasShrinkHeader = 1;
                        }
 
@@ -3914,11 +3871,11 @@ int yaffs_UpdateObjectHeader(yaffs_Object * in, const YCHAR * name, int force,
 
 /*------------------------ Short Operations Cache ----------------------------------------
  *   In many situations where there is no high level buffering (eg WinCE) a lot of
- *   reads might be short sequential reads, and a lot of writes may be short 
+ *   reads might be short sequential reads, and a lot of writes may be short
  *   sequential writes. eg. scanning/writing a jpeg file.
- *   In these cases, a short read/write cache can provide a huge perfomance benefit 
+ *   In these cases, a short read/write cache can provide a huge perfomance benefit
  *   with dumb-as-a-rock code.
- *   In Linux, the page cache provides read buffering aand the short op cache provides write 
+ *   In Linux, the page cache provides read buffering aand the short op cache provides write
  *   buffering.
  *
  *   There are a limited number (~10) of cache chunks per device so that we don't
@@ -3931,19 +3888,19 @@ static int yaffs_ObjectHasCachedWriteData(yaffs_Object *obj)
        int i;
        yaffs_ChunkCache *cache;
        int nCaches = obj->myDev->nShortOpCaches;
-       
-       for(i = 0; i < nCaches; i++){
+
+       for (i = 0; i < nCaches; i++) {
                cache = &dev->srCache[i];
                if (cache->object == obj &&
                    cache->dirty)
                        return 1;
        }
-       
+
        return 0;
 }
 
 
-static void yaffs_FlushFilesChunkCache(yaffs_Object * obj)
+static void yaffs_FlushFilesChunkCache(yaffs_Object *obj)
 {
        yaffs_Device *dev = obj->myDev;
        int lowest = -99;       /* Stop compiler whining. */
@@ -4004,38 +3961,38 @@ void yaffs_FlushEntireDeviceCache(yaffs_Device *dev)
        yaffs_Object *obj;
        int nCaches = dev->nShortOpCaches;
        int i;
-       
+
        /* Find a dirty object in the cache and flush it...
         * until there are no further dirty objects.
         */
        do {
                obj = NULL;
-               fori = 0; i < nCaches && !obj; i++) {
+               for (i = 0; i < nCaches && !obj; i++) {
                        if (dev->srCache[i].object &&
                            dev->srCache[i].dirty)
                                obj = dev->srCache[i].object;
-                           
+
                }
-               if(obj)
+               if (obj)
                        yaffs_FlushFilesChunkCache(obj);
-                       
-       } while(obj);
-       
+
+       } while (obj);
+
 }
 
 
 /* Grab us a cache chunk for use.
- * First look for an empty one. 
+ * First look for an empty one.
  * Then look for the least recently used non-dirty one.
  * Then look for the least recently used dirty one...., flush and look again.
  */
-static yaffs_ChunkCache *yaffs_GrabChunkCacheWorker(yaffs_Device * dev)
+static yaffs_ChunkCache *yaffs_GrabChunkCacheWorker(yaffs_Device *dev)
 {
        int i;
 
        if (dev->nShortOpCaches > 0) {
                for (i = 0; i < dev->nShortOpCaches; i++) {
-                       if (!dev->srCache[i].object) 
+                       if (!dev->srCache[i].object)
                                return &dev->srCache[i];
                }
        }
@@ -4043,7 +4000,7 @@ static yaffs_ChunkCache *yaffs_GrabChunkCacheWorker(yaffs_Device * dev)
        return NULL;
 }
 
-static yaffs_ChunkCache *yaffs_GrabChunkCache(yaffs_Device * dev)
+static yaffs_ChunkCache *yaffs_GrabChunkCache(yaffs_Device *dev)
 {
        yaffs_ChunkCache *cache;
        yaffs_Object *theObj;
@@ -4073,8 +4030,7 @@ static yaffs_ChunkCache *yaffs_GrabChunkCache(yaffs_Device * dev)
                        for (i = 0; i < dev->nShortOpCaches; i++) {
                                if (dev->srCache[i].object &&
                                    !dev->srCache[i].locked &&
-                                   (dev->srCache[i].lastUse < usage || !cache))
-                               {
+                                   (dev->srCache[i].lastUse < usage || !cache)) {
                                        usage = dev->srCache[i].lastUse;
                                        theObj = dev->srCache[i].object;
                                        cache = &dev->srCache[i];
@@ -4096,7 +4052,7 @@ static yaffs_ChunkCache *yaffs_GrabChunkCache(yaffs_Device * dev)
 }
 
 /* Find a cached chunk */
-static yaffs_ChunkCache *yaffs_FindChunkCache(const yaffs_Object * obj,
+static yaffs_ChunkCache *yaffs_FindChunkCache(const yaffs_Object *obj,
                                              int chunkId)
 {
        yaffs_Device *dev = obj->myDev;
@@ -4115,7 +4071,7 @@ static yaffs_ChunkCache *yaffs_FindChunkCache(const yaffs_Object * obj,
 }
 
 /* Mark the chunk for the least recently used algorithym */
-static void yaffs_UseChunkCache(yaffs_Device * dev, yaffs_ChunkCache * cache,
+static void yaffs_UseChunkCache(yaffs_Device *dev, yaffs_ChunkCache *cache,
                                int isAWrite)
 {
 
@@ -4143,7 +4099,7 @@ static void yaffs_UseChunkCache(yaffs_Device * dev, yaffs_ChunkCache * cache,
  * Do this when a whole page gets written,
  * ie the short cache for this page is no longer valid.
  */
-static void yaffs_InvalidateChunkCache(yaffs_Object * object, int chunkId)
+static void yaffs_InvalidateChunkCache(yaffs_Object *object, int chunkId)
 {
        if (object->myDev->nShortOpCaches > 0) {
                yaffs_ChunkCache *cache = yaffs_FindChunkCache(object, chunkId);
@@ -4157,7 +4113,7 @@ static void yaffs_InvalidateChunkCache(yaffs_Object * object, int chunkId)
 /* Invalidate all the cache pages associated with this object
  * Do this whenever ther file is deleted or resized.
  */
-static void yaffs_InvalidateWholeChunkCache(yaffs_Object * in)
+static void yaffs_InvalidateWholeChunkCache(yaffs_Object *in)
 {
        int i;
        yaffs_Device *dev = in->myDev;
@@ -4175,18 +4131,18 @@ static void yaffs_InvalidateWholeChunkCache(yaffs_Object * in)
 /*--------------------- Checkpointing --------------------*/
 
 
-static int yaffs_WriteCheckpointValidityMarker(yaffs_Device *dev,int head)
+static int yaffs_WriteCheckpointValidityMarker(yaffs_Device *dev, int head)
 {
        yaffs_CheckpointValidity cp;
-       
-       memset(&cp,0,sizeof(cp));
-       
+
+       memset(&cp, 0, sizeof(cp));
+
        cp.structType = sizeof(cp);
        cp.magic = YAFFS_MAGIC;
        cp.version = YAFFS_CHECKPOINT_VERSION;
        cp.head = (head) ? 1 : 0;
-       
-       return (yaffs_CheckpointWrite(dev,&cp,sizeof(cp)) == sizeof(cp))?
+
+       return (yaffs_CheckpointWrite(dev, &cp, sizeof(cp)) == sizeof(cp)) ?
                1 : 0;
 }
 
@@ -4194,10 +4150,10 @@ static int yaffs_ReadCheckpointValidityMarker(yaffs_Device *dev, int head)
 {
        yaffs_CheckpointValidity cp;
        int ok;
-       
-       ok = (yaffs_CheckpointRead(dev,&cp,sizeof(cp)) == sizeof(cp));
-       
-       if(ok)
+
+       ok = (yaffs_CheckpointRead(dev, &cp, sizeof(cp)) == sizeof(cp));
+
+       if (ok)
                ok = (cp.structType == sizeof(cp)) &&
                     (cp.magic == YAFFS_MAGIC) &&
                     (cp.version == YAFFS_CHECKPOINT_VERSION) &&
@@ -4205,20 +4161,20 @@ static int yaffs_ReadCheckpointValidityMarker(yaffs_Device *dev, int head)
        return ok ? 1 : 0;
 }
 
-static void yaffs_DeviceToCheckpointDevice(yaffs_CheckpointDevice *cp, 
+static void yaffs_DeviceToCheckpointDevice(yaffs_CheckpointDevice *cp,
                                           yaffs_Device *dev)
 {
        cp->nErasedBlocks = dev->nErasedBlocks;
        cp->allocationBlock = dev->allocationBlock;
        cp->allocationPage = dev->allocationPage;
        cp->nFreeChunks = dev->nFreeChunks;
-       
+
        cp->nDeletedFiles = dev->nDeletedFiles;
        cp->nUnlinkedFiles = dev->nUnlinkedFiles;
        cp->nBackgroundDeletions = dev->nBackgroundDeletions;
        cp->sequenceNumber = dev->sequenceNumber;
        cp->oldestDirtySequence = dev->oldestDirtySequence;
-       
+
 }
 
 static void yaffs_CheckpointDeviceToDevice(yaffs_Device *dev,
@@ -4228,7 +4184,7 @@ static void yaffs_CheckpointDeviceToDevice(yaffs_Device *dev,
        dev->allocationBlock = cp->allocationBlock;
        dev->allocationPage = cp->allocationPage;
        dev->nFreeChunks = cp->nFreeChunks;
-       
+
        dev->nDeletedFiles = cp->nDeletedFiles;
        dev->nUnlinkedFiles = cp->nUnlinkedFiles;
        dev->nBackgroundDeletions = cp->nBackgroundDeletions;
@@ -4244,23 +4200,23 @@ static int yaffs_WriteCheckpointDevice(yaffs_Device *dev)
        __u32 nBlocks = (dev->internalEndBlock - dev->internalStartBlock + 1);
 
        int ok;
-               
+
        /* Write device runtime values*/
-       yaffs_DeviceToCheckpointDevice(&cp,dev);
+       yaffs_DeviceToCheckpointDevice(&cp, dev);
        cp.structType = sizeof(cp);
-       
-       ok = (yaffs_CheckpointWrite(dev,&cp,sizeof(cp)) == sizeof(cp));
-       
+
+       ok = (yaffs_CheckpointWrite(dev, &cp, sizeof(cp)) == sizeof(cp));
+
        /* Write block info */
-       if(ok) {
+       if (ok) {
                nBytes = nBlocks * sizeof(yaffs_BlockInfo);
-               ok = (yaffs_CheckpointWrite(dev,dev->blockInfo,nBytes) == nBytes);
+               ok = (yaffs_CheckpointWrite(dev, dev->blockInfo, nBytes) == nBytes);
        }
-               
-       /* Write chunk bits */          
-       if(ok) {
+
+       /* Write chunk bits */
+       if (ok) {
                nBytes = nBlocks * dev->chunkBitmapStride;
-               ok = (yaffs_CheckpointWrite(dev,dev->chunkBits,nBytes) == nBytes);
+               ok = (yaffs_CheckpointWrite(dev, dev->chunkBits, nBytes) == nBytes);
        }
        return   ok ? 1 : 0;
 
@@ -4272,28 +4228,28 @@ static int yaffs_ReadCheckpointDevice(yaffs_Device *dev)
        __u32 nBytes;
        __u32 nBlocks = (dev->internalEndBlock - dev->internalStartBlock + 1);
 
-       int ok; 
-       
-       ok = (yaffs_CheckpointRead(dev,&cp,sizeof(cp)) == sizeof(cp));
-       if(!ok)
+       int ok;
+
+       ok = (yaffs_CheckpointRead(dev, &cp, sizeof(cp)) == sizeof(cp));
+       if (!ok)
                return 0;
-               
-       if(cp.structType != sizeof(cp))
+
+       if (cp.structType != sizeof(cp))
                return 0;
-               
-       
-       yaffs_CheckpointDeviceToDevice(dev,&cp);
-       
+
+
+       yaffs_CheckpointDeviceToDevice(dev, &cp);
+
        nBytes = nBlocks * sizeof(yaffs_BlockInfo);
-       
-       ok = (yaffs_CheckpointRead(dev,dev->blockInfo,nBytes) == nBytes);
-       
-       if(!ok)
+
+       ok = (yaffs_CheckpointRead(dev, dev->blockInfo, nBytes) == nBytes);
+
+       if (!ok)
                return 0;
        nBytes = nBlocks * dev->chunkBitmapStride;
-       
-       ok = (yaffs_CheckpointRead(dev,dev->chunkBits,nBytes) == nBytes);
-       
+
+       ok = (yaffs_CheckpointRead(dev, dev->chunkBits, nBytes) == nBytes);
+
        return ok ? 1 : 0;
 }
 
@@ -4313,42 +4269,43 @@ static void yaffs_ObjectToCheckpointObject(yaffs_CheckpointObject *cp,
        cp->unlinkAllowed = obj->unlinkAllowed;
        cp->serial = obj->serial;
        cp->nDataChunks = obj->nDataChunks;
-       
-       if(obj->variantType == YAFFS_OBJECT_TYPE_FILE)
+
+       if (obj->variantType == YAFFS_OBJECT_TYPE_FILE)
                cp->fileSizeOrEquivalentObjectId = obj->variant.fileVariant.fileSize;
-       else if(obj->variantType == YAFFS_OBJECT_TYPE_HARDLINK)
+       else if (obj->variantType == YAFFS_OBJECT_TYPE_HARDLINK)
                cp->fileSizeOrEquivalentObjectId = obj->variant.hardLinkVariant.equivalentObjectId;
 }
 
-static int yaffs_CheckpointObjectToObject( yaffs_Object *obj,yaffs_CheckpointObject *cp)
+static int yaffs_CheckpointObjectToObject(yaffs_Object *obj, yaffs_CheckpointObject *cp)
 {
 
        yaffs_Object *parent;
 
        if (obj->variantType != cp->variantType) {
-               T(YAFFS_TRACE_ERROR,(TSTR("Checkpoint read object %d type %d "
+               T(YAFFS_TRACE_ERROR, (TSTR("Checkpoint read object %d type %d "
                        TCONT("chunk %d does not match existing object type %d")
                        TENDSTR), cp->objectId, cp->variantType, cp->hdrChunk,
                        obj->variantType));
                return 0;
        }
-       
+
        obj->objectId = cp->objectId;
-       
-       if(cp->parentId)
+
+       if (cp->parentId)
                parent = yaffs_FindOrCreateObjectByNumber(
                                        obj->myDev,
                                        cp->parentId,
                                        YAFFS_OBJECT_TYPE_DIRECTORY);
        else
                parent = NULL;
-               
-       if(parent) {
+
+       if (parent) {
                if (parent->variantType != YAFFS_OBJECT_TYPE_DIRECTORY) {
-                       T(YAFFS_TRACE_ALWAYS,(TSTR("Checkpoint read object %d parent %d type %d"
+                       T(YAFFS_TRACE_ALWAYS, (TSTR("Checkpoint read object %d parent %d type %d"
                                TCONT(" chunk %d Parent type, %d, not directory")
                                TENDSTR),
-                               cp->objectId,cp->parentId,cp->variantType,cp->hdrChunk,parent->variantType));
+                               cp->objectId, cp->parentId, cp->variantType,
+                               cp->hdrChunk, parent->variantType));
                        return 0;
                }
                yaffs_AddObjectToDirectory(parent, obj);
@@ -4364,35 +4321,35 @@ static int yaffs_CheckpointObjectToObject( yaffs_Object *obj,yaffs_CheckpointObj
        obj->unlinkAllowed = cp->unlinkAllowed;
        obj->serial = cp->serial;
        obj->nDataChunks = cp->nDataChunks;
-       
-       if(obj->variantType == YAFFS_OBJECT_TYPE_FILE)
+
+       if (obj->variantType == YAFFS_OBJECT_TYPE_FILE)
                obj->variant.fileVariant.fileSize = cp->fileSizeOrEquivalentObjectId;
-       else if(obj->variantType == YAFFS_OBJECT_TYPE_HARDLINK)
+       else if (obj->variantType == YAFFS_OBJECT_TYPE_HARDLINK)
                obj->variant.hardLinkVariant.equivalentObjectId = cp->fileSizeOrEquivalentObjectId;
 
-       if(obj->hdrChunk > 0)
+       if (obj->hdrChunk > 0)
                obj->lazyLoaded = 1;
        return 1;
 }
 
 
 
-static int yaffs_CheckpointTnodeWorker(yaffs_Object * in, yaffs_Tnode * tn,
-                                       __u32 level, int chunkOffset)
+static int yaffs_CheckpointTnodeWorker(yaffs_Object *in, yaffs_Tnode *tn,
+                                       __u32 level, int chunkOffset)
 {
        int i;
        yaffs_Device *dev = in->myDev;
        int ok = 1;
        int tnodeSize = (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8;
 
-       if(tnodeSize < sizeof(yaffs_Tnode))
+       if (tnodeSize < sizeof(yaffs_Tnode))
                tnodeSize = sizeof(yaffs_Tnode);
-       
+
 
        if (tn) {
                if (level > 0) {
 
-                       for (i = 0; i < YAFFS_NTNODES_INTERNAL && ok; i++){
+                       for (i = 0; i < YAFFS_NTNODES_INTERNAL && ok; i++) {
                                if (tn->internal[i]) {
                                        ok = yaffs_CheckpointTnodeWorker(in,
                                                        tn->internal[i],
@@ -4402,9 +4359,9 @@ static int yaffs_CheckpointTnodeWorker(yaffs_Object * in, yaffs_Tnode * tn,
                        }
                } else if (level == 0) {
                        __u32 baseOffset = chunkOffset <<  YAFFS_TNODES_LEVEL0_BITS;
-                       ok = (yaffs_CheckpointWrite(dev,&baseOffset,sizeof(baseOffset)) == sizeof(baseOffset));
-                       if(ok)
-                               ok = (yaffs_CheckpointWrite(dev,tn,tnodeSize) == tnodeSize);
+                       ok = (yaffs_CheckpointWrite(dev, &baseOffset, sizeof(baseOffset)) == sizeof(baseOffset));
+                       if (ok)
+                               ok = (yaffs_CheckpointWrite(dev, tn, tnodeSize) == tnodeSize);
                }
        }
 
@@ -4416,17 +4373,17 @@ static int yaffs_WriteCheckpointTnodes(yaffs_Object *obj)
 {
        __u32 endMarker = ~0;
        int ok = 1;
-       
-       if(obj->variantType == YAFFS_OBJECT_TYPE_FILE){
+
+       if (obj->variantType == YAFFS_OBJECT_TYPE_FILE) {
                ok = yaffs_CheckpointTnodeWorker(obj,
                                            obj->variant.fileVariant.top,
                                            obj->variant.fileVariant.topLevel,
                                            0);
-               if(ok)
-                       ok = (yaffs_CheckpointWrite(obj->myDev,&endMarker,sizeof(endMarker)) == 
+               if (ok)
+                       ok = (yaffs_CheckpointWrite(obj->myDev, &endMarker, sizeof(endMarker)) ==
                                sizeof(endMarker));
        }
-       
+
        return ok ? 1 : 0;
 }
 
@@ -4440,85 +4397,83 @@ static int yaffs_ReadCheckpointTnodes(yaffs_Object *obj)
        int nread = 0;
        int tnodeSize = (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8;
 
-       if(tnodeSize < sizeof(yaffs_Tnode))
+       if (tnodeSize < sizeof(yaffs_Tnode))
                tnodeSize = sizeof(yaffs_Tnode);
 
-       ok = (yaffs_CheckpointRead(dev,&baseChunk,sizeof(baseChunk)) == sizeof(baseChunk));
-       
-       while(ok && (~baseChunk)){
+       ok = (yaffs_CheckpointRead(dev, &baseChunk, sizeof(baseChunk)) == sizeof(baseChunk));
+
+       while (ok && (~baseChunk)) {
                nread++;
                /* Read level 0 tnode */
-               
-               
+
+
                tn = yaffs_GetTnodeRaw(dev);
-               if(tn)
-                       ok = (yaffs_CheckpointRead(dev,tn,tnodeSize) == tnodeSize);
+               if (tn)
+                       ok = (yaffs_CheckpointRead(dev, tn, tnodeSize) == tnodeSize);
                else
                        ok = 0;
-                       
-               if(tn && ok){
+
+               if (tn && ok)
                        ok = yaffs_AddOrFindLevel0Tnode(dev,
-                                                       fileStructPtr,
-                                                       baseChunk,
-                                                       tn) ? 1 : 0;
-                                                       
-               }
-                       
-               if(ok)
-                       ok = (yaffs_CheckpointRead(dev,&baseChunk,sizeof(baseChunk)) == sizeof(baseChunk));
-               
+                                                       fileStructPtr,
+                                                       baseChunk,
+                                                       tn) ? 1 : 0;
+
+       &nbs