linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Joshua Clayton
	<stillcompiling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Applied "spi: spidev_test: output to a file" to the spi tree
Date: Mon, 23 Nov 2015 14:54:22 +0000	[thread overview]
Message-ID: <E1a0sVa-0000Lq-7x@debutante> (raw)
In-Reply-To: <9ef02d085de706dfbf7eb57370ce33f076dfd9ce.1447880230.git.stillcompiling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

The patch

   spi: spidev_test: output to a file

has been applied to the spi tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 983b27886a3c7f6eff4e987ddba932da74703f4e Mon Sep 17 00:00:00 2001
From: Joshua Clayton <stillcompiling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Wed, 18 Nov 2015 14:30:40 -0800
Subject: [PATCH] spi: spidev_test: output to a file

For testing of larger data transfers, output unmodified data
directly to a file.

Signed-off-by: Joshua Clayton <stillcompiling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
 tools/spi/spidev_test.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/tools/spi/spidev_test.c b/tools/spi/spidev_test.c
index 71a45a4d7d49..02fc3a44901b 100644
--- a/tools/spi/spidev_test.c
+++ b/tools/spi/spidev_test.c
@@ -35,6 +35,7 @@ static const char *device = "/dev/spidev1.1";
 static uint32_t mode;
 static uint8_t bits = 8;
 static char *input_file;
+static char *output_file;
 static uint32_t speed = 500000;
 static uint16_t delay;
 static int verbose;
