linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mtd: tests: nandbiterrs: Fix read_page return value
@ 2018-01-09  9:47 Sascha Hauer
  2018-01-09  9:51 ` Boris Brezillon
  2018-01-10  8:46 ` Boris Brezillon
  0 siblings, 2 replies; 4+ messages in thread
From: Sascha Hauer @ 2018-01-09  9:47 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 | 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) {
-- 
2.11.0

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

* Re: [PATCH v2] mtd: tests: nandbiterrs: Fix read_page return value
  2018-01-09  9:47 [PATCH v2] mtd: tests: nandbiterrs: Fix read_page return value Sascha Hauer
@ 2018-01-09  9:51 ` Boris Brezillon
  2018-01-09 11:08   ` Sascha Hauer
  2018-01-10  8:46 ` Boris Brezillon
  1 sibling, 1 reply; 4+ messages in thread
From: Boris Brezillon @ 2018-01-09  9:51 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: linux-mtd, Richard Weinberger, Brian Norris, kernel

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

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

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

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

-- 
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] 4+ messages in thread

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

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

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

end of thread, other threads:[~2018-01-10  8:46 UTC | newest]

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).