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:
parent
5779452fcc
commit
053d319141
19
flashrom.c
19
flashrom.c
@ -1345,18 +1345,25 @@ static int verify_by_layout(
|
|||||||
return 0;
|
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)
|
static void nonfatal_help_message(void)
|
||||||
{
|
{
|
||||||
msg_gerr("Good, writing to the flash chip apparently didn't do anything.\n");
|
msg_gerr("Good, writing to the flash chip apparently didn't do anything.\n");
|
||||||
#if CONFIG_INTERNAL == 1
|
if (is_internal_programmer())
|
||||||
if (programmer == &programmer_internal)
|
|
||||||
msg_gerr("This means we have to add special support for your board, programmer or flash\n"
|
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"
|
"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"
|
"IRC (see https://www.flashrom.org/Contact for details), thanks!\n"
|
||||||
"-------------------------------------------------------------------------------\n"
|
"-------------------------------------------------------------------------------\n"
|
||||||
"You may now reboot or simply leave the machine running.\n");
|
"You may now reboot or simply leave the machine running.\n");
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
msg_gerr("Please check the connections (especially those to write protection pins) between\n"
|
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"
|
"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"
|
"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)
|
void emergency_help_message(void)
|
||||||
{
|
{
|
||||||
msg_gerr("Your flash chip is in an unknown state.\n");
|
msg_gerr("Your flash chip is in an unknown state.\n");
|
||||||
#if CONFIG_INTERNAL == 1
|
if (is_internal_programmer())
|
||||||
if (programmer == &programmer_internal)
|
|
||||||
msg_gerr("Get help on IRC (see https://www.flashrom.org/Contact) or mail\n"
|
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>\"!"
|
"flashrom@flashrom.org with the subject \"FAILED: <your board name>\"!"
|
||||||
"-------------------------------------------------------------------------------\n"
|
"-------------------------------------------------------------------------------\n"
|
||||||
"DO NOT REBOOT OR POWEROFF!\n");
|
"DO NOT REBOOT OR POWEROFF!\n");
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
msg_gerr("Please report this to the mailing list at flashrom@flashrom.org or\n"
|
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");
|
"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 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) {
|
if (flashctx->flags.force_boardmismatch) {
|
||||||
msg_pinfo("Proceeding anyway because user forced us to.\n");
|
msg_pinfo("Proceeding anyway because user forced us to.\n");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user