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

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>
This commit is contained in:
Edward O'Callaghan 2022-08-12 21:27:41 +10:00 committed by Felix Singer
parent 5779452fcc
commit 053d319141

View File

@ -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 {