summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2022-08-12 21:27:41 +1000
committerFelix Singer <felixsinger@posteo.net>2022-10-10 04:20:13 +0000
commit053d319141db5954ab1ad34cb9db61983d238134 (patch)
tree65c59e38cf8d39bb4c914a3dca96f76bd7536e2f
parent5779452fccae5554f5b3637ed47717ae7874fe3f (diff)
downloadflashrom-053d319141db5954ab1ad34cb9db61983d238134.tar.gz
flashrom-053d319141db5954ab1ad34cb9db61983d238134.tar.bz2
flashrom-053d319141db5954ab1ad34cb9db61983d238134.zip
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>
-rw-r--r--flashrom.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/flashrom.c b/flashrom.c
index c5f712a48..088d80450 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1345,18 +1345,25 @@ static int verify_by_layout(
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 @@ static void nonfatal_help_message(void)
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 @@ int flashrom_image_write(struct flashctx *const flashctx, void *const buffer, co
}
#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 {