This patch adds correct handling of the suffices M,m,K,k for the spispeed value (K,k don't change anything). Drop an error for any other suffix.
Change-Id: Ideb2295df8e82ccb2bbe2d58a6ee035b2ea602d0 Signed-Off-By: Joerg Albert jal2@gmx.de --- flashrom.8.tmpl | 4 ++++ linux_spi.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+)
diff --git a/flashrom.8.tmpl b/flashrom.8.tmpl index a3528f1..642a697 100644 --- a/flashrom.8.tmpl +++ b/flashrom.8.tmpl @@ -1032,6 +1032,10 @@ Example that sets the frequency to 8 MHz: .sp .B " flashrom -p linux_spi:dev=/dev/spidevX.Y,spispeed=8000" .sp +or +.sp +.B " flashrom -p linux_spi:dev=/dev/spidevX.Y,spispeed=8M" +.sp Please note that the linux_spi driver only works on Linux. .SS .BR "mstarddc_spi " programmer diff --git a/linux_spi.c b/linux_spi.c index 3e60492..1f3632b 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -80,6 +80,25 @@ int linux_spi_init(void) free(p); return 1; } + if (strlen(endp) == 1) { + if (toupper(*endp) == 'M') { + speed_hz *= 1000; + } else { + if (toupper(*endp) == 'K') { + ; + } else { + msg_perr("Error: Garbage following 'spispeed' value: %s\n", p); + free(p); + return 1; + } + } + } else { + if (strlen(endp) > 1) { + msg_perr("Error: Garbage following 'spispeed' value: %s\n", p); + free(p); + return 1; + } + } } free(p);