diff options
author | Edward O'Callaghan <quasisec@google.com> | 2023-05-15 13:51:57 +1000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-05-16 04:24:02 +0000 |
commit | 1ee88b4cb3781af8795bb64b94ac90289f0c70e4 (patch) | |
tree | c101229134a60de4c988ba3de87623be381dbbbb | |
parent | 37634642631daeb219b8c798239e19da42614c8a (diff) | |
download | vboot-1ee88b4cb3781af8795bb64b94ac90289f0c70e4.tar.gz |
futility/: Inline write_firmware() as write_system_firmware()
Avoid confusing indirections.
BUG=b:282585789
BRANCH=none
TEST=`cros_run_unit_tests --host --packages vboot_reference`.
Change-Id: I5fdc01affcce2399955b594abf98c7550815b56b
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4532319
Tested-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
-rw-r--r-- | futility/cmd_gbb_utility.c | 5 | ||||
-rw-r--r-- | futility/updater.c | 25 | ||||
-rw-r--r-- | futility/updater.h | 9 |
3 files changed, 14 insertions, 25 deletions
diff --git a/futility/cmd_gbb_utility.c b/futility/cmd_gbb_utility.c index 00762380..4ab13819 100644 --- a/futility/cmd_gbb_utility.c +++ b/futility/cmd_gbb_utility.c @@ -413,7 +413,10 @@ static int write_to_flash(struct updater_config *cfg, uint8_t *outbuf, } cfg->image.data = outbuf; cfg->image.size = filesize; - int ret = write_firmware(cfg, &cfg->image, FMAP_RO_GBB); + + const char *sections[2] = { FMAP_RO_GBB, NULL }; + int ret = write_system_firmware(cfg, &cfg->image, sections); + cfg->image.data = NULL; cfg->image.size = 0; return ret; diff --git a/futility/updater.c b/futility/updater.c index da46704b..1a823924 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -292,16 +292,6 @@ static int set_try_cookies(struct updater_config *cfg, const char *target, return 0; } -int write_firmware(struct updater_config *cfg, - const struct firmware_image *image, const char *section_name) -{ - const char *sections[2] = {0}; - - sections[0] = section_name; - return write_system_firmware(cfg, image, - section_name ? sections : NULL); -} - /* * Returns True if we should start the update process for given image. */ @@ -348,7 +338,9 @@ static int write_ec_firmware(struct updater_config *cfg, return 0; } - return write_firmware(cfg, image, section_name); + /* TODO(quasisec): Uses cros_ec to program the EC. */ + const char *sections[2] = { section_name, NULL }; + return write_system_firmware(cfg, image, sections); } /* @@ -925,7 +917,8 @@ static enum updater_error_codes update_try_rw_firmware( STATUS("TRY-RW UPDATE: Updating %s to try on reboot.\n", target); - if (write_firmware(cfg, image_to, target)) + const char *sections[2] = { target, NULL }; + if (write_system_firmware(cfg, image_to, sections)) return UPDATE_ERR_WRITE_FIRMWARE; /* @@ -955,7 +948,8 @@ static enum updater_error_codes update_try_rw_firmware( if (legacy_needs_update(cfg)) { has_update = 1; STATUS("LEGACY UPDATE: Updating %s.\n", FMAP_RW_LEGACY); - write_firmware(cfg, image_to, FMAP_RW_LEGACY); + const char *sections[2] = { FMAP_RW_LEGACY, NULL }; + write_system_firmware(cfg, image_to, sections); } return UPDATE_ERR_DONE; @@ -1032,7 +1026,8 @@ static enum updater_error_codes update_legacy_firmware( { STATUS("LEGACY UPDATE: Updating firmware %s.\n", FMAP_RW_LEGACY); - if (write_firmware(cfg, image_to, FMAP_RW_LEGACY)) + const char *sections[2] = { FMAP_RW_LEGACY, NULL }; + if (write_system_firmware(cfg, image_to, sections)) return UPDATE_ERR_WRITE_FIRMWARE; return UPDATE_ERR_DONE; @@ -1090,7 +1085,7 @@ static enum updater_error_codes update_whole_firmware( return UPDATE_ERR_TPM_ROLLBACK; /* FMAP may be different so we should just update all. */ - if (write_firmware(cfg, image_to, NULL) || update_ec_firmware(cfg)) + if (write_system_firmware(cfg, image_to, NULL) || update_ec_firmware(cfg)) return UPDATE_ERR_WRITE_FIRMWARE; return UPDATE_ERR_DONE; diff --git a/futility/updater.h b/futility/updater.h index a026da48..5c9456fe 100644 --- a/futility/updater.h +++ b/futility/updater.h @@ -258,15 +258,6 @@ int quirk_override_signature_id(struct updater_config *cfg, struct model_config *model, const char **signature_id); -/* - * Writes a single section from the given firmware image to the system. - * Writes the whole firmware image if the section_name is NULL. - * Returns 0 if success, non-zero if error. - */ -int write_firmware(struct updater_config *cfg, - const struct firmware_image *image, - const char *section_name); - /* Functions from updater_archive.c */ /* |