X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=fs%2Fyaffs2%2Fyaffs_ecc.c;h=1b4a05d71b9e63b480645b01d3752d0c8dea4108;hb=19ef4f7a6ef3b725aa9fe4b4f5fb676a84160172;hp=d0b405f1eea34bbc2a146039b4882ece78d43268;hpb=0e8cc8bd92257da2e1df88cbc985e166e472ce61;p=u-boot diff --git a/fs/yaffs2/yaffs_ecc.c b/fs/yaffs2/yaffs_ecc.c index d0b405f1ee..1b4a05d71b 100644 --- a/fs/yaffs2/yaffs_ecc.c +++ b/fs/yaffs2/yaffs_ecc.c @@ -14,9 +14,9 @@ /* * This code implements the ECC algorithm used in SmartMedia. * - * The ECC comprises 22 bits of parity information and is stuffed into 3 bytes. + * The ECC comprises 22 bits of parity information and is stuffed into 3 bytes. * The two unused bit are set to 1. - * The ECC can correct single bit errors in a 256-byte page of data. Thus, two such ECC + * The ECC can correct single bit errors in a 256-byte page of data. Thus, two such ECC * blocks are used on a 512-byte NAND page. * */ @@ -28,6 +28,9 @@ * this bytes influence on the line parity. */ +/* XXX U-BOOT XXX */ +#include + const char *yaffs_ecc_c_version = "$Id: yaffs_ecc.c,v 1.9 2007/02/14 01:09:06 wookey Exp $"; @@ -228,8 +231,8 @@ int yaffs_ECCCorrect(unsigned char *data, unsigned char *read_ecc, return 1; /* Corrected the error */ } - if ((yaffs_CountBits(d0) + - yaffs_CountBits(d1) + + if ((yaffs_CountBits(d0) + + yaffs_CountBits(d1) + yaffs_CountBits(d2)) == 1) { /* Reccoverable error in ecc */ @@ -239,7 +242,7 @@ int yaffs_ECCCorrect(unsigned char *data, unsigned char *read_ecc, return 1; /* Corrected the error */ } - + /* Unrecoverable error */ return -1; @@ -293,7 +296,7 @@ int yaffs_ECCCorrectOther(unsigned char *data, unsigned nBytes, if ((cDelta | lDelta | lDeltaPrime) == 0) return 0; /* no error */ - if (lDelta == ~lDeltaPrime && + if (lDelta == ~lDeltaPrime && (((cDelta ^ (cDelta >> 1)) & 0x15) == 0x15)) { /* Single bit (recoverable) error in data */ @@ -309,7 +312,7 @@ int yaffs_ECCCorrectOther(unsigned char *data, unsigned nBytes, if(lDelta >= nBytes) return -1; - + data[lDelta] ^= (1 << bit); return 1; /* corrected */ @@ -328,4 +331,3 @@ int yaffs_ECCCorrectOther(unsigned char *data, unsigned nBytes, return -1; } -