aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/mtd.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/cmd/mtd.c b/cmd/mtd.c
index 1b6b8dd..a559b5a 100644
--- a/cmd/mtd.c
+++ b/cmd/mtd.c
@@ -387,7 +387,7 @@ static int do_mtd_erase(cmd_tbl_t *cmdtp, int flag, int argc,
struct mtd_info *mtd;
u64 off, len;
bool scrub;
- int ret;
+ int ret = 0;
if (argc < 2)
return CMD_RET_USAGE;
@@ -423,22 +423,22 @@ static int do_mtd_erase(cmd_tbl_t *cmdtp, int flag, int argc,
erase_op.mtd = mtd;
erase_op.addr = off;
- erase_op.len = len;
+ erase_op.len = mtd->erasesize;
erase_op.scrub = scrub;
- while (erase_op.len) {
+ while (len) {
ret = mtd_erase(mtd, &erase_op);
- /* Abort if its not a bad block error */
- if (ret != -EIO)
- break;
-
- printf("Skipping bad block at 0x%08llx\n", erase_op.fail_addr);
+ if (ret) {
+ /* Abort if its not a bad block error */
+ if (ret != -EIO)
+ break;
+ printf("Skipping bad block at 0x%08llx\n",
+ erase_op.addr);
+ }
- /* Skip bad block and continue behind it */
- erase_op.len -= erase_op.fail_addr - erase_op.addr;
- erase_op.len -= mtd->erasesize;
- erase_op.addr = erase_op.fail_addr + mtd->erasesize;
+ len -= mtd->erasesize;
+ erase_op.addr += mtd->erasesize;
}
if (ret && ret != -EIO)