Linux IIO development
 help / color / mirror / Atom feed
From: David Lechner <dlechner@baylibre.com>
To: "Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] iio: adc: ad7173: fix num_slots
Date: Fri, 4 Jul 2025 12:04:04 -0500	[thread overview]
Message-ID: <f023c92b-183c-4157-a6eb-ff722dfd716a@baylibre.com> (raw)
In-Reply-To: <20250704-iio-adc-ad7173-fix-num_slots-on-most-chips-v2-1-a74941609143@baylibre.com>

On 7/4/25 11:21 AM, David Lechner wrote:
> Fix the num_slots value for most chips in the ad7173 driver. The correct
> value is the number of CHANNELx registers on the chip.
> 
> In commit 4310e15b3140 ("iio: adc: ad7173: don't make copy of
> ad_sigma_delta_info struct"), we refactored struct ad_sigma_delta_info
> to be static const data instead of being dynamically populated during
> driver probe. However, there was an existing bug in commit 76a1e6a42802
> ("iio: adc: ad7173: add AD7173 driver") where num_slots was incorrectly
> set to the number of CONFIGx registers instead of the number of
> CHANNELx registers. This bug was partially propagated to the refactored
> code in that the 16-channel chips were only given 8 slots instead of
> 16 although we did managed to fix the 8-channel chips and one of the
> 4-channel chips in that commit. However, we botched two of the 4-channel
> chips and ended up incorrectly giving them 8 slots during the
> refactoring.
> 
> This patch fixes that mistake on the 4-channel chips and also
> corrects the 16-channel chips to have 16 slots.
> 
> Fixes: 4310e15b3140 ("iio: adc: ad7173: don't make copy of ad_sigma_delta_info struct")
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---
> Changes in v2:
> - Improve commit message.
> - Link to v1: https://lore.kernel.org/r/20250703-iio-adc-ad7173-fix-num_slots-on-most-chips-v1-1-326c5d113e15@baylibre.com
> ---
>  drivers/iio/adc/ad7173.c | 37 +++++++++++++++++++++++++++----------
>  1 file changed, 27 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c
> index dd9fa35555c79ead5a1b88d1dc6cc3db122502be..9c197cea11eb955becf4b9b97246379fa9c5da13 100644
> --- a/drivers/iio/adc/ad7173.c
> +++ b/drivers/iio/adc/ad7173.c
> @@ -771,10 +771,27 @@ static const struct ad_sigma_delta_info ad7173_sigma_delta_info_8_slots = {
>  	.num_slots = 8,
>  };
>  
> +static const struct ad_sigma_delta_info ad7173_sigma_delta_info_16_slots = {
> +	.set_channel = ad7173_set_channel,
> +	.append_status = ad7173_append_status,
> +	.disable_all = ad7173_disable_all,
> +	.disable_one = ad7173_disable_one,
> +	.set_mode = ad7173_set_mode,
> +	.has_registers = true,
> +	.has_named_irqs = true,

> +	.supports_spi_offload = true,

Well drat, I was too quick with the update and the bots [1] noticed that
this conflicts with the in-flight patch that added this field [2].

I guess we can drop this one line, but then the other patch will wait
until this fix makes its way back into the togreg/testing branches.

[1]: https://lore.kernel.org/linux-iio/202507050018.iWEJiG04-lkp@intel.com/
[2]: https://lore.kernel.org/linux-iio/20250701-iio-adc-ad7173-add-spi-offload-support-v3-12-42abb83e3dac@baylibre.com/

> +	.addr_shift = 0,
> +	.read_mask = BIT(6),
> +	.status_ch_mask = GENMASK(3, 0),
> +	.data_reg = AD7173_REG_DATA,
> +	.num_resetclks = 64,
> +	.num_slots = 16,
> +};
> +

  reply	other threads:[~2025-07-04 17:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-04 16:21 [PATCH v2] iio: adc: ad7173: fix num_slots David Lechner
2025-07-04 17:04 ` David Lechner [this message]
2025-07-06 10:15   ` Jonathan Cameron
2025-07-06 16:08     ` David Lechner
2025-07-06 16:57       ` Jonathan Cameron
2025-07-06 17:33         ` David Lechner

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=f023c92b-183c-4157-a6eb-ff722dfd716a@baylibre.com \
    --to=dlechner@baylibre.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.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