summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Singer <felixsinger@posteo.net>2022-08-09 06:01:55 +0200
committerAnastasia Klimchuk <aklm@chromium.org>2022-08-14 23:47:09 +0000
commitfddcc379dca27896af3c93559c1390c2b3c6c59d (patch)
tree7ecead1b9b7c6e66d89325b1203f9420c982e609
parent5c644d86efad14850c430328030f804ae83fdf8c (diff)
downloadflashrom-fddcc379dca27896af3c93559c1390c2b3c6c59d.tar.gz
flashrom-fddcc379dca27896af3c93559c1390c2b3c6c59d.tar.bz2
flashrom-fddcc379dca27896af3c93559c1390c2b3c6c59d.zip
linux_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: I31e0baa2c5800c722a9ba853bcd40d71ed343f6d Reviewed-on: https://review.coreboot.org/c/flashrom/+/66568 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Thomas Heijligen <src@posteo.de>
-rw-r--r--linux_spi.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/linux_spi.c b/linux_spi.c
index 233650e5e..6ed4f68cc 100644
--- a/linux_spi.c
+++ b/linux_spi.c
@@ -167,7 +167,7 @@ out:
static int linux_spi_init(void)
{
- char *p, *endp, *dev;
+ char *param_str, *endp;
uint32_t speed_hz = 2 * 1000 * 1000;
/* FIXME: make the following configurable by CLI options. */
/* SPI mode 0 (beware this also includes: MSB first, CS active low and others */
@@ -177,12 +177,12 @@ static int linux_spi_init(void)
size_t max_kernel_buf_size;
struct linux_spi_data *spi_data;
- p = extract_programmer_param_str("spispeed");
- if (p && strlen(p)) {
- speed_hz = (uint32_t)strtoul(p, &endp, 10) * 1000;
- if (p == endp || speed_hz == 0) {
- msg_perr("%s: invalid clock: %s kHz\n", __func__, p);
- free(p);
+ param_str = extract_programmer_param_str("spispeed");
+ if (param_str && strlen(param_str)) {
+ speed_hz = (uint32_t)strtoul(param_str, &endp, 10) * 1000;
+ if (param_str == endp || speed_hz == 0) {
+ msg_perr("%s: invalid clock: %s kHz\n", __func__, param_str);
+ free(param_str);
return 1;
}
} else {
@@ -190,24 +190,24 @@ static int linux_spi_init(void)
"kHz clock. Use 'spispeed' parameter to override.\n",
speed_hz / 1000);
}
- free(p);
+ free(param_str);
- dev = extract_programmer_param_str("dev");
- if (!dev || !strlen(dev)) {
+ param_str = extract_programmer_param_str("dev");
+ if (!param_str || !strlen(param_str)) {
msg_perr("No SPI device given. Use flashrom -p "
"linux_spi:dev=/dev/spidevX.Y\n");
- free(dev);
+ free(param_str);
return 1;
}
- msg_pdbg("Using device %s\n", dev);
- if ((fd = open(dev, O_RDWR)) == -1) {
+ msg_pdbg("Using device %s\n", param_str);
+ if ((fd = open(param_str, O_RDWR)) == -1) {
msg_perr("%s: failed to open %s: %s\n", __func__,
- dev, strerror(errno));
- free(dev);
+ param_str, strerror(errno));
+ free(param_str);
return 1;
}
- free(dev);
+ free(param_str);
if (ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed_hz) == -1) {
msg_perr("%s: failed to set speed to %"PRIu32"Hz: %s\n",