drivers: rkflash: should not return EIO for ecc corrected case

Change-Id: I637c48f27a4329715ec032a349c0ba56741504be
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
This commit is contained in:
Jon Lin
2020-05-06 17:15:20 +08:00
parent 0435b850fa
commit 781684d716
2 changed files with 11 additions and 3 deletions

View File

@@ -563,7 +563,7 @@ u32 sfc_nand_read_page_raw(u8 cs, u32 addr, u32 *p_page_buf)
rkflash_print_dio("%s %x %x\n", __func__, addr, p_page_buf[0]);
if (ret != SFC_OK)
return SFC_NAND_ECC_ERROR;
return SFC_NAND_HW_ERROR;
return ecc_result;
}
@@ -584,6 +584,9 @@ u32 sfc_nand_read_page(u8 cs, u32 addr, u32 *p_data, u32 *p_spare)
p_spare[3] = gp_page_buf[(data_size + meta->off3) / 4];
}
if (ret == SFC_NAND_HW_ERROR)
ret = SFC_NAND_ECC_ERROR;
if (ret != SFC_NAND_ECC_OK) {
rkflash_print_error("%s[0x%x], ret=0x%x\n", __func__, addr, ret);
if (p_data)

View File

@@ -92,12 +92,16 @@ static int sfc_nand_read_mtd(struct mtd_info *mtd, loff_t from,
while (remaining) {
ret = sfc_nand_read_page_raw(0, from >> mtd->writesize_shift,
(u32 *)p_dev->dma_buf);
if (ret == SFC_NAND_HW_ERROR) {
ret = -EIO;
break;
}
if (ret == SFC_NAND_ECC_ERROR) {
rkflash_print_error("%s addr %llx ret= %d\n",
__func__, from, ret);
ecc_failed = true;
mtd->ecc_stats.failed++;
ret = 0;
} else if (ret == SFC_NAND_ECC_REFRESH) {
rkflash_print_dio("%s addr %llx ret= %d\n",
__func__, from, ret);
@@ -117,6 +121,7 @@ static int sfc_nand_read_mtd(struct mtd_info *mtd, loff_t from,
memcpy(oob_buf, p_dev->dma_buf + mtd->writesize + ops->ooboffs,
oob_real);
ret = 0;
data += real_size;
ops->retlen += real_size;
remaining -= real_size;
@@ -130,7 +135,7 @@ static int sfc_nand_read_mtd(struct mtd_info *mtd, loff_t from,
if (ecc_failed && !ret)
ret = -EBADMSG;
return ret ? (-EIO) : max_bitflips;
return ret ? ret : max_bitflips;
}
static int sfc_nand_isbad_mtd(struct mtd_info *mtd, loff_t ofs)