]> git.karo-electronics.de Git - linux-beck.git/commitdiff
iio: st_magn: Add irq trigger handling
authorGiuseppe Barba <giuseppe.barba@st.com>
Tue, 21 Jul 2015 08:35:43 +0000 (10:35 +0200)
committerJonathan Cameron <jic23@kernel.org>
Thu, 23 Jul 2015 19:43:13 +0000 (20:43 +0100)
Add irq trigger handling for magnetometer also

Signed-off-by: Giuseppe Barba <giuseppe.barba@st.com>
Acked-by: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/magnetometer/st_magn.h
drivers/iio/magnetometer/st_magn_buffer.c
drivers/iio/magnetometer/st_magn_core.c

index 287691ca56c1f89924b06da7216cd5798f3668ef..604410236d99550af770c5c239fdd60d1d7d09a9 100644 (file)
@@ -25,6 +25,8 @@ void st_magn_common_remove(struct iio_dev *indio_dev);
 #ifdef CONFIG_IIO_BUFFER
 int st_magn_allocate_ring(struct iio_dev *indio_dev);
 void st_magn_deallocate_ring(struct iio_dev *indio_dev);
+int st_magn_trig_set_state(struct iio_trigger *trig, bool state);
+#define ST_MAGN_TRIGGER_SET_STATE (&st_magn_trig_set_state)
 #else /* CONFIG_IIO_BUFFER */
 static inline int st_magn_probe_trigger(struct iio_dev *indio_dev, int irq)
 {
index bf427dc0d226c40de9adc92257ece78ab6b14de6..ecd3bd0a97693420c13bfae8fc583ff74854edf8 100644 (file)
 #include <linux/iio/common/st_sensors.h>
 #include "st_magn.h"
 
+int st_magn_trig_set_state(struct iio_trigger *trig, bool state)
+{
+       struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
+
+       return st_sensors_set_dataready_irq(indio_dev, state);
+}
+
 static int st_magn_buffer_preenable(struct iio_dev *indio_dev)
 {
        return st_sensors_set_enable(indio_dev, true);
index 8d7d3a172874c2b11530b2b0928e0038c19e653b..4c0cef865517b16344221055ce2e9ee8e9f06e8e 100644 (file)
@@ -480,6 +480,16 @@ static const struct iio_info magn_info = {
        .write_raw = &st_magn_write_raw,
 };
 
+#ifdef CONFIG_IIO_TRIGGER
+static const struct iio_trigger_ops st_magn_trigger_ops = {
+       .owner = THIS_MODULE,
+       .set_trigger_state = ST_MAGN_TRIGGER_SET_STATE,
+};
+#define ST_MAGN_TRIGGER_OPS (&st_magn_trigger_ops)
+#else
+#define ST_MAGN_TRIGGER_OPS NULL
+#endif
+
 int st_magn_common_probe(struct iio_dev *indio_dev)
 {
        struct st_sensor_data *mdata = iio_priv(indio_dev);
@@ -516,7 +526,8 @@ int st_magn_common_probe(struct iio_dev *indio_dev)
                return err;
 
        if (irq > 0) {
-               err = st_sensors_allocate_trigger(indio_dev, NULL);
+               err = st_sensors_allocate_trigger(indio_dev,
+                                               ST_MAGN_TRIGGER_OPS);
                if (err < 0)
                        goto st_magn_probe_trigger_error;
        }