From 9fa68b0cfd2f8d148ae841ae5faeb86281b04b42 Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Wed, 14 Jul 2021 15:10:58 +1000 Subject: 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 Reviewed-on: https://review.coreboot.org/c/flashrom/+/56296 Reviewed-by: Anastasia Klimchuk Tested-by: build bot (Jenkins) --- flashrom.c | 52 +++++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 27 deletions(-) (limited to 'flashrom.c') diff --git a/flashrom.c b/flashrom.c index 1f94f33d..8d44c3d4 100644 --- a/flashrom.c +++ b/flashrom.c @@ -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. * -- cgit v1.2.3