Re: [PATCH v4 5/9] iio: imu: st_lsm6dsx: remove event_threshold field from hw struct

From: Jonathan Cameron

Date: Sun Dec 07 2025 - 10:31:22 EST


On Mon, 1 Dec 2025 11:00:14 +0100
Francesco Lavra <flavra@xxxxxxxxxxxx> wrote:

> This field is used to store the wakeup event detection threshold value.
> When adding support for more event types, some of which may have different
> threshold values for different axes, storing all threshold values for all
> event sources would be cumbersome. Thus, remove this field altogether, and
> read the currently configured value from the sensor when requested by
> userspace.
>
> Signed-off-by: Francesco Lavra <flavra@xxxxxxxxxxxx>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
> ---
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 3 +--
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 12 +++++++++---
> 2 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> index 4200e5231950..b27a833d5107 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -79,6 +79,7 @@ enum st_lsm6dsx_hw_id {
> #define ST_LSM6DSX_MAX_TAGGED_WORD_LEN ((32 / ST_LSM6DSX_TAGGED_SAMPLE_SIZE) \
> * ST_LSM6DSX_TAGGED_SAMPLE_SIZE)
> #define ST_LSM6DSX_SHIFT_VAL(val, mask) (((val) << __ffs(mask)) & (mask))
> +#define st_lsm6dsx_field_get(mask, reg) ((reg & mask) >> __ffs(mask))

I'm not going to fuss too much about this as expectation is that
this will be replaced soon anyway with a generic version but convention
would be to (reg) & (mask) to avoid precedence of operator problems if
there are any in the parameters passed. The generic version will I guess also deal
with avoiding multiple evaluation of mask.

Anyhow, doesn't matter here given the simple user.

Applied.

Jonathan