Aarya has uploaded this change for review.

View Change

flashrom.c: Plumb 'all_skipped' global state into func param

The 'all_skipped' global state can be made into a function
parameter if one just follows though the CFG.

Change-Id: Ic7990b0afebd49d2a27e89b03638b64e36c329df
Signed-off-by: Aarya Chaumal <aarya.chaumal@gmail.com>
---
M flashrom.c
1 file changed, 24 insertions(+), 8 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/73/67473/1
diff --git a/flashrom.c b/flashrom.c
index 044dd10..328ab12 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -66,9 +66,6 @@
*/
static bool may_register_shutdown = false;

-/* Did we change something or was every erase/write skipped (if any)? */
-static bool all_skipped = true;
-
struct programmer_cfg {
char *params;
};
@@ -992,7 +989,7 @@
return layout;
}

-static int erase_write(struct flashctx *const flashctx, chipoff_t region_start, chipoff_t region_end, uint8_t* curcontents, uint8_t* newcontents, struct erase_layout *erase_layout)
+static int erase_write(struct flashctx *const flashctx, chipoff_t region_start, chipoff_t region_end, uint8_t* curcontents, uint8_t* newcontents, struct erase_layout *erase_layout, bool *all_skipped)
{
size_t erasefn_count = count_usable_erasers(flashctx);
int ret = 0;
@@ -1039,6 +1036,7 @@
//after erase make it unselected again
erase_layout[i].layout_list[j].selected = false;
msg_cdbg("E(%x:%x)", start_addr, start_addr + block_len - 1);
+ *all_skipped = false;
}
}
}
@@ -1062,6 +1060,7 @@
//adjust curcontents
memcpy(curcontents + i, newcontents + i, flashctx->chip->page_size);
msg_cdbg("W(%lx:%lx)", i, i + flashctx->chip->page_size);
+ *all_skipped = false;
}
}

@@ -1100,6 +1099,7 @@
struct erase_layout *erase_layout = create_erase_layout(flashctx);
int erasefn_count = count_usable_erasers(flashctx);
int ret = 0;
+ bool all_skipped = true;

//not enough memory
if (curcontents == NULL || newcontents == NULL) {
@@ -1114,7 +1114,7 @@
const struct romentry *entry = NULL;

while ((entry = layout_next_included(flash_layout, entry))) {
- ret |= erase_write(flashctx, entry->start, entry->end, curcontents, newcontents, erase_layout);
+ ret |= erase_write(flashctx, entry->start, entry->end, curcontents, newcontents, erase_layout, &all_skipped);
//if ret!=0 ??
assert(!ret);
}
@@ -1139,7 +1139,8 @@
* 1 if anything has gone wrong.
*/
static int write_by_layout(struct flashctx *const flashctx,
- void *const curcontents, const void *const newcontents)
+ void *const curcontents, const void *const newcontents,
+ bool *all_skipped)
{
const struct flashrom_layout *const flash_layout = get_layout(flashctx);
const struct romentry *entry = NULL;
@@ -1148,7 +1149,7 @@
int ret = 0;

while ((entry = layout_next_included(flash_layout, entry))) {
- ret = erase_write(flashctx, entry->start, entry->end, (uint8_t*)curcontents, (uint8_t*)newcontents, erase_layout);
+ ret = erase_write(flashctx, entry->start, entry->end, (uint8_t*)curcontents, (uint8_t*)newcontents, erase_layout, all_skipped);
//if ret!=0 ??
assert(!ret);
}
@@ -1612,7 +1613,9 @@
msg_cinfo("done.\n");
}

- if (write_by_layout(flashctx, curcontents, newcontents)) {
+ bool all_skipped = true;
+
+ if (write_by_layout(flashctx, curcontents, newcontents, &all_skipped)) {
msg_cerr("Uh oh. Erase/write failed. ");
ret = 2;
if (verify_all) {

To view, visit change 67473. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ic7990b0afebd49d2a27e89b03638b64e36c329df
Gerrit-Change-Number: 67473
Gerrit-PatchSet: 1
Gerrit-Owner: Aarya <aarya.chaumal@gmail.com>
Gerrit-MessageType: newchange