Re: [PATCH 3/7] spi: spidev_test: allow disabling rx or tx buffers

From: Mark Brown

Date: Mon Sep 14 2026 - 13:54:03 EST


On Mon, Sep 14, 2026 at 04:50:42PM +0200, Jonas Rebmann wrote:
> From: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
>
> Allow not providing rx or tx buffers. This is useful to check if drivers
> that don't use SPI_CONTROLLER_MUST_RX (or -TX respectively) handle their
> operations correctly without a buffer.

> - if (output_file) {
> + if (rx && output_file) {
> out_fd = open(output_file, O_WRONLY | O_CREAT | O_TRUNC, 0666);
> if (out_fd < 0)
> pabort("could not open output file");

It'd be nice to complain if the user asks for output and no RX
simultaneously, but OTOH I'm sure the target audience can cope.

> - if (input_tx && input_file)
> - pabort("only one of -p and --input may be selected");
> + if (!!input_tx + !!input_file + !do_tx > 0)
> + pabort("only one of -p, -i (--input), -t (--no-tx) may be selected");

This logic is probably a bit *too* cute; it's far too hard to read.

Attachment: signature.asc
Description: PGP signature