diff options
author | Mark Brown <broonie@kernel.org> | 2020-03-27 15:53:00 +0000 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2020-03-27 15:53:00 +0000 |
commit | 1ba0b52ea73bd46ff053edea21f5630f5277fefe (patch) | |
tree | 1a4e561a0e0238a54aff02aa47e20cfcd61522be /tools/spi/spidev_test.c | |
parent | 16fbf79b0f83bc752cee8589279f1ebfe57b3b6e (diff) | |
parent | ebb3b9a92ba98efa8d0525367e653d5ee6630c1b (diff) |
Merge branch 'spi-5.7' into spi-next
Diffstat (limited to 'tools/spi/spidev_test.c')
-rw-r--r-- | tools/spi/spidev_test.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/tools/spi/spidev_test.c b/tools/spi/spidev_test.c index 3559e7646256..27967dd90f8f 100644 --- a/tools/spi/spidev_test.c +++ b/tools/spi/spidev_test.c @@ -13,6 +13,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <errno.h> #include <getopt.h> #include <fcntl.h> #include <time.h> @@ -26,7 +27,11 @@ static void pabort(const char *s) { - perror(s); + if (errno != 0) + perror(s); + else + printf("%s\n", s); + abort(); } @@ -283,7 +288,6 @@ static void parse_opts(int argc, char *argv[]) break; default: print_usage(argv[0]); - break; } } if (mode & SPI_LOOP) { @@ -405,6 +409,9 @@ int main(int argc, char *argv[]) parse_opts(argc, argv); + if (input_tx && input_file) + pabort("only one of -p and --input may be selected"); + fd = open(device, O_RDWR); if (fd < 0) pabort("can't open device"); @@ -446,9 +453,6 @@ int main(int argc, char *argv[]) printf("bits per word: %d\n", bits); printf("max speed: %d Hz (%d KHz)\n", speed, speed/1000); - if (input_tx && input_file) - pabort("only one of -p and --input may be selected"); - if (input_tx) transfer_escaped_string(fd, input_tx); else if (input_file) |