Skip to content

Commit 0c30896

Browse files
libang-linuxermiquelraynal
authored andcommitted
mtdblock: tolerate corrected bit-flips
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 <[email protected]> Fixes: e47f685 ("mtd: check for max_bitflips in mtd_read_oob()") Cc: <[email protected]> # v3.7 Acked-by: Richard Weinberger <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent ddbb664 commit 0c30896

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/mtd/mtdblock.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
153153
mtdblk->cache_state = STATE_EMPTY;
154154
ret = mtd_read(mtd, sect_start, sect_size,
155155
&retlen, mtdblk->cache_data);
156-
if (ret)
156+
if (ret && !mtd_is_bitflip(ret))
157157
return ret;
158158
if (retlen != sect_size)
159159
return -EIO;
@@ -188,8 +188,12 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos,
188188
pr_debug("mtdblock: read on \"%s\" at 0x%lx, size 0x%x\n",
189189
mtd->name, pos, len);
190190

191-
if (!sect_size)
192-
return mtd_read(mtd, pos, len, &retlen, buf);
191+
if (!sect_size) {
192+
ret = mtd_read(mtd, pos, len, &retlen, buf);
193+
if (ret && !mtd_is_bitflip(ret))
194+
return ret;
195+
return 0;
196+
}
193197

194198
while (len > 0) {
195199
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,
209213
memcpy (buf, mtdblk->cache_data + offset, size);
210214
} else {
211215
ret = mtd_read(mtd, pos, size, &retlen, buf);
212-
if (ret)
216+
if (ret && !mtd_is_bitflip(ret))
213217
return ret;
214218
if (retlen != size)
215219
return -EIO;

0 commit comments

Comments
 (0)