aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMikhail Kshevetskiy <mikhail.kshevetskiy@oktetlabs.ru>2020-06-22 16:16:34 +0300
committerJagan Teki <jagan@amarulasolutions.com>2020-12-18 16:16:36 +0530
commit25f068aa3e8aebda96a1a908a0bebd56f59374ca (patch)
tree6e9c7cee041d6e9c454ec46b145ad68a9425e724 /drivers
parent031b89e51b0fde5aabc258c2eb9c3f913f375f65 (diff)
downloadu-boot-25f068aa3e8aebda96a1a908a0bebd56f59374ca.zip
u-boot-25f068aa3e8aebda96a1a908a0bebd56f59374ca.tar.gz
u-boot-25f068aa3e8aebda96a1a908a0bebd56f59374ca.tar.bz2
mtd: spinand: enable erasing of bad mtd blocks
U-Boot is able to erase bad mtd blocks on raw nand devices, but this is not true for spinand flashes. Lets enable this feature for spinand flashes as well. This is extemelly useful for flash testing. Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@oktetlabs.ru>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/nand/core.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/mtd/nand/core.c b/drivers/mtd/nand/core.c
index 6fbd24b..219efdc 100644
--- a/drivers/mtd/nand/core.c
+++ b/drivers/mtd/nand/core.c
@@ -130,10 +130,18 @@ EXPORT_SYMBOL_GPL(nanddev_isreserved);
*/
int nanddev_erase(struct nand_device *nand, const struct nand_pos *pos)
{
+ unsigned int entry;
+
if (nanddev_isbad(nand, pos) || nanddev_isreserved(nand, pos)) {
pr_warn("attempt to erase a bad/reserved block @%llx\n",
nanddev_pos_to_offs(nand, pos));
- return -EIO;
+ if (nanddev_isreserved(nand, pos))
+ return -EIO;
+
+ /* remove bad block from BBT */
+ entry = nanddev_bbt_pos_to_entry(nand, pos);
+ nanddev_bbt_set_block_status(nand, entry,
+ NAND_BBT_BLOCK_STATUS_UNKNOWN);
}
return nand->ops->erase(nand, pos);