Edward O'Callaghan has uploaded this change for review.
cli_classic.c: Convert do_erase() to libflashrom call
Inline emergency_help_message() to flashrom_flash_erase()
to be consistent with the other libflashrom API's. This
leaves do_erase() a redudant wrapper and moves us a step
closer to cli_classic as a pure libflashrom user.
BUG=b:208132085
TEST=`make`
Change-Id: I8566164e7dbad69cf478b24208014f10fb99e4d0
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
---
M cli_classic.c
M flash.h
M flashrom.c
M tests/chip.c
4 files changed, 13 insertions(+), 21 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/68/60068/1
diff --git a/cli_classic.c b/cli_classic.c
index 101d272..4d702cc 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -841,7 +841,7 @@
else if (extract_it)
ret = do_extract(fill_flash);
else if (erase_it)
- ret = do_erase(fill_flash);
+ ret = flashrom_flash_erase(fill_flash);
else if (write_it)
ret = do_write(fill_flash, filename, referencefile);
else if (verify_it)
diff --git a/flash.h b/flash.h
index 8c24c0c..134d7d3 100644
--- a/flash.h
+++ b/flash.h
@@ -354,7 +354,6 @@
void finalize_flash_access(struct flashctx *);
int do_read(struct flashctx *, const char *filename);
int do_extract(struct flashctx *);
-int do_erase(struct flashctx *);
int do_write(struct flashctx *, const char *const filename, const char *const referencefile);
int do_verify(struct flashctx *, const char *const filename);
int register_chip_restore(chip_restore_fn_cb_t func, struct flashctx *flash, uint8_t status);
diff --git a/flashrom.c b/flashrom.c
index dc09b89..c2bf9d8 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1899,6 +1899,16 @@
finalize_flash_access(flashctx);
+ /*
+ * 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();
+
return ret;
}
@@ -2196,23 +2206,6 @@
return do_read(flash, NULL);
}
-int do_erase(struct flashctx *const flash)
-{
- const int ret = flashrom_flash_erase(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();
-
- return ret;
-}
-
int do_write(struct flashctx *const flash, const char *const filename, const char *const referencefile)
{
const size_t flash_size = flash->chip->total_size * 1024;
diff --git a/tests/chip.c b/tests/chip.c
index 9c06fe7..e07c900 100644
--- a/tests/chip.c
+++ b/tests/chip.c
@@ -182,7 +182,7 @@
setup_chip(&flashctx, &layout, &mock_chip, param);
printf("Erase chip operation started.\n");
- assert_int_equal(0, do_erase(&flashctx));
+ assert_int_equal(0, flashrom_flash_erase(&flashctx));
printf("Erase chip operation done.\n");
teardown(&layout);
@@ -204,7 +204,7 @@
setup_chip(&flashctx, &layout, &mock_chip, param_dup);
printf("Erase chip operation started.\n");
- assert_int_equal(0, do_erase(&flashctx));
+ assert_int_equal(0, flashrom_flash_erase(&flashctx));
printf("Erase chip operation done.\n");
teardown(&layout);
To view, visit change 60068. To unsubscribe, or for help writing mail filters, visit settings.