diff options
author | Felix Singer <felixsinger@posteo.net> | 2022-07-16 11:28:48 +0200 |
---|---|---|
committer | Anastasia Klimchuk <aklm@chromium.org> | 2022-08-14 23:39:54 +0000 |
commit | a93c2e7d1ee7af62c1f9bb342e6025ae1aa4c90d (patch) | |
tree | 556faeb02d19407640e7776b74e0782719ef185b | |
parent | bcdfcaf9b083ac4ce512c796313bdf1c6a143ff7 (diff) | |
download | flashrom-a93c2e7d1ee7af62c1f9bb342e6025ae1aa4c90d.tar.gz flashrom-a93c2e7d1ee7af62c1f9bb342e6025ae1aa4c90d.tar.bz2 flashrom-a93c2e7d1ee7af62c1f9bb342e6025ae1aa4c90d.zip |
stlinkv3_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: I548bb2e0786be0af20114e6bf1450c5fedb83d23
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65910
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
-rw-r--r-- | stlinkv3_spi.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c index 43e47bac..4919d48a 100644 --- a/stlinkv3_spi.c +++ b/stlinkv3_spi.c @@ -477,8 +477,7 @@ static const struct spi_master spi_programmer_stlinkv3 = { static int stlinkv3_spi_init(void) { uint16_t sck_freq_kHz = 1000; // selecting 1 MHz SCK is a good bet - char *speed_str = NULL; - char *serialno = NULL; + char *param_str; char *endptr = NULL; int ret = 1; int devIndex = 0; @@ -492,44 +491,44 @@ static int stlinkv3_spi_init(void) return 1; } - serialno = extract_programmer_param_str("serial"); - if (serialno) - msg_pdbg("Opening STLINK-V3 with serial: %s\n", serialno); + param_str = extract_programmer_param_str("serial"); + if (param_str) + msg_pdbg("Opening STLINK-V3 with serial: %s\n", param_str); while (devs_stlinkv3_spi[devIndex].vendor_id != 0) { stlinkv3_handle = usb_dev_get_by_vid_pid_serial(usb_ctx, devs_stlinkv3_spi[devIndex].vendor_id, devs_stlinkv3_spi[devIndex].device_id, - serialno); + param_str); if (stlinkv3_handle) break; devIndex++; } if (!stlinkv3_handle) { - if (serialno) - msg_perr("No STLINK-V3 seems to be connected with serial %s\n", serialno); + if (param_str) + msg_perr("No STLINK-V3 seems to be connected with serial %s\n", param_str); else msg_perr("Could not find any connected STLINK-V3\n"); - free(serialno); + free(param_str); goto init_err_exit; } - free(serialno); + free(param_str); - speed_str = extract_programmer_param_str("spispeed"); - if (speed_str) { - sck_freq_kHz = strtoul(speed_str, &endptr, 0); + param_str = extract_programmer_param_str("spispeed"); + if (param_str) { + sck_freq_kHz = strtoul(param_str, &endptr, 0); if (*endptr || sck_freq_kHz == 0) { msg_perr("The spispeed parameter passed with invalid format: %s\n", - speed_str); + param_str); msg_perr("Please pass the parameter " "with a simple non-zero number in kHz\n"); - free(speed_str); + free(param_str); ret = -1; goto init_err_exit; } - free(speed_str); + free(param_str); } if (stlinkv3_spi_open(sck_freq_kHz, stlinkv3_handle)) |