mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
mtdblock: tolerate corrected bit-flips
commit0c3089601fupstream. mtd_read() may return -EUCLEAN in case of corrected bit-flips.This particular condition should not be treated like an error. Signed-off-by: Bang Li <libang.linuxer@gmail.com> Fixes:e47f68587b("mtd: check for max_bitflips in mtd_read_oob()") Cc: <stable@vger.kernel.org> # v3.7 Acked-by: Richard Weinberger <richard@nod.at> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20230328163012.4264-1-libang.linuxer@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
0d07ea8d38
commit
441e57ff87
@@ -153,7 +153,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
|
|||||||
mtdblk->cache_state = STATE_EMPTY;
|
mtdblk->cache_state = STATE_EMPTY;
|
||||||
ret = mtd_read(mtd, sect_start, sect_size,
|
ret = mtd_read(mtd, sect_start, sect_size,
|
||||||
&retlen, mtdblk->cache_data);
|
&retlen, mtdblk->cache_data);
|
||||||
if (ret)
|
if (ret && !mtd_is_bitflip(ret))
|
||||||
return ret;
|
return ret;
|
||||||
if (retlen != sect_size)
|
if (retlen != sect_size)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
@@ -188,8 +188,12 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos,
|
|||||||
pr_debug("mtdblock: read on \"%s\" at 0x%lx, size 0x%x\n",
|
pr_debug("mtdblock: read on \"%s\" at 0x%lx, size 0x%x\n",
|
||||||
mtd->name, pos, len);
|
mtd->name, pos, len);
|
||||||
|
|
||||||
if (!sect_size)
|
if (!sect_size) {
|
||||||
return mtd_read(mtd, pos, len, &retlen, buf);
|
ret = mtd_read(mtd, pos, len, &retlen, buf);
|
||||||
|
if (ret && !mtd_is_bitflip(ret))
|
||||||
|
return ret;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
unsigned long sect_start = (pos/sect_size)*sect_size;
|
unsigned long sect_start = (pos/sect_size)*sect_size;
|
||||||
@@ -209,7 +213,7 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos,
|
|||||||
memcpy (buf, mtdblk->cache_data + offset, size);
|
memcpy (buf, mtdblk->cache_data + offset, size);
|
||||||
} else {
|
} else {
|
||||||
ret = mtd_read(mtd, pos, size, &retlen, buf);
|
ret = mtd_read(mtd, pos, size, &retlen, buf);
|
||||||
if (ret)
|
if (ret && !mtd_is_bitflip(ret))
|
||||||
return ret;
|
return ret;
|
||||||
if (retlen != size)
|
if (retlen != size)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|||||||
Reference in New Issue
Block a user