changeset 79:3eaa6f96e945

lindent
author marty
date Thu, 11 Aug 2005 03:33:03 +0100
parents 222238621f18
children 910ded3009f9
files 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
diffstat 10 files changed, 464 insertions(+), 491 deletions(-) [+]
line wrap: on
line diff
--- a/yaffs_packedtags1.c
+++ b/yaffs_packedtags1.c
@@ -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->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));
+
 	}
 }
-
--- a/yaffs_packedtags1.h
+++ b/yaffs_packedtags1.h
@@ -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
-
-
--- a/yaffs_packedtags2.c
+++ b/yaffs_packedtags2.c
@@ -12,20 +12,21 @@
  * 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
+/* 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.
+/* 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
@@ -34,84 +35,83 @@
 
 #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_ExtendedTag
 #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_ExtendedTag
 	yaffs_DumpTags2(t);
 
 }
-
--- a/yaffs_packedtags2.h
+++ b/yaffs_packedtags2.h
@@ -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
-
-
--- a/yaffs_tagscompat.c
+++ b/yaffs_tagscompat.c
@@ -17,33 +17,34 @@
 #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(yaff
 	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];
 
-	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);
+			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 (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;
+	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));
+	/* 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
+	/* 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);
-		}
 
-// /NCB
-		 yaffs_LoadTagsIntoSpare(&spare,&tags);
-		
+		if (!dev->useNANDECC && data) {
+			yaffs_CalcECC(data, &spare);
+		}
+		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;  
+
+	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;
 
-     return YAFFS_OK;
+	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;
 }
-
--- a/yaffs_tagscompat.h
+++ b/yaffs_tagscompat.h
@@ -13,18 +13,28 @@
  * $Id$
  */
 
-// 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
--- a/yaffs_tagsvalidity.c
+++ b/yaffs_tagsvalidity.c
@@ -13,23 +13,19 @@
  *
  * $Id$
  */
-//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);
 
 }
-
--- a/yaffs_tagsvalidity.h
+++ b/yaffs_tagsvalidity.h
@@ -15,13 +15,11 @@
  */
 //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
-
--- a/yaffsinterface.h
+++ b/yaffsinterface.h
@@ -14,12 +14,10 @@
  * 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
-
--- a/yportenv.h
+++ b/yportenv.h
@@ -18,20 +18,17 @@
  * $Id$
  *
  */
- 
+
 #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)
 
@@ -75,15 +72,14 @@
 #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
@@ -106,19 +101,16 @@
 
 #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
@@ -127,11 +119,10 @@
 #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
-
-