diff mbox

[v2,5/5] external/pflash: Use blocklevel_smart_erase()

Message ID 20170419041143.12042-6-cyril.bur@au1.ibm.com
State Not Applicable
Headers show

Commit Message

Cyril Bur April 19, 2017, 4:11 a.m. UTC
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
---
 external/pflash/pflash.c | 31 ++++---------------------------
 1 file changed, 4 insertions(+), 27 deletions(-)
diff mbox

Patch

diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index 2f9cc71d..a344987e 100644
--- a/external/pflash/pflash.c
+++ b/external/pflash/pflash.c
@@ -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);
@@ -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