Nikolai Artemiev has uploaded this change for review.

View Change

WIP: spi25_statusreg.c: restore SR contents at flashrom exit

spi_disable_blockprotect_generic() now uses
register_chip_restore() to reset the chip's status
register at flashrom exit.

Imported from cros flashrom at `b170dd4e1d5c33b169c5`

Change-Id: If2f0e73518d40519b7569f627c90a34c364df47c
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
---
M spi25_statusreg.c
1 file changed, 9 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/78/48778/1
diff --git a/spi25_statusreg.c b/spi25_statusreg.c
index 34f9ad4..5dda912 100644
--- a/spi25_statusreg.c
+++ b/spi25_statusreg.c
@@ -108,6 +108,12 @@
return readarr[0];
}

+static int spi_restore_status(struct flashctx *flash, uint8_t status)
+{
+ msg_cdbg("restoring chip status (0x%02x)\n", status);
+ return spi_write_status_register(flash, status);
+}
+
/* A generic block protection disable.
* Tests if a protection is enabled with the block protection mask (bp_mask) and returns success otherwise.
* Tests if the register bits are locked with the lock_mask (lock_mask).
@@ -139,6 +145,9 @@
return 0;
}

+ /* restore status register content upon exit */
+ register_chip_restore(spi_restore_status, flash, status);
+
msg_cdbg("Some block protection in effect, disabling... ");
if ((status & lock_mask) != 0) {
msg_cdbg("\n\tNeed to disable the register lock first... ");

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

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: If2f0e73518d40519b7569f627c90a34c364df47c
Gerrit-Change-Number: 48778
Gerrit-PatchSet: 1
Gerrit-Owner: Nikolai Artemiev <nartemiev@google.com>
Gerrit-MessageType: newchange