summaryrefslogtreecommitdiff
path: root/linux_spi.c
diff options
context:
space:
mode:
authorstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2014-03-19 17:17:06 +0000
committerstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2014-03-19 17:17:06 +0000
commitdc9fed440093eccc737ccf725cf2a963e1e070fb (patch)
treeda9d3b5f589abf8e14a7f1ad0571c0a12bd0ff19 /linux_spi.c
parent0c20a90e52ac9e9955af768a601eb838e9f1f2b5 (diff)
downloadflashrom-dc9fed440093eccc737ccf725cf2a963e1e070fb.tar.gz
linux_spi: Stop messing up the units of SPI speed.
'speed' is stored in Hz, so rename the variable to 'speed_hz' to clarify any potential confusion. Also, when printing the speed after setting it with an ioctl, convert it to kHz to match the units given in the message. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Acked-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1769 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'linux_spi.c')
-rw-r--r--linux_spi.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/linux_spi.c b/linux_spi.c
index 135af9f..f0c6404 100644
--- a/linux_spi.c
+++ b/linux_spi.c
@@ -60,7 +60,7 @@ static const struct spi_programmer spi_programmer_linux = {
int linux_spi_init(void)
{
char *p, *endp, *dev;
- uint32_t speed = 0;
+ uint32_t speed_hz = 0;
/* FIXME: make the following configurable by CLI options. */
/* SPI mode 0 (beware this also includes: MSB first, CS active low and others */
const uint8_t mode = SPI_MODE_0;
@@ -68,7 +68,7 @@ int linux_spi_init(void)
p = extract_programmer_param("spispeed");
if (p && strlen(p)) {
- speed = (uint32_t)strtoul(p, &endp, 10) * 1000;
+ speed_hz = (uint32_t)strtoul(p, &endp, 10) * 1000;
if (p == endp) {
msg_perr("%s: invalid clock: %s kHz\n", __func__, p);
free(p);
@@ -98,14 +98,14 @@ int linux_spi_init(void)
return 1;
/* We rely on the shutdown function for cleanup from here on. */
- if (speed > 0) {
- if (ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed) == -1) {
+ if (speed_hz > 0) {
+ if (ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed_hz) == -1) {
msg_perr("%s: failed to set speed to %d Hz: %s\n",
- __func__, speed, strerror(errno));
+ __func__, speed_hz, strerror(errno));
return 1;
}
- msg_pdbg("Using %d kHz clock\n", speed);
+ msg_pdbg("Using %d kHz clock\n", speed_hz/1000);
}
if (ioctl(fd, SPI_IOC_WR_MODE, &mode) == -1) {