Author: uwe Date: Wed Sep 7 22:48:34 2011 New Revision: 1432 URL: http://flashrom.org/trac/flashrom/changeset/1432
Log: Small fixes for the linux_spi programmer code.
Signed-off-by: Sven Schnelle svens@stackframe.org Acked-by: Uwe Hermann uwe@hermann-uwe.de
Modified: trunk/linux_spi.c
Modified: trunk/linux_spi.c ============================================================================== --- trunk/linux_spi.c Wed Sep 7 22:20:25 2011 (r1431) +++ trunk/linux_spi.c Wed Sep 7 22:48:34 2011 (r1432) @@ -54,7 +54,7 @@ int linux_spi_init(void) { char *p, *endp, *dev; - int speed = 0; + uint32_t speed = 0;
dev = extract_programmer_param("dev"); if (!dev || !strlen(dev)) { @@ -65,24 +65,29 @@
p = extract_programmer_param("speed"); if (p && strlen(p)) { - speed = strtoul(p, &endp, 10) * 1024; + speed = (uint32_t)strtoul(p, &endp, 10) * 1024; if (p == endp) { msg_perr("%s: invalid clock: %s kHz\n", __func__, p); return 1; } }
+ msg_pdbg("Using device %s\n", dev); if ((fd = open(dev, O_RDWR)) == -1) { msg_perr("%s: failed to open %s: %s\n", __func__, dev, strerror(errno)); return 1; }
- if (speed > 0 && ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed) == -1) { - msg_perr("%s: failed to set speed %dHz: %s\n", - __func__, speed, strerror(errno)); - close(fd); - return 1; + if (speed > 0) { + if (ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed) == -1) { + msg_perr("%s: failed to set speed %dHz: %s\n", + __func__, speed, strerror(errno)); + close(fd); + return 1; + } + + msg_pdbg("Using %d kHz clock\n", speed); }
if (register_shutdown(linux_spi_shutdown, NULL))