On Thu, 21 Apr 2022 02:41:02 +0530 Jagath Jog J <jagathjog1996@xxxxxxxxx> wrote: > Added support for event when there is a detection of step change. > INT1 pin is used to interrupt and event is pushed to userspace. > > Signed-off-by: Jagath Jog J <jagathjog1996@xxxxxxxxx> Hi Jagath, A query about handling of multiple interrupts... > --- > drivers/iio/accel/bma400.h | 2 + > drivers/iio/accel/bma400_core.c | 75 +++++++++++++++++++++++++++++++++ > 2 files changed, 77 insertions(+) > > * Read-write configuration registers > diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c > index aafb5a40944d..fe101df7b773 100644 > --- a/drivers/iio/accel/bma400_core.c > +++ b/drivers/iio/accel/bma400_core.c > > static const struct iio_trigger_ops bma400_trigger_ops = { > @@ -971,6 +1035,7 @@ static irqreturn_t bma400_interrupt(int irq, void *private) > { > struct iio_dev *indio_dev = private; > struct bma400_data *data = iio_priv(indio_dev); > + s64 timestamp = iio_get_time_ns(indio_dev); > int ret; > > /* Lock to protect the data->status */ > @@ -981,6 +1046,16 @@ static irqreturn_t bma400_interrupt(int irq, void *private) > if (ret) > goto unlock_err; > > + if (FIELD_GET(BMA400_STEP_STAT_MASK, le16_to_cpu(data->status))) { > + iio_push_event(indio_dev, > + IIO_EVENT_CODE(IIO_STEPS, 0, IIO_NO_MOD, > + IIO_EV_DIR_NONE, > + IIO_EV_TYPE_CHANGE, 0, 0, 0), > + timestamp); > + mutex_unlock(&data->mutex); Is it possible for two interrupt sources to be active at the same time? Given the device is clearing interrupts on read (which is unusual enough to make me check that on the datasheet) you will loose any other events. Normal trick is to act on all set bits and if any of them were acted on return HANDLED. > + return IRQ_HANDLED; > + } > + > if (FIELD_GET(BMA400_INT_DRDY_MSK, le16_to_cpu(data->status))) { > mutex_unlock(&data->mutex); > iio_trigger_poll_chained(data->trig);