cli_classic.c: Convert do_erase() to libflashrom call
Inline emergency_help_message() to cli_classic call site.
This leaves do_erase() a redudant wrapper and moves us a step
closer to cli_classic as a pure libflashrom user by using
flashrom_flash_erase().
Tested: `flashrom -E`
Change-Id: I8566164e7dbad69cf478b24208014f10fb99e4d0
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/60068
Original-Reviewed-by: Nico Huber <nico.h@gmx.de>
Original-Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72287
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/cli_classic.c b/cli_classic.c
index 9a6b6c0..882ea2e 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -668,8 +668,18 @@
programmer_delay(100000);
if (read_it)
ret = do_read(fill_flash, filename);
- else if (erase_it)
- ret = do_erase(fill_flash);
+ else if (erase_it) {
+ ret = flashrom_flash_erase(fill_flash);
+ /*
+ * FIXME: Do we really want the scary warning if erase failed?
+ * After all, after erase the chip is either blank or partially
+ * blank or it has the old contents. A blank chip won't boot,
+ * so if the user wanted erase and reboots afterwards, the user
+ * knows very well that booting won't work.
+ */
+ if (ret)
+ emergency_help_message();
+ }
else if (write_it)
ret = do_write(fill_flash, filename, referencefile);
else if (verify_it)