spi25_statusreg: Prefer volatile status register writes
Now that libflashprog API users can choose whether to target volatile
or non-volatile status register bits, we turn around the default beha-
vior if both are supported. This way, we won't unnecessarily wear sta-
tus registers in cases where we automatically disable protections.
Change-Id: I92d84e4a140169464e318c7f84690b7665fdb29f
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/194
diff --git a/spi25_statusreg.c b/spi25_statusreg.c
index 8d5e525..f7d988b 100644
--- a/spi25_statusreg.c
+++ b/spi25_statusreg.c
@@ -132,10 +132,10 @@
/* TODO: check database and remove this case! */
msg_cwarn("Missing status register write definition, assuming EWSR is needed\n");
enable_cmd = JEDEC_EWSR;
- } else if ((feature_bits & FEATURE_WRSR_WREN) && (target & WRSR_NON_VOLATILE_BITS)) {
- enable_cmd = JEDEC_WREN;
} else if ((feature_bits & FEATURE_WRSR_EWSR) && (target & WRSR_VOLATILE_BITS)) {
enable_cmd = JEDEC_EWSR;
+ } else if ((feature_bits & FEATURE_WRSR_WREN) && (target & WRSR_NON_VOLATILE_BITS)) {
+ enable_cmd = JEDEC_WREN;
} else {
msg_cerr("Chip doesn't support %svolatile status register writes.\n",
target & WRSR_NON_VOLATILE_BITS ? "non-" : "");