Nikolai Artemiev has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/58739 )
Change subject: [RFC] writeprotect, cli_classic: enable writeprotect ......................................................................
[RFC] writeprotect, cli_classic: enable writeprotect
Enable writeprotect. Tested with: GD25LQ128, GD25Q32, GD25Q64, GD25Q256, MX25L2006E, and W25X40.
TEST=flashrom --wp-{enable,disable,range,list,status} BRANCH=none
Change-Id: Id64a0789b05c5bc362865f7888f037367d6d566b Signed-off-by: Nikolai Artemiev nartemiev@google.com --- M cli_classic.c M writeprotect.c M writeprotect.h 3 files changed, 8 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/39/58739/1
diff --git a/cli_classic.c b/cli_classic.c index f078fb3..c735bfd 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -712,8 +712,7 @@ goto out_shutdown; }
- /* Disable writeprotect until support is complete */ - if (any_wp_op) { + if (any_wp_op && !wp_supported(fill_flash)) { msg_gerr("Error: write protect is not supported on this flash chip.\n"); ret = 1; goto out_shutdown; diff --git a/writeprotect.c b/writeprotect.c index 011f5d0..b35136e 100644 --- a/writeprotect.c +++ b/writeprotect.c @@ -240,6 +240,11 @@ return 0; }
+bool wp_supported(struct flashctx *flash) +{ + return flash->chip->decode_range != NULL; +} + int wp_get_ranges(struct flashctx *flash, struct wp_range *ranges, size_t *count) { struct wp_range_wpst_pair range_wpst_pairs[MAX_WP_RANGES]; diff --git a/writeprotect.h b/writeprotect.h index 0cfb2da..8080937 100644 --- a/writeprotect.h +++ b/writeprotect.h @@ -53,6 +53,8 @@ uint32_t len; };
+bool wp_supported(struct flashctx *flash); + #define MAX_WP_RANGES 128 int wp_get_ranges(struct flashctx *flash, struct wp_range *ranges, size_t *count);