@@ -105,7 +106,7 @@ static int unescape(char *_dst, char *_src, size_t len)
 static void transfer(int fd, uint8_t const *tx, uint8_t const *rx, size_t len)
 {
 	int ret;
-
+	int out_fd;
 	struct spi_ioc_transfer tr = {
 		.tx_buf = (unsigned long)tx,
 		.rx_buf = (unsigned long)rx,
@@ -136,7 +137,21 @@ static void transfer(int fd, uint8_t const *tx, uint8_t const *rx, size_t len)
 
 	if (verbose)
 		hex_dump(tx, len, 32, "TX");
-	hex_dump(rx, len, 32, "RX");
+
+	if (output_file) {
+		out_fd = open(output_file, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+		if (out_fd < 0)
+			pabort("could not open output file");
+
+		ret = write(out_fd, rx, len);
+		if (ret != len)
+			pabort("not all bytes written to utput file");
+
+		close(out_fd);
+	}
+
+	if (verbose || !output_file)
+		hex_dump(rx, len, 32, "RX");
 }
 
 static void print_usage(const char *prog)
@@ -147,6 +162,7 @@ static void print_usage(const char *prog)
 	     "  -d --delay    delay (usec)\n"
 	     "  -b --bpw      bits per word \n"
 	     "  -i --input    input data from a file (e.g. \"test.bin\")\n"
+	     "  -o --output   output data to a file (e.g. \"results.bin\")\n"
 	     "  -l --loop     loopback\n"
 	     "  -H --cpha     clock phase\n"
 	     "  -O --cpol     clock polarity\n"
@@ -171,6 +187,7 @@ static void parse_opts(int argc, char *argv[])
 			{ "delay",   1, 0, 'd' },
 			{ "bpw",     1, 0, 'b' },
 			{ "input",   1, 0, 'i' },
+			{ "output",  1, 0, 'o' },
 			{ "loop",    0, 0, 'l' },
 			{ "cpha",    0, 0, 'H' },
 			{ "cpol",    0, 0, 'O' },
@@ -186,7 +203,7 @@ static void parse_opts(int argc, char *argv[])
 		};
 		int c;
 
-		c = getopt_long(argc, argv, "D:s:d:b:i:lHOLC3NR24p:v",
+		c = getopt_long(argc, argv, "D:s:d:b:i:o:lHOLC3NR24p:v",
 				lopts, NULL);
 
 		if (c == -1)
@@ -208,6 +225,9 @@ static void parse_opts(int argc, char *argv[])
 		case 'i':
 			input_file = optarg;
 			break;
+		case 'o':
+			output_file = optarg;
+			break;
 		case 'l':
 			mode |= SPI_LOOP;
 			break;
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-11-23 14:54 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-17 15:24 [PATCH 0/8] spi: Add file i/o to spidev_test Joshua Clayton
2015-11-17 15:24 ` [PATCH 1/8] Documentation/spi/spidev_test.c: use one rx buffer Joshua Clayton
     [not found]   ` <2f17ae29e75967b4522b080c275b907622e1d353.1447773299.git.stillcompiling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-17 17:41     ` Mark Brown
     [not found]       ` <20151117174156.GX31303-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-11-17 18:58         ` Joshua Clayton
2015-11-17 15:24 ` [PATCH 2/8] Documentation/spi/spidev_test.c: clean up input_tx Joshua Clayton
2015-11-17 17:43   ` Mark Brown
     [not found]     ` <20151117174333.GY31303-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-11-17 19:21       ` Joshua Clayton
2015-11-17 22:52         ` Mark Brown
2015-11-17 15:24 ` [PATCH 3/8] Documentation/spi/spidev_test.c: accept input from a file Joshua Clayton
2015-11-17 18:26   ` Anton Bondarenko
2015-11-17 18:46     ` Mark Brown
     [not found]     ` <564B716E.5020605-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-17 19:28       ` Joshua Clayton
     [not found] ` <cover.1447773299.git.stillcompiling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-17 15:24   ` [PATCH 4/8] Documentation/spi/spidev_test.c: output to " Joshua Clayton
2015-11-17 15:24   ` [PATCH 5/8] Documentation/spi/spidev_test.c: check error Joshua Clayton
2015-11-17 15:24 ` [PATCH 6/8] Documentation/spi/spidev_test.c: fix whitespace Joshua Clayton
2015-11-17 15:24 ` [PATCH 7/8] tools/Makefile: minor whitespace cleanup Joshua Clayton
     [not found]   ` <155366ac799345f42c8c342609ffa11b2df529b0.1447773299.git.stillcompiling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-17 18:09     ` Mark Brown
2015-11-17 19:41       ` Joshua Clayton
2015-11-17 15:24 ` [PATCH 8/8] spi: Move spi code from Documentation to tools Joshua Clayton
     [not found]   ` <7f1a4995f0e48b738d3aa4f4d8ddd210a0ae2b24.1447773299.git.stillcompiling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-17 18:11     ` Mark Brown
2015-11-17 15:37 ` [PATCH 0/8] spi: Add file i/o to spidev_test Mark Brown
2015-11-17 16:15   ` Joshua Clayton
2015-11-17 16:53     ` Mark Brown
2015-11-18 22:30     ` [PATCH v2 0/6] " Joshua Clayton
2015-11-18 22:30       ` [PATCH v2 1/6] spi: Move spi code from Documentation to tools Joshua Clayton
2015-11-18 22:30       ` [PATCH v2 2/6] spi: spidev_test: transfer_escaped_string function Joshua Clayton
     [not found]         ` <b0719c2739aabcd9894e85d82cbae21fcf83df3a.1447880230.git.stillcompiling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-23 14:54           ` Applied "spi: spidev_test: transfer_escaped_string function" to the spi tree Mark Brown
2015-11-18 22:30       ` [PATCH v2 3/6] spi: spidev_test: accept input from a file Joshua Clayton
     [not found]         ` <783ea7346741b23f17c73a13f03f64ac17de8c2e.1447880230.git.stillcompiling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-23 14:54           ` Applied "spi: spidev_test: accept input from a file" to the spi tree Mark Brown
     [not found]       ` <cover.1447880230.git.stillcompiling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-18 22:30         ` [PATCH v2 4/6] spi: spidev_test: output to a file Joshua Clayton
     [not found]           ` <9ef02d085de706dfbf7eb57370ce33f076dfd9ce.1447880230.git.stillcompiling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-23 14:54             ` Mark Brown [this message]
2015-11-18 22:30       ` [PATCH v2 5/6] spi: spidev_test: check error Joshua Clayton
     [not found]         ` <2bbb0374d7fd390a04ceb8d7b552f1a8d946c0f0.1447880230.git.stillcompiling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-23 14:54           ` Applied "spi: spidev_test: check error" to the spi tree Mark Brown
2015-11-18 22:30       ` [PATCH v2 6/6] spi: spidev_test: fix whitespace Joshua Clayton
     [not found]         ` <0365b51d6bfd3002287a1ebe382e58a2766aa2d2.1447880230.git.stillcompiling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-23 14:54           ` Applied "spi: spidev_test: fix whitespace" to the spi tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1a0sVa-0000Lq-7x@debutante \
    --to=broonie-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=stillcompiling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).