Hello Julius Werner, Brian Norris,
I'd like you to do a code review. Please visit
https://review.coreboot.org/22509
to review the following change.
Change subject: linux_mtd: print correct wp-status info when whole flash is locked ......................................................................
linux_mtd: print correct wp-status info when whole flash is locked
We would never reach the 'end_found' condition if the flash is entirely write-protected.
BUG=none TEST=`flashrom --wp-status` when whole flash is write-protected BRANCH=none
Change-Id: I0cb1cba321a831f02037fc228ee35aab36de4d4e Signed-off-by: Brian Norris briannorris@chromium.org Reviewed-on: https://chromium-review.googlesource.com/349245 Reviewed-by: David Hendricks dhendrix@chromium.org Reviewed-by: Julius Werner jwerner@chromium.org --- M linux_mtd.c 1 file changed, 7 insertions(+), 10 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/09/22509/1
diff --git a/linux_mtd.c b/linux_mtd.c index 7d1e286..cd12d29 100644 --- a/linux_mtd.c +++ b/linux_mtd.c @@ -484,8 +484,8 @@
static int mtd_wp_status(const struct flashchip *flash) { - uint32_t start = 0, end = 0; - int start_found = 0, end_found = 0; + uint32_t start = 0, len = 0; + int start_found = 0; unsigned int u;
/* For now, assume only one contiguous region can be locked (NOR) */ @@ -506,23 +506,20 @@ start = erase_info.start; start_found = 1; } + len += mtd_erasesize; } else if (rc == 0) { if (start_found) { - end = erase_info.start; - end_found = 1; + /* TODO: changes required for supporting non-contiguous locked regions */ + break; } }
- if (start_found && end_found) { - /* TODO: changes required for supporting non-contiguous locked regions */ - break; - } }
msg_cinfo("WP: write protect is %s.\n", - (start_found && end_found)? "enabled": "disabled"); + start_found ? "enabled": "disabled"); msg_pinfo("WP: write protect range: start=0x%08x, " - "len=0x%08x\n", start, end - start); + "len=0x%08x\n", start, len);
return 0; }