summaryrefslogtreecommitdiff
path: root/futility
diff options
context:
space:
mode:
Diffstat (limited to 'futility')
-rw-r--r--futility/flashrom_wp_drv.c50
-rw-r--r--futility/updater.c2
-rw-r--r--futility/updater_utils.c2
-rw-r--r--futility/updater_utils.h9
4 files changed, 2 insertions, 61 deletions
diff --git a/futility/flashrom_wp_drv.c b/futility/flashrom_wp_drv.c
deleted file mode 100644
index ff7a8214..00000000
--- a/futility/flashrom_wp_drv.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * The utility functions for firmware updater.
- */
-
-#include <libflashrom.h>
-
-#include "updater.h"
-
-#define FLASHROM_OUTPUT_WP_PATTERN "write protect is "
-
-/* System environment values. */
-static const char * const FLASHROM_OUTPUT_WP_ENABLED =
- FLASHROM_OUTPUT_WP_PATTERN "enabled",
- * const FLASHROM_OUTPUT_WP_DISABLED =
- FLASHROM_OUTPUT_WP_PATTERN "disabled";
-
-
-/* Helper function to return write protection status via given programmer. */
-enum wp_state flashrom_get_wp(const char *programmer)
-{
- char *command, *result;
- const char *postfix;
- int r;
-
- /* grep is needed because host_shell only returns 1 line. */
- postfix = " 2>/dev/null | grep \"" FLASHROM_OUTPUT_WP_PATTERN "\"";
-
-
- /* TODO(b/203715651): link with flashrom directly. */
- ASPRINTF(&command, "flashrom --wp-status -p %s %s", programmer, postfix);
-
- /* invokes flashrom(8) with non-zero result if error. */
- result = host_shell(command);
- strip_string(result, NULL);
- free(command);
- VB2_DEBUG("wp-status: %s\n", result);
-
- if (strstr(result, FLASHROM_OUTPUT_WP_ENABLED))
- r = WP_ENABLED;
- else if (strstr(result, FLASHROM_OUTPUT_WP_DISABLED))
- r = WP_DISABLED;
- else
- r = WP_ERROR;
- free(result);
-
- return r;
-}
diff --git a/futility/updater.c b/futility/updater.c
index 1a5e99d1..6be7238c 100644
--- a/futility/updater.c
+++ b/futility/updater.c
@@ -393,7 +393,7 @@ static int write_optional_firmware(struct updater_config *cfg,
*/
if (check_programmer_wp &&
get_system_property(SYS_PROP_WP_HW, cfg) == WP_ENABLED &&
- flashrom_get_wp(image->programmer) == WP_ENABLED) {
+ flashrom_get_wp(image->programmer, -1) == WP_ENABLED) {
ERROR("Target %s is write protected, skip updating.\n",
image->programmer);
return 0;
diff --git a/futility/updater_utils.c b/futility/updater_utils.c
index d879f783..8a7b6f7b 100644
--- a/futility/updater_utils.c
+++ b/futility/updater_utils.c
@@ -821,7 +821,7 @@ int write_system_firmware(struct updater_config *cfg,
/* Helper function to return host software write protection status. */
static int host_get_wp_sw(void)
{
- return flashrom_get_wp(PROG_HOST);
+ return flashrom_get_wp(PROG_HOST, -1);
}
/* Helper function to configure all properties. */
diff --git a/futility/updater_utils.h b/futility/updater_utils.h
index a99c38c4..49b0adf5 100644
--- a/futility/updater_utils.h
+++ b/futility/updater_utils.h
@@ -181,15 +181,6 @@ int save_file_from_stdin(const char *output);
*/
char *host_shell(const char *command);
-enum wp_state {
- WP_ERROR = -1,
- WP_DISABLED = 0,
- WP_ENABLED,
-};
-
-/* Helper function to return write protection status via given programmer. */
-enum wp_state flashrom_get_wp(const char *programmer);
-
/* The environment variable name for setting servod port. */
#define ENV_SERVOD_PORT "SERVOD_PORT"