lindent
authormarty <marty>
Thu, 11 Aug 2005 02:33:02 +0000 (02:33 +0000)
committermarty <marty>
Thu, 11 Aug 2005 02:33:02 +0000 (02:33 +0000)
12 files changed:
devextras.h
yaffs_nandemul2k.h
yaffs_packedtags1.c
yaffs_packedtags1.h
yaffs_packedtags2.c
yaffs_packedtags2.h
yaffs_tagscompat.c
yaffs_tagscompat.h
yaffs_tagsvalidity.c
yaffs_tagsvalidity.h
yaffsinterface.h
yportenv.h

index 185e6ad..c858ba6 100644 (file)
  * Most of these are from kernel includes placed here so we can use them in 
  * applications.
  *
- * $Id: devextras.h,v 1.1 2004-11-03 08:14:07 charles Exp $
+ * $Id: devextras.h,v 1.2 2005-08-11 02:37:49 marty Exp $
  *
  */
+
 #ifndef __EXTRAS_H__
 #define __EXTRAS_H__
 
 
 #if !(defined __KERNEL__) || (defined WIN32)
 
-// User space defines
-
-typedef unsigned char   __u8;
-typedef unsigned short  __u16;
-typedef unsigned        __u32;
+/* User space defines */
 
+typedef unsigned char __u8;
+typedef unsigned short __u16;
+typedef unsigned __u32;
 
 /*
  * Simple doubly linked list implementation.
@@ -47,9 +46,8 @@ typedef unsigned        __u32;
  * generate better code by using them directly rather than
  * using the generic single-entry routines.
  */
