Aarya has uploaded this change for review.
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: Ib14d1b87958ae933aae937eb5233afcfa0f32582
Signed-off-by: Aarya Chaumal <aarya.chaumal@gmail.com>
---
M flashrom.c
1 file changed, 23 insertions(+), 11 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/70/67470/1
diff --git a/flashrom.c b/flashrom.c
index a0a7627..8f9e6a2 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -65,9 +65,6 @@
*/
static int may_register_shutdown = 0;
-/* Did we change something or was every erase/write skipped (if any)? */
-static bool all_skipped = true;
-
/* Register a function to be executed on programmer shutdown.
* The advantage over atexit() is that you can supply a void pointer which will
* be used as parameter to the registered function upon programmer shutdown.
@@ -875,7 +872,7 @@
chipoff_t erase_end;
};
/* returns 0 on success, 1 to retry with another erase function, 2 for immediate abort */
-typedef int (*per_blockfn_t)(struct flashctx *, const struct walk_info *, erasefn_t);
+typedef int (*per_blockfn_t)(struct flashctx *, const struct walk_info *, erasefn_t, bool *);
void align_region(const struct erase_layout *layout, struct flashctx *const flashctx, chipoff_t *region_start, chipoff_t *region_end);
@@ -1014,7 +1011,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;
@@ -1063,7 +1060,7 @@
//after erase make it unselected again
erase_layout[i].layout_list[j].selected = false;
msg_cinfo("E(%x:%x)", start_addr, start_addr + block_len - 1);
- all_skipped = false;
+ *all_skipped = false;
}
}
}
@@ -1081,7 +1078,7 @@
//adjust curcontents
memcpy(curcontents + i, newcontents + i, flashctx->chip->page_size);
msg_cinfo("W(%lx:%lx)", i, i + flashctx->chip->page_size);
- all_skipped = false;
+ *all_skipped = false;
}
}
@@ -1117,6 +1114,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) {
@@ -1131,7 +1129,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);
}
@@ -1156,7 +1154,7 @@
* 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;
@@ -1165,7 +1163,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);
}
@@ -1629,7 +1627,8 @@
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 67470. To unsubscribe, or for help writing mail filters, visit settings.