X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=yaffs_packedtags2.c;h=f8ae94ccddb479854f8398e6f8fc3949979180c1;hp=a78c03c9d6ce368b3c8447d482c76252b32143e3;hb=ef32964aac3e4dfee477d4c2b0df608fbe849397;hpb=97f9eea27dc6b83fe55f9b86adbb5e4961ea921a diff --git a/yaffs_packedtags2.c b/yaffs_packedtags2.c index a78c03c..f8ae94c 100644 --- a/yaffs_packedtags2.c +++ b/yaffs_packedtags2.c @@ -1,7 +1,7 @@ /* * YAFFS: Yet Another Flash File System. A NAND-flash specific file system. * - * Copyright (C) 2002-2007 Aleph One Ltd. + * Copyright (C) 2002-2010 Aleph One Ltd. * for Toby Churchill Ltd and Brightstar Engineering * * Created by Charles Manning @@ -13,6 +13,7 @@ #include "yaffs_packedtags2.h" #include "yportenv.h" +#include "yaffs_trace.h" #include "yaffs_tagsvalidity.h" /* This code packs a set of extended tags into a binary structure for @@ -96,17 +97,14 @@ void yaffs_PackTags2TagsPart(yaffs_PackedTags2TagsPart *ptt, } -void yaffs_PackTags2(yaffs_PackedTags2 *pt, const yaffs_ExtendedTags *t) +void yaffs_PackTags2(yaffs_PackedTags2 *pt, const yaffs_ExtendedTags *t, int tagsECC) { yaffs_PackTags2TagsPart(&pt->t, t); -#ifndef YAFFS_IGNORE_TAGS_ECC - { + if(tagsECC) yaffs_ECCCalculateOther((unsigned char *)&pt->t, sizeof(yaffs_PackedTags2TagsPart), &pt->ecc); - } -#endif } @@ -158,27 +156,24 @@ void yaffs_UnpackTags2TagsPart(yaffs_ExtendedTags *t, } -void yaffs_UnpackTags2(yaffs_ExtendedTags *t, yaffs_PackedTags2 *pt) +void yaffs_UnpackTags2(yaffs_ExtendedTags *t, yaffs_PackedTags2 *pt, int tagsECC) { yaffs_ECCResult eccResult = YAFFS_ECC_RESULT_NO_ERROR; - if (pt->t.sequenceNumber != 0xFFFFFFFF) { - /* Page is in use */ -#ifndef YAFFS_IGNORE_TAGS_ECC - { - yaffs_ECCOther ecc; - int result; - yaffs_ECCCalculateOther((unsigned char *)&pt->t, - sizeof - (yaffs_PackedTags2TagsPart), - &ecc); - result = - yaffs_ECCCorrectOther((unsigned char *)&pt->t, - sizeof - (yaffs_PackedTags2TagsPart), - &pt->ecc, &ecc); - switch (result) { + if (pt->t.sequenceNumber != 0xFFFFFFFF && + tagsECC){ + /* Chunk is in use and we need to do ECC */ + + yaffs_ECCOther ecc; + int result; + yaffs_ECCCalculateOther((unsigned char *)&pt->t, + sizeof(yaffs_PackedTags2TagsPart), + &ecc); + result = yaffs_ECCCorrectOther((unsigned char *)&pt->t, + sizeof(yaffs_PackedTags2TagsPart), + &pt->ecc, &ecc); + switch (result) { case 0: eccResult = YAFFS_ECC_RESULT_NO_ERROR; break; @@ -190,9 +185,7 @@ void yaffs_UnpackTags2(yaffs_ExtendedTags *t, yaffs_PackedTags2 *pt) break; default: eccResult = YAFFS_ECC_RESULT_UNKNOWN; - } } -#endif } yaffs_UnpackTags2TagsPart(t, &pt->t); @@ -201,6 +194,5 @@ void yaffs_UnpackTags2(yaffs_ExtendedTags *t, yaffs_PackedTags2 *pt) yaffs_DumpPackedTags2(pt); yaffs_DumpTags2(t); - }