- #define prefetch(x) 1
+
+#define prefetch(x) 1
 
 struct list_head {
        struct list_head *next, *prev;
@@ -70,9 +68,9 @@ struct list_head {
  * This is only for internal list manipulation where we know
  * the prev/next entries already!
  */
-static __inline__ void __list_add(struct list_head * new,
-       struct list_head * prev,
-       struct list_head * next)
+static __inline__ void __list_add(struct list_head *new,
+                                 struct list_head *prev,
+                                 struct list_head *next)
 {
        next->prev = new;
        new->next = next;
@@ -101,7 +99,8 @@ static __inline__ void list_add(struct list_head *new, struct list_head *head)
  * Insert a new entry before the specified head.
  * This is useful for implementing queues.
  */
-static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
+static __inline__ void list_add_tail(struct list_head *new,
+                                    struct list_head *head)
 {
        __list_add(new, head->prev, head);
 }
@@ -113,8 +112,8 @@ static __inline__ void list_add_tail(struct list_head *new, struct list_head *he
  * This is only for internal list manipulation where we know
  * the prev/next entries already!
  */
-static __inline__ void __list_del(struct list_head * prev,
-                                 struct list_head * next)
+static __inline__ void __list_del(struct list_head *prev,
+                                 struct list_head *next)
 {
        next->prev = prev;
        prev->next = next;
@@ -123,7 +122,8 @@ static __inline__ void __list_del(struct list_head * prev,
 /**
  * list_del - deletes entry from list.
  * @entry: the element to delete from the list.
- * Note: list_empty on entry does not return true after this, the entry is in an undefined state.
+ * Note: list_empty on entry does not return true after this, the entry is
+ * in an undefined state.
  */
 static __inline__ void list_del(struct list_head *entry)
 {
@@ -154,7 +154,8 @@ static __inline__ int list_empty(struct list_head *head)
  * @list: the new list to add.
  * @head: the place to add it in the first list.
  */
-static __inline__ void list_splice(struct list_head *list, struct list_head *head)
+static __inline__ void list_splice(struct list_head *list,
+                                  struct list_head *head)
 {
        struct list_head *first = list->next;
 
@@ -189,7 +190,8 @@ static __inline__ void list_splice(struct list_head *list, struct list_head *hea
                pos = pos->next, prefetch(pos->next))
 
 /**
- * list_for_each_safe  -       iterate over a list safe against removal of list entry
+ * list_for_each_safe  -       iterate over a list safe against removal
+ *                              of list entry
  * @pos:       the &struct list_head to use as a loop counter.
  * @n:         another &struct list_head to use as temporary storage
  * @head:      the head for your list.
@@ -198,9 +200,6 @@ static __inline__ void list_splice(struct list_head *list, struct list_head *hea
        for (pos = (head)->next, n = pos->next; pos != (head); \
                pos = n, n = pos->next)
 
-
-
-
 /*
  * File types
  */
@@ -234,22 +233,20 @@ static __inline__ void list_splice(struct list_head *list, struct list_head *hea
 #define ATTR_FORCE     512     /* Not a change, but a change it */
 #define ATTR_ATTR_FLAG 1024
 
-
 struct iattr {
-       unsigned int    ia_valid;
-       unsigned                ia_mode;
-       unsigned                ia_uid;
-       unsigned                ia_gid;
-       unsigned                ia_size;
-       unsigned                ia_atime;
-       unsigned        ia_mtime;
-       unsigned        ia_ctime;
-       unsigned int    ia_attr_flags;
+       unsigned int ia_valid;
+       unsigned ia_mode;
+       unsigned ia_uid;
+       unsigned ia_gid;
+       unsigned ia_size;
+       unsigned ia_atime;
+       unsigned ia_mtime;
+       unsigned ia_ctime;
+       unsigned int ia_attr_flags;
 };
 
 #define KERN_DEBUG
 
-
 #else
 
 #ifndef WIN32
@@ -261,11 +258,8 @@ struct iattr {
 
 #endif
 
-
-
 #if defined WIN32
 #undef new
-#endif 
-
 #endif
 
+#endif
index 9778b86..483f140 100644 (file)
  *
  * yaffs_nandemul2k.h: Interface to emulated NAND functions (2k page size)
  *
- * $Id: yaffs_nandemul2k.h,v 1.1 2004-12-17 04:39:04 charles Exp $
+ * $Id: yaffs_nandemul2k.h,v 1.2 2005-08-11 02:37:49 marty Exp $
  */
+
 #ifndef __YAFFS_NANDEMUL2K_H__
 #define __YAFFS_NANDEMUL2K_H__
 
-#include "yaffs_guts.h" 
-int nandemul2k_WriteChunkWithTagsToNAND(struct yaffs_DeviceStruct *dev,int chunkInNAND, const __u8 *data, yaffs_ExtendedTags *tags);
-int nandemul2k_ReadChunkWithTagsFromNAND(struct yaffs_DeviceStruct *dev,int chunkInNAND, __u8 *data, yaffs_ExtendedTags *tags);
+#include "yaffs_guts.h"
+
+int nandemul2k_WriteChunkWithTagsToNAND(struct yaffs_DeviceStruct *dev,
+                                       int chunkInNAND, const __u8 * data,
+                                       yaffs_ExtendedTags * tags);
+int nandemul2k_ReadChunkWithTagsFromNAND(struct yaffs_DeviceStruct *dev,
+                                        int chunkInNAND, __u8 * data,
+                                        yaffs_ExtendedTags * tags);
 int nandemul2k_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo);
-int nandemul2k_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo, yaffs_BlockState *state, int *sequenceNumber);
-int nandemul2k_EraseBlockInNAND(struct yaffs_DeviceStruct *dev,int blockInNAND);
+int nandemul2k_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo,
+                             yaffs_BlockState * state, int *sequenceNumber);
+int nandemul2k_EraseBlockInNAND(struct yaffs_DeviceStruct *dev,
+                               int blockInNAND);
 int nandemul2k_InitialiseNAND(struct yaffs_DeviceStruct *dev);
 int nandemul2k_GetBytesPerChunk(void);
 int nandemul2k_GetChunksPerBlock(void);
 int nandemul2k_GetNumberOfBlocks(void);
 
 #endif
-
index bab338f..920fed2 100644 (file)
@@ -1,7 +1,7 @@
 #include "yaffs_packedtags1.h"
 #include "yportenv.h"
 
-void yaffs_PackTags1(yaffs_PackedTags1 *pt, const yaffs_ExtendedTags *t)
+void yaffs_PackTags1(yaffs_PackedTags1 * pt, const yaffs_ExtendedTags * t)
 {
        pt->chunkId = t->chunkId;
        pt->serialNumber = t->serialNumber;
@@ -11,32 +11,29 @@ void yaffs_PackTags1(yaffs_PackedTags1 *pt, const yaffs_ExtendedTags *t)
        pt->deleted = (t->chunkDeleted) ? 0 : 1;
        pt->unusedStuff = 0;
        pt->shouldBeFF = 0xFFFFFFFF;
-       
+
 }
 
-void yaffs_UnpackTags1(yaffs_ExtendedTags *t, const yaffs_PackedTags1 *pt)
+void yaffs_UnpackTags1(yaffs_ExtendedTags * t, const yaffs_PackedTags1 * pt)
 {
-       static const __u8 allFF[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff, 0xff, 0xff};
-       
-       if(memcmp(allFF,pt,sizeof(yaffs_PackedTags1)))
-       {
+       static const __u8 allFF[] =
+           { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff };
+
+       if (memcmp(allFF, pt, sizeof(yaffs_PackedTags1))) {
                t->blockBad = 0;
-               if(pt->shouldBeFF != 0xFFFFFFFF)
-               {
+               if (pt->shouldBeFF != 0xFFFFFFFF) {
                        t->blockBad = 1;
                }
                t->chunkUsed = 1;
                t->objectId = pt->objectId;
                t->chunkId = pt->chunkId;
                t->byteCount = pt->byteCount;
-               t->eccResult =  YAFFS_ECC_RESULT_NO_ERROR;
+               t->eccResult = YAFFS_ECC_RESULT_NO_ERROR;
                t->chunkDeleted = (pt->deleted) ? 0 : 1;
                t->serialNumber = pt->serialNumber;
-       }
-       else
-       {
-               memset(t,0,sizeof(yaffs_ExtendedTags));
-               
+       } else {
+               memset(t, 0, sizeof(yaffs_ExtendedTags));
+
        }
 }
-
index 0f76615..ea43ad6 100644 (file)
@@ -3,26 +3,20 @@
 #ifndef __YAFFS_PACKEDTAGS1_H__
 #define __YAFFS_PACKEDTAGS1_H__
 
-
 #include "yaffs_guts.h"
 
-typedef struct
-{   
-    unsigned chunkId:20;
-    unsigned serialNumber:2;
-    unsigned byteCount:10;
-    unsigned objectId:18;
-    unsigned ecc:12;
-    unsigned deleted:1;
-    unsigned unusedStuff:1;
-    unsigned shouldBeFF;
+typedef struct {
+       unsigned chunkId:20;
+       unsigned serialNumber:2;
+       unsigned byteCount:10;
+       unsigned objectId:18;
+       unsigned ecc:12;
+       unsigned deleted:1;
+       unsigned unusedStuff:1;
+       unsigned shouldBeFF;
 
 } yaffs_PackedTags1;
 
-
-
-void yaffs_PackTags1(yaffs_PackedTags1 *pt, const yaffs_ExtendedTags *t);
-void yaffs_UnpackTags1(yaffs_ExtendedTags *t, const yaffs_PackedTags1 *pt);
+void yaffs_PackTags1(yaffs_PackedTags1 * pt, const yaffs_ExtendedTags * t);
+void yaffs_UnpackTags1(yaffs_ExtendedTags * t, const yaffs_PackedTags1 * pt);
 #endif
-
-
index f4de18d..5cc68af 100644 (file)
  * modify it under the terms of the GNU Lesser General Public License
  * version 2.1 as published by the Free Software Foundation.
  */
+
 #include "yaffs_packedtags2.h"
 #include "yportenv.h"
 #include "yaffs_tagsvalidity.h"
 
+/* This code packs a set of extended tags into a binary structure for
+ * NAND storage
+ */
 
+/* Some of the information is "extra" struff which can be packed in to
+ * speed scanning
+ * This is defined by having the EXTRA_HEADER_INFO_FLAG set.
+ */
 
-// This code packs a set of extended tags into a binary structure for NAND storage
-
-// Some of the information is "extra" struff which can be packed in to speed scanning
-// This is defined by having the EXTRA_HEADER_INFO_FLAG set.
-
-
-// Extra flags applied to chunkId
+/* Extra flags applied to chunkId */
 
 #define EXTRA_HEADER_INFO_FLAG 0x80000000
 #define EXTRA_SHRINK_FLAG      0x40000000
 
 #define ALL_EXTRA_FLAGS                0xF0000000
 
-
-
-// Also, the top 4 bits of the object Id are set to the object type.
+/* Also, the top 4 bits of the object Id are set to the object type. */
 #define EXTRA_OBJECT_TYPE_SHIFT (28)
 #define EXTRA_OBJECT_TYPE_MASK  ((0x0F) << EXTRA_OBJECT_TYPE_SHIFT)
 
-
-
-static void yaffs_DumpPackedTags2(const yaffs_PackedTags2 *pt)
+static void yaffs_DumpPackedTags2(const yaffs_PackedTags2 * pt)
 {
-       T(YAFFS_TRACE_MTD,(TSTR("packed tags obj %d chunk %d byte %d seq %d"TENDSTR),pt->t.objectId,pt->t.chunkId,pt->t.byteCount,pt->t.sequenceNumber));
+       T(YAFFS_TRACE_MTD,
+         (TSTR("packed tags obj %d chunk %d byte %d seq %d" TENDSTR),
+          pt->t.objectId, pt->t.chunkId, pt->t.byteCount,
+          pt->t.sequenceNumber));
 }
 
-static void yaffs_DumpTags2(const yaffs_ExtendedTags *t)
+static void yaffs_DumpTags2(const yaffs_ExtendedTags * t)
 {
-       T(YAFFS_TRACE_MTD,(TSTR("ext.tags eccres %d blkbad %d chused %d obj %d chunk%d byte %d del %d ser %d seq %d"TENDSTR),
-            t->eccResult, t->blockBad, t->chunkUsed, t->objectId, t->chunkId, t->byteCount, t->chunkDeleted, t->serialNumber, t->sequenceNumber));
-         
+       T(YAFFS_TRACE_MTD,
+         (TSTR
+          ("ext.tags eccres %d blkbad %d chused %d obj %d chunk%d byte "
+           "%d del %d ser %d seq %d"
+           TENDSTR), t->eccResult, t->blockBad, t->chunkUsed, t->objectId,
+          t->chunkId, t->byteCount, t->chunkDeleted, t->serialNumber,
+          t->sequenceNumber));
+
 }
 
-void yaffs_PackTags2(yaffs_PackedTags2 *pt, const yaffs_ExtendedTags *t)
+void yaffs_PackTags2(yaffs_PackedTags2 * pt, const yaffs_ExtendedTags * t)
 {
        pt->t.chunkId = t->chunkId;
        pt->t.sequenceNumber = t->sequenceNumber;
        pt->t.byteCount = t->byteCount;
        pt->t.objectId = t->objectId;
-       
-       if(t->chunkId == 0 && t->extraHeaderInfoAvailable)
-       {
-               // Store the extra header info instead
-               pt->t.chunkId = EXTRA_HEADER_INFO_FLAG | t->extraParentObjectId; // We save the parent object in the chunkId
-               if(t->extraIsShrinkHeader) 
-               {
-                   pt->t.chunkId |= EXTRA_SHRINK_FLAG;
+
+       if (t->chunkId == 0 && t->extraHeaderInfoAvailable) {
+               /* Store the extra header info instead */
+               /* We save the parent object in the chunkId */
+               pt->t.chunkId = EXTRA_HEADER_INFO_FLAG
+                       | t->extraParentObjectId;
+               if (t->extraIsShrinkHeader) {
+                       pt->t.chunkId |= EXTRA_SHRINK_FLAG;
                }
-               if(t->extraShadows) 
-               {
-                   pt->t.chunkId |= EXTRA_SHADOWS_FLAG;
+               if (t->extraShadows) {
+                       pt->t.chunkId |= EXTRA_SHADOWS_FLAG;
                }
-               
+
                pt->t.objectId &= ~EXTRA_OBJECT_TYPE_MASK;
-               pt->t.objectId |= (t->extraObjectType << EXTRA_OBJECT_TYPE_SHIFT);
-                
-               if(t->extraObjectType == YAFFS_OBJECT_TYPE_HARDLINK)
-               {
-                  pt->t.byteCount = t->extraEquivalentObjectId;
-               }
-               else if(t->extraObjectType == YAFFS_OBJECT_TYPE_FILE)
-               {
-                  pt->t.byteCount = t->extraFileLength;
-               }
-               else
-               {
-                  pt->t.byteCount = 0;
+               pt->t.objectId |=
+                   (t->extraObjectType << EXTRA_OBJECT_TYPE_SHIFT);
+
+               if (t->extraObjectType == YAFFS_OBJECT_TYPE_HARDLINK) {
+                       pt->t.byteCount = t->extraEquivalentObjectId;
+               } else if (t->extraObjectType == YAFFS_OBJECT_TYPE_FILE) {
+                       pt->t.byteCount = t->extraFileLength;
+               } else {
+                       pt->t.byteCount = 0;
                }
        }
-       
+
        yaffs_DumpPackedTags2(pt);
        yaffs_DumpTags2(t);
-       
+
 #ifndef YAFFS_IGNORE_TAGS_ECC
-       { 
-         yaffs_ECCCalculateOther((unsigned char *)&pt->t,sizeof(yaffs_PackedTags2TagsPart),&pt->ecc);
+       {
+               yaffs_ECCCalculateOther((unsigned char *)&pt->t,
+                                       sizeof(yaffs_PackedTags2TagsPart),
+                                       &pt->ecc);
        }
 #endif
 }
 
-void yaffs_UnpackTags2(yaffs_ExtendedTags *t, yaffs_PackedTags2 *pt)
+void yaffs_UnpackTags2(yaffs_ExtendedTags * t, yaffs_PackedTags2 * pt)
 {
 
-       
-       memset(t,0,sizeof(yaffs_ExtendedTags));
-       
+       memset(t, 0, sizeof(yaffs_ExtendedTags));
+
        yaffs_InitialiseTags(t);
-       
-       if(pt->t.sequenceNumber != 0xFFFFFFFF)
-       {
-               // Page is in use
+
+       if (pt->t.sequenceNumber != 0xFFFFFFFF) {
+               /* Page is in use */
 #ifdef YAFFS_IGNORE_TAGS_ECC
                {
                        t->eccResult = 0;
@@ -119,40 +119,47 @@ void yaffs_UnpackTags2(yaffs_ExtendedTags *t, yaffs_PackedTags2 *pt)
 #else
                {
                        yaffs_ECCOther ecc;
-                       yaffs_ECCCalculateOther((unsigned char *)&pt->t,sizeof(yaffs_PackedTags2TagsPart),&ecc);
-                       t->eccResult = yaffs_ECCCorrectOther((unsigned char *)&pt->t,sizeof(yaffs_PackedTags2TagsPart),&pt->ecc,&ecc);
+                       yaffs_ECCCalculateOther((unsigned char *)&pt->t,
+                                               sizeof
+                                               (yaffs_PackedTags2TagsPart),
+                                               &ecc);
+                       t->eccResult =
+                           yaffs_ECCCorrectOther((unsigned char *)&pt->t,
+                                                 sizeof
+                                                 (yaffs_PackedTags2TagsPart),
+                                                 &pt->ecc, &ecc);
                }
 #endif
                t->blockBad = 0;
                t->chunkUsed = 1;
                t->objectId = pt->t.objectId;
-               t->chunkId =  pt->t.chunkId;
+               t->chunkId = pt->t.chunkId;
                t->byteCount = pt->t.byteCount;
                t->chunkDeleted = 0;
                t->serialNumber = 0;
                t->sequenceNumber = pt->t.sequenceNumber;
-               
-               // Do extra header info stuff
-               
-               if(pt->t.chunkId & EXTRA_HEADER_INFO_FLAG)
-               {
+
+               /* Do extra header info stuff */
+
+               if (pt->t.chunkId & EXTRA_HEADER_INFO_FLAG) {
                        t->chunkId = 0;
                        t->byteCount = 0;
-                       
+
                        t->extraHeaderInfoAvailable = 1;
-                       t->extraParentObjectId = pt->t.chunkId & (~(ALL_EXTRA_FLAGS));
-                       t->extraIsShrinkHeader =  (pt->t.chunkId & EXTRA_SHRINK_FLAG) ? 1 : 0;
-                       t->extraShadows =  (pt->t.chunkId & EXTRA_SHADOWS_FLAG) ? 1 : 0;
-                       t->extraObjectType = pt->t.objectId >> EXTRA_OBJECT_TYPE_SHIFT;
+                       t->extraParentObjectId =
+                           pt->t.chunkId & (~(ALL_EXTRA_FLAGS));
+                       t->extraIsShrinkHeader =
+                           (pt->t.chunkId & EXTRA_SHRINK_FLAG) ? 1 : 0;
+                       t->extraShadows =
+                           (pt->t.chunkId & EXTRA_SHADOWS_FLAG) ? 1 : 0;
+                       t->extraObjectType =
+                           pt->t.objectId >> EXTRA_OBJECT_TYPE_SHIFT;
                        t->objectId &= ~EXTRA_OBJECT_TYPE_MASK;
-                       
-                       if(t->extraObjectType == YAFFS_OBJECT_TYPE_HARDLINK)
-                       {
-                           t->extraEquivalentObjectId = pt->t.byteCount;
-                       }
-                       else 
-                       {
-                           t->extraFileLength = pt->t.byteCount;
+
+                       if (t->extraObjectType == YAFFS_OBJECT_TYPE_HARDLINK) {
+                               t->extraEquivalentObjectId = pt->t.byteCount;
+                       } else {
+                               t->extraFileLength = pt->t.byteCount;
                        }
                }
        }
@@ -161,4 +168,3 @@ void yaffs_UnpackTags2(yaffs_ExtendedTags *t, yaffs_PackedTags2 *pt)
        yaffs_DumpTags2(t);
 
 }
-
index 564dd58..4eb1416 100644 (file)
@@ -1,30 +1,23 @@
-// This is used to pack YAFFS2 tags, not YAFFS1tags.
+/* This is used to pack YAFFS2 tags, not YAFFS1tags. */
 
 #ifndef __YAFFS_PACKEDTAGS2_H__
 #define __YAFFS_PACKEDTAGS2_H__
 
-
 #include "yaffs_guts.h"
 #include "yaffs_ecc.h"
 
-
-typedef struct
-{   
-    unsigned sequenceNumber;
-    unsigned objectId;    
-    unsigned chunkId;
-    unsigned byteCount;    
+typedef struct {
+       unsigned sequenceNumber;
+       unsigned objectId;
+       unsigned chunkId;
+       unsigned byteCount;
 } yaffs_PackedTags2TagsPart;
 
-typedef struct
-{
-    yaffs_PackedTags2TagsPart t;
-    yaffs_ECCOther ecc;
+typedef struct {
+       yaffs_PackedTags2TagsPart t;
+       yaffs_ECCOther ecc;
 } yaffs_PackedTags2;
 
-
-void yaffs_PackTags2(yaffs_PackedTags2 *pt, const  yaffs_ExtendedTags *t);
-void yaffs_UnpackTags2(yaffs_ExtendedTags *t, yaffs_PackedTags2 *pt);
+void yaffs_PackTags2(yaffs_PackedTags2 * pt, const yaffs_ExtendedTags * t);
+void yaffs_UnpackTags2(yaffs_ExtendedTags * t, yaffs_PackedTags2 * pt);
 #endif
-
-
index ace4b28..61880d5 100644 (file)
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- * $Id: yaffs_tagscompat.c,v 1.5 2005-08-10 20:34:40 charles Exp $
+ * $Id: yaffs_tagscompat.c,v 1.6 2005-08-11 02:33:03 marty Exp $
  */
 
 #include "yaffs_guts.h"
 #include "yaffs_tagscompat.h"
 #include "yaffs_ecc.h"
 
-static void yaffs_HandleReadDataError(yaffs_Device *dev,int chunkInNAND);
+static void yaffs_HandleReadDataError(yaffs_Device * dev, int chunkInNAND);
 #ifdef NOTYET
-static void yaffs_CheckWrittenBlock(yaffs_Device *dev,int chunkInNAND);
-static void yaffs_HandleWriteChunkOk(yaffs_Device *dev,int chunkInNAND,const __u8 *data, const yaffs_Spare *spare);
-static void yaffs_HandleUpdateChunk(yaffs_Device *dev,int chunkInNAND, const yaffs_Spare *spare);
-static void yaffs_HandleWriteChunkError(yaffs_Device *dev,int chunkInNAND);
+static void yaffs_CheckWrittenBlock(yaffs_Device * dev, int chunkInNAND);
+static void yaffs_HandleWriteChunkOk(yaffs_Device * dev, int chunkInNAND,
+                                    const __u8 * data,
+                                    const yaffs_Spare * spare);
+static void yaffs_HandleUpdateChunk(yaffs_Device * dev, int chunkInNAND,
+                                   const yaffs_Spare * spare);
+static void yaffs_HandleWriteChunkError(yaffs_Device * dev, int chunkInNAND);
 #endif
 
-
-static const char yaffs_countBitsTable[256] =
-{
-0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,
-1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
-1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
-2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
-1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
-2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
-2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
-3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
-1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
-2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
-2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
-3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
-2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
-3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
-3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
-4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
+static const char yaffs_countBitsTable[256] = {
+       0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
+       1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+       1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+       2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+       1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+       2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+       2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+       3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+       1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+       2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+       2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+       3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+       2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+       3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+       3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+       4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
 };
 
 static int yaffs_CountBits(__u8 x)
@@ -53,33 +54,29 @@ static int yaffs_CountBits(__u8 x)
        return retVal;
 }
 
+/********** Tags ECC calculations  *********/
 
-/////////////// Tags ECC calculations ///////////////////
-
-void yaffs_CalcECC(const __u8 *data, yaffs_Spare *spare)
+void yaffs_CalcECC(const __u8 * data, yaffs_Spare * spare)
 {
-       yaffs_ECCCalculate(data , spare->ecc1);
-       yaffs_ECCCalculate(&data[256] , spare->ecc2);
+       yaffs_ECCCalculate(data, spare->ecc1);
+       yaffs_ECCCalculate(&data[256], spare->ecc2);
 }
 
-void yaffs_CalcTagsECC(yaffs_Tags *tags)
+void yaffs_CalcTagsECC(yaffs_Tags * tags)
 {
-       // Calculate an ecc
+       /* Calculate an ecc */
 
-       unsigned char *b = ((yaffs_TagsUnion *)tags)->asBytes;
-       unsigned  i,j;
-       unsigned  ecc = 0;
+       unsigned char *b = ((yaffs_TagsUnion *) tags)->asBytes;
+       unsigned i, j;
+       unsigned ecc = 0;
        unsigned bit = 0;
 
        tags->ecc = 0;
 
-       for(i = 0; i < 8; i++)
-       {
-               for(j = 1; j &0xff; j<<=1)
-               {
+       for (i = 0; i < 8; i++) {
+               for (j = 1; j & 0xff; j <<= 1) {
                        bit++;
-                       if(b[i] & j)
-                       {
+                       if (b[i] & j) {
                                ecc ^= bit;
                        }
                }
@@ -87,49 +84,46 @@ void yaffs_CalcTagsECC(yaffs_Tags *tags)
 
        tags->ecc = ecc;
 
-
 }
 
-int  yaffs_CheckECCOnTags(yaffs_Tags *tags)
+int yaffs_CheckECCOnTags(yaffs_Tags * tags)
 {
        unsigned ecc = tags->ecc;
 
        yaffs_CalcTagsECC(tags);
 
        ecc ^= tags->ecc;
-       
-       if(ecc && ecc <= 64)
-       {
-               // TODO: Handle the failure better. Retire?
-               unsigned char *b = ((yaffs_TagsUnion *)tags)->asBytes;
+
+       if (ecc && ecc <= 64) {
+               /* TODO: Handle the failure better. Retire? */
+               unsigned char *b = ((yaffs_TagsUnion *) tags)->asBytes;
 
                ecc--;
 
                b[ecc / 8] ^= (1 << (ecc & 7));
 
-               // Now recvalc the ecc
+               /* Now recvalc the ecc */
                yaffs_CalcTagsECC(tags);
 
-               return 1; // recovered error
-       }
-       else if(ecc)
-       {
-               // Wierd ecc failure value
-               // TODO Need to do somethiong here
-               return -1; //unrecovered error
+               return 1;       /* recovered error */
+       } else if (ecc) {
+               /* Wierd ecc failure value */
+               /* TODO Need to do somethiong here */
+               return -1;      /* unrecovered error */
        }
 
        return 0;
 }
 
-//////////////////////////// Tags ///////////////////////////////////////
+/********** Tags **********/
 
-static void yaffs_LoadTagsIntoSpare(yaffs_Spare *sparePtr, yaffs_Tags *tagsPtr)
+static void yaffs_LoadTagsIntoSpare(yaffs_Spare * sparePtr,
+                                   yaffs_Tags * tagsPtr)
 {
-       yaffs_TagsUnion *tu = (yaffs_TagsUnion *)tagsPtr;
+       yaffs_TagsUnion *tu = (yaffs_TagsUnion *) tagsPtr;
 
        yaffs_CalcTagsECC(tagsPtr);
-       
+
        sparePtr->tagByte0 = tu->asBytes[0];
        sparePtr->tagByte1 = tu->asBytes[1];
        sparePtr->tagByte2 = tu->asBytes[2];
@@ -140,398 +134,397 @@ static void yaffs_LoadTagsIntoSpare(yaffs_Spare *sparePtr, yaffs_Tags *tagsPtr)
        sparePtr->tagByte7 = tu->asBytes[7];
 }
 
-static void yaffs_GetTagsFromSpare(yaffs_Device *dev, yaffs_Spare *sparePtr,yaffs_Tags *tagsPtr)
+static void yaffs_GetTagsFromSpare(yaffs_Device * dev, yaffs_Spare * sparePtr,
+                                  yaffs_Tags * tagsPtr)
 {
-       yaffs_TagsUnion *tu = (yaffs_TagsUnion *)tagsPtr;
+       yaffs_TagsUnion *tu = (yaffs_TagsUnion *) tagsPtr;
        int result;
 
-       tu->asBytes[0]= sparePtr->tagByte0;
-       tu->asBytes[1]= sparePtr->tagByte1;
-       tu->asBytes[2]= sparePtr->tagByte2;
-       tu->asBytes[3]= sparePtr->tagByte3;
-       tu->asBytes[4]= sparePtr->tagByte4;
-       tu->asBytes[5]= sparePtr->tagByte5;
-       tu->asBytes[6]= sparePtr->tagByte6;
-       tu->asBytes[7]= sparePtr->tagByte7;
-       
-       result =  yaffs_CheckECCOnTags(tagsPtr);
-       if(result> 0)
-       {
+       tu->asBytes[0] = sparePtr->tagByte0;
+       tu->asBytes[1] = sparePtr->tagByte1;
+       tu->asBytes[2] = sparePtr->tagByte2;
+       tu->asBytes[3] = sparePtr->tagByte3;
+       tu->asBytes[4] = sparePtr->tagByte4;
+       tu->asBytes[5] = sparePtr->tagByte5;
+       tu->asBytes[6] = sparePtr->tagByte6;
+       tu->asBytes[7] = sparePtr->tagByte7;
+
+       result = yaffs_CheckECCOnTags(tagsPtr);
+       if (result > 0) {
                dev->tagsEccFixed++;
-       }
-       else if(result <0)
-       {
+       } else if (result < 0) {
                dev->tagsEccUnfixed++;
        }
 }
 
-static void yaffs_SpareInitialise(yaffs_Spare *spare)
+static void yaffs_SpareInitialise(yaffs_Spare * spare)
 {
-       memset(spare,0xFF,sizeof(yaffs_Spare));
+       memset(spare, 0xFF, sizeof(yaffs_Spare));
 }
 
-
-
-
-static int yaffs_WriteChunkToNAND(struct yaffs_DeviceStruct *dev,int chunkInNAND, const __u8 *data, yaffs_Spare *spare)
+static int yaffs_WriteChunkToNAND(struct yaffs_DeviceStruct *dev,
+                                 int chunkInNAND, const __u8 * data,
+                                 yaffs_Spare * spare)
 {
-       if(chunkInNAND < dev->startBlock * dev->nChunksPerBlock)
-       {
-               T(YAFFS_TRACE_ERROR,(TSTR("**>> yaffs chunk %d is not valid" TENDSTR),chunkInNAND));
+       if (chunkInNAND < dev->startBlock * dev->nChunksPerBlock) {
+               T(YAFFS_TRACE_ERROR,
+                 (TSTR("**>> yaffs chunk %d is not valid" TENDSTR),
+                  chunkInNAND));
                return YAFFS_FAIL;
        }
 
        dev->nPageWrites++;
-       return dev->writeChunkToNAND(dev,chunkInNAND,data,spare);
+       return dev->writeChunkToNAND(dev, chunkInNAND, data, spare);
 }
 
-
-
 static int yaffs_ReadChunkFromNAND(struct yaffs_DeviceStruct *dev,
-                                                       int chunkInNAND, 
-                                                       __u8 *data, 
-                                                       yaffs_Spare *spare,
-                                                       yaffs_ECCResult *eccResult,
-                                                       int doErrorCorrection)
+                                  int chunkInNAND,
+                                  __u8 * data,
+                                  yaffs_Spare * spare,
+                                  yaffs_ECCResult * eccResult,
+                                  int doErrorCorrection)
 {
        int retVal;
        yaffs_Spare localSpare;
 
        dev->nPageReads++;
-       
-       
-
-       
-       if(!spare && data)
-       {
-               // If we don't have a real spare, then we use a local one.
-               // Need this for the calculation of the ecc
+
+       if (!spare && data) {
+               /* If we don't have a real spare, then we use a local one. */
+               /* Need this for the calculation of the ecc */
                spare = &localSpare;
        }
-       
-
-       if(!dev->useNANDECC)
-       {
-               retVal  = dev->readChunkFromNAND(dev,chunkInNAND,data,spare);
-               if(data && doErrorCorrection)
-               {
-                       // Do ECC correction
-                       //Todo handle any errors
-               int eccResult1,eccResult2;
-               __u8 calcEcc[3];
-                
-                       yaffs_ECCCalculate(data,calcEcc);
-                       eccResult1 = yaffs_ECCCorrect (data,spare->ecc1, calcEcc);
-                       yaffs_ECCCalculate(&data[256],calcEcc);
-                       eccResult2 = yaffs_ECCCorrect(&data[256],spare->ecc2, calcEcc);
-
-                       if(eccResult1>0)
-                       {
-                               T(YAFFS_TRACE_ERROR, (TSTR("**>>ecc error fix performed on chunk %d:0" TENDSTR),chunkInNAND));
+
+       if (!dev->useNANDECC) {
+               retVal = dev->readChunkFromNAND(dev, chunkInNAND, data, spare);
+               if (data && doErrorCorrection) {
+                       /* Do ECC correction */
+                       /* Todo handle any errors */
+                       int eccResult1, eccResult2;
+                       __u8 calcEcc[3];
+
+                       yaffs_ECCCalculate(data, calcEcc);
+                       eccResult1 =
+                           yaffs_ECCCorrect(data, spare->ecc1, calcEcc);
+                       yaffs_ECCCalculate(&data[256], calcEcc);
+                       eccResult2 =
+                           yaffs_ECCCorrect(&data[256], spare->ecc2, calcEcc);
+
+                       if (eccResult1 > 0) {
+                               T(YAFFS_TRACE_ERROR,
+                                 (TSTR
+                                  ("**>>ecc error fix performed on chunk %d:0"
+                                   TENDSTR), chunkInNAND));
                                dev->eccFixed++;
-                       }
-                       else if(eccResult1<0)
-                       {
-                               T(YAFFS_TRACE_ERROR,(TSTR("**>>ecc error unfixed on chunk %d:0" TENDSTR),chunkInNAND));
+                       } else if (eccResult1 < 0) {
+                               T(YAFFS_TRACE_ERROR,
+                                 (TSTR
+                                  ("**>>ecc error unfixed on chunk %d:0"
+                                   TENDSTR), chunkInNAND));
                                dev->eccUnfixed++;
                        }
 
-                       if(eccResult2>0)
-                       {
-                               T(YAFFS_TRACE_ERROR,(TSTR("**>>ecc error fix performed on chunk %d:1" TENDSTR),chunkInNAND));
+                       if (eccResult2 > 0) {
+                               T(YAFFS_TRACE_ERROR,
+                                 (TSTR
+                                  ("**>>ecc error fix performed on chunk %d:1"
+                                   TENDSTR), chunkInNAND));
                                dev->eccFixed++;
-                       }
-                       else if(eccResult2<0)
-                       {
-                               T(YAFFS_TRACE_ERROR,(TSTR("**>>ecc error unfixed on chunk %d:1" TENDSTR),chunkInNAND));
+                       } else if (eccResult2 < 0) {
+                               T(YAFFS_TRACE_ERROR,
+                                 (TSTR
+                                  ("**>>ecc error unfixed on chunk %d:1"
+                                   TENDSTR), chunkInNAND));
                                dev->eccUnfixed++;
                        }
 
-                       if(eccResult1 || eccResult2)
-                       {
-                               // Hoosterman, we had a data problem on this page
-                               yaffs_HandleReadDataError(dev,chunkInNAND);
+                       if (eccResult1 || eccResult2) {
+                               /* We had a data problem on this page */
+                               yaffs_HandleReadDataError(dev, chunkInNAND);
                        }
-                       
-                       if(eccResult1 < 0 || eccResult2 < 0) 
+
+                       if (eccResult1 < 0 || eccResult2 < 0)
                                *eccResult = YAFFS_ECC_RESULT_UNFIXED;
-                       else if(eccResult1 > 0 || eccResult2 > 0)
+                       else if (eccResult1 > 0 || eccResult2 > 0)
                                *eccResult = YAFFS_ECC_RESULT_FIXED;
                        else
                                *eccResult = YAFFS_ECC_RESULT_NO_ERROR;
                }
-       }
-       else
-       {
-        // Must allocate enough memory for spare+2*sizeof(int) for ecc results from device.
-       struct yaffs_NANDSpare nspare;
-               retVal  = dev->readChunkFromNAND(dev,chunkInNAND,data,(yaffs_Spare*)&nspare);
-               memcpy (spare, &nspare, sizeof(yaffs_Spare));
-               if(data && doErrorCorrection)
-               {
-                       if(nspare.eccres1>0)
-                       {
-                               T(YAFFS_TRACE_ERROR,(TSTR("**>>ecc error fix performed on chunk %d:0" TENDSTR),chunkInNAND));
-                       }
-                       else if(nspare.eccres1<0)
-                       {
-                               T(YAFFS_TRACE_ERROR,(TSTR("**>>ecc error unfixed on chunk %d:0" TENDSTR),chunkInNAND));
+       } else {
+               /* Must allocate enough memory for spare+2*sizeof(int) */
+               /* for ecc results from device. */
+               struct yaffs_NANDSpare nspare;
+               retVal =
+                   dev->readChunkFromNAND(dev, chunkInNAND, data,
+                                          (yaffs_Spare *) & nspare);
+               memcpy(spare, &nspare, sizeof(yaffs_Spare));
+               if (data && doErrorCorrection) {
+                       if (nspare.eccres1 > 0) {
+                               T(YAFFS_TRACE_ERROR,
+                                 (TSTR
+                                  ("**>>ecc error fix performed on chunk %d:0"
+                                   TENDSTR), chunkInNAND));
+                       } else if (nspare.eccres1 < 0) {
+                               T(YAFFS_TRACE_ERROR,
+                                 (TSTR
+                                  ("**>>ecc error unfixed on chunk %d:0"
+                                   TENDSTR), chunkInNAND));
                        }
 
-                       if(nspare.eccres2>0)
-                       {
-                               T(YAFFS_TRACE_ERROR,(TSTR("**>>ecc error fix performed on chunk %d:1" TENDSTR),chunkInNAND));
-                       }
-                       else if(nspare.eccres2<0)
-                       {
-                               T(YAFFS_TRACE_ERROR,(TSTR("**>>ecc error unfixed on chunk %d:1" TENDSTR),chunkInNAND));
+                       if (nspare.eccres2 > 0) {
+                               T(YAFFS_TRACE_ERROR,
+                                 (TSTR
+                                  ("**>>ecc error fix performed on chunk %d:1"
+                                   TENDSTR), chunkInNAND));
+                       } else if (nspare.eccres2 < 0) {
+                               T(YAFFS_TRACE_ERROR,
+                                 (TSTR
+                                  ("**>>ecc error unfixed on chunk %d:1"
+                                   TENDSTR), chunkInNAND));
                        }
 
-                       if(nspare.eccres1 || nspare.eccres2)
-                       {
-                               // Hoosterman, we had a data problem on this page
-                               yaffs_HandleReadDataError(dev,chunkInNAND);
+                       if (nspare.eccres1 || nspare.eccres2) {
+                               /* We had a data problem on this page */
+                               yaffs_HandleReadDataError(dev, chunkInNAND);
                        }
-                       
-                       if(nspare.eccres1 < 0 || nspare.eccres2 < 0) 
+
+                       if (nspare.eccres1 < 0 || nspare.eccres2 < 0)
                                *eccResult = YAFFS_ECC_RESULT_UNFIXED;
-                       else if(nspare.eccres1 > 0 || nspare.eccres2 > 0)
+                       else if (nspare.eccres1 > 0 || nspare.eccres2 > 0)
                                *eccResult = YAFFS_ECC_RESULT_FIXED;
                        else
                                *eccResult = YAFFS_ECC_RESULT_NO_ERROR;
 
-
                }
        }
        return retVal;
 }
 
 #ifdef NOTYET
-static int yaffs_CheckChunkErased(struct yaffs_DeviceStruct *dev,int chunkInNAND)
+static int yaffs_CheckChunkErased(struct yaffs_DeviceStruct *dev,
+                                 int chunkInNAND)
 {
 
        static int init = 0;
        static __u8 cmpbuf[YAFFS_BYTES_PER_CHUNK];
        static __u8 data[YAFFS_BYTES_PER_CHUNK];
-    // Might as well always allocate the larger size for dev->useNANDECC == true;
+       /* Might as well always allocate the larger size for */
+       /* dev->useNANDECC == true; */
        static __u8 spare[sizeof(struct yaffs_NANDSpare)];
 
-       dev->readChunkFromNAND(dev,chunkInNAND,data,(yaffs_Spare *)spare);
+       dev->readChunkFromNAND(dev, chunkInNAND, data, (yaffs_Spare *) spare);
 
-       if(!init)
-       {
-               memset(cmpbuf,0xff,YAFFS_BYTES_PER_CHUNK);
+       if (!init) {
+               memset(cmpbuf, 0xff, YAFFS_BYTES_PER_CHUNK);
                init = 1;
        }
 
-       if(memcmp(cmpbuf,data,YAFFS_BYTES_PER_CHUNK)) return  YAFFS_FAIL;
-       if(memcmp(cmpbuf,spare,16)) return YAFFS_FAIL;
-
+       if (memcmp(cmpbuf, data, YAFFS_BYTES_PER_CHUNK))
+               return YAFFS_FAIL;
+       if (memcmp(cmpbuf, spare, 16))
+               return YAFFS_FAIL;
 
        return YAFFS_OK;
 
 }
 #endif
 
+/*
+ * Functions for robustisizing
+ */
 
-
-///
-// Functions for robustisizing
-//
-//
-
-static void yaffs_HandleReadDataError(yaffs_Device *dev,int chunkInNAND)
+static void yaffs_HandleReadDataError(yaffs_Device * dev, int chunkInNAND)
 {
-       int blockInNAND = chunkInNAND/dev->nChunksPerBlock;
-
-       // Mark the block for retirement
-       yaffs_GetBlockInfo(dev,blockInNAND)->needsRetiring = 1;
-       T(YAFFS_TRACE_ERROR | YAFFS_TRACE_BAD_BLOCKS,(TSTR("**>>Block %d marked for retirement" TENDSTR),blockInNAND));
-
-
-       //TODO
-       // Just do a garbage collection on the affected block then retire the block
-       // NB recursion
+       int blockInNAND = chunkInNAND / dev->nChunksPerBlock;
+
+       /* Mark the block for retirement */
+       yaffs_GetBlockInfo(dev, blockInNAND)->needsRetiring = 1;
+       T(YAFFS_TRACE_ERROR | YAFFS_TRACE_BAD_BLOCKS,
+         (TSTR("**>>Block %d marked for retirement" TENDSTR), blockInNAND));
+
+       /* TODO:
+        * Just do a garbage collection on the affected block
+        * then retire the block
+        * NB recursion
+        */
 }
 
-
 #ifdef NOTYET
-static void yaffs_CheckWrittenBlock(yaffs_Device *dev,int chunkInNAND)
+static void yaffs_CheckWrittenBlock(yaffs_Device * dev, int chunkInNAND)
 {
 }
 
-static void yaffs_HandleWriteChunkOk(yaffs_Device *dev,int chunkInNAND,const __u8 *data, const yaffs_Spare *spare)
+static void yaffs_HandleWriteChunkOk(yaffs_Device * dev, int chunkInNAND,
+                                    const __u8 * data,
+                                    const yaffs_Spare * spare)
 {
 }
 
-static void yaffs_HandleUpdateChunk(yaffs_Device *dev,int chunkInNAND, const yaffs_Spare *spare)
+static void yaffs_HandleUpdateChunk(yaffs_Device * dev, int chunkInNAND,
+                                   const yaffs_Spare * spare)
 {
 }
 
-static void yaffs_HandleWriteChunkError(yaffs_Device *dev,int chunkInNAND)
+static void yaffs_HandleWriteChunkError(yaffs_Device * dev, int chunkInNAND)
 {
-       int blockInNAND = chunkInNAND/dev->nChunksPerBlock;
+       int blockInNAND = chunkInNAND / dev->nChunksPerBlock;
 
-       // Mark the block for retirement
-       yaffs_GetBlockInfo(dev,blockInNAND)->needsRetiring = 1;
-       // Delete the chunk
-       yaffs_DeleteChunk(dev,chunkInNAND,1,__LINE__);
+       /* Mark the block for retirement */
+       yaffs_GetBlockInfo(dev, blockInNAND)->needsRetiring = 1;
+       /* Delete the chunk */
+       yaffs_DeleteChunk(dev, chunkInNAND, 1, __LINE__);
 }
 
-
-
-
-static int yaffs_VerifyCompare(const __u8 *d0, const __u8 * d1, const yaffs_Spare *s0, const yaffs_Spare *s1)
+static int yaffs_VerifyCompare(const __u8 * d0, const __u8 * d1,
+                              const yaffs_Spare * s0, const yaffs_Spare * s1)
 {
 
-
-       if( memcmp(d0,d1,YAFFS_BYTES_PER_CHUNK) != 0 ||
-               s0->tagByte0 != s1->tagByte0 ||
-               s0->tagByte1 != s1->tagByte1 ||
-               s0->tagByte2 != s1->tagByte2 ||
-               s0->tagByte3 != s1->tagByte3 ||
-               s0->tagByte4 != s1->tagByte4 ||
-               s0->tagByte5 != s1->tagByte5 ||
-               s0->tagByte6 != s1->tagByte6 ||
-               s0->tagByte7 != s1->tagByte7 ||
-               s0->ecc1[0]  != s1->ecc1[0]  ||
-               s0->ecc1[1]  != s1->ecc1[1]  ||
-               s0->ecc1[2]  != s1->ecc1[2]  ||
-               s0->ecc2[0]  != s1->ecc2[0]  ||
-               s0->ecc2[1]  != s1->ecc2[1]  ||
-               s0->ecc2[2]  != s1->ecc2[2] )
-               {
-                       return 0;
-               }
+       if (memcmp(d0, d1, YAFFS_BYTES_PER_CHUNK) != 0 ||
+           s0->tagByte0 != s1->tagByte0 ||
+           s0->tagByte1 != s1->tagByte1 ||
+           s0->tagByte2 != s1->tagByte2 ||
+           s0->tagByte3 != s1->tagByte3 ||
+           s0->tagByte4 != s1->tagByte4 ||
+           s0->tagByte5 != s1->tagByte5 ||
+           s0->tagByte6 != s1->tagByte6 ||
+           s0->tagByte7 != s1->tagByte7 ||
+           s0->ecc1[0] != s1->ecc1[0] ||
+           s0->ecc1[1] != s1->ecc1[1] ||
+           s0->ecc1[2] != s1->ecc1[2] ||
+           s0->ecc2[0] != s1->ecc2[0] ||
+           s0->ecc2[1] != s1->ecc2[1] || s0->ecc2[2] != s1->ecc2[2]) {
+               return 0;
+       }
 
        return 1;
 }
-#endif /* NOTYET */
-
-
+#endif                         /* NOTYET */
 
-int yaffs_TagsCompatabilityWriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, const yaffs_ExtendedTags *eTags)
+int yaffs_TagsCompatabilityWriteChunkWithTagsToNAND(yaffs_Device * dev,
+                                                   int chunkInNAND,
+                                                   const __u8 * data,
+                                                   const yaffs_ExtendedTags *
+                                                   eTags)
 {
        yaffs_Spare spare;
-       yaffs_Tags tags;        
-       
+       yaffs_Tags tags;
+
        yaffs_SpareInitialise(&spare);
-       
-       if(eTags->chunkDeleted)
-       {
+
+       if (eTags->chunkDeleted) {
                spare.pageStatus = 0;
-       }
-       else
-       {
+       } else {
                tags.objectId = eTags->objectId;
                tags.chunkId = eTags->chunkId;
                tags.byteCount = eTags->byteCount;
                tags.serialNumber = eTags->serialNumber;
-               
-// NCB
-               if (!dev->useNANDECC && data)
-               {
-                   yaffs_CalcECC(data,&spare);
+
+               if (!dev->useNANDECC && data) {
+                       yaffs_CalcECC(data, &spare);
                }
+               yaffs_LoadTagsIntoSpare(&spare, &tags);
 
-// /NCB
-                yaffs_LoadTagsIntoSpare(&spare,&tags);
-               
        }
-       
-       return yaffs_WriteChunkToNAND(dev,chunkInNAND,data,&spare);
-}
 
+       return yaffs_WriteChunkToNAND(dev, chunkInNAND, data, &spare);
+}
 
-int yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaffs_ExtendedTags *eTags)
+int yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(yaffs_Device * dev,
+                                                    int chunkInNAND,
+                                                    __u8 * data,
+                                                    yaffs_ExtendedTags * eTags)
 {
 
        yaffs_Spare spare;
        yaffs_Tags tags;
        yaffs_ECCResult eccResult;
-       
-// NCB
-     static yaffs_Spare spareFF;
-     static int init;
-     
-     if(!init)
-     {
-            memset(&spareFF,0xFF,sizeof(spareFF));
-            init = 1;
-     }
-// /NCB
-       if(yaffs_ReadChunkFromNAND(dev,chunkInNAND,data,&spare,&eccResult,1))
-       {
-// added NCB - eTags may be NULL
+
+       static yaffs_Spare spareFF;
+       static int init;
+
+       if (!init) {
+               memset(&spareFF, 0xFF, sizeof(spareFF));
+               init = 1;
+       }
+
+       if (yaffs_ReadChunkFromNAND
+           (dev, chunkInNAND, data, &spare, &eccResult, 1)) {
+               /* eTags may be NULL */
                if (eTags) {
 
-                int deleted = (yaffs_CountBits(spare.pageStatus) < 7) ? 1 : 0;
-                       
-                yaffs_GetTagsFromSpare(dev,&spare,&tags);
-                
-                eTags->chunkDeleted = deleted;
-                eTags->objectId = tags.objectId;
-                eTags->chunkId = tags.chunkId;
-                eTags->byteCount = tags.byteCount;
-                eTags->serialNumber = tags.serialNumber;
-                eTags->eccResult = eccResult;
-                eTags->blockBad = 0; // We're reading it therefore it is not a bad block
-                
-// NCB added 18/2/2005
-                eTags->chunkUsed = (memcmp(&spareFF,&spare,sizeof(spareFF)) != 0) ? 1:0;
+                       int deleted =
+                           (yaffs_CountBits(spare.pageStatus) < 7) ? 1 : 0;
+
+                       yaffs_GetTagsFromSpare(dev, &spare, &tags);
+
+                       eTags->chunkDeleted = deleted;
+                       eTags->objectId = tags.objectId;
+                       eTags->chunkId = tags.chunkId;
+                       eTags->byteCount = tags.byteCount;
+                       eTags->serialNumber = tags.serialNumber;
+                       eTags->eccResult = eccResult;
+                       eTags->blockBad = 0;    /* We're reading it */
+                       /* therefore it is not a bad block */
+
+                       eTags->chunkUsed =
+                           (memcmp(&spareFF, &spare, sizeof(spareFF)) !=
+                            0) ? 1 : 0;
                }
-                
-                return YAFFS_OK;
-       }
-       else
-       { 
+
+               return YAFFS_OK;
+       } else {
                return YAFFS_FAIL;
        }
 }
 
-int yaffs_TagsCompatabilityMarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockInNAND)
+int yaffs_TagsCompatabilityMarkNANDBlockBad(struct yaffs_DeviceStruct *dev,
+                                           int blockInNAND)
 {
 
        yaffs_Spare spare;
 
-       memset(&spare, 0xff,sizeof(yaffs_Spare));
+       memset(&spare, 0xff, sizeof(yaffs_Spare));
 
        spare.blockStatus = 'Y';
 
-       yaffs_WriteChunkToNAND(dev, blockInNAND * dev->nChunksPerBlock, NULL , &spare);
-       yaffs_WriteChunkToNAND(dev, blockInNAND * dev->nChunksPerBlock + 1, NULL , &spare);
-       
+       yaffs_WriteChunkToNAND(dev, blockInNAND * dev->nChunksPerBlock, NULL,
+                              &spare);
+       yaffs_WriteChunkToNAND(dev, blockInNAND * dev->nChunksPerBlock + 1,
+                              NULL, &spare);
+
        return YAFFS_OK;
-       
-}
 
+}
 
-int yaffs_TagsCompatabilityQueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo, yaffs_BlockState *state, int *sequenceNumber)
+int yaffs_TagsCompatabilityQueryNANDBlock(struct yaffs_DeviceStruct *dev,
+                                         int blockNo, yaffs_BlockState *
+                                         state,
+                                         int *sequenceNumber)
 {
-     
-     yaffs_Spare spare0,spare1;
-     static yaffs_Spare spareFF;
-     static int init;
-     yaffs_ECCResult dummy;
-     
-     if(!init)
-     {
-            memset(&spareFF,0xFF,sizeof(spareFF));
-            init = 1;
-     }
-     
-     *sequenceNumber = 0;
-     
-     yaffs_ReadChunkFromNAND(dev,blockNo * dev->nChunksPerBlock,NULL,&spare0,&dummy,1);
-     yaffs_ReadChunkFromNAND(dev,blockNo * dev->nChunksPerBlock + 1,NULL,&spare1,&dummy,1);
-     
-     if(yaffs_CountBits(spare0.blockStatus & spare1.blockStatus) < 7)
-       *state = YAFFS_BLOCK_STATE_DEAD;
-     else if(memcmp(&spareFF,&spare0,sizeof(spareFF)) == 0)
-         *state = YAFFS_BLOCK_STATE_EMPTY;
-     else
-        *state = YAFFS_BLOCK_STATE_NEEDS_SCANNING;  
-
-     return YAFFS_OK;
-}
 
+       yaffs_Spare spare0, spare1;
+       static yaffs_Spare spareFF;
+       static int init;
+       yaffs_ECCResult dummy;
+
+       if (!init) {
+               memset(&spareFF, 0xFF, sizeof(spareFF));
+               init = 1;
+       }
+
+       *sequenceNumber = 0;
+
+       yaffs_ReadChunkFromNAND(dev, blockNo * dev->nChunksPerBlock, NULL,
+                               &spare0, &dummy, 1);
+       yaffs_ReadChunkFromNAND(dev, blockNo * dev->nChunksPerBlock + 1, NULL,
+                               &spare1, &dummy, 1);
+
+       if (yaffs_CountBits(spare0.blockStatus & spare1.blockStatus) < 7)
+               *state = YAFFS_BLOCK_STATE_DEAD;
+       else if (memcmp(&spareFF, &spare0, sizeof(spareFF)) == 0)
+               *state = YAFFS_BLOCK_STATE_EMPTY;
+       else
+               *state = YAFFS_BLOCK_STATE_NEEDS_SCANNING;
+
+       return YAFFS_OK;
+}
index 46db082..7922ab3 100644 (file)
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- * $Id: yaffs_tagscompat.h,v 1.1 2004-11-03 08:14:07 charles Exp $
+ * $Id: yaffs_tagscompat.h,v 1.2 2005-08-11 02:33:03 marty Exp $
  */
 
-// This provides a rma disk under yaffs.
-// NB this is not intended for NAND emulation.
-// Use this with dev->useNANDECC enabled, then ECC overheads are not required.
-
+/* This provides a ram disk under yaffs.
+ * NB this is not intended for NAND emulation.
+ * Use this with dev->useNANDECC enabled, then ECC overheads are not required.
+ */
 #ifndef __YAFFS_TAGSCOMPAT_H__
 #define __YAFFS_TAGSCOMPAT_H__
 
-
 #include "yaffs_guts.h"
-int yaffs_TagsCompatabilityWriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, const yaffs_ExtendedTags *tags);
-int yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaffs_ExtendedTags *tags);
-int yaffs_TagsCompatabilityMarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo);
-int yaffs_TagsCompatabilityQueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo, yaffs_BlockState *state, int *sequenceNumber);
+int yaffs_TagsCompatabilityWriteChunkWithTagsToNAND(yaffs_Device * dev,
+                                                   int chunkInNAND,
+                                                   const __u8 * data,
+                                                   const yaffs_ExtendedTags *
+                                                   tags);
+int yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(yaffs_Device * dev,
+                                                    int chunkInNAND,
+                                                    __u8 * data,
+                                                    yaffs_ExtendedTags *
+                                                    tags);
+int yaffs_TagsCompatabilityMarkNANDBlockBad(struct yaffs_DeviceStruct *dev,
+                                           int blockNo);
+int yaffs_TagsCompatabilityQueryNANDBlock(struct yaffs_DeviceStruct *dev,
+                                         int blockNo, yaffs_BlockState *
+                                         state, int *sequenceNumber);
 
 #endif
index 14b8ed0..101ad03 100644 (file)
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- * $Id: yaffs_tagsvalidity.c,v 1.1 2005-04-29 18:09:16 charles Exp $
+ * $Id: yaffs_tagsvalidity.c,v 1.2 2005-08-11 02:33:03 marty Exp $
  */
-//yaffs_tagsvalidity.c
 
 #include "yaffs_tagsvalidity.h"
 
-
-
-void yaffs_InitialiseTags(yaffs_ExtendedTags *tags)
+void yaffs_InitialiseTags(yaffs_ExtendedTags * tags)
 {
-       memset(tags,0,sizeof(yaffs_ExtendedTags));
+       memset(tags, 0, sizeof(yaffs_ExtendedTags));
        tags->validMarker0 = 0xAAAAAAAA;
        tags->validMarker1 = 0x55555555;
 }
 
-int yaffs_ValidateTags(yaffs_ExtendedTags *tags)
+int yaffs_ValidateTags(yaffs_ExtendedTags * tags)
 {
        return (tags->validMarker0 == 0xAAAAAAAA &&
                tags->validMarker1 == 0x55555555);
 
 }
-
index f0ed4d8..371445e 100644 (file)
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- * $Id: yaffs_tagsvalidity.h,v 1.1 2005-04-29 18:09:16 charles Exp $
+ * $Id: yaffs_tagsvalidity.h,v 1.2 2005-08-11 02:33:03 marty Exp $
  */
 //yaffs_tagsvalidity.h
 
-
 #ifndef __YAFFS_TAGS_VALIDITY_H__
 #define __YAFFS_TAGS_VALIDITY_H__
 
 #include "yaffs_guts.h"
 
-void yaffs_InitialiseTags(yaffs_ExtendedTags *tags);
-int yaffs_ValidateTags(yaffs_ExtendedTags *tags);
+void yaffs_InitialiseTags(yaffs_ExtendedTags * tags);
+int yaffs_ValidateTags(yaffs_ExtendedTags * tags);
 #endif
-
index e4b0ff1..d6ec50c 100644 (file)
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  *
  */
+
 #ifndef __YAFFSINTERFACE_H__
 #define __YAFFSINTERFACE_H__
 
-
 int yaffs_Initialise(unsigned nBlocks);
 
 #endif
-
index b5e0434..1fc2272 100644 (file)
  *
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  *
- * $Id: yportenv.h,v 1.6 2005-07-31 00:26:57 charles Exp $
+ * $Id: yportenv.h,v 1.7 2005-08-11 02:33:03 marty Exp $
  *
  */
+
 #ifndef __YPORTENV_H__
 #define __YPORTENV_H__
 
-
 #if defined CONFIG_YAFFS_WINCE
 
 #include "ywinceenv.h"
 
 #elif  defined __KERNEL__
 
-
-
-// Linux kernel
+/* Linux kernel */
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/version.h>
@@ -53,7 +50,7 @@
 #define YAFFS_LOSTNFOUND_NAME          "lost+found"
 #define YAFFS_LOSTNFOUND_PREFIX                "obj"
 
-//#define YPRINTF(x) printk x
+/* #define YPRINTF(x) printk x */
 #define YMALLOC(x) kmalloc(x,GFP_KERNEL)
 #define YFREE(x)   kfree(x)
 
 #define TSTR(x) KERN_WARNING x
 #define TOUT(p) printk p
 
-
 #elif defined CONFIG_YAFFS_DIRECT
 
-// Direct interface
+/* Direct interface */
 #include "ydirectenv.h"
 
 #elif defined CONFIG_YAFFS_UTIL
 
-// Stuff for YAFFS utilities
+/* Stuff for YAFFS utilities */
 
 #include "stdlib.h"
 #include "stdio.h"
@@ -94,7 +90,6 @@
 #define YMALLOC(x) malloc(x)
 #define YFREE(x)   free(x)
 
-
 #define YCHAR char
 #define YUCHAR unsigned char
 #define _Y(x)     x
 
 #define Y_INLINE inline
 
-//#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))
-//#define YALERT(s) YINFO(s)
-
+/* #define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s)) */
+/* #define YALERT(s) YINFO(s) */
 
 #define TENDSTR "\n"
 #define TSTR(x) x
 #define TOUT(p) printf p
 
-
 #define YAFFS_LOSTNFOUND_NAME          "lost+found"
 #define YAFFS_LOSTNFOUND_PREFIX                "obj"
-//#define YPRINTF(x) printf x
-
+/* #define YPRINTF(x) printf x */
 
 #define YAFFS_ROOT_MODE                                0666
 #define YAFFS_LOSTNFOUND_MODE          0666
 #define yaffs_strcmp(a,b) strcmp(a,b)
 
 #else
-// Should have specified a configuration type
+/* Should have specified a configuration type */
 #error Unknown configuration
 
-#endif 
-
+#endif
 
 extern unsigned yaffs_traceMask;
 
@@ -153,13 +144,10 @@ extern unsigned yaffs_traceMask;
 #define YAFFS_TRACE_ALWAYS             0x40000000
 #define YAFFS_TRACE_BUG                        0x80000000
 
-#define T(mask,p) do{ if((mask) & (yaffs_traceMask | YAFFS_TRACE_ERROR)) TOUT(p);} while(0) 
-
+#define T(mask,p) do{ if((mask) & (yaffs_traceMask | YAFFS_TRACE_ERROR)) TOUT(p);} while(0)
 
 #ifndef CONFIG_YAFFS_WINCE
 #define YBUG() T(YAFFS_TRACE_BUG,(TSTR("==>> yaffs bug: " __FILE__ " %d" TENDSTR),__LINE__))
 #endif
 
 #endif
-
-