diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2016-03-24 14:18:05 +0100 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2016-04-19 19:58:12 +0100 |
commit | 97865fe41322d83dac4373fe0a0de5b1a1b318c5 (patch) | |
tree | 6d14571a7fed1c01d8e6ed74d5817aa5edd6b5d0 /drivers/iio/common/st_sensors | |
parent | 6436db37b4a5da1ae1f381e4791e17e2236fd276 (diff) | |
download | op-kernel-dev-97865fe41322d83dac4373fe0a0de5b1a1b318c5.zip op-kernel-dev-97865fe41322d83dac4373fe0a0de5b1a1b318c5.tar.gz |
iio: st_sensors: verify interrupt event to status
This makes all ST sensor drivers check that they actually have
new data available for the requested channel(s) before claiming
an IRQ, by reading the status register (which is conveniently
the same for all ST sensors) and check that the channel has new
data before proceeding to read it and fill the buffer.
This way sensors can share an interrupt line: it can be flaged
as shared and then the sensor that did not fire will return
NO_IRQ, and the sensor that fired will handle the IRQ and
return IRQ_HANDLED.
Cc: Giuseppe Barba <giuseppe.barba@st.com>
Cc: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/common/st_sensors')
-rw-r--r-- | drivers/iio/common/st_sensors/st_sensors_buffer.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c index 2ce0d2a..c558985 100644 --- a/drivers/iio/common/st_sensors/st_sensors_buffer.c +++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c @@ -58,6 +58,24 @@ irqreturn_t st_sensors_trigger_handler(int irq, void *p) struct iio_dev *indio_dev = pf->indio_dev; struct st_sensor_data *sdata = iio_priv(indio_dev); + /* If we have a status register, check if this IRQ came from us */ + if (sdata->sensor_settings->drdy_irq.addr_stat_drdy) { + u8 status; + + len = sdata->tf->read_byte(&sdata->tb, sdata->dev, + sdata->sensor_settings->drdy_irq.addr_stat_drdy, + &status); + if (len < 0) + dev_err(sdata->dev, "could not read channel status\n"); + + /* + * If this was not caused by any channels on this sensor, + * return IRQ_NONE + */ + if (!(status & (u8)indio_dev->active_scan_mask[0])) + return IRQ_NONE; + } + len = st_sensors_get_buffer_element(indio_dev, sdata->buffer_data); if (len < 0) goto st_sensors_get_buffer_element_error; |