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

realtek_mst_i2c_spi.c: Use one variable to store raw parameter values

Currently, each programmer parameter has their own temp variable to
store their raw value into it. That's not needed since these variables
are only used for a short time to do some configuration and stay unused
then. Thus, use only one variable for all of them.

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I48502161add9b59d97f5eeb46f5984c075ad924a
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65909
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
This commit is contained in:
Felix Singer 2022-07-16 11:20:27 +02:00 committed by Anastasia Klimchuk
parent ca4608db6f
commit bcdfcaf9b0

View File

@ -446,48 +446,48 @@ static const struct spi_master spi_master_i2c_realtek_mst = {
static int get_params(bool *reset, bool *enter_isp, bool *allow_brick) static int get_params(bool *reset, bool *enter_isp, bool *allow_brick)
{ {
char *reset_str = NULL, *isp_str = NULL, *brick_str = NULL; char *param_str;
int ret = 0; int ret = 0;
*allow_brick = false; /* Default behaviour is to bail. */ *allow_brick = false; /* Default behaviour is to bail. */
brick_str = extract_programmer_param_str("allow_brick"); param_str = extract_programmer_param_str("allow_brick");
if (brick_str) { if (param_str) {
if (!strcmp(brick_str, "yes")) { if (!strcmp(param_str, "yes")) {
*allow_brick = true; *allow_brick = true;
} else { } else {
msg_perr("%s: Incorrect param format, allow_brick=yes.\n", __func__); msg_perr("%s: Incorrect param format, allow_brick=yes.\n", __func__);
ret = SPI_GENERIC_ERROR; ret = SPI_GENERIC_ERROR;
} }
} }
free(brick_str); free(param_str);
*reset = false; /* Default behaviour is no MCU reset on tear-down. */ *reset = false; /* Default behaviour is no MCU reset on tear-down. */
reset_str = extract_programmer_param_str("reset_mcu"); param_str = extract_programmer_param_str("reset_mcu");
if (reset_str) { if (param_str) {
if (reset_str[0] == '1') { if (param_str[0] == '1') {
*reset = true; *reset = true;
} else if (reset_str[0] == '0') { } else if (param_str[0] == '0') {
*reset = false; *reset = false;
} else { } else {
msg_perr("%s: Incorrect param format, reset_mcu=1 or 0.\n", __func__); msg_perr("%s: Incorrect param format, reset_mcu=1 or 0.\n", __func__);
ret = SPI_GENERIC_ERROR; ret = SPI_GENERIC_ERROR;
} }
} }
free(reset_str); free(param_str);
*enter_isp = true; /* Default behaviour is enter ISP on setup. */ *enter_isp = true; /* Default behaviour is enter ISP on setup. */
isp_str = extract_programmer_param_str("enter_isp"); param_str = extract_programmer_param_str("enter_isp");
if (isp_str) { if (param_str) {
if (isp_str[0] == '1') { if (param_str[0] == '1') {
*enter_isp = true; *enter_isp = true;
} else if (isp_str[0] == '0') { } else if (param_str[0] == '0') {
*enter_isp = false; *enter_isp = false;
} else { } else {
msg_perr("%s: Incorrect param format, enter_isp=1 or 0.\n", __func__); msg_perr("%s: Incorrect param format, enter_isp=1 or 0.\n", __func__);
ret = SPI_GENERIC_ERROR; ret = SPI_GENERIC_ERROR;
} }
} }
free(isp_str); free(param_str);
return ret; return ret;
} }