diff mbox series

[v2] mtd: tests: nandbiterrs: Fix read_page return value

Message ID 20180109094702.21488-1-s.hauer@pengutronix.de
State Accepted
Delegated to: Boris Brezillon
Headers show
Series [v2] mtd: tests: nandbiterrs: Fix read_page return value | expand

Commit Message

Sascha Hauer Jan. 9, 2018, 9:47 a.m. UTC
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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Boris Brezillon Jan. 9, 2018, 9:51 a.m. UTC | #1
On Tue,  9 Jan 2018 10:47:02 +0100
Sascha Hauer <s.hauer@pengutronix.de> wrote:

> 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>

I'll apply this patch, but you should really start using the userspace
tests provided by mtd-utils, because I still plan to remove the
in-kernel test modules at some point ;-).

> ---
>  drivers/mtd/tests/nandbiterrs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/tests/nandbiterrs.c b/drivers/mtd/tests/nandbiterrs.c
> index 5f03b8c885a9..cde19c99e77b 100644
> --- a/drivers/mtd/tests/nandbiterrs.c
> +++ b/drivers/mtd/tests/nandbiterrs.c
> @@ -151,7 +151,7 @@ static int read_page(int log)
>  	memcpy(&oldstats, &mtd->ecc_stats, sizeof(oldstats));
>  
>  	err = mtd_read(mtd, offset, mtd->writesize, &read, rbuffer);
> -	if (err == -EUCLEAN)
> +	if (!err || err == -EUCLEAN)
>  		err = mtd->ecc_stats.corrected - oldstats.corrected;
>  
>  	if (err < 0 || read != mtd->writesize) {
Sascha Hauer Jan. 9, 2018, 11:08 a.m. UTC | #2
On Tue, Jan 09, 2018 at 10:51:08AM +0100, Boris Brezillon wrote:
> On Tue,  9 Jan 2018 10:47:02 +0100
> Sascha Hauer <s.hauer@pengutronix.de> wrote:
> 
> > 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>
> 
> I'll apply this patch, but you should really start using the userspace
> tests provided by mtd-utils, because I still plan to remove the
> in-kernel test modules at some point ;-).

Please do so. When I cannot find the in-kernel tests anymore I'll recall
that there are tests in userspace ;)

Sascha
Boris Brezillon Jan. 10, 2018, 8:46 a.m. UTC | #3
On Tue,  9 Jan 2018 10:47:02 +0100
Sascha Hauer <s.hauer@pengutronix.de> wrote:

> 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.
> 

Applied.

Thanks,

Boris

> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  drivers/mtd/tests/nandbiterrs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/tests/nandbiterrs.c b/drivers/mtd/tests/nandbiterrs.c
> index 5f03b8c885a9..cde19c99e77b 100644
> --- a/drivers/mtd/tests/nandbiterrs.c
> +++ b/drivers/mtd/tests/nandbiterrs.c
> @@ -151,7 +151,7 @@ static int read_page(int log)
>  	memcpy(&oldstats, &mtd->ecc_stats, sizeof(oldstats));
>  
>  	err = mtd_read(mtd, offset, mtd->writesize, &read, rbuffer);
> -	if (err == -EUCLEAN)
> +	if (!err || err == -EUCLEAN)
>  		err = mtd->ecc_stats.corrected - oldstats.corrected;
>  
>  	if (err < 0 || read != mtd->writesize) {
diff mbox series

Patch

diff --git a/drivers/mtd/tests/nandbiterrs.c b/drivers/mtd/tests/nandbiterrs.c
index 5f03b8c885a9..cde19c99e77b 100644
--- a/drivers/mtd/tests/nandbiterrs.c
+++ b/drivers/mtd/tests/nandbiterrs.c
@@ -151,7 +151,7 @@  static int read_page(int log)
 	memcpy(&oldstats, &mtd->ecc_stats, sizeof(oldstats));
 
 	err = mtd_read(mtd, offset, mtd->writesize, &read, rbuffer);
-	if (err == -EUCLEAN)
+	if (!err || err == -EUCLEAN)
 		err = mtd->ecc_stats.corrected - oldstats.corrected;
 
 	if (err < 0 || read != mtd->writesize) {