Skip to content

Commit 0760468

Browse files
masahir0yBoris Brezillon
authored andcommitted
mtd: nand: relax ecc.read_page() return value for uncorrectable ECC
The comment for ecc.read_page() requires that it should return "0 if bitflips uncorrectable". Actually, drivers could return positive values when uncorrectable bitflips occur. For example, nand_read_page_swecc() is the case. If ecc.correct() returns -EBADMSG for the first ECC sector, and a positive value for the second one, nand_read_page_swecc() returns a positive max_bitflips and increments ecc_stats.failed for the same page. The requirement can be relaxed by tweaking nand_do_read_ops(). Move the max_bitflips calculation below the retry. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Suggested-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
1 parent f107d7a commit 0760468

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

‎drivers/mtd/nand/nand_base.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,8 +1993,6 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
19931993
break;
19941994
}
19951995

1996-
max_bitflips = max_t(unsigned int, max_bitflips, ret);
1997-
19981996
/* Transfer not aligned data */
19991997
if (use_bufpoi) {
20001998
if (!NAND_HAS_SUBPAGE_READ(chip) && !oob &&
@@ -2045,6 +2043,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
20452043
}
20462044

20472045
buf += bytes;
2046+
max_bitflips = max_t(unsigned int, max_bitflips, ret);
20482047
} else {
20492048
memcpy(buf, chip->buffers->databuf + col, bytes);
20502049
buf += bytes;

‎include/linux/mtd/nand.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ static inline void nand_hw_control_init(struct nand_hw_control *nfc)
516516
* out-of-band data).
517517
* @read_page: function to read a page according to the ECC generator
518518
* requirements; returns maximum number of bitflips corrected in
519-
* any single ECC step, 0 if bitflips uncorrectable, -EIO hw error
519+
* any single ECC step, -EIO hw error
520520
* @read_subpage: function to read parts of the page covered by ECC;
521521
* returns same as read_page()
522522
* @write_subpage: function to write parts of the page covered by ECC.

0 commit comments

Comments
 (0)