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

pickit2_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: Ib4ebc0e6354aad007145e1b0a761d9011c59ff7c
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66571
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
This commit is contained in:
Felix Singer 2022-08-09 06:35:43 +02:00 committed by Anastasia Klimchuk
parent fddcc379dc
commit d4a46375da

View File

@ -410,28 +410,30 @@ static int pickit2_spi_init(void)
libusb_device_handle *pickit2_handle;
struct pickit2_spi_data *pickit2_data;
int spispeed_idx = 0;
char *spispeed = extract_programmer_param_str("spispeed");
if (spispeed != NULL) {
char *param_str;
param_str = extract_programmer_param_str("spispeed");
if (param_str != NULL) {
int i = 0;
for (; spispeeds[i].name; i++) {
if (strcasecmp(spispeeds[i].name, spispeed) == 0) {
if (strcasecmp(spispeeds[i].name, param_str) == 0) {
spispeed_idx = i;
break;
}
}
if (spispeeds[i].name == NULL) {
msg_perr("Error: Invalid 'spispeed' value.\n");
free(spispeed);
free(param_str);
return 1;
}
free(spispeed);
free(param_str);
}
int millivolt = 3500;
char *voltage = extract_programmer_param_str("voltage");
if (voltage != NULL) {
millivolt = parse_voltage(voltage);
free(voltage);
param_str = extract_programmer_param_str("voltage");
if (param_str != NULL) {
millivolt = parse_voltage(param_str);
free(param_str);
if (millivolt < 0)
return 1;
}