summaryrefslogtreecommitdiffstats
path: root/realtek_mst_i2c_spi.c
diff options
context:
space:
mode:
authorFelix Singer <felixsinger@posteo.net>2022-07-18 04:14:13 +0200
committerAnastasia Klimchuk <aklm@chromium.org>2022-07-22 01:28:15 +0000
commitbde9479dc167aacbaaeb1bec2338eb9fb096e018 (patch)
treedadedee7e190c4df96fc482af9772e3cfd934c7b /realtek_mst_i2c_spi.c
parente6e4ca5fe48989539a26e30417688757cfd6bf75 (diff)
downloadflashrom-bde9479dc167aacbaaeb1bec2338eb9fb096e018.tar.gz
flashrom-bde9479dc167aacbaaeb1bec2338eb9fb096e018.tar.bz2
flashrom-bde9479dc167aacbaaeb1bec2338eb9fb096e018.zip
realtek_mst_i2c_spi.c: Clean up get_params()
Set the default value for programmer options just before the user-provided parameters are evaluated. The values get overridden if the user specified their own values, else the pre-set values are used. This way, we get rid of these else-blocks. Signed-off-by: Felix Singer <felixsinger@posteo.net> Change-Id: Ibb43aaa4d70ee0827587288c658f01bcef583ddd Reviewed-on: https://review.coreboot.org/c/flashrom/+/65936 Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Thomas Heijligen <src@posteo.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Diffstat (limited to 'realtek_mst_i2c_spi.c')
-rw-r--r--realtek_mst_i2c_spi.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c
index ce1637a10..126f7de1a 100644
--- a/realtek_mst_i2c_spi.c
+++ b/realtek_mst_i2c_spi.c
@@ -449,6 +449,7 @@ static int get_params(int *reset, int *enter_isp, int *allow_brick)
char *reset_str = NULL, *isp_str = NULL, *brick_str = NULL;
int ret = 0;
+ *allow_brick = 0; /* Default behaviour is to bail. */
brick_str = extract_programmer_param_str("allow_brick");
if (brick_str) {
if (!strcmp(brick_str, "yes")) {
@@ -457,11 +458,10 @@ static int get_params(int *reset, int *enter_isp, int *allow_brick)
msg_perr("%s: Incorrect param format, allow_brick=yes.\n", __func__);
ret = SPI_GENERIC_ERROR;
}
- } else {
- *allow_brick = 0; /* Default behaviour is to bail. */
}
free(brick_str);
+ *reset = 0; /* Default behaviour is no MCU reset on tear-down. */
reset_str = extract_programmer_param_str("reset_mcu");
if (reset_str) {
if (reset_str[0] == '1') {
@@ -472,11 +472,10 @@ static int get_params(int *reset, int *enter_isp, int *allow_brick)
msg_perr("%s: Incorrect param format, reset_mcu=1 or 0.\n", __func__);
ret = SPI_GENERIC_ERROR;
}
- } else {
- *reset = 0; /* Default behaviour is no MCU reset on tear-down. */
}
free(reset_str);
+ *enter_isp = 1; /* Default behaviour is enter ISP on setup. */
isp_str = extract_programmer_param_str("enter_isp");
if (isp_str) {
if (isp_str[0] == '1') {
@@ -487,8 +486,6 @@ static int get_params(int *reset, int *enter_isp, int *allow_brick)
msg_perr("%s: Incorrect param format, enter_isp=1 or 0.\n", __func__);
ret = SPI_GENERIC_ERROR;
}
- } else {
- *enter_isp = 1; /* Default behaviour is enter ISP on setup. */
}
free(isp_str);