aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2022-09-05 11:13:56 +1000
committerEdward O'Callaghan <quasisec@chromium.org>2022-12-02 11:06:04 +0000
commiteda27e4d1b23ac602b76c3f99b02a791953e9eed (patch)
treef2eaafaed11a774ad18624fa8b35780861f2b7e5
parent748575abb2dbd93a7f4c87ca10887b9d72ac6a37 (diff)
downloadflashrom-eda27e4d1b23ac602b76c3f99b02a791953e9eed.tar.gz
flashrom-eda27e4d1b23ac602b76c3f99b02a791953e9eed.tar.bz2
flashrom-eda27e4d1b23ac602b76c3f99b02a791953e9eed.zip
cli_classic.c: Make count_max_decode_exceedings() pure
Pass by argument the max_rom_decode structure such that the function is pure and defined upon its parameters. Note, unfortunately a itermediate step of a '_' suffix is required for the 'max_rom_decode' parameter as to not alias the global symbol within the function body. Change-Id: Ia01f77993deab68e251850008e885828e55b9462 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/68479 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Felix Singer <felixsinger@posteo.net> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r--cli_classic.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/cli_classic.c b/cli_classic.c
index fe50cf4d..5cc14a01 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -520,43 +520,44 @@ _free_ret:
/* Returns the number of buses commonly supported by the current programmer and flash chip where the latter
* can not be completely accessed due to size/address limits of the programmer. */
-static unsigned int count_max_decode_exceedings(const struct flashctx *flash)
+static unsigned int count_max_decode_exceedings(const struct flashctx *flash,
+ const struct decode_sizes *max_rom_decode_)
{
unsigned int limitexceeded = 0;
uint32_t size = flash->chip->total_size * 1024;
enum chipbustype buses = flash->mst->buses_supported & flash->chip->bustype;
- if ((buses & BUS_PARALLEL) && (max_rom_decode.parallel < size)) {
+ if ((buses & BUS_PARALLEL) && (max_rom_decode_->parallel < size)) {
limitexceeded++;
msg_pdbg("Chip size %u kB is bigger than supported "
"size %u kB of chipset/board/programmer "
"for %s interface, "
"probe/read/erase/write may fail. ", size / 1024,
- max_rom_decode.parallel / 1024, "Parallel");
+ max_rom_decode_->parallel / 1024, "Parallel");
}
- if ((buses & BUS_LPC) && (max_rom_decode.lpc < size)) {
+ if ((buses & BUS_LPC) && (max_rom_decode_->lpc < size)) {
limitexceeded++;
msg_pdbg("Chip size %u kB is bigger than supported "
"size %u kB of chipset/board/programmer "
"for %s interface, "
"probe/read/erase/write may fail. ", size / 1024,
- max_rom_decode.lpc / 1024, "LPC");
+ max_rom_decode_->lpc / 1024, "LPC");
}
- if ((buses & BUS_FWH) && (max_rom_decode.fwh < size)) {
+ if ((buses & BUS_FWH) && (max_rom_decode_->fwh < size)) {
limitexceeded++;
msg_pdbg("Chip size %u kB is bigger than supported "
"size %u kB of chipset/board/programmer "
"for %s interface, "
"probe/read/erase/write may fail. ", size / 1024,
- max_rom_decode.fwh / 1024, "FWH");
+ max_rom_decode_->fwh / 1024, "FWH");
}
- if ((buses & BUS_SPI) && (max_rom_decode.spi < size)) {
+ if ((buses & BUS_SPI) && (max_rom_decode_->spi < size)) {
limitexceeded++;
msg_pdbg("Chip size %u kB is bigger than supported "
"size %u kB of chipset/board/programmer "
"for %s interface, "
"probe/read/erase/write may fail. ", size / 1024,
- max_rom_decode.spi / 1024, "SPI");
+ max_rom_decode_->spi / 1024, "SPI");
}
return limitexceeded;
}
@@ -1060,7 +1061,7 @@ int main(int argc, char *argv[])
print_chip_support_status(fill_flash->chip);
- unsigned int limitexceeded = count_max_decode_exceedings(fill_flash);
+ unsigned int limitexceeded = count_max_decode_exceedings(fill_flash, &max_rom_decode);
if (limitexceeded > 0 && !force) {
enum chipbustype commonbuses = fill_flash->mst->buses_supported & fill_flash->chip->bustype;