soc: rockchip: mtd_vendor_storage: Erase block in initial progress

Change-Id: Ibbff54cd7a14d5f37ec23a4d52ab557c820caec3
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
This commit is contained in:
Jon Lin
2020-12-25 11:37:46 +08:00
committed by Tao Huang
parent 6d85832a79
commit 508d2dcbfe

View File

@@ -117,6 +117,7 @@ static int mtd_vendor_storage_init(void)
{
int err, offset;
size_t bytes_read;
struct erase_info ei;
mtd = get_mtd_device_nm(vendor_mtd_name);
if (IS_ERR(mtd))
@@ -170,6 +171,14 @@ static int mtd_vendor_storage_init(void)
g_vendor->version = 1;
g_vendor->tag = MTD_VENDOR_TAG;
g_vendor->free_size = sizeof(g_vendor->data);
for (offset = 0; offset < mtd->size; offset += mtd->erasesize) {
if (!mtd_block_isbad(mtd, offset)) {
memset(&ei, 0, sizeof(struct erase_info));
ei.addr = nand_info.blk_offset + offset;
ei.len = mtd->erasesize;
mtd_erase(mtd, &ei);
}
}
}
return 0;