From: Jonathan Cameron <jic23@kernel.org>
To: Salah Triki <salah.triki@gmail.com>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
"Joshua Crofts" <joshua.crofts1@gmail.com>
Subject: Re: [PATCH v2] iio: accel: sca3000: fix frequency divider condition check
Date: Sun, 23 Aug 2026 19:49:05 +0100 [thread overview]
Message-ID: <20260823194905.5a73f55f@jic23-huawei> (raw)
In-Reply-To: <20260821150113.45972-1-salah.triki@gmail.com>
On Fri, 21 Aug 2026 16:01:12 +0100
Salah Triki <salah.triki@gmail.com> wrote:
> When setting the sampling frequency, the check for `base_freq / 2` is
> followed by an independent `if` statement for `base_freq / 4`. If `val`
> equals `base_freq / 2`, the second check fails and falls through to the
> `else if (val != base_freq)` branch, returning `-EINVAL` erroneously.
>
> Fix this by chaining the checks with `else if`.
>
> Fixes: e0f3fc9b47e6 ("iio: accel: sca3000_core: implemented IIO_CHAN_INFO_SAMP_FREQ")
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
> Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
> ---
Ah, I should have checked for a new version. Generally when it's just tags pick
up (even for fixes) no need to send a new version. Never mind though as I think
the right thing landed anyway!
Jonathan
> Changes since v1:
> - Add Fixes and Reviewed-by tags
>
> drivers/iio/accel/sca3000.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
> index 573831199bba..cced5cd82b02 100644
> --- a/drivers/iio/accel/sca3000.c
> +++ b/drivers/iio/accel/sca3000.c
> @@ -638,7 +638,7 @@ static int sca3000_write_raw_samp_freq(struct sca3000_state *st, int val)
>
> if (val == base_freq / 2)
> ctrlval |= SCA3000_REG_OUT_CTRL_BUF_DIV_2;
> - if (val == base_freq / 4)
> + else if (val == base_freq / 4)
> ctrlval |= SCA3000_REG_OUT_CTRL_BUF_DIV_4;
> else if (val != base_freq)
> return -EINVAL;
prev parent reply other threads:[~2026-08-23 18:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 15:01 [PATCH v2] iio: accel: sca3000: fix frequency divider condition check Salah Triki
2026-08-23 18:49 ` Jonathan Cameron [this message]
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=20260823194905.5a73f55f@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=joshua.crofts1@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=salah.triki@gmail.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