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

Boris Brezillon boris.brezillon at free-electrons.com
Tue Jan 9 01:31:12 PST 2018


On Tue,  9 Jan 2018 10:09:38 +0100
Sascha Hauer <s.hauer at 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 at 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 */




More information about the linux-mtd mailing list