mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
drivers: rkflash: Fix mtd mark bad strategy
1.Fix wrong return value 2.Results are subject to back reading verification Change-Id: Ifd3965423261617bdaeecc10fd4da28cb703b2aa Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
This commit is contained in:
@@ -188,19 +188,27 @@ static int sfc_markbad_mtd(struct mtd_info *mtd, loff_t ofs)
|
||||
/* Erase block before marking it bad. */
|
||||
ret = sfc_nand_erase_block(0, ofs >> mtd->writesize_shift);
|
||||
if (ret)
|
||||
goto out;
|
||||
rkflash_print_error("%s erase fail ofs 0x%llx ret=%d\n",
|
||||
__func__, ofs, ret);
|
||||
|
||||
/* Mark bad. */
|
||||
ret = sfc_nand_mark_bad_block(0, ofs >> mtd->writesize_shift);
|
||||
if (ret)
|
||||
goto out;
|
||||
rkflash_print_error("%s mark fail ofs 0x%llx ret=%d\n",
|
||||
__func__, ofs, ret);
|
||||
|
||||
out:
|
||||
mutex_unlock(p_dev->lock);
|
||||
if (!ret) {
|
||||
/* Mark bad recheck */
|
||||
if (sfc_nand_check_bad_block(0, ofs >> mtd->writesize_shift)) {
|
||||
mtd->ecc_stats.badblocks++;
|
||||
ret = 0;
|
||||
} else {
|
||||
rkflash_print_error("%s recheck fail ofs 0x%llx ret=%d\n",
|
||||
__func__, ofs, ret);
|
||||
ret = -EIO;
|
||||
}
|
||||
|
||||
mutex_unlock(p_dev->lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user