Message ID | 20190715081514.81129-5-sean@geanix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,1/6] iio: imu: st_lsm6dsx: move interrupt thread to core | expand |
> The interrupt source can come from multiple sources, > fifo and wake interrupts. > Enter interrupt thread to check which interrupt that has fired. > > Signed-off-by: Sean Nyekjaer <sean@geanix.com> > --- > > Changes since v1: > * None > > drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c > index fc450eeb9870..0503abab6efc 100644 > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c > @@ -1215,19 +1215,19 @@ int st_lsm6dsx_event_setup(int id, struct st_lsm6dsx_hw *hw) > > static irqreturn_t st_lsm6dsx_handler_irq(int irq, void *private) > { > - struct st_lsm6dsx_hw *hw = private; > - > - return hw->sip > 0 ? IRQ_WAKE_THREAD : IRQ_NONE; > + return IRQ_WAKE_THREAD; > } > > static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private) > { > struct st_lsm6dsx_hw *hw = private; > - int count; > + int count = 0; > > - mutex_lock(&hw->fifo_lock); > - count = st_lsm6dsx_read_fifo(hw); > - mutex_unlock(&hw->fifo_lock); > + if (hw->sip > 0) { I think we do not need this if() statement since st_lsm6dsx_read_fifo will return 0 in case > + mutex_lock(&hw->fifo_lock); > + count = st_lsm6dsx_read_fifo(hw); > + mutex_unlock(&hw->fifo_lock); > + } > > return !count ? IRQ_NONE : IRQ_HANDLED; > } > -- > 2.22.0 >
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index fc450eeb9870..0503abab6efc 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -1215,19 +1215,19 @@ int st_lsm6dsx_event_setup(int id, struct st_lsm6dsx_hw *hw) static irqreturn_t st_lsm6dsx_handler_irq(int irq, void *private) { - struct st_lsm6dsx_hw *hw = private; - - return hw->sip > 0 ? IRQ_WAKE_THREAD : IRQ_NONE; + return IRQ_WAKE_THREAD; } static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private) { struct st_lsm6dsx_hw *hw = private; - int count; + int count = 0; - mutex_lock(&hw->fifo_lock); - count = st_lsm6dsx_read_fifo(hw); - mutex_unlock(&hw->fifo_lock); + if (hw->sip > 0) { + mutex_lock(&hw->fifo_lock); + count = st_lsm6dsx_read_fifo(hw); + mutex_unlock(&hw->fifo_lock); + } return !count ? IRQ_NONE : IRQ_HANDLED; }
The interrupt source can come from multiple sources, fifo and wake interrupts. Enter interrupt thread to check which interrupt that has fired. Signed-off-by: Sean Nyekjaer <sean@geanix.com> --- Changes since v1: * None drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)