From bde9479dc167aacbaaeb1bec2338eb9fb096e018 Mon Sep 17 00:00:00 2001 From: Felix Singer Date: Mon, 18 Jul 2022 04:14:13 +0200 Subject: 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 Change-Id: Ibb43aaa4d70ee0827587288c658f01bcef583ddd Reviewed-on: https://review.coreboot.org/c/flashrom/+/65936 Reviewed-by: Anastasia Klimchuk Reviewed-by: Peter Marheine Reviewed-by: Angel Pons Reviewed-by: Thomas Heijligen Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan --- realtek_mst_i2c_spi.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'realtek_mst_i2c_spi.c') diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c index ce1637a1..126f7de1 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); -- cgit v1.2.3