From: "Nuno Sá" <nuno.sa@analog.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jonathan Cameron <jic23@kernel.org>,
Josef Bacik <josef@toxicpanda.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
stable <stable@kernel.org>,
Marcelo Schmitt <marcelo.schmitt@analog.com>,
Antoniu Miclaus <antoniu.miclaus@analog.com>,
Michael Hennerich <Michael.Hennerich@analog.com>,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>,
Cosmin Tanislav <demonsingur@gmail.com>
Subject: Re: [PATCH 03/15] iio: accel: adxl367: don't stay in standby on -EINVAL
Date: Wed, 28 Oct 2026 10:01:47 +0000 [thread overview]
Message-ID: <auHHf3JSYXE7IthG@nsa> (raw)
In-Reply-To: <20261027-llm-char-misc-iio-v1-3-0d818334f6c7@linuxfoundation.org>
On Tue, Oct 27, 2026 at 05:19:07PM +0100, Greg Kroah-Hartman wrote:
> From: Josef Bacik <josef@toxicpanda.com>
>
> adxl367_set_act_threshold() puts the sensor into standby, writes the
> threshold and switches the measurement on again. A threshold above 8191 is
> refused in between, and the sensor stays in standby: no samples and no
> events until the next write that succeeds.
>
> adxl367_set_range() has the same problem and a worse one. It rescales both
> thresholds for the new range, times four from 8 g to 2 g. If one no longer
> fits it returns -EINVAL with the sensor in standby, the new range in the
> chip, the old one in st->range and rescaled thresholds in the driver's
> state: from the next successful write on the samples are reported with the
> wrong scale.
>
> Switch the measurement on again if the threshold is refused. In
> adxl367_set_range() see whether the thresholds fit before anything is
> changed.
>
> Fixes: cbab791c5e2a ("iio: accel: add ADXL367 driver")
> Cc: stable <stable@kernel.org>
> Cc: Marcelo Schmitt <marcelo.schmitt@analog.com>
> Cc: Antoniu Miclaus <antoniu.miclaus@analog.com>
> Cc: "Nuno Sá" <nuno.sa@analog.com>
> Cc: Michael Hennerich <Michael.Hennerich@analog.com>
> Cc: David Lechner <dlechner@baylibre.com>
> Cc: Andy Shevchenko <andy@kernel.org>
> Cc: Cosmin Tanislav <demonsingur@gmail.com>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
Why don't we use mul_frac() as in the next patch? Also don't love the
condition duplication (feels like some refactor would be worth it). But
for backporting purposes, seems reasonable like. With mul_frac()
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> drivers/iio/accel/adxl367.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/adxl367.c b/drivers/iio/accel/adxl367.c
> index 026db73057c5..ba6e7423978f 100644
> --- a/drivers/iio/accel/adxl367.c
> +++ b/drivers/iio/accel/adxl367.c
> @@ -349,8 +349,11 @@ static int adxl367_set_act_threshold(struct adxl367_state *st,
> return ret;
>
> ret = _adxl367_set_act_threshold(st, act, threshold);
> - if (ret)
> + if (ret) {
> + /* Leave standby also if the value was refused */
> + adxl367_set_measure_en(st, true);
> return ret;
> + }
>
> return adxl367_set_measure_en(st, true);
> }
> @@ -483,6 +486,12 @@ static int adxl367_set_range(struct iio_dev *indio_dev,
>
> guard(mutex)(&st->lock);
>
> + /* The thresholds are rescaled: see that they fit before any change */
> + if (max(st->act_threshold, st->inact_threshold) *
> + adxl367_range_scale_factor_tbl[st->range] /
> + adxl367_range_scale_factor_tbl[range] > ADXL367_THRESH_MAX)
> + return -EINVAL;
> +
> ret = adxl367_set_measure_en(st, false);
> if (ret)
> return ret;
>
> --
> 2.56.0
>
next prev parent reply other threads:[~2026-10-28 10:00 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 16:19 [PATCH 00/15] IIO: a bunch of llm-found fixes Greg Kroah-Hartman
2026-10-27 16:19 ` [PATCH 01/15] iio: buffer: let the block keep its DMA fence Greg Kroah-Hartman
2026-10-28 9:30 ` Nuno Sá
2026-10-27 16:19 ` [PATCH 02/15] iio: trigger: fail the attach if no sub-IRQ is left Greg Kroah-Hartman
2026-10-28 9:38 ` Nuno Sá
2026-10-27 16:19 ` [PATCH 03/15] iio: accel: adxl367: don't stay in standby on -EINVAL Greg Kroah-Hartman
2026-10-28 10:01 ` Nuno Sá [this message]
2026-10-27 16:19 ` [PATCH 04/15] iio: accel: adxl380: " Greg Kroah-Hartman
2026-10-28 10:02 ` Nuno Sá
2026-10-27 16:19 ` [PATCH 05/15] iio: adc: check the result of ad_sd_init() Greg Kroah-Hartman
2026-10-28 9:40 ` Nuno Sá
2026-10-27 16:19 ` [PATCH 06/15] iio: adc: ad7923: add the AD7927 to the SPI ID table Greg Kroah-Hartman
2026-10-28 9:35 ` Nuno Sá
2026-10-27 16:19 ` [PATCH 07/15] iio: addac: ad74413r: fix the values of set_multiple Greg Kroah-Hartman
2026-10-28 9:38 ` Nuno Sá
2026-10-27 16:19 ` [PATCH 08/15] iio: light: apds9306: push events to the IIO device Greg Kroah-Hartman
2026-10-27 16:19 ` [PATCH 09/15] iio: light: tsl2591: don't divide by zero in the dark Greg Kroah-Hartman
2026-10-27 16:19 ` [PATCH 10/15] iio: light: tsl2591: don't divide by zero with low gain Greg Kroah-Hartman
2026-10-28 2:13 ` Jonathan Cameron
2026-10-28 4:16 ` Greg Kroah-Hartman
2026-10-27 16:19 ` [PATCH 11/15] iio: hid-sensors: fix a division by zero Greg Kroah-Hartman
2026-10-27 16:19 ` [PATCH 12/15] iio: imu: inv_mpu6050: don't disable the IRQ under lock Greg Kroah-Hartman
2026-10-27 16:19 ` [PATCH 13/15] iio: proximity: sx9500: hand on probe deferral of GPIOs Greg Kroah-Hartman
2026-10-28 2:09 ` Jonathan Cameron
2026-10-27 16:19 ` [PATCH 14/15] iio: scmi: use 64-bit divisions for rates and intervals Greg Kroah-Hartman
2026-10-28 1:46 ` Jonathan Cameron
2026-10-27 16:19 ` [PATCH 15/15] iio: sx9310: use the data of the I2C table Greg Kroah-Hartman
2026-10-27 16:25 ` Biju Das
2026-10-27 16:38 ` Andy Shevchenko
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=auHHf3JSYXE7IthG@nsa \
--to=nuno.sa@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=antoniu.miclaus@analog.com \
--cc=demonsingur@gmail.com \
--cc=dlechner@baylibre.com \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=josef@toxicpanda.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.schmitt@analog.com \
--cc=stable@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.