Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Janani Sunil" <janani.sunil@analog.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 08/18] iio: adc: ad4170-4: Fix output data rate on AD4190-4 and AD4195-4
Date: Thu, 03 Dec 2026 16:40:31 +0000	[thread overview]
Message-ID: <sashiko-outbox-248209@kernel.org> (raw)
In-Reply-To: <20261203-ad419x-release-v1-8-18578ab50524@analog.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] iio: adc: ad4170-4: regmap_write() to CLOCK_CTRL clears
  CLOCKDIV bits
--

commit 84752f37f843ed1d5b601d76f07823a7fc84e2bf
Author: Janani Sunil <janani.sunil@analog.com>

iio: adc: ad4170-4: Fix output data rate on AD4190-4 and AD4195-4

This commit adds a per-device clock_div to chip_info to divide the main
clock on AD4190-4 and AD4195-4, and initializes each channel's FILTER_FS
to its reset value instead of setting a fixed default sampling frequency.

> diff --git a/drivers/iio/adc/ad4170-4.c b/drivers/iio/adc/ad4170-4.c
> index 575ac8d613014..0a5d29200ff2e 100644
> --- a/drivers/iio/adc/ad4170-4.c
> +++ b/drivers/iio/adc/ad4170-4.c

[ ... ]

> @@ -2479,7 +2484,7 @@ static int ad4170_clock_select(struct iio_dev *indio_dev)
>  
>  	if (!ext_clk) {
>  		/* Use internal clock reference */
> -		st->mclk_hz = AD4170_INT_CLOCK_16MHZ;
> +		st->mclk_hz = AD4170_INT_CLOCK_16MHZ / st->chip->clock_div;
>  		st->clock_ctrl |= FIELD_PREP(AD4170_CLOCK_CTRL_CLOCKSEL_MSK,
>  					     AD4170_CLOCK_CTRL_CLOCKSEL_INT_OUT);
>  
> @@ -2506,6 +2511,8 @@ static int ad4170_clock_select(struct iio_dev *indio_dev)
>  				     st->mclk_hz);
>  	}
>  
> +	st->mclk_hz /= st->chip->clock_div;
> +
>  	return 0;
>  }

[Severity: Medium]
Does writing st->clock_ctrl to AD4170_CLOCK_CTRL_REG clear the hardware
CLOCKDIV default?

st->clock_ctrl starts at zero and ad4170_clock_select() only populates
AD4170_CLOCK_CTRL_CLOCKSEL_MSK.  ad4170_parse_firmware() then writes all
16 bits via regmap_write(st->regmap, AD4170_CLOCK_CTRL_REG,
st->clock_ctrl), zeroing bits 15:2 (as does ad4170_sel_clk()).

If CLOCKDIV encodes divide-by-2 as a non-zero value on AD4190-4 and
AD4195-4, clearing it defeats the divider that st->chip->clock_div
assumes, leaving st->mclk_hz mismatched with the actual ADC clock and
potentially clocking the ADC core above its rated frequency.

Using regmap_update_bits() with AD4170_CLOCK_CTRL_CLOCKSEL_MSK (or
programming CLOCKDIV in st->clock_ctrl) would keep the hardware divider
in sync with st->chip->clock_div.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-ad419x-release-v1-0-18578ab50524@analog.com?part=8

  reply	other threads:[~2026-12-03 16:40 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 15:19 [PATCH 00/18] iio: adc: ad4170-4: Fixes and AD4171-8/AD4190-8/AD4195-8 support Janani Sunil
2026-12-03 15:19 ` [PATCH 01/18] dt-bindings: iio: adc: ad4170-4: Restrict AD4170-4 only properties Janani Sunil
2026-12-03 15:19 ` [PATCH 02/18] dt-bindings: iio: adc: ad4170-4: Restrict channel inputs to valid codes Janani Sunil
2026-12-03 15:19 ` [PATCH 03/18] dt-bindings: iio: adc: ad4170-4: Allow running from the internal oscillator only Janani Sunil
2026-12-03 15:19 ` [PATCH 04/18] dt-bindings: iio: adc: ad4170-4: Fix the voltage bias description Janani Sunil
2026-12-03 15:19 ` [PATCH 05/18] iio: adc: ad4170-4: Fix out-of-bounds accesses to pins_fn[] Janani Sunil
2026-12-03 15:19 ` [PATCH 06/18] iio: adc: ad4170-4: Fix voltage bias programming Janani Sunil
2026-12-03 15:19 ` [PATCH 07/18] iio: adc: ad4170-4: Fix overflow in sample rate fractional part Janani Sunil
2026-12-03 16:22   ` sashiko-bot
2026-12-03 15:19 ` [PATCH 08/18] iio: adc: ad4170-4: Fix output data rate on AD4190-4 and AD4195-4 Janani Sunil
2026-12-03 16:40   ` sashiko-bot [this message]
2026-12-03 15:19 ` [PATCH 09/18] iio: adc: ad4170-4: Fix filter_fs adjustment on filter type change Janani Sunil
2026-12-03 15:19 ` [PATCH 10/18] iio: adc: ad4170-4: Fix lock order inversion with IIO direct mode Janani Sunil
2026-12-03 15:19 ` [PATCH 11/18] iio: adc: ad4170-4: Fix sinc5 filter FILTER_FS range on AD4190-4 and AD4195-4 Janani Sunil
2026-12-03 15:19 ` [PATCH 12/18] iio: adc: ad4170-4: Do not drive XTAL2 when using the internal clock Janani Sunil
2026-12-03 15:19 ` [PATCH 13/18] iio: adc: ad4170-4: Restrict current sources and AC excitation to supported parts Janani Sunil
2026-12-03 15:19 ` [PATCH 14/18] iio: adc: ad4170-4: Require equal chopped excitation currents Janani Sunil
2026-12-03 15:19 ` [PATCH 15/18] iio: adc: ad4170-4: Fix channel count with 15 external channels Janani Sunil
2026-12-03 15:19 ` [PATCH 16/18] iio: adc: ad4170-4: Drop ad4170_iout_pin_tbl Janani Sunil
2026-12-03 15:19 ` [PATCH 17/18] dt-bindings: iio: adc: ad4170-4: Add AD4171-8, AD4190-8 and AD4195-8 Janani Sunil
2026-12-03 15:19 ` [PATCH 18/18] iio: adc: ad4170-4: Add support for " Janani Sunil

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-248209@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