Re: [PATCH 2/9] iio: imu: st_lsm6dsx: make event_settings more generic

From: Francesco Lavra

Date: Fri Oct 31 2025 - 04:08:17 EST


On Thu, 2025-10-30 at 17:44 +0100, Lorenzo Bianconi wrote:
> On Oct 30, Francesco Lavra wrote:
> > The st_lsm6dsx_event_settings structure contains fields specific
> > for one event type (wakeup). In preparation for adding support for
> > more event types, introduce an event id enum and a generic event
> > source structure, and replace wakeup-specific data in struct
> > st_lsm6dsx_event_settings with an array of event source structures.
> >
> > Signed-off-by: Francesco Lavra <flavra@xxxxxxxxxxxx>
> > ---
> >  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      |  21 ++-
> >  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 136 +++++++++++--------
> >  2 files changed, 96 insertions(+), 61 deletions(-)
> >
> > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > index db863bd1898d..05689887f7ec 100644
> > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > @@ -221,14 +221,23 @@ struct st_lsm6dsx_shub_settings {
> >         u8 pause;
> >  };
> >  
> > +enum st_lsm6dsx_event_id {
> > +       ST_LSM6DSX_EVENT_WAKEUP,
> > +       ST_LSM6DSX_EVENT_MAX
> > +};
> > +
> > +struct st_lsm6dsx_event_src {
> > +       struct st_lsm6dsx_reg value;
> > +       u8 status_reg;
> > +       u8 status_mask;
> > +       u8 status_x_mask;
> > +       u8 status_y_mask;
> > +       u8 status_z_mask;
>
> you can use st_lsm6dsx_reg here.

Do you mean replacing the status_* fields with 4 struct st_lsm6dsx_reg
fields (one for the global status flag, and one for each axis)?