[PATCH 3/5] fwu: use FWU_MAX_STATE_BANKS for bank_state array
Dario Binacchi
dario.binacchi at amarulasolutions.com
Sun Dec 28 16:17:53 CET 2025
Replace the hardcoded size of the bank_state array with
FWU_MAX_STATE_BANKS to improve readability and ensure consistency
between the structure definition and code that relies on it,
including the mkfwumdata tool.
Signed-off-by: Dario Binacchi <dario.binacchi at amarulasolutions.com>
---
include/fwu_mdata.h | 5 ++++-
tools/mkfwumdata.c | 5 +----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/fwu_mdata.h b/include/fwu_mdata.h
index 43b3487c4a23..b84a9987f769 100644
--- a/include/fwu_mdata.h
+++ b/include/fwu_mdata.h
@@ -94,6 +94,9 @@ struct fwu_mdata {
} __packed;
#else /* CONFIG_FWU_MDATA_V1 */
+
+#define FWU_MAX_STATE_BANKS 4
+
/**
* struct fwu_mdata - FWU metadata structure for multi-bank updates
* @crc32: crc32 value for the FWU metadata
@@ -120,7 +123,7 @@ struct fwu_mdata {
uint32_t metadata_size;
uint16_t desc_offset;
uint16_t reserved1;
- uint8_t bank_state[4];
+ uint8_t bank_state[FWU_MAX_STATE_BANKS];
uint32_t reserved2;
// struct fwu_fw_store_desc fw_desc;
diff --git a/tools/mkfwumdata.c b/tools/mkfwumdata.c
index 0d1697622e6a..c2fd3d4232f5 100644
--- a/tools/mkfwumdata.c
+++ b/tools/mkfwumdata.c
@@ -30,9 +30,6 @@ typedef uint64_t u64;
#define CONFIG_FWU_NUM_BANKS 0
#define CONFIG_FWU_NUM_IMAGES_PER_BANK 0
-/* version 2 supports maximum of 4 banks */
-#define MAX_BANKS_V2 4
-
#include <fwu_mdata.h>
static const char *opts_short = "b:i:a:p:v:V:gh";
@@ -292,7 +289,7 @@ static void fwu_fill_version_specific_mdata(struct fwu_mdata_object *mobj)
mdata->metadata_size = mobj->size;
mdata->desc_offset = sizeof(struct fwu_mdata);
- for (i = 0; i < MAX_BANKS_V2; i++)
+ for (i = 0; i < FWU_MAX_STATE_BANKS; i++)
mdata->bank_state[i] = i < mobj->banks ?
FWU_BANK_ACCEPTED : FWU_BANK_INVALID;
--
2.43.0
More information about the U-Boot
mailing list