aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/common/st_sensors/st_sensors_core.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2015-11-19 10:15:17 +0100
committerJonathan Cameron <jic23@kernel.org>2016-01-10 12:35:32 +0000
commita9fd053b56c6bb14972ab7a19da0b575fe4c5d66 (patch)
tree625a014d7de7fd5ad114f8c045e8f2821f99679a /drivers/iio/common/st_sensors/st_sensors_core.c
parentStaging: iio: cdc: ad7150: Fix alignment should match open parenthesis (diff)
downloadlinux-dev-a9fd053b56c6bb14972ab7a19da0b575fe4c5d66.tar.xz
linux-dev-a9fd053b56c6bb14972ab7a19da0b575fe4c5d66.zip
iio: st_sensors: support active-low interrupts
Most ST MEMS Sensors that support interrupts can also handle sending an active low interrupt, i.e. going from high to low on data ready (or other interrupt) and thus triggering on a falling edge to the interrupt controller. Set up logic to inspect the interrupt line we get for a sensor: if it is triggering on rising edge, leave everything alone, but if it triggers on falling edges, set up active low, and if unsupported configurations appear: warn with errors and reconfigure the interrupt to a rising edge, which all interrupt generating sensors support. Create a local header for st_sensors_core.h to share functions between the sensor core and the trigger setup code. 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/st_sensors_core.c')
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_core.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index 8447c31e27f2..f5a2d445d0c0 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -18,13 +18,15 @@
#include <asm/unaligned.h>
#include <linux/iio/common/st_sensors.h>
+#include "st_sensors_core.h"
+
static inline u32 st_sensors_get_unaligned_le24(const u8 *p)
{
return (s32)((p[0] | p[1] << 8 | p[2] << 16) << 8) >> 8;
}
-static int st_sensors_write_data_with_mask(struct iio_dev *indio_dev,
- u8 reg_addr, u8 mask, u8 data)
+int st_sensors_write_data_with_mask(struct iio_dev *indio_dev,
+ u8 reg_addr, u8 mask, u8 data)
{
int err;
u8 new_data;