Linux userland API discussions
 help / color / mirror / Atom feed
From: Cheng Ming Lin <linchengming884@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org, linux-api@vger.kernel.org,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	alvinzhou@mxic.com.tw
Subject: [PATCH 2/2] spi: spidev_test: Add an option to request DTR transfers
Date: Mon, 30 Nov 2026 13:49:31 +0800	[thread overview]
Message-ID: <20261130054931.2441438-3-chengminglin@mxic.com.tw> (raw)
In-Reply-To: <20261130054931.2441438-1-chengminglin@mxic.com.tw>

Add a -x/--dtr option setting SPI_IOC_XFER_DTR on every transfer of the
message, so that Double Transfer Rate transfers can be exercised with
spidev_test. Like the bus width options, it applies to all the
transfers. Report it along with the other device settings.

Controllers without DTR support reject such transfers, in which case
spidev_test reports that the message could not be sent.

Signed-off-by: Cheng Ming Lin <chengminglin@mxic.com.tw>
---
 tools/spi/spidev_test.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tools/spi/spidev_test.c b/tools/spi/spidev_test.c
index 5bd3159f6..dd429a94c 100644
--- a/tools/spi/spidev_test.c
+++ b/tools/spi/spidev_test.c
@@ -41,6 +41,7 @@ static char *output_file;
 static uint32_t speed = 500000;
 static uint16_t delay;
 static uint16_t word_delay;
+static int dtr;
 static int verbose;
 static int transfer_size = -1;
 static int transfers = 1;
@@ -169,6 +170,7 @@ static void transfer(int fd, uint8_t const * const tx, uint8_t const * const rx,
 			.word_delay_usecs = word_delay,
 			.speed_hz = speed,
 			.bits_per_word = bits,
+			.flags = dtr ? SPI_IOC_XFER_DTR : 0,
 		};
 
 		if (tx_buf)
@@ -244,7 +246,7 @@ static void transfer(int fd, uint8_t const * const tx, uint8_t const * const rx,
 
 static void print_usage(const char *prog)
 {
-	printf("Usage: %s [-2348CDFHILMNOPRSTZbcdiloprstvwz]\n", prog);
+	printf("Usage: %s [-2348CDFHILMNOPRSTZbcdiloprstvwxz]\n", prog);
 	puts("general device settings:\n"
 		 "  -D --device         device to use (default /dev/spidev1.1)\n"
 		 "  -s --speed          max speed (Hz)\n"
@@ -262,6 +264,7 @@ static void print_usage(const char *prog)
 		 "  -2 --dual           dual transfer\n"
 		 "  -4 --quad           quad transfer\n"
 		 "  -8 --octal          octal transfer\n"
+		 "  -x --dtr            double transfer rate\n"
 		 "  -3 --3wire          SI/SO signals shared\n"
 		 "  -Z --3wire-hiz      high impedance turnaround\n"
 		 "data:\n"
@@ -318,12 +321,13 @@ static void parse_opts(int argc, char *argv[])
 			{ "mosi-idle-low", 0, 0, 'M' },
 			{ "predictable",   1, 0, 'P' },
 			{ "transfers",     1, 0, 'T' },
+			{ "dtr",           0, 0, 'x' },
 			{ "verbose",       0, 0, 'v' },
 			{ NULL, 0, 0, 0 },
 		};
 		int c;
 
-		c = getopt_long(argc, argv, "D:s:d:w:b:i:o:lctrHOLC3ZFMNR248p:P:T:vS:zI:",
+		c = getopt_long(argc, argv, "D:s:d:w:b:i:o:lctrHOLC3ZFMNR248p:P:T:vS:zI:x",
 				lopts, NULL);
 
 		if (c == -1)
@@ -429,6 +433,9 @@ static void parse_opts(int argc, char *argv[])
 		case 'I':
 			iterations = atoi(optarg);
 			break;
+		case 'x':
+			dtr = 1;
+			break;
 		default:
 			print_usage(argv[0]);
 		}
@@ -648,6 +655,8 @@ int main(int argc, char *argv[])
 	printf("spi mode: 0x%x\n", mode);
 	printf("bits per word: %u\n", bits);
 	printf("max speed: %u Hz (%u kHz)\n", speed, speed/1000);
+	if (dtr)
+		printf("dtr: on\n");
 
 	if (input_tx)
 		transfer_escaped_string(fd, input_tx);
-- 
2.25.1


  parent reply	other threads:[~2026-11-30  5:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  5:49 [PATCH 0/2] spi: spidev: Allow userspace to request DTR transfers Cheng Ming Lin
2026-11-30  5:49 ` [PATCH 1/2] " Cheng Ming Lin
2026-11-30  5:49 ` Cheng Ming Lin [this message]
2026-11-30  8:36 ` [PATCH 0/2] " Miquel Raynal

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=20261130054931.2441438-3-chengminglin@mxic.com.tw \
    --to=linchengming884@gmail.com \
    --cc=alvinzhou@mxic.com.tw \
    --cc=broonie@kernel.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    /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