Skip to content

Commit

Permalink
external/pflash: Use blocklevel_smart_erase()
Browse files Browse the repository at this point in the history
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
cyrilbur-ibm authored and stewartsmith committed Apr 7, 2017
1 parent 7bfa8e5 commit 47a4831
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions external/pflash/pflash.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ static void erase_chip(void)

static void erase_range(uint32_t start, uint32_t size, bool will_program)
{
uint32_t done = 0;
int rc;

printf("About to erase 0x%08x..0x%08x !\n", start, start + size);
Expand All @@ -247,33 +246,11 @@ static void erase_range(uint32_t start, uint32_t size, bool will_program)
}

printf("Erasing...\n");
progress_init(size >> 8);
while(size) {
/* If aligned to 64k and at least 64k, use 64k erase */
if ((start & 0xffff) == 0 && size >= 0x10000) {
rc = blocklevel_erase(bl, start, 0x10000);
if (rc) {
fprintf(stderr, "Error %d erasing 0x%08x\n",
rc, start);
exit(1);
}
start += 0x10000;
size -= 0x10000;
done += 0x10000;
} else {
rc = blocklevel_erase(bl, start, 0x1000);
if (rc) {
fprintf(stderr, "Error %d erasing 0x%08x\n",
rc, start);
exit(1);
}
start += 0x1000;
size -= 0x1000;
done += 0x1000;
}
progress_tick(done >> 8);
rc = blocklevel_smart_erase(bl, start, size);
if (rc) {
fprintf(stderr, "Failed to blocklevel_smart_erase(): %d\n", rc);
return;
}
progress_end();

/* If this is a flash partition, mark it empty if we aren't
* going to program over it as well
Expand Down

0 comments on commit 47a4831

Please sign in to comment.