public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] mtd: tests: nandbiterrs: Fix read_page return value
@ 2018-01-09  9:09 Sascha Hauer
  2018-01-09  9:31 ` Boris Brezillon
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2018-01-09  9:09 UTC (permalink / raw)
  To: linux-mtd
  Cc: Boris Brezillon, Richard Weinberger, Brian Norris, kernel,
	Sascha Hauer

The number of corrected bitflips is not correctly reported by
the test until the bitflip threshold is reached.

read_page() shall return the number of corrected bitflips, but
mtd_read() returns 0 or a negative error, so we can't forward
its return value. In the absence of an error we always have
calculate the number of bitflips ourselves.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/tests/nandbiterrs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/tests/nandbiterrs.c b/drivers/mtd/tests/nandbiterrs.c
index 5f03b8c885a9..11e39ab4a810 100644
--- a/drivers/mtd/tests/nandbiterrs.c
+++ b/drivers/mtd/tests/nandbiterrs.c
@@ -152,15 +152,16 @@ static int read_page(int log)
 
 	err = mtd_read(mtd, offset, mtd->writesize, &read, rbuffer);
 	if (err == -EUCLEAN)
-		err = mtd->ecc_stats.corrected - oldstats.corrected;
+		err = 0;
 
 	if (err < 0 || read != mtd->writesize) {
 		pr_err("error: read failed at %#llx\n", (long long)offset);
 		if (err >= 0)
 			err = -EIO;
+		return err;
 	}
 
-	return err;
+	return mtd->ecc_stats.corrected - oldstats.corrected;
 }
 
 /* Verifies rbuffer against random sequence */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-09  9:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-09  9:09 [PATCH] mtd: tests: nandbiterrs: Fix read_page return value Sascha Hauer
2018-01-09  9:31 ` Boris Brezillon
2018-01-09  9:47   ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox