9
0
Fork 0

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 <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2013-12-19 16:17:40 +01:00
parent 26f2c815d1
commit a8fd9bfd12
1 changed files with 4 additions and 5 deletions

View File

@ -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