Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jonathan Santos" <Jonathan.Santos@analog.com>,
	devicetree@vger.kernel.org
Cc: robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v4 9/9] iio: adc: ad7768-1: add support for multiple chip aggregation
Date: Wed, 21 Oct 2026 02:11:45 +0000	[thread overview]
Message-ID: <sashiko-outbox-179690@kernel.org> (raw)
In-Reply-To: <7afbafd67ad52b2342af30c278b8b001413221ee.1792435248.git.Jonathan.Santos@analog.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] iio: adc: ad7768-1: incomplete multi-device read in ad7768_trigger_handler()
--

commit 093b4a79a74e19badb41a08df17fd753e9cf37ec
Author: Jonathan Santos <Jonathan.Santos@analog.com>

iio: adc: ad7768-1: add support for multiple chip aggregation

This commit adds support for aggregating multiple ad7768-1 devices connected
to the same spi controller using dedicated chip selects and data lanes. It
dynamically configures the channels, registers per-lane ancillary devices for
direct reads, and enables striped multi-lane transfers in offload mode.

> diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c
> index 3972821c295a1..667c09326f92f 100644
> --- a/drivers/iio/adc/ad7768-1.c
> +++ b/drivers/iio/adc/ad7768-1.c
[ ... ]
> @@ -335,7 +341,7 @@ struct ad7768_state {
>  	 */
>  	union {
>  		struct {
> -			__be32 chan;
> +			__be32 chan[AD7768_MAX_AGGR_DEVICES];
>  			aligned_s64 timestamp;
>  		} scan;
>  		__be32 d32;

[Severity: High]
While struct ad7768_state expands st->data.scan.chan[] for non-offload
triggered buffer capture, does ad7768_trigger_handler() in
drivers/iio/adc/ad7768-1.c also need to be updated when multiple devices are
aggregated?

When st->num_devices > 1 and spi offload is not present, ad7768_probe() still
falls back to registering the triggered buffer path via
ad7768_triggered_buffer_alloc():

drivers/iio/adc/ad7768-1.c:ad7768_probe() {
	...
	st->offload = devm_spi_offload_get(dev, spi, &ad7768_spi_offload_config);
	ret = PTR_ERR_OR_ZERO(st->offload);
	if (ret == -ENODEV) {
		/* If not using SPI offload, fall back to low speed usage */
		ret = ad7768_triggered_buffer_alloc(indio_dev);
	...
}

However, when buffered capture is enabled and the interrupt fires,
ad7768_trigger_handler() still performs a single-lane, single-sample read:

drivers/iio/adc/ad7768-1.c:ad7768_trigger_handler() {
	...
	ret = spi_read(st->spi, &st->data.scan.chan,
		       BITS_TO_BYTES(scan_type->realbits));
	if (ret < 0)
		goto out;

	iio_push_to_buffers_with_ts(indio_dev, &st->data.scan,
				    sizeof(st->data.scan),
				    iio_get_time_ns(indio_dev));
	...
}

Because spi_read() only reads a single sample of scan_type->realbits bits on
one lane into the start of st->data.scan.chan[0] while asserting all chip
selects on st->spi, the samples from devices 1 through st->num_devices - 1
are clocked out and lost on the bus, pushing unpopulated channel data to the
buffer.

Furthermore, with multiple channels enabled, a 3-byte read in 24-bit mode
(realbits = 24, storagebits = 32) or a 2-byte read in 16-bit mode
(st->oversampling_ratio == 8, realbits = 16, storagebits = 16) does not match
the 4-byte __be32 element stride of st->data.scan.chan[].

Should ad7768_trigger_handler() be updated to read and pack all
st->num_devices channels according to scan_type->storagebits, or is
non-offload buffered capture unsupported when st->num_devices > 1?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1792435248.git.Jonathan.Santos@analog.com?part=9

      reply	other threads:[~2026-10-21  2:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21  1:56 [PATCH v4 0/9] spi: add multi-CS and multi-chip aggregation support Jonathan Santos
2026-10-21  1:56 ` [PATCH v4 1/9] spi: dt-bindings: Add spi-cs-composite property Jonathan Santos
2026-10-21  1:56 ` [PATCH v4 2/9] dt-bindings: iio: adc: ad7768-1: Document multidevice support Jonathan Santos
2026-10-21  2:08   ` sashiko-bot
2026-10-21  1:57 ` [PATCH v4 3/9] spi: support simultaneous assertion of multiple CS Jonathan Santos
2026-10-21  1:57 ` [PATCH v4 4/9] spi: restrict CS logical values to a contiguous sequence Jonathan Santos
2026-10-21  2:09   ` sashiko-bot
2026-10-21  1:57 ` [PATCH v4 5/9] spi: expand device name to include enabled CS lines for multi-CS devices Jonathan Santos
2026-10-21  1:58 ` [PATCH v4 6/9] spi: introduce SPI ancillary device with lanes Jonathan Santos
2026-10-21  1:58 ` [PATCH v4 7/9] spi: add KUnit tests for the multi-CS framework Jonathan Santos
2026-10-21  2:08   ` sashiko-bot
2026-10-21  1:58 ` [PATCH v4 8/9] spi: spi-engine-ex: Add support for multi-CS devices Jonathan Santos
2026-10-21  1:58 ` [PATCH v4 9/9] iio: adc: ad7768-1: add support for multiple chip aggregation Jonathan Santos
2026-10-21  2:11   ` sashiko-bot [this message]

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=sashiko-outbox-179690@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Jonathan.Santos@analog.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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