OSDN Git Service

iio: imu: adis16400: move trigger handler into adis16400_core
authorAlexandru Ardelean <alexandru.ardelean@analog.com>
Fri, 22 Mar 2019 20:44:38 +0000 (22:44 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 4 Apr 2019 19:20:23 +0000 (20:20 +0100)
The trigger handler for the ADIS16400 is very different from the generic
one in the ADIS library. Keeping it in a separate file won't make much
sense once the update_scan_mode function will be made more generic and
moved into the ADIS library.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/imu/adis16400.h
drivers/iio/imu/adis16400_buffer.c
drivers/iio/imu/adis16400_core.c

index 73b189c..93b6c0c 100644 (file)
@@ -203,12 +203,10 @@ ssize_t adis16400_read_data_from_ring(struct device *dev,
 
 int adis16400_update_scan_mode(struct iio_dev *indio_dev,
        const unsigned long *scan_mask);
-irqreturn_t adis16400_trigger_handler(int irq, void *p);
 
 #else /* CONFIG_IIO_BUFFER */
 
 #define adis16400_update_scan_mode NULL
-#define adis16400_trigger_handler NULL
 
 #endif /* CONFIG_IIO_BUFFER */
 
index e70a533..268349e 100644 (file)
@@ -58,44 +58,3 @@ int adis16400_update_scan_mode(struct iio_dev *indio_dev,
 
        return 0;
 }
-
-irqreturn_t adis16400_trigger_handler(int irq, void *p)
-{
-       struct iio_poll_func *pf = p;
-       struct iio_dev *indio_dev = pf->indio_dev;
-       struct adis16400_state *st = iio_priv(indio_dev);
-       struct adis *adis = &st->adis;
-       u32 old_speed_hz = st->adis.spi->max_speed_hz;
-       void *buffer;
-       int ret;
-
-       if (!adis->buffer)
-               return -ENOMEM;
-
-       if (!(st->variant->flags & ADIS16400_NO_BURST) &&
-               st->adis.spi->max_speed_hz > ADIS16400_SPI_BURST) {
-               st->adis.spi->max_speed_hz = ADIS16400_SPI_BURST;
-               spi_setup(st->adis.spi);
-       }
-
-       ret = spi_sync(adis->spi, &adis->msg);
-       if (ret)
-               dev_err(&adis->spi->dev, "Failed to read data: %d\n", ret);
-
-       if (!(st->variant->flags & ADIS16400_NO_BURST)) {
-               st->adis.spi->max_speed_hz = old_speed_hz;
-               spi_setup(st->adis.spi);
-       }
-
-       if (st->variant->flags & ADIS16400_BURST_DIAG_STAT)
-               buffer = adis->buffer + sizeof(u16);
-       else
-               buffer = adis->buffer;
-
-       iio_push_to_buffers_with_timestamp(indio_dev, buffer,
-               pf->timestamp);
-
-       iio_trigger_notify_done(indio_dev->trig);
-
-       return IRQ_HANDLED;
-}
index 46a5690..f9cb9e1 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/iio/buffer.h>
+#include <linux/iio/trigger_consumer.h>
 
 #include "adis16400.h"
 
@@ -465,6 +466,51 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
        }
 }
 
+#if IS_ENABLED(CONFIG_IIO_BUFFER)
+static irqreturn_t adis16400_trigger_handler(int irq, void *p)
+{
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->indio_dev;
+       struct adis16400_state *st = iio_priv(indio_dev);
+       struct adis *adis = &st->adis;
+       u32 old_speed_hz = st->adis.spi->max_speed_hz;
+       void *buffer;
+       int ret;
+
+       if (!adis->buffer)
+               return -ENOMEM;
+
+       if (!(st->variant->flags & ADIS16400_NO_BURST) &&
+               st->adis.spi->max_speed_hz > ADIS16400_SPI_BURST) {
+               st->adis.spi->max_speed_hz = ADIS16400_SPI_BURST;
+               spi_setup(st->adis.spi);
+       }
+
+       ret = spi_sync(adis->spi, &adis->msg);
+       if (ret)
+               dev_err(&adis->spi->dev, "Failed to read data: %d\n", ret);
+
+       if (!(st->variant->flags & ADIS16400_NO_BURST)) {
+               st->adis.spi->max_speed_hz = old_speed_hz;
+               spi_setup(st->adis.spi);
+       }
+
+       if (st->variant->flags & ADIS16400_BURST_DIAG_STAT)
+               buffer = adis->buffer + sizeof(u16);
+       else
+               buffer = adis->buffer;
+
+       iio_push_to_buffers_with_timestamp(indio_dev, buffer,
+               pf->timestamp);
+
+       iio_trigger_notify_done(indio_dev->trig);
+
+       return IRQ_HANDLED;
+}
+#else
+#define adis16400_trigger_handler      NULL
+#endif /* IS_ENABLED(CONFIG_IIO_BUFFER) */
+
 #define ADIS16400_VOLTAGE_CHAN(addr, bits, name, si, chn) { \
        .type = IIO_VOLTAGE, \
        .indexed = 1, \