Nico Huber submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved Edward O'Callaghan: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved
layout: Rework normalize_romentries() API

Rename it to layout_sanity_checks() as that is what it does and
let it work on the currently active layout instead of the global
layout.

Change-Id: Ifae3480d4bd68c939c291f05734544e93f00306c
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/54285
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M flash.h
M flashrom.c
M layout.c
M layout.h
4 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/flash.h b/flash.h
index 3912e73..c8c0f9d 100644
--- a/flash.h
+++ b/flash.h
@@ -420,7 +420,6 @@
/* layout.c */
int register_include_arg(struct layout_include_args **args, const char *arg);
int read_romlayout(const char *name);
-int normalize_romentries(const struct flashctx *flash);
void layout_cleanup(struct layout_include_args **args);

/* spi.c */
diff --git a/flashrom.c b/flashrom.c
index b20e3e1..6cc899f 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1865,7 +1865,7 @@
return 1;
}

- if (flash->layout == get_global_layout() && normalize_romentries(flash)) {
+ if (layout_sanity_checks(flash)) {
msg_cerr("Requested regions can not be handled. Aborting.\n");
return 1;
}
diff --git a/layout.c b/layout.c
index 9df0035..e4f1681 100644
--- a/layout.c
+++ b/layout.c
@@ -298,11 +298,10 @@
flashrom_layout_release(layout);
}

-/* Validate and - if needed - normalize layout entries. */
-int normalize_romentries(const struct flashctx *flash)
+int layout_sanity_checks(const struct flashrom_flashctx *const flash)
{
- struct flashrom_layout *const layout = get_global_layout();
- chipsize_t total_size = flash->chip->total_size * 1024;
+ const struct flashrom_layout *const layout = get_layout(flash);
+ const chipsize_t total_size = flash->chip->total_size * 1024;
int ret = 0;

const struct romentry *entry = NULL;
diff --git a/layout.h b/layout.h
index 808c516..f5fbc50 100644
--- a/layout.h
+++ b/layout.h
@@ -62,5 +62,6 @@
const struct romentry *layout_next(const struct flashrom_layout *, const struct romentry *);
int included_regions_overlap(const struct flashrom_layout *const flashrom_layout);
void prepare_layout_for_extraction(struct flashrom_flashctx *flash);
+int layout_sanity_checks(const struct flashrom_flashctx *);

#endif /* !__LAYOUT_H__ */

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

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ifae3480d4bd68c939c291f05734544e93f00306c
Gerrit-Change-Number: 54285
Gerrit-PatchSet: 8
Gerrit-Owner: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Daniel Campello <campello@chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Peter Marheine <pmarheine@chromium.org>
Gerrit-Reviewer: Thomas Heijligen <src@posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter@mailbox.org>
Gerrit-MessageType: merged