mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Lechner <dlechner@baylibre.com>
To: "Ben Collins" <bcollins@kernel.org>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Antoniu Miclaus" <antoniu.miclaus@analog.com>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 5/5] iio: ad4080: Rework filter_type "none" logic
Date: Tue, 26 Aug 2025 11:51:56 -0500	[thread overview]
Message-ID: <0f515c35-b2ac-4d23-b8bb-77151ed2eb9f@baylibre.com> (raw)
In-Reply-To: <20250825-mcp9600-iir-v7-5-2ba676a52589@kernel.org>

On 8/25/25 7:10 PM, Ben Collins wrote:
> The filter_type logic for "none" needed to be reworked to be more
> general.
> 
> As documented, return IIO_VAL_EMPTY for sampling rates in "none" type
> and EINVAL when there's an attempt to write a rate for "none" type.

This patch breaks usespace, which is something we always must avoid.

> 
> Signed-off-by: Ben Collins <bcollins@kernel.org>
> ---
>  drivers/iio/adc/ad4080.c | 23 ++++++++++-------------
>  1 file changed, 10 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad4080.c b/drivers/iio/adc/ad4080.c
> index 6e61787ed3213fe4332bd92b938a7a717dada99f..c7408b9703731ee5d4229a85ffa91ea64b233cd9 100644
> --- a/drivers/iio/adc/ad4080.c
> +++ b/drivers/iio/adc/ad4080.c
> @@ -154,8 +154,6 @@ static const int ad4080_dec_rate_avail[] = {
>  	2, 4, 8, 16, 32, 64, 128, 256, 512, 1024,
>  };
>  
> -static const int ad4080_dec_rate_none[] = { 1 };
> -
>  static const char * const ad4080_power_supplies[] = {
>  	"vdd33", "vdd11", "vddldo", "iovdd", "vrefin",
>  };
> @@ -268,13 +266,13 @@ static int ad4080_read_raw(struct iio_dev *indio_dev,
>  			*val = st->clk_rate;
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
> -		if (st->filter_type == FILTER_NONE) {
> -			*val = 1;
> -		} else {
> -			*val = ad4080_get_dec_rate(indio_dev, chan);
> -			if (*val < 0)
> -				return *val;
> -		}
> +		if (st->filter_type == FILTER_NONE)
> +			return IIO_VAL_EMPTY;
> +
> +		*val = ad4080_get_dec_rate(indio_dev, chan);
> +		if (*val < 0)
> +			return *val;
> +
>  		return IIO_VAL_INT;
>  	default:
>  		return -EINVAL;
> @@ -289,7 +287,7 @@ static int ad4080_write_raw(struct iio_dev *indio_dev,
>  
>  	switch (mask) {
>  	case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
> -		if (st->filter_type == FILTER_NONE && val > 1)
> +		if (st->filter_type == FILTER_NONE)
>  			return -EINVAL;
>  
>  		return ad4080_set_dec_rate(indio_dev, chan, val);
> @@ -376,17 +374,16 @@ static int ad4080_read_avail(struct iio_dev *indio_dev,
>  	case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
>  		switch (st->filter_type) {
>  		case FILTER_NONE:
> -			*vals = ad4080_dec_rate_none;
> -			*length = ARRAY_SIZE(ad4080_dec_rate_none);
> +			*type = IIO_VAL_EMPTY;
>  			break;
>  		default:
>  			*vals = ad4080_dec_rate_avail;
>  			*length = st->filter_type >= SINC_5 ?
>  				  (ARRAY_SIZE(ad4080_dec_rate_avail) - 2) :
>  				  ARRAY_SIZE(ad4080_dec_rate_avail);
> +			*type = IIO_VAL_INT;
>  			break;
>  		}
> -		*type = IIO_VAL_INT;
>  		return IIO_AVAIL_LIST;
>  	default:
>  		return -EINVAL;
> 

Returning a value of 1 for the oversampling ratio when there is no
oversampling going on is perfectly reasonable and mathematically correct.
So I don't consider this change an improvement.

  reply	other threads:[~2025-08-26 16:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-26  0:10 [PATCH v7 0/5] iio: mcp9600: Implement IIR feature and add iio core support Ben Collins
2025-08-26  0:10 ` [PATCH v7 1/5] iio: core: Add IIO_VAL_EMPTY type Ben Collins
2025-08-26 17:00   ` David Lechner
2025-08-26 18:52     ` Ben Collins
2025-08-31 15:19       ` Jonathan Cameron
2025-08-26  0:10 ` [PATCH v7 2/5] ABI: sysfs-bus-iio: Disambiguate usage for filter_type "none" Ben Collins
2025-08-26  0:10 ` [PATCH v7 3/5] ABI: sysfs-bus-iio: Document "ema" filter_type Ben Collins
2025-08-26  0:10 ` [PATCH v7 4/5] iio: mcp9600: Add support for IIR filter Ben Collins
2025-08-26 17:20   ` David Lechner
2025-08-26 19:08     ` Ben Collins
2025-08-26  0:10 ` [PATCH v7 5/5] iio: ad4080: Rework filter_type "none" logic Ben Collins
2025-08-26 16:51   ` David Lechner [this message]
2025-08-26 19:11     ` Ben Collins
2025-08-31 15:25       ` Jonathan Cameron
2025-08-26  8:14 ` [PATCH v7 0/5] iio: mcp9600: Implement IIR feature and add iio core support Andy Shevchenko
2025-08-26  9:38   ` Ben Collins

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=0f515c35-b2ac-4d23-b8bb-77151ed2eb9f@baylibre.com \
    --to=dlechner@baylibre.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=antoniu.miclaus@analog.com \
    --cc=bcollins@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

all inboxes | Powered by JetHome®