Commit 74f5683f authored by Giuseppe Barba's avatar Giuseppe Barba Committed by Jonathan Cameron

iio: st_magn: Add irq trigger handling

Add irq trigger handling for magnetometer also
Signed-off-by: default avatarGiuseppe Barba <giuseppe.barba@st.com>
Acked-by: default avatarDenis Ciocca <denis.ciocca@st.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent bb602f8c
...@@ -25,6 +25,8 @@ void st_magn_common_remove(struct iio_dev *indio_dev); ...@@ -25,6 +25,8 @@ void st_magn_common_remove(struct iio_dev *indio_dev);
#ifdef CONFIG_IIO_BUFFER #ifdef CONFIG_IIO_BUFFER
int st_magn_allocate_ring(struct iio_dev *indio_dev); int st_magn_allocate_ring(struct iio_dev *indio_dev);
void st_magn_deallocate_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 */ #else /* CONFIG_IIO_BUFFER */
static inline int st_magn_probe_trigger(struct iio_dev *indio_dev, int irq) static inline int st_magn_probe_trigger(struct iio_dev *indio_dev, int irq)
{ {
......
...@@ -23,6 +23,13 @@ ...@@ -23,6 +23,13 @@
#include <linux/iio/common/st_sensors.h> #include <linux/iio/common/st_sensors.h>
#include "st_magn.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) static int st_magn_buffer_preenable(struct iio_dev *indio_dev)
{ {
return st_sensors_set_enable(indio_dev, true); return st_sensors_set_enable(indio_dev, true);
......
...@@ -480,6 +480,16 @@ static const struct iio_info magn_info = { ...@@ -480,6 +480,16 @@ static const struct iio_info magn_info = {
.write_raw = &st_magn_write_raw, .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) int st_magn_common_probe(struct iio_dev *indio_dev)
{ {
struct st_sensor_data *mdata = iio_priv(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) ...@@ -516,7 +526,8 @@ int st_magn_common_probe(struct iio_dev *indio_dev)
return err; return err;
if (irq > 0) { 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) if (err < 0)
goto st_magn_probe_trigger_error; goto st_magn_probe_trigger_error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment