mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mtd: fix wrong return values in cdev read
@ 2013-12-19 15:21 Sascha Hauer
  2013-12-20 14:06 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2013-12-19 15:21 UTC (permalink / raw)
  To: barebox

mtd->read returns the number of bitflips as positive numbers.
Instead of returning these numbers Return -EUCLEAN when the bitflip
threshold has been reached, 0 otherwise.

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

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index f63b10e..57b0fad 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -74,12 +74,11 @@ static ssize_t mtd_op_read(struct cdev *cdev, void* buf, size_t count,
 			offset, count);
 
 	ret = mtd_read(mtd, offset, count, &retlen, buf);
-
-	if(ret) {
-		printf("err %d\n", ret);
+	if (ret < 0)
 		return ret;
-	}
-	return retlen;
+	if (mtd->ecc_strength == 0)
+		return 0;	/* device lacks ecc */
+	return ret >= mtd->bitflip_threshold ? -EUCLEAN : 0;
 }
 
 #define NOTALIGNED(x) (x & (mtd->writesize - 1)) != 0
-- 
1.8.5.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] mtd: fix wrong return values in cdev read
  2013-12-19 15:21 [PATCH] mtd: fix wrong return values in cdev read Sascha Hauer
@ 2013-12-20 14:06 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2013-12-20 14:06 UTC (permalink / raw)
  To: barebox

On Thu, Dec 19, 2013 at 04:21:23PM +0100, Sascha Hauer wrote:
> mtd->read returns the number of bitflips as positive numbers.
> Instead of returning these numbers Return -EUCLEAN when the bitflip
> threshold has been reached, 0 otherwise.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  drivers/mtd/core.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
> index f63b10e..57b0fad 100644
> --- a/drivers/mtd/core.c
> +++ b/drivers/mtd/core.c
> @@ -74,12 +74,11 @@ static ssize_t mtd_op_read(struct cdev *cdev, void* buf, size_t count,
>  			offset, count);
>  
>  	ret = mtd_read(mtd, offset, count, &retlen, buf);
> -
> -	if(ret) {
> -		printf("err %d\n", ret);
> +	if (ret < 0)
>  		return ret;
> -	}
> -	return retlen;
> +	if (mtd->ecc_strength == 0)
> +		return 0;	/* device lacks ecc */
> +	return ret >= mtd->bitflip_threshold ? -EUCLEAN : 0;

This is not correct. We have to return retlen, not 0. Will resend along
with some other fixes.

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 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2013-12-20 14:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-19 15:21 [PATCH] mtd: fix wrong return values in cdev read Sascha Hauer
2013-12-20 14:06 ` Sascha Hauer

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