summaryrefslogtreecommitdiffstats
path: root/flashrom.c
diff options
context:
space:
mode:
authorNico Huber <nico.h@gmx.de>2019-06-15 22:29:08 +0200
committerNico Huber <nico.h@gmx.de>2019-06-17 08:33:09 +0000
commit5ca5523fd8f6800c32cbc8f3724b393e791cebd6 (patch)
treef68209e48c9c54006a5af5c09e6d0b5d4ad1c9d9 /flashrom.c
parent70461a9524fc84ec5c095f11927cffa0429a6267 (diff)
downloadflashrom-5ca5523fd8f6800c32cbc8f3724b393e791cebd6.tar.gz
flashrom-5ca5523fd8f6800c32cbc8f3724b393e791cebd6.tar.bz2
flashrom-5ca5523fd8f6800c32cbc8f3724b393e791cebd6.zip
layout: Introduce layout_next_included()
Change-Id: Ib01c8af06c3f84eafbd585760e74c3c287b9fa7d Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/33518 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Diffstat (limited to 'flashrom.c')
-rw-r--r--flashrom.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/flashrom.c b/flashrom.c
index 2d3cd1853..b47d0a2ce 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1597,14 +1597,11 @@ static int check_block_eraser(const struct flashctx *flash, int k, int log)
static int read_by_layout(struct flashctx *const flashctx, uint8_t *const buffer)
{
const struct flashrom_layout *const layout = get_layout(flashctx);
+ const struct romentry *entry = NULL;
- size_t i;
- for (i = 0; i < layout->num_entries; ++i) {
- if (!layout->entries[i].included)
- continue;
-
- const chipoff_t region_start = layout->entries[i].start;
- const chipsize_t region_len = layout->entries[i].end - layout->entries[i].start + 1;
+ while ((entry = layout_next_included(layout, entry))) {
+ const chipoff_t region_start = entry->start;
+ const chipsize_t region_len = entry->end - entry->start + 1;
if (flashctx->chip->read(flashctx, buffer + region_start, region_start, region_len))
return 1;
@@ -1681,17 +1678,14 @@ static int walk_by_layout(struct flashctx *const flashctx, struct walk_info *con
const per_blockfn_t per_blockfn)
{
const struct flashrom_layout *const layout = get_layout(flashctx);
+ const struct romentry *entry = NULL;
all_skipped = true;
msg_cinfo("Erasing and writing flash chip... ");
- size_t i;
- for (i = 0; i < layout->num_entries; ++i) {
- if (!layout->entries[i].included)
- continue;
-
- info->region_start = layout->entries[i].start;
- info->region_end = layout->entries[i].end;
+ while ((entry = layout_next_included(layout, entry))) {
+ info->region_start = entry->start;
+ info->region_end = entry->end;
size_t j;
int error = 1; /* retry as long as it's 1 */
@@ -1962,14 +1956,11 @@ static int verify_by_layout(struct flashctx *const flashctx,
void *const curcontents, const uint8_t *const newcontents)
{
const struct flashrom_layout *const layout = get_layout(flashctx);
+ const struct romentry *entry = NULL;
- size_t i;
- for (i = 0; i < layout->num_entries; ++i) {
- if (!layout->entries[i].included)
- continue;
-
- const chipoff_t region_start = layout->entries[i].start;
- const chipsize_t region_len = layout->entries[i].end - layout->entries[i].start + 1;
+ while ((entry = layout_next_included(layout, entry))) {
+ const chipoff_t region_start = entry->start;
+ const chipsize_t region_len = entry->end - entry->start + 1;
if (flashctx->chip->read(flashctx, curcontents + region_start, region_start, region_len))
return 1;