summaryrefslogtreecommitdiff
path: root/futility
diff options
context:
space:
mode:
Diffstat (limited to 'futility')
-rw-r--r--futility/cmd_gbb_utility.c2
-rw-r--r--futility/updater.c4
-rw-r--r--futility/updater_dut.c10
-rw-r--r--futility/updater_utils.c13
4 files changed, 13 insertions, 16 deletions
diff --git a/futility/cmd_gbb_utility.c b/futility/cmd_gbb_utility.c
index db0c04a1..79c14130 100644
--- a/futility/cmd_gbb_utility.c
+++ b/futility/cmd_gbb_utility.c
@@ -440,7 +440,7 @@ static int write_to_flash(struct updater_config *cfg, uint8_t *outbuf,
off_t filesize)
{
#ifdef USE_FLASHROM
- if (is_write_protection_enabled(cfg) == WP_ENABLED) {
+ if (is_write_protection_enabled(cfg)) {
ERROR("You must disable write protection before setting flags.\n");
return -1;
}
diff --git a/futility/updater.c b/futility/updater.c
index 362d5dfc..7f1e215f 100644
--- a/futility/updater.c
+++ b/futility/updater.c
@@ -348,9 +348,7 @@ static int write_optional_firmware(struct updater_config *cfg,
* EC & PD may have different WP settings and we want to write
* only if it is OK.
*/
- if (check_programmer_wp &&
- dut_get_property(DUT_PROP_WP_HW, cfg) == WP_ENABLED &&
- flashrom_get_wp(image->programmer, -1) == WP_ENABLED) {
+ if (check_programmer_wp && is_write_protection_enabled(cfg)) {
ERROR("Target %s is write protected, skip updating.\n",
image->programmer);
return 0;
diff --git a/futility/updater_dut.c b/futility/updater_dut.c
index 6cb03727..634fd447 100644
--- a/futility/updater_dut.c
+++ b/futility/updater_dut.c
@@ -107,7 +107,7 @@ static int dut_get_tpm_fwver(struct updater_config *cfg)
static int dut_get_wp_hw(struct updater_config *cfg)
{
/* wpsw refers to write protection 'switch', not 'software'. */
- return dut_get_property_int("wpsw_cur", cfg) ? WP_ENABLED : WP_DISABLED;
+ return dut_get_property_int("wpsw_cur", cfg);
}
static int dut_get_platform_version(struct updater_config *cfg)
@@ -125,7 +125,13 @@ static int dut_get_platform_version(struct updater_config *cfg)
static int dut_get_wp_sw(struct updater_config *cfg)
{
assert(cfg->image.programmer);
- return flashrom_get_wp(cfg->image.programmer, -1);
+ bool mode;
+
+ if (flashrom_get_wp(cfg->image.programmer, &mode, NULL, NULL, -1)) {
+ /* Read WP status error */
+ return -1;
+ }
+ return mode;
}
/* Helper functions to use or configure the DUT properties. */
diff --git a/futility/updater_utils.c b/futility/updater_utils.c
index b04e56ca..03b0378d 100644
--- a/futility/updater_utils.c
+++ b/futility/updater_utils.c
@@ -362,16 +362,9 @@ const struct vb2_gbb_header *find_gbb(const struct firmware_image *image)
*/
int is_write_protection_enabled(struct updater_config *cfg)
{
- /* Default to enabled. */
- int wp = dut_get_property(DUT_PROP_WP_HW, cfg);
- if (wp == WP_DISABLED)
- return wp;
- /* For error or enabled, check WP SW. */
- wp = dut_get_property(DUT_PROP_WP_SW, cfg);
- /* Consider all errors as enabled. */
- if (wp != WP_DISABLED)
- return WP_ENABLED;
- return wp;
+ /* Assume HW/SW WP are enabled if -1 error code is returned */
+ return dut_get_property(DUT_PROP_WP_HW, cfg) &&
+ dut_get_property(DUT_PROP_WP_SW, cfg);
}
/*