summaryrefslogtreecommitdiffstats
path: root/flashrom.c
diff options
context:
space:
mode:
authorNico Huber <nico.h@gmx.de>2019-06-16 03:27:26 +0200
committerNico Huber <nico.h@gmx.de>2021-06-26 15:55:57 +0000
commita1afc84156fdd1efce124a9f1441058db10d02ff (patch)
tree0cd4a9a75578fee8da8344a557821a039dcde129 /flashrom.c
parenta630a564135f6fd7a7e14f0e002fb02df7d8d66f (diff)
downloadflashrom-a1afc84156fdd1efce124a9f1441058db10d02ff.tar.gz
flashrom-a1afc84156fdd1efce124a9f1441058db10d02ff.tar.bz2
flashrom-a1afc84156fdd1efce124a9f1441058db10d02ff.zip
Pass layout directly to verify_by_layout()
It used the current layout from the flash context, before. This made it necessary to replace the pointer on-the-fly. Passing the layout directly, works without that stunt. Change-Id: Id496deec85c18bdfe968df6a798b626eb9cfbed5 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/33520 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'flashrom.c')
-rw-r--r--flashrom.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/flashrom.c b/flashrom.c
index 7c91fa14b..34cbdac84 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1513,16 +1513,18 @@ static int write_by_layout(struct flashctx *const flashctx,
* contents will be compared.
*
* @param flashctx Flash context to be used.
+ * @param layout Flash layout information.
* @param curcontents A buffer of full chip size to read current chip contents into.
* @param newcontents The new image to compare to.
* @return 0 on success,
* 1 if reading failed,
* 3 if the contents don't match.
*/
-static int verify_by_layout(struct flashctx *const flashctx,
- void *const curcontents, const uint8_t *const newcontents)
+static int verify_by_layout(
+ struct flashctx *const flashctx,
+ const struct flashrom_layout *const layout,
+ void *const curcontents, const uint8_t *const newcontents)
{
- const struct flashrom_layout *const layout = get_layout(flashctx);
const struct romentry *entry = NULL;
while ((entry = layout_next_included(layout, entry))) {
@@ -2029,6 +2031,8 @@ int flashrom_image_write(struct flashctx *const flashctx, void *const buffer, co
const size_t flash_size = flashctx->chip->total_size * 1024;
const bool verify_all = flashctx->flags.verify_whole_chip;
const bool verify = flashctx->flags.verify_after_write;
+ const struct flashrom_layout *const verify_layout =
+ verify_all ? get_default_layout(flashctx) : get_layout(flashctx);
if (buffer_len != flash_size)
return 4;
@@ -2117,19 +2121,14 @@ int flashrom_image_write(struct flashctx *const flashctx, void *const buffer, co
/* Verify only if we actually changed something. */
if (verify && !all_skipped) {
- const struct flashrom_layout *const layout_bak = flashctx->layout;
-
msg_cinfo("Verifying flash... ");
/* Work around chips which need some time to calm down. */
programmer_delay(1000*1000);
- if (verify_all) {
+ if (verify_all)
combine_image_by_layout(flashctx, newcontents, oldcontents);
- flashctx->layout = NULL;
- }
- ret = verify_by_layout(flashctx, curcontents, newcontents);
- flashctx->layout = layout_bak;
+ ret = verify_by_layout(flashctx, verify_layout, curcontents, newcontents);
/* If we tried to write, and verification now fails, we
might have an emergency situation. */
if (ret)
@@ -2165,6 +2164,7 @@ _free_ret:
*/
int flashrom_image_verify(struct flashctx *const flashctx, const void *const buffer, const size_t buffer_len)
{
+ const struct flashrom_layout *const layout = get_layout(flashctx);
const size_t flash_size = flashctx->chip->total_size * 1024;
if (buffer_len != flash_size)
@@ -2183,7 +2183,7 @@ int flashrom_image_verify(struct flashctx *const flashctx, const void *const buf
goto _free_ret;
msg_cinfo("Verifying flash... ");
- ret = verify_by_layout(flashctx, curcontents, newcontents);
+ ret = verify_by_layout(flashctx, layout, curcontents, newcontents);
if (!ret)
msg_cinfo("VERIFIED.\n");