From a8fd9bfd126cee8a02400f49301fb58228a2bf26 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 19 Dec 2013 16:17:40 +0100 Subject: [PATCH] mtd: fix wrong return values in cdev read 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 --- 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 33f900e73..0abe6675e 100644 --- a/drivers/mtd/core.c +++ b/drivers/mtd/core.c @@ -75,12 +75,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 retlen; /* device lacks ecc */ + return ret >= mtd->bitflip_threshold ? -EUCLEAN : retlen; } #define NOTALIGNED(x) (x & (mtd->writesize - 1)) != 0