Commit d57f4054 authored by Brian Norris's avatar Brian Norris Committed by Artem Bityutskiy

mtd: utilize `mtd_is_*()' functions

Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@intel.com>
parent 7387ce77
...@@ -346,7 +346,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned ...@@ -346,7 +346,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
ret = mtd->read(mtd, (inftl->EraseSize * BlockMap[block]) + ret = mtd->read(mtd, (inftl->EraseSize * BlockMap[block]) +
(block * SECTORSIZE), SECTORSIZE, &retlen, (block * SECTORSIZE), SECTORSIZE, &retlen,
movebuf); movebuf);
if (ret < 0 && ret != -EUCLEAN) { if (ret < 0 && !mtd_is_bitflip(ret)) {
ret = mtd->read(mtd, ret = mtd->read(mtd,
(inftl->EraseSize * BlockMap[block]) + (inftl->EraseSize * BlockMap[block]) +
(block * SECTORSIZE), SECTORSIZE, (block * SECTORSIZE), SECTORSIZE,
...@@ -917,7 +917,7 @@ static int inftl_readblock(struct mtd_blktrans_dev *mbd, unsigned long block, ...@@ -917,7 +917,7 @@ static int inftl_readblock(struct mtd_blktrans_dev *mbd, unsigned long block,
int ret = mtd->read(mtd, ptr, SECTORSIZE, &retlen, buffer); int ret = mtd->read(mtd, ptr, SECTORSIZE, &retlen, buffer);
/* Handle corrected bit flips gracefully */ /* Handle corrected bit flips gracefully */
if (ret < 0 && ret != -EUCLEAN) if (ret < 0 && !mtd_is_bitflip(ret))
return -EIO; return -EIO;
} }
return 0; return 0;
......
...@@ -242,7 +242,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t ...@@ -242,7 +242,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
* Userspace software which accesses NAND this way * Userspace software which accesses NAND this way
* must be aware of the fact that it deals with NAND * must be aware of the fact that it deals with NAND
*/ */
if (!ret || (ret == -EUCLEAN) || (ret == -EBADMSG)) { if (!ret || mtd_is_bitflip_or_eccerr(ret)) {
*ppos += retlen; *ppos += retlen;
if (copy_to_user(buf, kbuf, retlen)) { if (copy_to_user(buf, kbuf, retlen)) {
kfree(kbuf); kfree(kbuf);
...@@ -491,7 +491,7 @@ static int mtd_do_readoob(struct file *file, struct mtd_info *mtd, ...@@ -491,7 +491,7 @@ static int mtd_do_readoob(struct file *file, struct mtd_info *mtd,
* does not calculate ECC for the OOB area, so do not rely on * does not calculate ECC for the OOB area, so do not rely on
* this behavior unless you have replaced it with your own. * this behavior unless you have replaced it with your own.
*/ */
if (ret == -EUCLEAN || ret == -EBADMSG) if (mtd_is_bitflip_or_eccerr(ret))
return 0; return 0;
return ret; return ret;
......
...@@ -95,10 +95,10 @@ concat_read(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -95,10 +95,10 @@ concat_read(struct mtd_info *mtd, loff_t from, size_t len,
/* Save information about bitflips! */ /* Save information about bitflips! */
if (unlikely(err)) { if (unlikely(err)) {
if (err == -EBADMSG) { if (mtd_is_eccerr(err)) {
mtd->ecc_stats.failed++; mtd->ecc_stats.failed++;
ret = err; ret = err;
} else if (err == -EUCLEAN) { } else if (mtd_is_bitflip(err)) {
mtd->ecc_stats.corrected++; mtd->ecc_stats.corrected++;
/* Do not overwrite -EBADMSG !! */ /* Do not overwrite -EBADMSG !! */
if (!ret) if (!ret)
...@@ -279,10 +279,10 @@ concat_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) ...@@ -279,10 +279,10 @@ concat_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
/* Save information about bitflips! */ /* Save information about bitflips! */
if (unlikely(err)) { if (unlikely(err)) {
if (err == -EBADMSG) { if (mtd_is_eccerr(err)) {
mtd->ecc_stats.failed++; mtd->ecc_stats.failed++;
ret = err; ret = err;
} else if (err == -EUCLEAN) { } else if (mtd_is_bitflip(err)) {
mtd->ecc_stats.corrected++; mtd->ecc_stats.corrected++;
/* Do not overwrite -EBADMSG !! */ /* Do not overwrite -EBADMSG !! */
if (!ret) if (!ret)
......
...@@ -258,7 +258,7 @@ static void find_next_position(struct mtdoops_context *cxt) ...@@ -258,7 +258,7 @@ static void find_next_position(struct mtdoops_context *cxt)
ret = mtd->read(mtd, page * record_size, MTDOOPS_HEADER_SIZE, ret = mtd->read(mtd, page * record_size, MTDOOPS_HEADER_SIZE,
&retlen, (u_char *) &count[0]); &retlen, (u_char *) &count[0]);
if (retlen != MTDOOPS_HEADER_SIZE || if (retlen != MTDOOPS_HEADER_SIZE ||
(ret < 0 && ret != -EUCLEAN)) { (ret < 0 && !mtd_is_bitflip(ret))) {
printk(KERN_ERR "mtdoops: read failure at %ld (%td of %d read), err %d\n", printk(KERN_ERR "mtdoops: read failure at %ld (%td of %d read), err %d\n",
page * record_size, retlen, page * record_size, retlen,
MTDOOPS_HEADER_SIZE, ret); MTDOOPS_HEADER_SIZE, ret);
......
...@@ -73,9 +73,9 @@ static int part_read(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -73,9 +73,9 @@ static int part_read(struct mtd_info *mtd, loff_t from, size_t len,
res = part->master->read(part->master, from + part->offset, res = part->master->read(part->master, from + part->offset,
len, retlen, buf); len, retlen, buf);
if (unlikely(res)) { if (unlikely(res)) {
if (res == -EUCLEAN) if (mtd_is_bitflip(res))
mtd->ecc_stats.corrected += part->master->ecc_stats.corrected - stats.corrected; mtd->ecc_stats.corrected += part->master->ecc_stats.corrected - stats.corrected;
if (res == -EBADMSG) if (mtd_is_eccerr(res))
mtd->ecc_stats.failed += part->master->ecc_stats.failed - stats.failed; mtd->ecc_stats.failed += part->master->ecc_stats.failed - stats.failed;
} }
return res; return res;
...@@ -142,9 +142,9 @@ static int part_read_oob(struct mtd_info *mtd, loff_t from, ...@@ -142,9 +142,9 @@ static int part_read_oob(struct mtd_info *mtd, loff_t from,
res = part->master->read_oob(part->master, from + part->offset, ops); res = part->master->read_oob(part->master, from + part->offset, ops);
if (unlikely(res)) { if (unlikely(res)) {
if (res == -EUCLEAN) if (mtd_is_bitflip(res))
mtd->ecc_stats.corrected++; mtd->ecc_stats.corrected++;
if (res == -EBADMSG) if (mtd_is_eccerr(res))
mtd->ecc_stats.failed++; mtd->ecc_stats.failed++;
} }
return res; return res;
......
...@@ -314,7 +314,7 @@ static int mtdswap_read_oob(struct mtdswap_dev *d, loff_t from, ...@@ -314,7 +314,7 @@ static int mtdswap_read_oob(struct mtdswap_dev *d, loff_t from,
{ {
int ret = d->mtd->read_oob(d->mtd, from, ops); int ret = d->mtd->read_oob(d->mtd, from, ops);
if (ret == -EUCLEAN) if (mtd_is_bitflip(ret))
return ret; return ret;
if (ret) { if (ret) {
...@@ -354,7 +354,7 @@ static int mtdswap_read_markers(struct mtdswap_dev *d, struct swap_eb *eb) ...@@ -354,7 +354,7 @@ static int mtdswap_read_markers(struct mtdswap_dev *d, struct swap_eb *eb)
ret = mtdswap_read_oob(d, offset, &ops); ret = mtdswap_read_oob(d, offset, &ops);
if (ret && ret != -EUCLEAN) if (ret && !mtd_is_bitflip(ret))
return ret; return ret;
data = (struct mtdswap_oobdata *)d->oob_buf; data = (struct mtdswap_oobdata *)d->oob_buf;
...@@ -363,7 +363,7 @@ static int mtdswap_read_markers(struct mtdswap_dev *d, struct swap_eb *eb) ...@@ -363,7 +363,7 @@ static int mtdswap_read_markers(struct mtdswap_dev *d, struct swap_eb *eb)
if (le16_to_cpu(data->magic) == MTDSWAP_MAGIC_CLEAN) { if (le16_to_cpu(data->magic) == MTDSWAP_MAGIC_CLEAN) {
eb->erase_count = le32_to_cpu(data->count); eb->erase_count = le32_to_cpu(data->count);
if (ret == -EUCLEAN) if (mtd_is_bitflip(ret))
ret = MTDSWAP_SCANNED_BITFLIP; ret = MTDSWAP_SCANNED_BITFLIP;
else { else {
if (le16_to_cpu(data2->magic) == MTDSWAP_MAGIC_DIRTY) if (le16_to_cpu(data2->magic) == MTDSWAP_MAGIC_DIRTY)
...@@ -408,7 +408,7 @@ static int mtdswap_write_marker(struct mtdswap_dev *d, struct swap_eb *eb, ...@@ -408,7 +408,7 @@ static int mtdswap_write_marker(struct mtdswap_dev *d, struct swap_eb *eb,
if (ret) { if (ret) {
dev_warn(d->dev, "Write OOB failed for block at %08llx " dev_warn(d->dev, "Write OOB failed for block at %08llx "
"error %d\n", offset, ret); "error %d\n", offset, ret);
if (ret == -EIO || ret == -EBADMSG) if (ret == -EIO || mtd_is_eccerr(ret))
mtdswap_handle_write_error(d, eb); mtdswap_handle_write_error(d, eb);
return ret; return ret;
} }
...@@ -628,7 +628,7 @@ static int mtdswap_map_free_block(struct mtdswap_dev *d, unsigned int page, ...@@ -628,7 +628,7 @@ static int mtdswap_map_free_block(struct mtdswap_dev *d, unsigned int page,
TREE_COUNT(d, CLEAN)--; TREE_COUNT(d, CLEAN)--;
ret = mtdswap_write_marker(d, eb, MTDSWAP_TYPE_DIRTY); ret = mtdswap_write_marker(d, eb, MTDSWAP_TYPE_DIRTY);
} while (ret == -EIO || ret == -EBADMSG); } while (ret == -EIO || mtd_is_eccerr(ret));
if (ret) if (ret)
return ret; return ret;
...@@ -678,7 +678,7 @@ static int mtdswap_write_block(struct mtdswap_dev *d, char *buf, ...@@ -678,7 +678,7 @@ static int mtdswap_write_block(struct mtdswap_dev *d, char *buf,
ret = mtdswap_map_free_block(d, page, bp); ret = mtdswap_map_free_block(d, page, bp);
eb = d->eb_data + (*bp / d->pages_per_eblk); eb = d->eb_data + (*bp / d->pages_per_eblk);
if (ret == -EIO || ret == -EBADMSG) { if (ret == -EIO || mtd_is_eccerr(ret)) {
d->curr_write = NULL; d->curr_write = NULL;
eb->active_count--; eb->active_count--;
d->revmap[*bp] = PAGE_UNDEF; d->revmap[*bp] = PAGE_UNDEF;
...@@ -690,7 +690,7 @@ static int mtdswap_write_block(struct mtdswap_dev *d, char *buf, ...@@ -690,7 +690,7 @@ static int mtdswap_write_block(struct mtdswap_dev *d, char *buf,
writepos = (loff_t)*bp << PAGE_SHIFT; writepos = (loff_t)*bp << PAGE_SHIFT;
ret = mtd->write(mtd, writepos, PAGE_SIZE, &retlen, buf); ret = mtd->write(mtd, writepos, PAGE_SIZE, &retlen, buf);
if (ret == -EIO || ret == -EBADMSG) { if (ret == -EIO || mtd_is_eccerr(ret)) {
d->curr_write_pos--; d->curr_write_pos--;
eb->active_count--; eb->active_count--;
d->revmap[*bp] = PAGE_UNDEF; d->revmap[*bp] = PAGE_UNDEF;
...@@ -738,7 +738,7 @@ static int mtdswap_move_block(struct mtdswap_dev *d, unsigned int oldblock, ...@@ -738,7 +738,7 @@ static int mtdswap_move_block(struct mtdswap_dev *d, unsigned int oldblock,
retry: retry:
ret = mtd->read(mtd, readpos, PAGE_SIZE, &retlen, d->page_buf); ret = mtd->read(mtd, readpos, PAGE_SIZE, &retlen, d->page_buf);
if (ret < 0 && ret != -EUCLEAN) { if (ret < 0 && !mtd_is_bitflip(ret)) {
oldeb = d->eb_data + oldblock / d->pages_per_eblk; oldeb = d->eb_data + oldblock / d->pages_per_eblk;
oldeb->flags |= EBLOCK_READERR; oldeb->flags |= EBLOCK_READERR;
...@@ -1016,7 +1016,7 @@ static int mtdswap_gc(struct mtdswap_dev *d, unsigned int background) ...@@ -1016,7 +1016,7 @@ static int mtdswap_gc(struct mtdswap_dev *d, unsigned int background)
if (ret == 0) if (ret == 0)
mtdswap_rb_add(d, eb, MTDSWAP_CLEAN); mtdswap_rb_add(d, eb, MTDSWAP_CLEAN);
else if (ret != -EIO && ret != -EBADMSG) else if (ret != -EIO && !mtd_is_eccerr(ret))
mtdswap_rb_add(d, eb, MTDSWAP_DIRTY); mtdswap_rb_add(d, eb, MTDSWAP_DIRTY);
return 0; return 0;
...@@ -1164,7 +1164,7 @@ static int mtdswap_readsect(struct mtd_blktrans_dev *dev, ...@@ -1164,7 +1164,7 @@ static int mtdswap_readsect(struct mtd_blktrans_dev *dev,
ret = mtd->read(mtd, readpos, PAGE_SIZE, &retlen, buf); ret = mtd->read(mtd, readpos, PAGE_SIZE, &retlen, buf);
d->mtd_read_count++; d->mtd_read_count++;
if (ret == -EUCLEAN) { if (mtd_is_bitflip(ret)) {
eb->flags |= EBLOCK_BITFLIP; eb->flags |= EBLOCK_BITFLIP;
mtdswap_rb_add(d, eb, MTDSWAP_BITFLIP); mtdswap_rb_add(d, eb, MTDSWAP_BITFLIP);
ret = 0; ret = 0;
......
...@@ -1031,7 +1031,7 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, ...@@ -1031,7 +1031,7 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat,
WriteDOC(DOC_ECC_DIS, docptr, Mplus_ECCConf); WriteDOC(DOC_ECC_DIS, docptr, Mplus_ECCConf);
else else
WriteDOC(DOC_ECC_DIS, docptr, ECCConf); WriteDOC(DOC_ECC_DIS, docptr, ECCConf);
if (no_ecc_failures && (ret == -EBADMSG)) { if (no_ecc_failures && mtd_is_eccerr(ret)) {
printk(KERN_ERR "suppressing ECC failure\n"); printk(KERN_ERR "suppressing ECC failure\n");
ret = 0; ret = 0;
} }
......
...@@ -400,7 +400,7 @@ static int scan_block_full(struct mtd_info *mtd, struct nand_bbt_descr *bd, ...@@ -400,7 +400,7 @@ static int scan_block_full(struct mtd_info *mtd, struct nand_bbt_descr *bd,
ret = scan_read_raw_oob(mtd, buf, offs, readlen); ret = scan_read_raw_oob(mtd, buf, offs, readlen);
/* Ignore ECC errors when checking for BBM */ /* Ignore ECC errors when checking for BBM */
if (ret && ret != -EUCLEAN && ret != -EBADMSG) if (ret && !mtd_is_bitflip_or_eccerr(ret))
return ret; return ret;
for (j = 0; j < len; j++, buf += scanlen) { for (j = 0; j < len; j++, buf += scanlen) {
...@@ -430,7 +430,7 @@ static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd, ...@@ -430,7 +430,7 @@ static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd,
*/ */
ret = mtd->read_oob(mtd, offs, &ops); ret = mtd->read_oob(mtd, offs, &ops);
/* Ignore ECC errors when checking for BBM */ /* Ignore ECC errors when checking for BBM */
if (ret && ret != -EUCLEAN && ret != -EBADMSG) if (ret && !mtd_is_bitflip_or_eccerr(ret))
return ret; return ret;
if (check_short_pattern(buf, bd)) if (check_short_pattern(buf, bd))
......
...@@ -425,7 +425,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p ...@@ -425,7 +425,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
ret = mtd->read(mtd, (nftl->EraseSize * BlockMap[block]) + (block * 512), ret = mtd->read(mtd, (nftl->EraseSize * BlockMap[block]) + (block * 512),
512, &retlen, movebuf); 512, &retlen, movebuf);
if (ret < 0 && ret != -EUCLEAN) { if (ret < 0 && !mtd_is_bitflip(ret)) {
ret = mtd->read(mtd, (nftl->EraseSize * BlockMap[block]) ret = mtd->read(mtd, (nftl->EraseSize * BlockMap[block])
+ (block * 512), 512, &retlen, + (block * 512), 512, &retlen,
movebuf); movebuf);
...@@ -773,7 +773,7 @@ static int nftl_readblock(struct mtd_blktrans_dev *mbd, unsigned long block, ...@@ -773,7 +773,7 @@ static int nftl_readblock(struct mtd_blktrans_dev *mbd, unsigned long block,
size_t retlen; size_t retlen;
int res = mtd->read(mtd, ptr, 512, &retlen, buffer); int res = mtd->read(mtd, ptr, 512, &retlen, buffer);
if (res < 0 && res != -EUCLEAN) if (res < 0 && !mtd_is_bitflip(res))
return -EIO; return -EIO;
} }
return 0; return 0;
......
...@@ -1079,7 +1079,7 @@ static int onenand_recover_lsb(struct mtd_info *mtd, loff_t addr, int status) ...@@ -1079,7 +1079,7 @@ static int onenand_recover_lsb(struct mtd_info *mtd, loff_t addr, int status)
return status; return status;
/* check if we failed due to uncorrectable error */ /* check if we failed due to uncorrectable error */
if (status != -EBADMSG && status != ONENAND_BBT_READ_ECC_ERROR) if (!mtd_is_eccerr(status) && status != ONENAND_BBT_READ_ECC_ERROR)
return status; return status;
/* check if address lies in MLC region */ /* check if address lies in MLC region */
...@@ -1159,7 +1159,7 @@ static int onenand_mlc_read_ops_nolock(struct mtd_info *mtd, loff_t from, ...@@ -1159,7 +1159,7 @@ static int onenand_mlc_read_ops_nolock(struct mtd_info *mtd, loff_t from,
if (unlikely(ret)) if (unlikely(ret))
ret = onenand_recover_lsb(mtd, from, ret); ret = onenand_recover_lsb(mtd, from, ret);
onenand_update_bufferram(mtd, from, !ret); onenand_update_bufferram(mtd, from, !ret);
if (ret == -EBADMSG) if (mtd_is_eccerr(ret))
ret = 0; ret = 0;
if (ret) if (ret)
break; break;
...@@ -1255,7 +1255,7 @@ static int onenand_read_ops_nolock(struct mtd_info *mtd, loff_t from, ...@@ -1255,7 +1255,7 @@ static int onenand_read_ops_nolock(struct mtd_info *mtd, loff_t from,
this->command(mtd, ONENAND_CMD_READ, from, writesize); this->command(mtd, ONENAND_CMD_READ, from, writesize);
ret = this->wait(mtd, FL_READING); ret = this->wait(mtd, FL_READING);
onenand_update_bufferram(mtd, from, !ret); onenand_update_bufferram(mtd, from, !ret);
if (ret == -EBADMSG) if (mtd_is_eccerr(ret))
ret = 0; ret = 0;
} }
} }
...@@ -1315,7 +1315,7 @@ static int onenand_read_ops_nolock(struct mtd_info *mtd, loff_t from, ...@@ -1315,7 +1315,7 @@ static int onenand_read_ops_nolock(struct mtd_info *mtd, loff_t from,
/* Now wait for load */ /* Now wait for load */
ret = this->wait(mtd, FL_READING); ret = this->wait(mtd, FL_READING);
onenand_update_bufferram(mtd, from, !ret); onenand_update_bufferram(mtd, from, !ret);
if (ret == -EBADMSG) if (mtd_is_eccerr(ret))
ret = 0; ret = 0;
} }
...@@ -1403,7 +1403,7 @@ static int onenand_read_oob_nolock(struct mtd_info *mtd, loff_t from, ...@@ -1403,7 +1403,7 @@ static int onenand_read_oob_nolock(struct mtd_info *mtd, loff_t from,
if (unlikely(ret)) if (unlikely(ret))
ret = onenand_recover_lsb(mtd, from, ret); ret = onenand_recover_lsb(mtd, from, ret);
if (ret && ret != -EBADMSG) { if (ret && !mtd_is_eccerr(ret)) {
printk(KERN_ERR "%s: read failed = 0x%x\n", printk(KERN_ERR "%s: read failed = 0x%x\n",
__func__, ret); __func__, ret);
break; break;
......
...@@ -281,7 +281,7 @@ static int sm_read_sector(struct sm_ftl *ftl, ...@@ -281,7 +281,7 @@ static int sm_read_sector(struct sm_ftl *ftl,
ret = mtd->read_oob(mtd, sm_mkoffset(ftl, zone, block, boffset), &ops); ret = mtd->read_oob(mtd, sm_mkoffset(ftl, zone, block, boffset), &ops);
/* Test for unknown errors */ /* Test for unknown errors */
if (ret != 0 && ret != -EUCLEAN && ret != -EBADMSG) { if (ret != 0 && !mtd_is_bitflip_or_eccerr(ret)) {
dbg("read of block %d at zone %d, failed due to error (%d)", dbg("read of block %d at zone %d, failed due to error (%d)",
block, zone, ret); block, zone, ret);
goto again; goto again;
...@@ -306,7 +306,7 @@ static int sm_read_sector(struct sm_ftl *ftl, ...@@ -306,7 +306,7 @@ static int sm_read_sector(struct sm_ftl *ftl,
} }
/* Test ECC*/ /* Test ECC*/
if (ret == -EBADMSG || if (mtd_is_eccerr(ret) ||
(ftl->smallpagenand && sm_correct_sector(buffer, oob))) { (ftl->smallpagenand && sm_correct_sector(buffer, oob))) {
dbg("read of block %d at zone %d, failed due to ECC error", dbg("read of block %d at zone %d, failed due to ECC error",
......
...@@ -128,7 +128,7 @@ static int verify_eraseblock(int ebnum) ...@@ -128,7 +128,7 @@ static int verify_eraseblock(int ebnum)
for (j = 0; j < pgcnt - 1; ++j, addr += pgsize) { for (j = 0; j < pgcnt - 1; ++j, addr += pgsize) {
/* Do a read to set the internal dataRAMs to different data */ /* Do a read to set the internal dataRAMs to different data */
err = mtd->read(mtd, addr0, bufsize, &read, twopages); err = mtd->read(mtd, addr0, bufsize, &read, twopages);
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != bufsize) { if (err || read != bufsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
...@@ -136,7 +136,7 @@ static int verify_eraseblock(int ebnum) ...@@ -136,7 +136,7 @@ static int verify_eraseblock(int ebnum)
return err; return err;
} }
err = mtd->read(mtd, addrn - bufsize, bufsize, &read, twopages); err = mtd->read(mtd, addrn - bufsize, bufsize, &read, twopages);
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != bufsize) { if (err || read != bufsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
...@@ -146,7 +146,7 @@ static int verify_eraseblock(int ebnum) ...@@ -146,7 +146,7 @@ static int verify_eraseblock(int ebnum)
memset(twopages, 0, bufsize); memset(twopages, 0, bufsize);
read = 0; read = 0;
err = mtd->read(mtd, addr, bufsize, &read, twopages); err = mtd->read(mtd, addr, bufsize, &read, twopages);
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != bufsize) { if (err || read != bufsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
...@@ -164,7 +164,7 @@ static int verify_eraseblock(int ebnum) ...@@ -164,7 +164,7 @@ static int verify_eraseblock(int ebnum)
unsigned long oldnext = next; unsigned long oldnext = next;
/* Do a read to set the internal dataRAMs to different data */ /* Do a read to set the internal dataRAMs to different data */
err = mtd->read(mtd, addr0, bufsize, &read, twopages); err = mtd->read(mtd, addr0, bufsize, &read, twopages);
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != bufsize) { if (err || read != bufsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
...@@ -172,7 +172,7 @@ static int verify_eraseblock(int ebnum) ...@@ -172,7 +172,7 @@ static int verify_eraseblock(int ebnum)
return err; return err;
} }
err = mtd->read(mtd, addrn - bufsize, bufsize, &read, twopages); err = mtd->read(mtd, addrn - bufsize, bufsize, &read, twopages);
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != bufsize) { if (err || read != bufsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
...@@ -182,7 +182,7 @@ static int verify_eraseblock(int ebnum) ...@@ -182,7 +182,7 @@ static int verify_eraseblock(int ebnum)
memset(twopages, 0, bufsize); memset(twopages, 0, bufsize);
read = 0; read = 0;
err = mtd->read(mtd, addr, bufsize, &read, twopages); err = mtd->read(mtd, addr, bufsize, &read, twopages);
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != bufsize) { if (err || read != bufsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
...@@ -231,7 +231,7 @@ static int crosstest(void) ...@@ -231,7 +231,7 @@ static int crosstest(void)
read = 0; read = 0;
addr = addrn - pgsize - pgsize; addr = addrn - pgsize - pgsize;
err = mtd->read(mtd, addr, pgsize, &read, pp1); err = mtd->read(mtd, addr, pgsize, &read, pp1);
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != pgsize) { if (err || read != pgsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
...@@ -244,7 +244,7 @@ static int crosstest(void) ...@@ -244,7 +244,7 @@ static int crosstest(void)
read = 0; read = 0;
addr = addrn - pgsize - pgsize - pgsize; addr = addrn - pgsize - pgsize - pgsize;
err = mtd->read(mtd, addr, pgsize, &read, pp1); err = mtd->read(mtd, addr, pgsize, &read, pp1);
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != pgsize) { if (err || read != pgsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
...@@ -258,7 +258,7 @@ static int crosstest(void) ...@@ -258,7 +258,7 @@ static int crosstest(void)
addr = addr0; addr = addr0;
printk(PRINT_PREF "reading page at %#llx\n", (long long)addr); printk(PRINT_PREF "reading page at %#llx\n", (long long)addr);
err = mtd->read(mtd, addr, pgsize, &read, pp2); err = mtd->read(mtd, addr, pgsize, &read, pp2);
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != pgsize) { if (err || read != pgsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
...@@ -272,7 +272,7 @@ static int crosstest(void) ...@@ -272,7 +272,7 @@ static int crosstest(void)
addr = addrn - pgsize; addr = addrn - pgsize;
printk(PRINT_PREF "reading page at %#llx\n", (long long)addr); printk(PRINT_PREF "reading page at %#llx\n", (long long)addr);
err = mtd->read(mtd, addr, pgsize, &read, pp3); err = mtd->read(mtd, addr, pgsize, &read, pp3);
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != pgsize) { if (err || read != pgsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
...@@ -286,7 +286,7 @@ static int crosstest(void) ...@@ -286,7 +286,7 @@ static int crosstest(void)
addr = addr0; addr = addr0;
printk(PRINT_PREF "reading page at %#llx\n", (long long)addr); printk(PRINT_PREF "reading page at %#llx\n", (long long)addr);
err = mtd->read(mtd, addr, pgsize, &read, pp4); err = mtd->read(mtd, addr, pgsize, &read, pp4);
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != pgsize) { if (err || read != pgsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
...@@ -345,7 +345,7 @@ static int erasecrosstest(void) ...@@ -345,7 +345,7 @@ static int erasecrosstest(void)
printk(PRINT_PREF "reading 1st page of block %d\n", ebnum); printk(PRINT_PREF "reading 1st page of block %d\n", ebnum);
memset(readbuf, 0, pgsize); memset(readbuf, 0, pgsize);
err = mtd->read(mtd, addr0, pgsize, &read, readbuf); err = mtd->read(mtd, addr0, pgsize, &read, readbuf);
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != pgsize) { if (err || read != pgsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
...@@ -383,7 +383,7 @@ static int erasecrosstest(void) ...@@ -383,7 +383,7 @@ static int erasecrosstest(void)
printk(PRINT_PREF "reading 1st page of block %d\n", ebnum); printk(PRINT_PREF "reading 1st page of block %d\n", ebnum);
memset(readbuf, 0, pgsize); memset(readbuf, 0, pgsize);
err = mtd->read(mtd, addr0, pgsize, &read, readbuf); err = mtd->read(mtd, addr0, pgsize, &read, readbuf);
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != pgsize) { if (err || read != pgsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
...@@ -439,7 +439,7 @@ static int erasetest(void) ...@@ -439,7 +439,7 @@ static int erasetest(void)
printk(PRINT_PREF "reading 1st page of block %d\n", ebnum); printk(PRINT_PREF "reading 1st page of block %d\n", ebnum);
err = mtd->read(mtd, addr0, pgsize, &read, twopages); err = mtd->read(mtd, addr0, pgsize, &read, twopages);
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != pgsize) { if (err || read != pgsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
......
...@@ -75,7 +75,7 @@ static int read_eraseblock_by_page(int ebnum) ...@@ -75,7 +75,7 @@ static int read_eraseblock_by_page(int ebnum)
ops.datbuf = NULL; ops.datbuf = NULL;
ops.oobbuf = oobbuf; ops.oobbuf = oobbuf;
ret = mtd->read_oob(mtd, addr, &ops); ret = mtd->read_oob(mtd, addr, &ops);
if ((ret && ret != -EUCLEAN) || if ((ret && !mtd_is_bitflip(ret)) ||
ops.oobretlen != mtd->oobsize) { ops.oobretlen != mtd->oobsize) {
printk(PRINT_PREF "error: read oob failed at " printk(PRINT_PREF "error: read oob failed at "
"%#llx\n", (long long)addr); "%#llx\n", (long long)addr);
......
...@@ -216,7 +216,7 @@ static int read_eraseblock(int ebnum) ...@@ -216,7 +216,7 @@ static int read_eraseblock(int ebnum)
err = mtd->read(mtd, addr, mtd->erasesize, &read, iobuf); err = mtd->read(mtd, addr, mtd->erasesize, &read, iobuf);
/* Ignore corrected ECC errors */ /* Ignore corrected ECC errors */
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != mtd->erasesize) { if (err || read != mtd->erasesize) {
printk(PRINT_PREF "error: read failed at %#llx\n", addr); printk(PRINT_PREF "error: read failed at %#llx\n", addr);
...@@ -237,7 +237,7 @@ static int read_eraseblock_by_page(int ebnum) ...@@ -237,7 +237,7 @@ static int read_eraseblock_by_page(int ebnum)
for (i = 0; i < pgcnt; i++) { for (i = 0; i < pgcnt; i++) {
err = mtd->read(mtd, addr, pgsize, &read, buf); err = mtd->read(mtd, addr, pgsize, &read, buf);
/* Ignore corrected ECC errors */ /* Ignore corrected ECC errors */
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != pgsize) { if (err || read != pgsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
...@@ -263,7 +263,7 @@ static int read_eraseblock_by_2pages(int ebnum) ...@@ -263,7 +263,7 @@ static int read_eraseblock_by_2pages(int ebnum)
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
err = mtd->read(mtd, addr, sz, &read, buf); err = mtd->read(mtd, addr, sz, &read, buf);
/* Ignore corrected ECC errors */ /* Ignore corrected ECC errors */
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != sz) { if (err || read != sz) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
...@@ -278,7 +278,7 @@ static int read_eraseblock_by_2pages(int ebnum) ...@@ -278,7 +278,7 @@ static int read_eraseblock_by_2pages(int ebnum)
if (pgcnt % 2) { if (pgcnt % 2) {
err = mtd->read(mtd, addr, pgsize, &read, buf); err = mtd->read(mtd, addr, pgsize, &read, buf);
/* Ignore corrected ECC errors */ /* Ignore corrected ECC errors */
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (err || read != pgsize) { if (err || read != pgsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", printk(PRINT_PREF "error: read failed at %#llx\n",
......
...@@ -154,7 +154,7 @@ static int do_read(void) ...@@ -154,7 +154,7 @@ static int do_read(void)
} }
addr = eb * mtd->erasesize + offs; addr = eb * mtd->erasesize + offs;
err = mtd->read(mtd, addr, len, &read, readbuf); err = mtd->read(mtd, addr, len, &read, readbuf);
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
err = 0; err = 0;
if (unlikely(err || read != len)) { if (unlikely(err || read != len)) {
printk(PRINT_PREF "error: read failed at 0x%llx\n", printk(PRINT_PREF "error: read failed at 0x%llx\n",
......
...@@ -198,7 +198,7 @@ static int verify_eraseblock(int ebnum) ...@@ -198,7 +198,7 @@ static int verify_eraseblock(int ebnum)
read = 0; read = 0;
err = mtd->read(mtd, addr, subpgsize, &read, readbuf); err = mtd->read(mtd, addr, subpgsize, &read, readbuf);
if (unlikely(err || read != subpgsize)) { if (unlikely(err || read != subpgsize)) {
if (err == -EUCLEAN && read == subpgsize) { if (mtd_is_bitflip(err) && read == subpgsize) {
printk(PRINT_PREF "ECC correction at %#llx\n", printk(PRINT_PREF "ECC correction at %#llx\n",
(long long)addr); (long long)addr);
err = 0; err = 0;
...@@ -226,7 +226,7 @@ static int verify_eraseblock(int ebnum) ...@@ -226,7 +226,7 @@ static int verify_eraseblock(int ebnum)
read = 0; read = 0;
err = mtd->read(mtd, addr, subpgsize, &read, readbuf); err = mtd->read(mtd, addr, subpgsize, &read, readbuf);
if (unlikely(err || read != subpgsize)) { if (unlikely(err || read != subpgsize)) {
if (err == -EUCLEAN && read == subpgsize) { if (mtd_is_bitflip(err) && read == subpgsize) {
printk(PRINT_PREF "ECC correction at %#llx\n", printk(PRINT_PREF "ECC correction at %#llx\n",
(long long)addr); (long long)addr);
err = 0; err = 0;
...@@ -264,7 +264,7 @@ static int verify_eraseblock2(int ebnum) ...@@ -264,7 +264,7 @@ static int verify_eraseblock2(int ebnum)
read = 0; read = 0;
err = mtd->read(mtd, addr, subpgsize * k, &read, readbuf); err = mtd->read(mtd, addr, subpgsize * k, &read, readbuf);
if (unlikely(err || read != subpgsize * k)) { if (unlikely(err || read != subpgsize * k)) {
if (err == -EUCLEAN && read == subpgsize * k) { if (mtd_is_bitflip(err) && read == subpgsize * k) {
printk(PRINT_PREF "ECC correction at %#llx\n", printk(PRINT_PREF "ECC correction at %#llx\n",
(long long)addr); (long long)addr);
err = 0; err = 0;
...@@ -298,7 +298,7 @@ static int verify_eraseblock_ff(int ebnum) ...@@ -298,7 +298,7 @@ static int verify_eraseblock_ff(int ebnum)
read = 0; read = 0;
err = mtd->read(mtd, addr, subpgsize, &read, readbuf); err = mtd->read(mtd, addr, subpgsize, &read, readbuf);
if (unlikely(err || read != subpgsize)) { if (unlikely(err || read != subpgsize)) {
if (err == -EUCLEAN && read == subpgsize) { if (mtd_is_bitflip(err) && read == subpgsize) {
printk(PRINT_PREF "ECC correction at %#llx\n", printk(PRINT_PREF "ECC correction at %#llx\n",
(long long)addr); (long long)addr);
err = 0; err = 0;
......
...@@ -138,7 +138,7 @@ static inline int check_eraseblock(int ebnum, unsigned char *buf) ...@@ -138,7 +138,7 @@ static inline int check_eraseblock(int ebnum, unsigned char *buf)
retry: retry:
err = mtd->read(mtd, addr, len, &read, check_buf); err = mtd->read(mtd, addr, len, &read, check_buf);
if (err == -EUCLEAN) if (mtd_is_bitflip(err))
printk(PRINT_PREF "single bit flip occurred at EB %d " printk(PRINT_PREF "single bit flip occurred at EB %d "
"MTD reported that it was fixed.\n", ebnum); "MTD reported that it was fixed.\n", ebnum);
else if (err) { else if (err) {
......
...@@ -443,7 +443,7 @@ int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, ...@@ -443,7 +443,7 @@ int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
if (err == UBI_IO_BITFLIPS) { if (err == UBI_IO_BITFLIPS) {
scrub = 1; scrub = 1;
err = 0; err = 0;
} else if (err == -EBADMSG) { } else if (mtd_is_eccerr(err)) {
if (vol->vol_type == UBI_DYNAMIC_VOLUME) if (vol->vol_type == UBI_DYNAMIC_VOLUME)
goto out_unlock; goto out_unlock;
scrub = 1; scrub = 1;
......
...@@ -172,9 +172,9 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset, ...@@ -172,9 +172,9 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset,
retry: retry:
err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf); err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf);
if (err) { if (err) {
const char *errstr = (err == -EBADMSG) ? " (ECC error)" : ""; const char *errstr = mtd_is_eccerr(err) ? " (ECC error)" : "";
if (err == -EUCLEAN) { if (mtd_is_bitflip(err)) {
/* /*
* -EUCLEAN is reported if there was a bit-flip which * -EUCLEAN is reported if there was a bit-flip which
* was corrected, so this is harmless. * was corrected, so this is harmless.
...@@ -205,7 +205,7 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset, ...@@ -205,7 +205,7 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset,
* all the requested data. But some buggy drivers might do * all the requested data. But some buggy drivers might do
* this, so we change it to -EIO. * this, so we change it to -EIO.
*/ */
if (read != len && err == -EBADMSG) { if (read != len && mtd_is_eccerr(err)) {
ubi_assert(0); ubi_assert(0);
err = -EIO; err = -EIO;
} }
...@@ -469,7 +469,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum) ...@@ -469,7 +469,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum)
out: out:
mutex_unlock(&ubi->buf_mutex); mutex_unlock(&ubi->buf_mutex);
if (err == UBI_IO_BITFLIPS || err == -EBADMSG) { if (err == UBI_IO_BITFLIPS || mtd_is_eccerr(err)) {
/* /*
* If a bit-flip or data integrity error was detected, the test * If a bit-flip or data integrity error was detected, the test
* has not passed because it happened on a freshly erased * has not passed because it happened on a freshly erased
...@@ -760,7 +760,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, ...@@ -760,7 +760,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
read_err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE); read_err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE);
if (read_err) { if (read_err) {
if (read_err != UBI_IO_BITFLIPS && read_err != -EBADMSG) if (read_err != UBI_IO_BITFLIPS && !mtd_is_eccerr(read_err))
return read_err; return read_err;
/* /*
...@@ -776,7 +776,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, ...@@ -776,7 +776,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
magic = be32_to_cpu(ec_hdr->magic); magic = be32_to_cpu(ec_hdr->magic);
if (magic != UBI_EC_HDR_MAGIC) { if (magic != UBI_EC_HDR_MAGIC) {
if (read_err == -EBADMSG) if (mtd_is_eccerr(read_err))
return UBI_IO_BAD_HDR_EBADMSG; return UBI_IO_BAD_HDR_EBADMSG;
/* /*
...@@ -1032,12 +1032,12 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, ...@@ -1032,12 +1032,12 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
p = (char *)vid_hdr - ubi->vid_hdr_shift; p = (char *)vid_hdr - ubi->vid_hdr_shift;
read_err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset, read_err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset,
ubi->vid_hdr_alsize); ubi->vid_hdr_alsize);
if (read_err && read_err != UBI_IO_BITFLIPS && read_err != -EBADMSG) if (read_err && read_err != UBI_IO_BITFLIPS && !mtd_is_eccerr(read_err))
return read_err; return read_err;
magic = be32_to_cpu(vid_hdr->magic); magic = be32_to_cpu(vid_hdr->magic);
if (magic != UBI_VID_HDR_MAGIC) { if (magic != UBI_VID_HDR_MAGIC) {
if (read_err == -EBADMSG) if (mtd_is_eccerr(read_err))
return UBI_IO_BAD_HDR_EBADMSG; return UBI_IO_BAD_HDR_EBADMSG;
if (ubi_check_pattern(vid_hdr, 0xFF, UBI_VID_HDR_SIZE)) { if (ubi_check_pattern(vid_hdr, 0xFF, UBI_VID_HDR_SIZE)) {
...@@ -1219,7 +1219,7 @@ static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum) ...@@ -1219,7 +1219,7 @@ static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum)
return -ENOMEM; return -ENOMEM;
err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE); err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE);
if (err && err != UBI_IO_BITFLIPS && err != -EBADMSG) if (err && err != UBI_IO_BITFLIPS && !mtd_is_eccerr(err))
goto exit; goto exit;
crc = crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC); crc = crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC);
...@@ -1306,7 +1306,7 @@ static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum) ...@@ -1306,7 +1306,7 @@ static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
p = (char *)vid_hdr - ubi->vid_hdr_shift; p = (char *)vid_hdr - ubi->vid_hdr_shift;
err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset, err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset,
ubi->vid_hdr_alsize); ubi->vid_hdr_alsize);
if (err && err != UBI_IO_BITFLIPS && err != -EBADMSG) if (err && err != UBI_IO_BITFLIPS && !mtd_is_eccerr(err))
goto exit; goto exit;
crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_EC_HDR_SIZE_CRC); crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_EC_HDR_SIZE_CRC);
...@@ -1358,7 +1358,7 @@ int ubi_dbg_check_write(struct ubi_device *ubi, const void *buf, int pnum, ...@@ -1358,7 +1358,7 @@ int ubi_dbg_check_write(struct ubi_device *ubi, const void *buf, int pnum,
} }
err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf1); err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf1);
if (err && err != -EUCLEAN) if (err && !mtd_is_bitflip(err))
goto out_free; goto out_free;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
...@@ -1422,7 +1422,7 @@ int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len) ...@@ -1422,7 +1422,7 @@ int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
} }
err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf); err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf);
if (err && err != -EUCLEAN) { if (err && !mtd_is_bitflip(err)) {
ubi_err("error %d while reading %d bytes from PEB %d:%d, " ubi_err("error %d while reading %d bytes from PEB %d:%d, "
"read %zd bytes", err, len, pnum, offset, read); "read %zd bytes", err, len, pnum, offset, read);
goto error; goto error;
......
...@@ -410,7 +410,7 @@ int ubi_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset, ...@@ -410,7 +410,7 @@ int ubi_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset,
return 0; return 0;
err = ubi_eba_read_leb(ubi, vol, lnum, buf, offset, len, check); err = ubi_eba_read_leb(ubi, vol, lnum, buf, offset, len, check);
if (err && err == -EBADMSG && vol->vol_type == UBI_STATIC_VOLUME) { if (err && mtd_is_eccerr(err) && vol->vol_type == UBI_STATIC_VOLUME) {
ubi_warn("mark volume %d as corrupted", vol_id); ubi_warn("mark volume %d as corrupted", vol_id);
vol->corrupted = 1; vol->corrupted = 1;
} }
......
...@@ -81,7 +81,7 @@ int ubi_check_volume(struct ubi_device *ubi, int vol_id) ...@@ -81,7 +81,7 @@ int ubi_check_volume(struct ubi_device *ubi, int vol_id)
err = ubi_eba_read_leb(ubi, vol, i, buf, 0, size, 1); err = ubi_eba_read_leb(ubi, vol, i, buf, 0, size, 1);
if (err) { if (err) {
if (err == -EBADMSG) if (mtd_is_eccerr(err))
err = 1; err = 1;
break; break;
} }
......
...@@ -395,7 +395,7 @@ static int compare_lebs(struct ubi_device *ubi, const struct ubi_scan_leb *seb, ...@@ -395,7 +395,7 @@ static int compare_lebs(struct ubi_device *ubi, const struct ubi_scan_leb *seb,
} }
err = ubi_io_read_data(ubi, buf, pnum, 0, len); err = ubi_io_read_data(ubi, buf, pnum, 0, len);
if (err && err != UBI_IO_BITFLIPS && err != -EBADMSG) if (err && err != UBI_IO_BITFLIPS && !mtd_is_eccerr(err))
goto out_free_buf; goto out_free_buf;
data_crc = be32_to_cpu(vid_hdr->data_crc); data_crc = be32_to_cpu(vid_hdr->data_crc);
...@@ -793,7 +793,7 @@ static int check_corruption(struct ubi_device *ubi, struct ubi_vid_hdr *vid_hdr, ...@@ -793,7 +793,7 @@ static int check_corruption(struct ubi_device *ubi, struct ubi_vid_hdr *vid_hdr,
err = ubi_io_read(ubi, ubi->peb_buf1, pnum, ubi->leb_start, err = ubi_io_read(ubi, ubi->peb_buf1, pnum, ubi->leb_start,
ubi->leb_size); ubi->leb_size);
if (err == UBI_IO_BITFLIPS || err == -EBADMSG) { if (err == UBI_IO_BITFLIPS || mtd_is_eccerr(err)) {
/* /*
* Bit-flips or integrity errors while reading the data area. * Bit-flips or integrity errors while reading the data area.
* It is difficult to say for sure what type of corruption is * It is difficult to say for sure what type of corruption is
......
...@@ -423,7 +423,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, ...@@ -423,7 +423,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
err = ubi_io_read_data(ubi, leb[seb->lnum], seb->pnum, 0, err = ubi_io_read_data(ubi, leb[seb->lnum], seb->pnum, 0,
ubi->vtbl_size); ubi->vtbl_size);
if (err == UBI_IO_BITFLIPS || err == -EBADMSG) if (err == UBI_IO_BITFLIPS || mtd_is_eccerr(err))
/* /*
* Scrub the PEB later. Note, -EBADMSG indicates an * Scrub the PEB later. Note, -EBADMSG indicates an
* uncorrectable ECC error, but we have our own CRC and * uncorrectable ECC error, but we have our own CRC and
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment