Daniel Campello has uploaded this change for review.
cli_classic.c: reorder writeprotect operation processing
Make sure that layout is set before. Also as the comment instructs make
sure that set_rw_range happens before set_wp_enable.
Signed-off-by: Daniel Campello <campello@chromium.org>
Change-Id: I7480d3f947aaaf30093d056226fe0c402763efdc
---
M cli_classic.c
1 file changed, 61 insertions(+), 61 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/30/52530/1
diff --git a/cli_classic.c b/cli_classic.c
index 0557b80..78ae76f 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -770,66 +770,6 @@
goto out_shutdown;
}
- if (wp_status) {
- if (fill_flash->chip->wp && fill_flash->chip->wp->wp_status) {
- ret |= fill_flash->chip->wp->wp_status(fill_flash);
- } else {
- msg_gerr("Error: write protect is not supported on this flash chip.\n");
- ret = 1;
- }
- goto out_shutdown;
- }
-
- /* Note: set_wp_disable should be done before setting the range */
- if (set_wp_disable) {
- if (fill_flash->chip->wp && fill_flash->chip->wp->disable) {
- ret |= fill_flash->chip->wp->disable(fill_flash);
- } else {
- msg_gerr("Error: write protect is not supported on this flash chip.\n");
- ret = 1;
- goto out_shutdown;
- }
- }
-
- if (!ret && set_wp_enable) {
- enum wp_mode wp_mode;
-
- if (wp_mode_opt)
- wp_mode = get_wp_mode(wp_mode_opt);
- else
- wp_mode = WP_MODE_HARDWARE; /* default */
-
- if (wp_mode == WP_MODE_UNKNOWN) {
- msg_gerr("Error: Invalid WP mode: \"%s\"\n", wp_mode_opt);
- ret = 1;
- goto out_shutdown;
- }
-
- if (fill_flash->chip->wp && fill_flash->chip->wp->enable) {
- ret |= fill_flash->chip->wp->enable(fill_flash, wp_mode);
- } else {
- msg_gerr("Error: write protect is not supported on this flash chip.\n");
- ret = 1;
- goto out_shutdown;
- }
- }
-
- if (wp_list) {
- msg_ginfo("Valid write protection ranges:\n");
- if (fill_flash->chip->wp && fill_flash->chip->wp->list_ranges) {
- ret |= fill_flash->chip->wp->list_ranges(fill_flash);
- } else {
- msg_gerr("Error: write protect is not supported on this flash chip.\n");
- ret = 1;
- }
- goto out_shutdown;
- }
-
- /* Note: set_wp_range must happen before set_wp_enable */
- if (set_wp_range) {
- ret |= fill_flash->chip->wp->set_range(fill_flash, wp_start, wp_len);
- }
-
if (layoutfile) {
layout = get_global_layout();
} else if (ifd && (flashrom_layout_read_from_ifd(&layout, fill_flash, NULL, 0) ||
@@ -869,8 +809,68 @@
ret = 1;
goto out_shutdown;
}
-
flashrom_layout_set(fill_flash, layout);
+
+ if (wp_status) {
+ if (fill_flash->chip->wp && fill_flash->chip->wp->wp_status) {
+ ret |= fill_flash->chip->wp->wp_status(fill_flash);
+ } else {
+ msg_gerr("Error: write protect is not supported on this flash chip.\n");
+ ret = 1;
+ }
+ goto out_shutdown;
+ }
+
+ /* Note: set_wp_disable should be done before setting the range */
+ if (set_wp_disable) {
+ if (fill_flash->chip->wp && fill_flash->chip->wp->disable) {
+ ret |= fill_flash->chip->wp->disable(fill_flash);
+ } else {
+ msg_gerr("Error: write protect is not supported on this flash chip.\n");
+ ret = 1;
+ goto out_shutdown;
+ }
+ }
+
+ /* Note: set_wp_range must happen before set_wp_enable */
+ if (set_wp_range) {
+ ret |= fill_flash->chip->wp->set_range(fill_flash, wp_start, wp_len);
+ }
+
+ if (!ret && set_wp_enable) {
+ enum wp_mode wp_mode;
+
+ if (wp_mode_opt)
+ wp_mode = get_wp_mode(wp_mode_opt);
+ else
+ wp_mode = WP_MODE_HARDWARE; /* default */
+
+ if (wp_mode == WP_MODE_UNKNOWN) {
+ msg_gerr("Error: Invalid WP mode: \"%s\"\n", wp_mode_opt);
+ ret = 1;
+ goto out_shutdown;
+ }
+
+ if (fill_flash->chip->wp && fill_flash->chip->wp->enable) {
+ ret |= fill_flash->chip->wp->enable(fill_flash, wp_mode);
+ } else {
+ msg_gerr("Error: write protect is not supported on this flash chip.\n");
+ ret = 1;
+ goto out_shutdown;
+ }
+ }
+
+ if (wp_list) {
+ msg_ginfo("Valid write protection ranges:\n");
+ if (fill_flash->chip->wp && fill_flash->chip->wp->list_ranges) {
+ ret |= fill_flash->chip->wp->list_ranges(fill_flash);
+ } else {
+ msg_gerr("Error: write protect is not supported on this flash chip.\n");
+ ret = 1;
+ }
+ goto out_shutdown;
+ }
+
flashrom_flag_set(fill_flash, FLASHROM_FLAG_FORCE, !!force);
#if CONFIG_INTERNAL == 1
flashrom_flag_set(fill_flash, FLASHROM_FLAG_FORCE_BOARDMISMATCH, !!force_boardmismatch);
To view, visit change 52530. To unsubscribe, or for help writing mail filters, visit settings.