> Report iio motion events to iio subsystem > > Signed-off-by: Sean Nyekjaer > --- > Changes since v4: > * Updated bitmask as pr Jonathans comments > > Changes since v5: > * None > > drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 5 ++ > drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 70 ++++++++++++++++++++ > 2 files changed, 75 insertions(+) > [...] > static irqreturn_t st_lsm6dsx_handler_irq(int irq, void *private) > { > return IRQ_WAKE_THREAD; > @@ -1668,6 +1726,18 @@ static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private) > { > struct st_lsm6dsx_hw *hw = private; > int count; > + int data, err; > + > + if (hw->enable_event) { Maybe I understood the issue between the buffered reading and event generation. I guess it is a race here between when the device is generating the interrupt and when you set enable_event. I think there are two solutions: 1- trivial one: always read wakeup_src_reg 2- set hw->enable_event as first instruction in st_lsm6dsx_write_event_config() and roll back in case of error. Could you please try that changes and double check if you are still able to trigger the issue? Regards, Lorenzo > + err = regmap_read(hw->regmap, > + hw->settings->event_settings.wakeup_src_reg, > + &data); > + if (err < 0) > + return IRQ_NONE; > + > + if (data & hw->settings->event_settings.wakeup_src_status_mask) > + st_lsm6dsx_report_motion_event(hw, data); > + } > > mutex_lock(&hw->fifo_lock); > count = hw->settings->fifo_ops.read_fifo(hw); > -- > 2.23.0 >