Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Janani Sunil" <janani.sunil@analog.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v8 05/17] iio: adc: Add AD7768 and AD7768-4 core support
Date: Wed, 16 Sep 2026 11:29:53 +0000	[thread overview]
Message-ID: <20260916112954.1DB5B1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260916-ad7768-driver-v8-5-27aa24db5225@analog.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] pm: missing pm_runtime_mark_last_busy() defeats autosuspend delay
- [Medium] spi: DMA API violation by reusing buffer across spi_transfer in same message
- [Medium] iio: adc: ad7768: CH_STANDBY uses logical instead of physical channel mask
--

commit 7e51bcc24a25f10a36ea6f88decaae9ab960a856
Author: Janani Sunil <janani.sunil@analog.com>

    iio: adc: Add AD7768 and AD7768-4 core support
    
    Add core support for the AD7768 and AD7768-4 simultaneous sampling ADCs.
    Configure supplies, clock and reset, use a custom regmap bus for the SPI
    protocol, and parse the enabled channels and input buffer settings from
    devicetree.

> diff --git a/drivers/iio/adc/ad7768.c b/drivers/iio/adc/ad7768.c
> new file mode 100644
> index 0000000000000..2c5d0657edf95
> --- /dev/null
> +++ b/drivers/iio/adc/ad7768.c
[ ... ]
> +static u8 ad7768_all_standby_mask(const struct ad7768_state *st)
> +{
> +	return GENMASK(st->chip_info->num_channels - 1, 0);
> +}

[Severity: Medium]
Does this correctly handle the physical channels for the AD7768-4?

The AD7768-4 uses physical channels 0, 1, 4, and 5 (as defined in
ad7768_4_chan_map). Generating a logical mask of GENMASK(3, 0) yields
0x0F, which would write 0 to bits 4 and 5 in the CH_STANDBY register. 
Since 0 means active, won't this force physical channels 4 and 5 to remain 
permanently active and cause a continuous power leak?

