summaryrefslogtreecommitdiffstats
path: root/tools/spi/spidev_test.c
Commit message (Collapse)AuthorAgeFilesLines
* spi: spidev_test: Improve decoded text part of hex dumpGeert Uytterhoeven2018-09-041-3/+3
| | | | | | | | | | | | | | - Print spaces as spaces, - Do not print characters > 126, as they will be shown as garbage in the modern UTF-8 era, - Use a normal period instead of its hexadecimal ASCII value, - Delimit the text part with pipe symbols on both sides (was left side only), without any spaces, to make it clear where the decoded text starts and ends, - Drop a useless comment. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: spidev_test: add option to continuously transfer dataFrode Isaksen2017-03-211-5/+88
| | | | | | | | | | | Add option to send+recv <size> bytes with <iter> iterations and show the transfer rate every 5 seconds. Example: rate: tx 4235.2kbps, rx 4235.2kbps total: tx 4882.8KB, rx 4882.8KB Signed-off-by: Frode Isaksen <fisaksen@baylibre.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: spidev_test: Fix input file check when transferring fileMichal Vokáč2016-11-041-1/+1
| | | | | | | | | | Check the input file fd instead of spidev fd. The spidev fd is supposed to be OK otherwise the transfer_file() function would not be called at all. Signed-off-by: Michal Vokáč <vokac.m@gmail.com> Reviewed-by: Joshua Clayton <stillcompiling@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
*-. Merge remote-tracking branches 'spi/topic/rspi', 'spi/topic/sc18is602', ↵Mark Brown2016-09-301-0/+1
|\ \ | | | | | | | | | 'spi/topic/sh-msiof', 'spi/topic/spidev-test' and 'spi/topic/st-ssc4' into spi-next
| | * spi: spidev_test: fix build with musl libcBaruch Siach2016-08-151-0/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | spidev.h uses _IOC_SIZEBITS directly. musl libc does not provide this macro unless linux/ioctl.h is included explicitly. Fixes build failures like: In file included from .../host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/sys/ioctl.h:7:0, from .../build/spidev_test-v3.15/spidev_test.c:20: .../build/spidev_test-v3.15/spidev_test.c: In function ‘transfer’: .../build/spidev_test-v3.15/spidev_test.c:75:18: error: ‘_IOC_SIZEBITS’ undeclared (first use in this function) ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); ^ Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Mark Brown <broonie@kernel.org>
* / spi: spidev_test: Fix buffer overflow in unescape()Geert Uytterhoeven2016-09-141-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | Sometimes spidev_test crashes with: *** Error in `spidev_test': munmap_chunk(): invalid pointer: 0x00022020 *** Aborted or just Segmentation fault This is due to transfer_escaped_string() miscalculating the required size of the buffer by one byte, causing a buffer overflow in unescape(). Drop the bogus "+ 1" in the strlen() parameter to fix this. Note that unescape() never copies the zero-terminator of the source string, so it writes at most as many bytes as the length of the source string. Fixes: 30061915be6e3a2c (spi: spidev_test: Added input buffer from the terminal) Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: <stable@vger.kernel.org> # v4.5+
* spi: spidev_test: Fix typo in error messageFabio Estevam2015-12-081-1/+1
| | | | | | | Fix the spelling of 'output' in the error message. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: spidev_test: fix whitespaceJoshua Clayton2015-11-231-2/+3
| | | | | Signed-off-by: Joshua Clayton <stillcompiling@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: spidev_test: check errorJoshua Clayton2015-11-231-1/+5
| | | | | | | | Check the result of sscanf to verify a result was found. report and error and abort if pattern was not found. Signed-off-by: Joshua Clayton <stillcompiling@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: spidev_test: output to a fileJoshua Clayton2015-11-231-3/+23
| | | | | | | | For testing of larger data transfers, output unmodified data directly to a file. Signed-off-by: Joshua Clayton <stillcompiling@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: spidev_test: accept input from a fileJoshua Clayton2015-11-231-1/+47
| | | | | | | Add input file support to facilitate testing larger data. Signed-off-by: Joshua Clayton <stillcompiling@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: spidev_test: transfer_escaped_string functionJoshua Clayton2015-11-231-13/+23
| | | | | | | | | Move the input_tx code into its own small function. This cleans up some variables from main() that are used only here. While we are at it, check malloc calls instead of assuming they succeed. Signed-off-by: Joshua Clayton <stillcompiling@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: Move spi code from Documentation to toolsJoshua Clayton2015-11-231-0/+318
Jon Corbet requested this code moved with the last changeset, https://lkml.org/lkml/2015/3/1/144, but the patch was not applied because it missed the Makefile. Moved spidev_test, spidev_fdx and their Makefile infrastructure. Signed-off-by: Joshua Clayton <stillcompiling@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>