summaryrefslogtreecommitdiffstats
path: root/libflashrom.c
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2022-05-16 15:38:18 +1000
committerEdward O'Callaghan <quasisec@chromium.org>2022-06-21 03:38:49 +0000
commitf630a1623f84b452873e3fc69d608925d90fd85b (patch)
tree3656eb2d97bc0d869d0e6cb50abe3baa643beb7c /libflashrom.c
parentfac9fc28f5a6cadf7c94264f429faa597a2058ac (diff)
downloadflashrom-f630a1623f84b452873e3fc69d608925d90fd85b.tar.gz
flashrom-f630a1623f84b452873e3fc69d608925d90fd85b.tar.bz2
flashrom-f630a1623f84b452873e3fc69d608925d90fd85b.zip
writeprotect.c: Allow opaque masters to hook {read,write}_register()
Allow specialisation in opaque masters, such as ichspi hwseq, to write to status registers. Also update the dispatch logic in libflashrom to call wp code when status register access functions are provided by an opaque master. BUG=none BRANCH=none TEST=flashrom --wp-status on AMD and Intel DUTs Change-Id: I3ab0d7f5f48338c8ecb118a69651c203fbc516ac Signed-off-by: Edward O'Callaghan <quasisec@google.com> Signed-off-by: Nikolai Artemiev <nartemiev@google.com> Co-Authored-by: Nikolai Artemiev <nartemiev@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/64375 Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'libflashrom.c')
-rw-r--r--libflashrom.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/libflashrom.c b/libflashrom.c
index 0c6613e94..3e28938c9 100644
--- a/libflashrom.c
+++ b/libflashrom.c
@@ -470,34 +470,34 @@ void flashrom_wp_get_range(size_t *start, size_t *len, const struct flashrom_wp_
enum flashrom_wp_result flashrom_wp_write_cfg(struct flashctx *flash, const struct flashrom_wp_cfg *cfg)
{
- if (flash->mst->buses_supported & BUS_SPI)
- return wp_write_cfg(flash, cfg);
-
if (flash->mst->buses_supported & BUS_PROG && flash->mst->opaque.wp_write_cfg)
return flash->mst->opaque.wp_write_cfg(flash, cfg);
+ if (wp_operations_available(flash))
+ return wp_write_cfg(flash, cfg);
+
return FLASHROM_WP_ERR_OTHER;
}
enum flashrom_wp_result flashrom_wp_read_cfg(struct flashrom_wp_cfg *cfg, struct flashctx *flash)
{
- if (flash->mst->buses_supported & BUS_SPI)
- return wp_read_cfg(cfg, flash);
-
if (flash->mst->buses_supported & BUS_PROG && flash->mst->opaque.wp_read_cfg)
return flash->mst->opaque.wp_read_cfg(cfg, flash);
+ if (wp_operations_available(flash))
+ return wp_read_cfg(cfg, flash);
+
return FLASHROM_WP_ERR_OTHER;
}
enum flashrom_wp_result flashrom_wp_get_available_ranges(struct flashrom_wp_ranges **list, struct flashrom_flashctx *flash)
{
- if (flash->mst->buses_supported & BUS_SPI)
- return wp_get_available_ranges(list, flash);
-
if (flash->mst->buses_supported & BUS_PROG && flash->mst->opaque.wp_get_ranges)
return flash->mst->opaque.wp_get_ranges(list, flash);
+ if (wp_operations_available(flash))
+ return wp_get_available_ranges(list, flash);
+
return FLASHROM_WP_ERR_OTHER;
}