summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2023-05-15 14:32:18 +1000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-05-16 15:01:28 +0000
commiteda40d1b9352692ac270652b79f2f18e31c5420e (patch)
tree499d6e4d835f918058c07a1a16e742e85ef19942
parent1ee88b4cb3781af8795bb64b94ac90289f0c70e4 (diff)
downloadvboot-eda40d1b9352692ac270652b79f2f18e31c5420e.tar.gz
futility/updater.c: Dedup update_legacy_firmware() logic
BUG=b:282585789 BRANCH=none TEST=`cros_run_unit_tests --host --packages vboot_reference`. Change-Id: I8fdc14236a478cc1ad0f39e091b19223cb3d9470 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4532321 Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org>
-rw-r--r--futility/updater.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/futility/updater.c b/futility/updater.c
index 1a823924..57b18ce1 100644
--- a/futility/updater.c
+++ b/futility/updater.c
@@ -872,6 +872,24 @@ const char * const updater_error_messages[] = {
};
/*
+ * The main updater for "Legacy update".
+ * This is equivalent to --mode=legacy.
+ * Returns UPDATE_ERR_DONE if success, otherwise error.
+ */
+static enum updater_error_codes update_legacy_firmware(
+ struct updater_config *cfg,
+ struct firmware_image *image_to)
+{
+ STATUS("LEGACY UPDATE: Updating firmware %s.\n", 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;
+}
+
+/*
* The main updater for "Try-RW update", to update only one RW section
* and try if it can boot properly on reboot.
* This was also known as --mode=autoupdate,--wp=1 in legacy updater.
@@ -947,9 +965,7 @@ static enum updater_error_codes update_try_rw_firmware(
/* Do not fail on updating legacy. */
if (legacy_needs_update(cfg)) {
has_update = 1;
- STATUS("LEGACY UPDATE: Updating %s.\n", FMAP_RW_LEGACY);
- const char *sections[2] = { FMAP_RW_LEGACY, NULL };
- write_system_firmware(cfg, image_to, sections);
+ update_legacy_firmware(cfg, image_to);
}
return UPDATE_ERR_DONE;
@@ -1016,24 +1032,6 @@ static enum updater_error_codes update_rw_firmware(
}
/*
- * The main updater for "Legacy update".
- * This is equivalent to --mode=legacy.
- * Returns UPDATE_ERR_DONE if success, otherwise error.
- */
-static enum updater_error_codes update_legacy_firmware(
- struct updater_config *cfg,
- struct firmware_image *image_to)
-{
- STATUS("LEGACY UPDATE: Updating firmware %s.\n", 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;
-}
-
-/*
* The main updater for "Full update".
* This was also known as "--mode=factory" or "--mode=recovery, --wp=0" in
* legacy updater.