diff options
author | Edward O'Callaghan <quasisec@google.com> | 2023-05-15 14:24:12 +1000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-05-17 00:09:57 +0000 |
commit | 723cb4517c9ff7291f2f446ac2042b8bc10f761d (patch) | |
tree | d8254c55bf2d7b61933112aefffe767684444b6a | |
parent | 04a4e072af73f190e5cc16fb444232573cd8acda (diff) | |
download | vboot-723cb4517c9ff7291f2f446ac2042b8bc10f761d.tar.gz |
futility/updater.c: Inline write_ec_firmware()
Avoid indirection.
BUG=b:282585789
BRANCH=none
TEST=`cros_run_unit_tests --host --packages vboot_reference`.
Change-Id: I5391c349ff60569e4dcc6c1c4605ccb9901c290b
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4532320
Commit-Queue: Nikolai Artemiev <nartemiev@google.com>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Tested-by: Edward O'Callaghan <quasisec@chromium.org>
Auto-Submit: Edward O'Callaghan <quasisec@chromium.org>
-rw-r--r-- | futility/updater.c | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/futility/updater.c b/futility/updater.c index 57b18ce1..0877b302 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -321,29 +321,6 @@ static int has_valid_update(struct updater_config *cfg, } /* - * Write a section from given firmware image to system EC firmware if possible. - * If section_name is NULL, write whole image. If the image has no data or if - * the section does not exist, ignore and return success. - * Returns 0 if success, non-zero if error. - */ -static int write_ec_firmware(struct updater_config *cfg, - const struct firmware_image *image, - const char *section_name) -{ - /** EC may have different WP settings and we want to write - * only if it is OK. - */ - if (is_write_protection_enabled(cfg)) { - ERROR("Target ec is write protected, skip updating.\n"); - return 0; - } - - /* TODO(quasisec): Uses cros_ec to program the EC. */ - const char *sections[2] = { section_name, NULL }; - return write_system_firmware(cfg, image, sections); -} - -/* * Preserve the GBB contents from image_from to image_to. * HWID is always preserved, and flags are preserved only if preserve_flags set. * Returns 0 if success, otherwise -1 if GBB header can't be found or if HWID is @@ -830,7 +807,8 @@ static int check_compatible_tpm_keys(struct updater_config *cfg, /* - * Update EC (RO+RW) firmware. + * Update EC (RO+RW) firmware if possible. + * If the image has no data or if the section does not exist, ignore and return success. * Returns 0 if success, non-zero if error. */ static int update_ec_firmware(struct updater_config *cfg) @@ -839,19 +817,35 @@ static int update_ec_firmware(struct updater_config *cfg) if (!has_valid_update(cfg, ec_image, NULL, 0)) return 0; + const char *sections[2] = {0}; int r = try_apply_quirk(QUIRK_EC_PARTIAL_RECOVERY, cfg); switch (r) { case EC_RECOVERY_FULL: - return write_ec_firmware(cfg, ec_image, NULL); + break; /* NULL sections implies write whole image. */ - case EC_RECOVERY_RO: - return write_ec_firmware(cfg, ec_image, "WP_RO"); + case EC_RECOVERY_RO: { + sections[0] = "WP_RO"; + break; + } case EC_RECOVERY_DONE: /* Done by some quirks, for example EC RO software sync. */ return 0; + + default: + return r; } - return r; + + /** EC may have different WP settings and we want to write + * only if it is OK. + */ + if (is_write_protection_enabled(cfg)) { + ERROR("Target ec is write protected, skip updating.\n"); + return 0; + } + + /* TODO(quasisec): Uses cros_ec to program the EC. */ + return write_system_firmware(cfg, ec_image, sections); } const char * const updater_error_messages[] = { |