mtd: omap3: nand: report corrected ecc errors
The number of corrected ECC errors should be reported since other MTD systems make use of this information (such as UBI data scrubbing). Signed-off-by: John Ogness <john.ogness@linutronix.de> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
parent
bea9312839
commit
74f1b7244e
1 changed files with 12 additions and 4 deletions
|
@ -517,6 +517,8 @@ static void gen_true_ecc(u8 *ecc_buf)
|
||||||
*
|
*
|
||||||
* This function compares two ECC's and indicates if there is an error.
|
* This function compares two ECC's and indicates if there is an error.
|
||||||
* If the error can be corrected it will be corrected to the buffer.
|
* If the error can be corrected it will be corrected to the buffer.
|
||||||
|
* If there is no error, %0 is returned. If there is an error but it
|
||||||
|
* was corrected, %1 is returned. Otherwise, %-1 is returned.
|
||||||
*/
|
*/
|
||||||
static int omap_compare_ecc(u8 *ecc_data1, /* read from NAND memory */
|
static int omap_compare_ecc(u8 *ecc_data1, /* read from NAND memory */
|
||||||
u8 *ecc_data2, /* read from register */
|
u8 *ecc_data2, /* read from register */
|
||||||
|
@ -622,7 +624,7 @@ static int omap_compare_ecc(u8 *ecc_data1, /* read from NAND memory */
|
||||||
|
|
||||||
page_data[find_byte] ^= (1 << find_bit);
|
page_data[find_byte] ^= (1 << find_bit);
|
||||||
|
|
||||||
return 0;
|
return 1;
|
||||||
default:
|
default:
|
||||||
if (isEccFF) {
|
if (isEccFF) {
|
||||||
if (ecc_data2[0] == 0 &&
|
if (ecc_data2[0] == 0 &&
|
||||||
|
@ -643,8 +645,11 @@ static int omap_compare_ecc(u8 *ecc_data1, /* read from NAND memory */
|
||||||
* @calc_ecc: ecc read from HW ECC registers
|
* @calc_ecc: ecc read from HW ECC registers
|
||||||
*
|
*
|
||||||
* Compares the ecc read from nand spare area with ECC registers values
|
* Compares the ecc read from nand spare area with ECC registers values
|
||||||
* and if ECC's mismached, it will call 'omap_compare_ecc' for error detection
|
* and if ECC's mismatched, it will call 'omap_compare_ecc' for error
|
||||||
* and correction.
|
* detection and correction. If there are no errors, %0 is returned. If
|
||||||
|
* there were errors and all of the errors were corrected, the number of
|
||||||
|
* corrected errors is returned. If uncorrectable errors exist, %-1 is
|
||||||
|
* returned.
|
||||||
*/
|
*/
|
||||||
static int omap_correct_data(struct mtd_info *mtd, u_char *dat,
|
static int omap_correct_data(struct mtd_info *mtd, u_char *dat,
|
||||||
u_char *read_ecc, u_char *calc_ecc)
|
u_char *read_ecc, u_char *calc_ecc)
|
||||||
|
@ -652,6 +657,7 @@ static int omap_correct_data(struct mtd_info *mtd, u_char *dat,
|
||||||
struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
|
struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
|
||||||
mtd);
|
mtd);
|
||||||
int blockCnt = 0, i = 0, ret = 0;
|
int blockCnt = 0, i = 0, ret = 0;
|
||||||
|
int stat = 0;
|
||||||
|
|
||||||
/* Ex NAND_ECC_HW12_2048 */
|
/* Ex NAND_ECC_HW12_2048 */
|
||||||
if ((info->nand.ecc.mode == NAND_ECC_HW) &&
|
if ((info->nand.ecc.mode == NAND_ECC_HW) &&
|
||||||
|
@ -665,12 +671,14 @@ static int omap_correct_data(struct mtd_info *mtd, u_char *dat,
|
||||||
ret = omap_compare_ecc(read_ecc, calc_ecc, dat);
|
ret = omap_compare_ecc(read_ecc, calc_ecc, dat);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
/* keep track of the number of corrected errors */
|
||||||
|
stat += ret;
|
||||||
}
|
}
|
||||||
read_ecc += 3;
|
read_ecc += 3;
|
||||||
calc_ecc += 3;
|
calc_ecc += 3;
|
||||||
dat += 512;
|
dat += 512;
|
||||||
}
|
}
|
||||||
return 0;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue