diff mbox series

[v2,13/21] efi_firmware: fwu: get the number of FWU banks at runtime

Message ID 20240212074712.3657076-14-sughosh.ganu@linaro.org
State New
Headers show
Series FWU: Migrate FWU metadata to version 2 | expand

Commit Message

Sughosh Ganu Feb. 12, 2024, 7:47 a.m. UTC
With the migration of the FWU metadata to version 2, the number of
banks are now obtained at runtime, instead of the config symbols. Make
use of the API to get the number of banks in the versioning
functions.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---

Changes since V1: None

 lib/efi_loader/efi_firmware.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c
index c742e23268..26d2916ee1 100644
--- a/lib/efi_loader/efi_firmware.c
+++ b/lib/efi_loader/efi_firmware.c
@@ -207,7 +207,8 @@  void efi_firmware_fill_version_info(struct efi_firmware_image_descriptor *image_
 	u16 varname[13]; /* u"FmpStateXXXX" */
 	efi_status_t ret;
 	efi_uintn_t size, expected_size;
-	uint num_banks = 1;
+	u8 num_banks = 1;
+	u16 __maybe_unused num_images;
 	uint active_index = 0;
 	struct fmp_state *var_state;
 
@@ -229,7 +230,9 @@  void efi_firmware_fill_version_info(struct efi_firmware_image_descriptor *image_
 		if (ret)
 			return;
 
-		num_banks = CONFIG_FWU_NUM_BANKS;
+		ret = fwu_get_banks_images(&num_banks, &num_images);
+		if (ret)
+			return;
 	}
 
 	size = num_banks * sizeof(*var_state);
@@ -379,7 +382,8 @@  efi_status_t efi_firmware_set_fmp_state_var(struct fmp_state *state, u8 image_in
 {
 	u16 varname[13]; /* u"FmpStateXXXX" */
 	efi_status_t ret;
-	uint num_banks = 1;
+	u8 num_banks = 1;
+	u16 __maybe_unused num_images;
 	uint update_bank = 0;
 	efi_uintn_t size;
 	efi_guid_t *image_type_id;
@@ -398,7 +402,9 @@  efi_status_t efi_firmware_set_fmp_state_var(struct fmp_state *state, u8 image_in
 		if (ret)
 			return EFI_INVALID_PARAMETER;
 
-		num_banks = CONFIG_FWU_NUM_BANKS;
+		ret = fwu_get_banks_images(&num_banks, &num_images);
+		if (ret)
+			return EFI_INVALID_PARAMETER;
 	}
 
 	size = num_banks * sizeof(*var_state);