X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=yaffs_guts.c;h=9ddabf687170d561ea5a87fbed323b82527540c9;hb=3d5f3cc536fd1e1c2ce477c4f3ba5147eb8678be;hp=2fddbc2d66ea2c3ecf055cde57e397070e37f51c;hpb=fda65c091dee0b79326a319fea302015e5f19683;p=yaffs%2F.git diff --git a/yaffs_guts.c b/yaffs_guts.c index 2fddbc2..9ddabf6 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -14,7 +14,7 @@ */ //yaffs_guts.c -const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.14 2002-12-04 19:12:43 charles Exp $"; +const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.15 2002-12-13 00:13:06 charles Exp $"; #include "yportenv.h" @@ -190,12 +190,44 @@ int yaffs_ReadChunkFromNAND(struct yaffs_DeviceStruct *dev, #ifndef CONFIG_YAFFS_USE_NANDECC - retVal = dev->readChunkFromNAND(dev,chunkInNAND,data,spare); - if(data && doErrorCorrection) - { - // Hoosterman, we had a data problem on this page - yaffs_HandleReadDataError(dev,chunkInNAND); - } + retVal = dev->readChunkFromNAND(dev,chunkInNAND,data,spare); + if(data && doErrorCorrection) + { + // Do ECC correction + //Todo handle any errors + nand_calculate_ecc(data,calcEcc); + eccResult1 = nand_correct_data (data,spare->ecc1, calcEcc); + nand_calculate_ecc(&data[256],calcEcc); + eccResult2 = nand_correct_data (&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)); + dev->eccUnfixed++; + } + + 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)); + dev->eccUnfixed++; + } + + if(eccResult1 || eccResult2) + { + // Hoosterman, we had a data problem on this page + yaffs_HandleReadDataError(dev,chunkInNAND); + } + } #else retVal = dev->readChunkFromNAND(dev,chunkInNAND,data,(yaffs_Spare*)&nspare); memcpy (spare, &nspare, sizeof(yaffs_Spare)); @@ -1869,12 +1901,19 @@ static int yaffs_FindBlockForAllocation(yaffs_Device *dev) for(i = dev->startBlock; i <= dev->endBlock; i++) { - bi = yaffs_GetBlockInfo(dev,i); + dev->allocationBlockFinder++; + if(dev->allocationBlockFinder < dev->startBlock || + dev->allocationBlockFinder > dev->endBlock) + { + dev->allocationBlockFinder = dev->startBlock; + } + + bi = yaffs_GetBlockInfo(dev,dev->allocationBlockFinder); if(bi->blockState == YAFFS_BLOCK_STATE_EMPTY) { bi->blockState = YAFFS_BLOCK_STATE_ALLOCATING; dev->nErasedBlocks--; - return i; + return dev->allocationBlockFinder; } }