mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Marcelo Schmitt <marcelo.schmitt@analog.com>, linux-iio@vger.kernel.org
Cc: "Marcelo Schmitt" <marcelo.schmitt1@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Dan Carpenter" <dan.carpenter@linaro.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Michael Hennerich" <michael.hennerich@analog.com>
Subject: Re: [PATCH] iio: adc: ad4170-4: Correctly update filter_fs after filter type change
Date: Sun, 20 Jul 2025 10:48:41 +0200	[thread overview]
Message-ID: <43ed8918-0116-4e8b-943c-2e62906b1fdb@web.de> (raw)
In-Reply-To: <7b2fec30e9c6a80630a5fc08fb061d17417eb350.1752956751.git.marcelo.schmitt@analog.com>

…
> +++ b/drivers/iio/adc/ad4170-4.c
> @@ -880,10 +880,12 @@ static int ad4170_set_filter_type(struct iio_dev *indio_dev,
>  			return -EBUSY;
>  
>  		if (val == AD4170_SINC5_AVG || val == AD4170_SINC3)
> -			setup->filter_fs = clamp(val, AD4170_SINC3_MIN_FS,
> +			setup->filter_fs = clamp(setup->filter_fs,
> +						 AD4170_SINC3_MIN_FS,
>  						 AD4170_SINC3_MAX_FS);
>  		else
> -			setup->filter_fs = clamp(val, AD4170_SINC5_MIN_FS,
> +			setup->filter_fs = clamp(setup->filter_fs,
> +						 AD4170_SINC5_MIN_FS,
>  						 AD4170_SINC5_MAX_FS);
>  
>  		setup->filter &= ~AD4170_FILTER_FILTER_TYPE_MSK;

How do you think about to use the following code variant?

		setup->filter_fs = (val == AD4170_SINC5_AVG || val == AD4170_SINC3)
				   ? clamp(setup->filter_fs,
					   AD4170_SINC3_MIN_FS, AD4170_SINC3_MAX_FS)
				   : clamp(setup->filter_fs,
					   AD4170_SINC5_MIN_FS, AD4170_SINC5_MAX_FS);


Regards,
Markus

  reply	other threads:[~2025-07-20  8:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-19 20:36 Marcelo Schmitt
2025-07-20  8:48 ` Markus Elfring [this message]
2025-07-20 13:33   ` Marcelo Schmitt

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=43ed8918-0116-4e8b-943c-2e62906b1fdb@web.de \
    --to=markus.elfring@web.de \
    --cc=andy@kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.schmitt1@gmail.com \
    --cc=marcelo.schmitt@analog.com \
    --cc=michael.hennerich@analog.com \
    --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®