Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[22.03] ramips: correct page read return value of the mt7621 nand driver #12698

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions target/linux/ramips/files/drivers/mtd/nand/raw/mt7621_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ static int mt7621_nfc_read_page_hwecc(struct nand_chip *nand, uint8_t *buf,
{
struct mt7621_nfc *nfc = nand_get_controller_data(nand);
struct mtd_info *mtd = nand_to_mtd(nand);
int bitflips = 0;
int bitflips = 0, ret = 0;
int rc, i;

nand_read_page_op(nand, page, 0, NULL, 0);
Expand All @@ -1031,7 +1031,7 @@ static int mt7621_nfc_read_page_hwecc(struct nand_chip *nand, uint8_t *buf,
mt7621_nfc_read_sector_fdm(nfc, i);

if (rc < 0) {
bitflips = -EIO;
ret = -EIO;
continue;
}

Expand All @@ -1043,10 +1043,11 @@ static int mt7621_nfc_read_page_hwecc(struct nand_chip *nand, uint8_t *buf,
dev_dbg(nfc->dev,
"Uncorrectable ECC error at page %d.%d\n",
page, i);
bitflips = -EBADMSG;
bitflips = nand->ecc.strength + 1;
mtd->ecc_stats.failed++;
} else if (bitflips >= 0) {
bitflips += rc;
} else {
if (rc > bitflips)
bitflips = rc;
mtd->ecc_stats.corrected += rc;
}
}
Expand All @@ -1055,6 +1056,9 @@ static int mt7621_nfc_read_page_hwecc(struct nand_chip *nand, uint8_t *buf,

nfi_write16(nfc, NFI_CON, 0);

if (ret < 0)
return ret;

return bitflips;
}

Expand Down