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

* Re: [PATCH] mtd: tests: nandbiterrs: Fix read_page return value
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Boris Brezillon @ 2018-01-09  9:31 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: linux-mtd, Richard Weinberger, Brian Norris, kernel

On Tue,  9 Jan 2018 10:09:38 +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>
> ---
>  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)

Why not just replacing the above test by

	if (!err || 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 */

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

* Re: [PATCH] mtd: tests: nandbiterrs: Fix read_page return value
  2018-01-09  9:31 ` Boris Brezillon
@ 2018-01-09  9:47   ` Sascha Hauer
  0 siblings, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2018-01-09  9:47 UTC (permalink / raw)
  To: Boris Brezillon; +Cc: linux-mtd, Richard Weinberger, Brian Norris, kernel

On Tue, Jan 09, 2018 at 10:31:12AM +0100, Boris Brezillon wrote:
> On Tue,  9 Jan 2018 10:09:38 +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>
> > ---
> >  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)
> 
> Why not just replacing the above test by
> 
> 	if (!err || err == -EUCLEAN)

Looks better indeed. I just sent an update.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[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