|
@@ -252,7 +252,7 @@ static int bf5xx_nand_correct_data_256(struct mtd_info *mtd, u_char *dat,
|
|
|
*/
|
|
|
if (hweight32(syndrome[0]) == 1) {
|
|
|
dev_err(info->device, "ECC data was incorrect!\n");
|
|
|
- return 1;
|
|
|
+ return -EBADMSG;
|
|
|
}
|
|
|
|
|
|
syndrome[1] = (calced & 0x7FF) ^ (stored & 0x7FF);
|
|
@@ -285,7 +285,7 @@ static int bf5xx_nand_correct_data_256(struct mtd_info *mtd, u_char *dat,
|
|
|
data = data ^ (0x1 << failing_bit);
|
|
|
*(dat + failing_byte) = data;
|
|
|
|
|
|
- return 0;
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -298,26 +298,34 @@ static int bf5xx_nand_correct_data_256(struct mtd_info *mtd, u_char *dat,
|
|
|
dev_err(info->device,
|
|
|
"Please discard data, mark bad block\n");
|
|
|
|
|
|
- return 1;
|
|
|
+ return -EBADMSG;
|
|
|
}
|
|
|
|
|
|
static int bf5xx_nand_correct_data(struct mtd_info *mtd, u_char *dat,
|
|
|
u_char *read_ecc, u_char *calc_ecc)
|
|
|
{
|
|
|
struct nand_chip *chip = mtd_to_nand(mtd);
|
|
|
- int ret;
|
|
|
+ int ret, bitflips = 0;
|
|
|
|
|
|
ret = bf5xx_nand_correct_data_256(mtd, dat, read_ecc, calc_ecc);
|
|
|
+ if (ret < 0)
|
|
|
+ return ret;
|
|
|
+
|
|
|
+ bitflips = ret;
|
|
|
|
|
|
/* If ecc size is 512, correct second 256 bytes */
|
|
|
if (chip->ecc.size == 512) {
|
|
|
dat += 256;
|
|
|
read_ecc += 3;
|
|
|
calc_ecc += 3;
|
|
|
- ret |= bf5xx_nand_correct_data_256(mtd, dat, read_ecc, calc_ecc);
|
|
|
+ ret = bf5xx_nand_correct_data_256(mtd, dat, read_ecc, calc_ecc);
|
|
|
+ if (ret < 0)
|
|
|
+ return ret;
|
|
|
+
|
|
|
+ bitflips += ret;
|
|
|
}
|
|
|
|
|
|
- return ret;
|
|
|
+ return bitflips;
|
|
|
}
|
|
|
|
|
|
static void bf5xx_nand_enable_hwecc(struct mtd_info *mtd, int mode)
|