1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 23:22:37 +02:00

flashrom.c: Reorder check_block_eraser() to avoid forward decl

Help make groking flashrom.c fractionaly easier.

BUG=none
BRANCH=none
TEST=builds

Change-Id: I0906a6e581ce5135b58f6acc6339908dfa770a59
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/56296
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Edward O'Callaghan 2021-07-14 15:10:58 +10:00 committed by Edward O'Callaghan
parent 4ebe65c733
commit 9fa68b0cfd

View File

@ -73,8 +73,6 @@ static int may_register_shutdown = 0;
/* Did we change something or was every erase/write skipped (if any)? */
static bool all_skipped = true;
static int check_block_eraser(const struct flashctx *flash, int k, int log);
/* Register a function to be executed on programmer shutdown.
* The advantage over atexit() is that you can supply a void pointer which will
* be used as parameter to the registered function upon programmer shutdown.
@ -333,6 +331,31 @@ char *extract_programmer_param(const char *param_name)
return extract_param(&programmer_param, param_name, ",");
}
static int check_block_eraser(const struct flashctx *flash, int k, int log)
{
struct block_eraser eraser = flash->chip->block_erasers[k];
if (!eraser.block_erase && !eraser.eraseblocks[0].count) {
if (log)
msg_cdbg("not defined. ");
return 1;
}
if (!eraser.block_erase && eraser.eraseblocks[0].count) {
if (log)
msg_cdbg("eraseblock layout is known, but matching "
"block erase function is not implemented. ");
return 1;
}
if (eraser.block_erase && !eraser.eraseblocks[0].count) {
if (log)
msg_cdbg("block erase function found, but "
"eraseblock layout is not defined. ");
return 1;
}
// TODO: Once erase functions are annotated with allowed buses, check that as well.
return 0;
}
/* Returns the number of well-defined erasers for a chip. */
static unsigned int count_usable_erasers(const struct flashctx *flash)
{
@ -1125,31 +1148,6 @@ static int selfcheck_eraseblocks(const struct flashchip *chip)
return ret;
}
static int check_block_eraser(const struct flashctx *flash, int k, int log)
{
struct block_eraser eraser = flash->chip->block_erasers[k];
if (!eraser.block_erase && !eraser.eraseblocks[0].count) {
if (log)
msg_cdbg("not defined. ");
return 1;
}
if (!eraser.block_erase && eraser.eraseblocks[0].count) {
if (log)
msg_cdbg("eraseblock layout is known, but matching "
"block erase function is not implemented. ");
return 1;
}
if (eraser.block_erase && !eraser.eraseblocks[0].count) {
if (log)
msg_cdbg("block erase function found, but "
"eraseblock layout is not defined. ");
return 1;
}
// TODO: Once erase functions are annotated with allowed buses, check that as well.
return 0;
}
/**
* @brief Reads the included layout regions into a buffer.
*