*/
//yaffs_guts.c
-const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.21 2003-02-03 18:33:28 charles Exp $";
+const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.22 2003-03-11 05:16:53 charles Exp $";
#include "yportenv.h"
int retVal;
yaffs_Spare localSpare;
- __u8 calcEcc[3];
- int eccResult1,eccResult2;
- struct yaffs_NANDSpare nspare;
-
dev->nPageReads++;
{
// Do ECC correction
//Todo handle any errors
+ int eccResult1,eccResult2;
+ __u8 calcEcc[3];
+
nand_calculate_ecc(data,calcEcc);
eccResult1 = nand_correct_data (data,spare->ecc1, calcEcc);
nand_calculate_ecc(&data[256],calcEcc);
}
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)
T(YAFFS_TRACE_ERROR,(TSTR("**>>ecc error unfixed on chunk %d:1" TENDSTR),chunkInNAND));
}
- if(nspare.eccres2 || nspare.eccres2)
+ if(nspare.eccres1 || nspare.eccres2)
{
// Hoosterman, we had a data problem on this page
yaffs_HandleReadDataError(dev,chunkInNAND);
static int init = 0;
static __u8 cmpbuf[YAFFS_BYTES_PER_CHUNK];
static __u8 data[YAFFS_BYTES_PER_CHUNK];
- static __u8 spare[16];
-
-
- dev->readChunkFromNAND(dev,chunkInNAND,data,(yaffs_Spare *)spare);
-
-
+ // 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);
if(!init)
{