Felix Singer has submitted this change. ( https://review.coreboot.org/c/flashrom/+/66684 )
(
9 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: flashrom.c: create is_internal_programmer() helper ......................................................................
flashrom.c: create is_internal_programmer() helper
As suggested by Angel Pons, add the function `is_internal_programmer` to cut down on some pre-processor usage by moving it into the new function.
The function then checks if the internal programmer is the selected one. If the internal programmer is not built in, then it just returns false.
Change-Id: I43243b990192077583a9a3a95d35844923d9c158 Signed-off-by: Edward O'Callaghan quasisec@google.com Reviewed-on: https://review.coreboot.org/c/flashrom/+/66684 Reviewed-by: Angel Pons th3fanbus@gmail.com Reviewed-by: Anastasia Klimchuk aklm@chromium.org Reviewed-by: Felix Singer felixsinger@posteo.net Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M flashrom.c 1 file changed, 35 insertions(+), 7 deletions(-)
Approvals: build bot (Jenkins): Verified Felix Singer: Looks good to me, approved Angel Pons: Looks good to me, but someone else must approve Anastasia Klimchuk: Looks good to me, approved
diff --git a/flashrom.c b/flashrom.c index c5f712a..088d804 100644 --- a/flashrom.c +++ b/flashrom.c @@ -1345,18 +1345,25 @@ return 0; }
+static bool is_internal_programmer() +{ +#if CONFIG_INTERNAL == 1 + return programmer == &programmer_internal; +#else + return false; +#endif +} + static void nonfatal_help_message(void) { msg_gerr("Good, writing to the flash chip apparently didn't do anything.\n"); -#if CONFIG_INTERNAL == 1 - if (programmer == &programmer_internal) + if (is_internal_programmer()) msg_gerr("This means we have to add special support for your board, programmer or flash\n" "chip. Please report this to the mailing list at flashrom@flashrom.org or on\n" "IRC (see https://www.flashrom.org/Contact for details), thanks!\n" "-------------------------------------------------------------------------------\n" "You may now reboot or simply leave the machine running.\n"); else -#endif msg_gerr("Please check the connections (especially those to write protection pins) between\n" "the programmer and the flash chip. If you think the error is caused by flashrom\n" "please report this to the mailing list at flashrom@flashrom.org or on IRC (see\n" @@ -1366,14 +1373,12 @@ void emergency_help_message(void) { msg_gerr("Your flash chip is in an unknown state.\n"); -#if CONFIG_INTERNAL == 1 - if (programmer == &programmer_internal) + if (is_internal_programmer()) msg_gerr("Get help on IRC (see https://www.flashrom.org/Contact) or mail\n" "flashrom@flashrom.org with the subject "FAILED: <your board name>"!" "-------------------------------------------------------------------------------\n" "DO NOT REBOOT OR POWEROFF!\n"); else -#endif msg_gerr("Please report this to the mailing list at flashrom@flashrom.org or\n" "on IRC (see https://www.flashrom.org/Contact for details), thanks!\n"); } @@ -1709,7 +1714,7 @@ }
#if CONFIG_INTERNAL == 1 - if (programmer == &programmer_internal && cb_check_image(newcontents, flash_size) < 0) { + if (is_internal_programmer() && cb_check_image(newcontents, flash_size) < 0) { if (flashctx->flags.force_boardmismatch) { msg_pinfo("Proceeding anyway because user forced us to.\n"); } else {