[ ... ]
> +static int ad7768_regmap_read(void *context, const void *reg_buf,
> +			      size_t reg_size, void *val_buf, size_t val_size)
> +{
> +	struct ad7768_state *st = spi_get_drvdata(context);
> +	struct spi_device *spi = context;
> +	struct spi_transfer t[] = {
> +		{
> +			.tx_buf = &st->d16,
> +			.len = sizeof(st->d16),
> +			.cs_change = 1,
> +		}, {
> +			/*
> +			 * Register responses are delayed by one CS frame. While
> +			 * receiving the response to this read, the device also
> +			 * decodes another command on SDI. Repeat the read
> +			 * command to avoid sending an unspecified dummy
> +			 * command.
> +			 */
> +			.tx_buf = &st->d16,
> +			.rx_buf = &st->d16,
> +			.len = sizeof(st->d16),
> +		},
> +	};

[Severity: Medium]
Can reusing the same virtual address (&st->d16) across multiple spi_transfer
structures in the same message lead to DMA mapping conflicts?

When spi_sync_transfer() processes this message, it maps the buffers for each
transfer. Won't this cause &st->d16 to be mapped as DMA_TO_DEVICE for the
first transfer, and then immediately mapped as DMA_BIDIRECTIONAL for the 
second transfer without an unmap in between, potentially violating the
DMA API and causing cache coherence issues?

[ ... ]
> +static int ad7768_buffer_postdisable(struct iio_dev *indio_dev)
> +{
> +	struct ad7768_state *st = iio_priv(indio_dev);
> +
> +	pm_runtime_put_autosuspend(regmap_get_device(st->regmap));
> +
> +	return 0;
> +}

[Severity: Medium]
Will this suspend the device synchronously and immediately rather than
honoring the autosuspend delay?

Since pm_runtime_mark_last_busy() is not called before
pm_runtime_put_autosuspend(), the last_busy timestamp will not be refreshed.
If the device was active for longer than the 2000ms autosuspend delay, won't
this result in unnecessary power cycling? This pattern also appears to be
missing in other disable paths.

[ ... ]
> +static int ad7768_parse_config(struct iio_dev *indio_dev,
> +			       struct device *dev)
> +{
[ ... ]
> +		if (channel >= st->chip_info->num_channels)
> +			return dev_err_probe(dev, -ECHRNG,
> +					     "Invalid channel %u in firmware\n",
> +					     channel);
> +
> +		ret = regmap_clear_bits(st->regmap, AD7768_REG_CH_STANDBY,
> +					BIT(channel));

[Severity: Medium]
Is it intentional to use the logical channel index here instead of the
mapped physical channel?

If this is the AD7768-4, the parsed channel index might be 2 or 3, but the
hardware channels that should be taken out of standby are 4 and 5. Should
this use ad7768_channel_mask(st, channel) to derive the correct physical
bits instead of BIT(channel)?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260916-ad7768-driver-v8-0-27aa24db5225@analog.com?part=5

  reply	other threads:[~2026-09-16 11:29 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 11:13 [PATCH v8 00/17] iio: adc: Add AD7768/AD7768-4 ADC driver support Janani Sunil
2026-09-16 11:13 ` [PATCH v8 01/17] iio: adc: adi-axi-adc: Initialize state mutex Janani Sunil
2026-09-16 11:13 ` [PATCH v8 02/17] dt-bindings: iio: adc: Add AD7768 Janani Sunil
2026-09-16 11:23   ` sashiko-bot
2026-09-16 11:13 ` [PATCH v8 03/17] iio: backend: Add support for CRC Janani Sunil
2026-09-16 11:13 ` [PATCH v8 04/17] iio: adc: adi-axi-adc: " Janani Sunil
2026-09-16 11:25   ` sashiko-bot
2026-09-16 11:13 ` [PATCH v8 05/17] iio: adc: Add AD7768 and AD7768-4 core support Janani Sunil
2026-09-16 11:29   ` sashiko-bot [this message]
2026-09-21  0:31   ` Jonathan Cameron
2026-09-16 11:13 ` [PATCH v8 06/17] iio: adc: ad7768: Validate master clock rate Janani Sunil
2026-09-16 11:13 ` [PATCH v8 07/17] iio: adc: ad7768: Add power mode helper Janani Sunil
2026-09-16 11:13 ` [PATCH v8 08/17] iio: adc: ad7768: Derive output data rates Janani Sunil
2026-09-16 11:13 ` [PATCH v8 09/17] iio: adc: ad7768: Configure channel sampling profiles Janani Sunil
2026-09-16 11:13 ` [PATCH v8 10/17] iio: adc: ad7768: Add sampling frequency controls Janani Sunil
2026-09-16 11:14 ` [PATCH v8 11/17] iio: adc: ad7768: Add per-channel filter controls Janani Sunil
2026-09-16 11:14 ` [PATCH v8 12/17] iio: adc: ad7768: Wait for digital filters to settle Janani Sunil
2026-09-16 11:14 ` [PATCH v8 13/17] iio: adc: ad7768: Add calibration controls Janani Sunil
2026-09-16 11:14 ` [PATCH v8 14/17] iio: adc: ad7768: Add per-channel conversion delay Janani Sunil
2026-09-16 11:14 ` [PATCH v8 15/17] iio: adc: ad7768: Add VCM regulator support Janani Sunil
2026-09-16 11:14 ` [PATCH v8 16/17] iio: adc: ad7768: Register GPIO auxiliary device Janani Sunil
2026-09-16 11:14 ` [PATCH v8 17/17] Documentation: iio: Add AD7768 Documentation Janani Sunil
2026-09-21  0:37 ` [PATCH v8 00/17] iio: adc: Add AD7768/AD7768-4 ADC driver support Jonathan Cameron
2026-09-21  8:46   ` Janani Sunil
2026-09-22  0:13     ` Jonathan Cameron

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=20260916112954.1DB5B1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=janani.sunil@analog.com \
    --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