]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
iio: imu: adis16400: move burst logic to ADIS lib
authorAlexandru Ardelean <alexandru.ardelean@analog.com>
Fri, 22 Mar 2019 20:44:40 +0000 (22:44 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 4 Apr 2019 19:20:26 +0000 (20:20 +0100)
This change has been done separately, so that it's easier to visualize the
changed logic in the adis_scan_update() function.

Most of the function in this `adis16400_update_scan_mode()` that deals with
burst-mode will be re-used in the ADIS16480, but with different parameters.

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

index 68629c68b19bd6f45885253e1c04c75ffee433e3..4898799347d5e08eb54fcbde7e8aca11b2f7328d 100644 (file)
@@ -5,7 +5,6 @@
 
 # When adding new entries keep the list in alphabetical order
 adis16400-y             := adis16400_core.o
-adis16400-$(CONFIG_IIO_BUFFER) += adis16400_buffer.o
 obj-$(CONFIG_ADIS16400) += adis16400.o
 obj-$(CONFIG_ADIS16480) += adis16480.o
 
index 93b6c0c41fdd3b6fccc1c43b17119cbd19a05980..7e2e0dbaa2e1aa418ba1644a1f271561174fceaa 100644 (file)
@@ -194,20 +194,4 @@ enum {
        ADIS16400_SCAN_TIMESTAMP,
 };
 
-#ifdef CONFIG_IIO_BUFFER
-
-ssize_t adis16400_read_data_from_ring(struct device *dev,
-                                     struct device_attribute *attr,
-                                     char *buf);
-
-
-int adis16400_update_scan_mode(struct iio_dev *indio_dev,
-       const unsigned long *scan_mask);
-
-#else /* CONFIG_IIO_BUFFER */
-
-#define adis16400_update_scan_mode NULL
-
-#endif /* CONFIG_IIO_BUFFER */
-
 #endif /* SPI_ADIS16400_H_ */
diff --git a/drivers/iio/imu/adis16400_buffer.c b/drivers/iio/imu/adis16400_buffer.c
deleted file mode 100644 (file)
index 199bd72..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <linux/interrupt.h>
-#include <linux/mutex.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/bitops.h>
-#include <linux/export.h>
-
-#include <linux/iio/iio.h>
-#include <linux/iio/buffer.h>
-#include <linux/iio/triggered_buffer.h>
-#include <linux/iio/trigger_consumer.h>
-
-#include "adis16400.h"
-
-int adis16400_update_scan_mode(struct iio_dev *indio_dev,
-       const unsigned long *scan_mask)
-{
-       struct adis16400_state *st = iio_priv(indio_dev);
-       struct adis *adis = &st->adis;
-       unsigned int burst_length;
-       u8 *tx;
-
-       if (!adis->burst || !adis->burst->en)
-               return adis_update_scan_mode(indio_dev, scan_mask);
-
-       kfree(adis->xfer);
-       kfree(adis->buffer);
-
-       /* All but the timestamp channel */
-       burst_length = (indio_dev->num_channels - 1) * sizeof(u16);
-       burst_length += adis->burst->extra_len;
-
-       adis->xfer = kcalloc(2, sizeof(*adis->xfer), GFP_KERNEL);
-       if (!adis->xfer)
-               return -ENOMEM;
-
-       adis->buffer = kzalloc(burst_length + sizeof(u16), GFP_KERNEL);
-       if (!adis->buffer)
-               return -ENOMEM;
-
-       tx = adis->buffer + burst_length;
-       tx[0] = ADIS_READ_REG(adis->burst->reg_cmd);
-       tx[1] = 0;
-
-       adis->xfer[0].tx_buf = tx;
-       adis->xfer[0].bits_per_word = 8;
-       adis->xfer[0].len = 2;
-       adis->xfer[1].rx_buf = adis->buffer;
-       adis->xfer[1].bits_per_word = 8;
-       adis->xfer[1].len = burst_length;
-
-       spi_message_init(&adis->msg);
-       spi_message_add_tail(&adis->xfer[0], &adis->msg);
-       spi_message_add_tail(&adis->xfer[1], &adis->msg);
-
-       return 0;
-}
index 093c809dae5080f586681c252531d69d59544e83..c75d23bc49bf30af0cff534ef7d29ab9bef85aa8 100644 (file)
@@ -886,7 +886,7 @@ static struct adis16400_chip_info adis16400_chips[] = {
 static const struct iio_info adis16400_info = {
        .read_raw = &adis16400_read_raw,
        .write_raw = &adis16400_write_raw,
-       .update_scan_mode = adis16400_update_scan_mode,
+       .update_scan_mode = adis_update_scan_mode,
        .debugfs_reg_access = adis_debugfs_reg_access,
 };
 
index 76643c5571aa87286bef0eeee0a557f04326ac6b..3a7c970568dc80d31e7c90208ee99d3072cab63f 100644 (file)
 #include <linux/iio/triggered_buffer.h>
 #include <linux/iio/imu/adis.h>
 
+static int adis_update_scan_mode_burst(struct iio_dev *indio_dev,
+       const unsigned long *scan_mask)
+{
+       struct adis *adis = iio_device_get_drvdata(indio_dev);
+       unsigned int burst_length;
+       u8 *tx;
+
+       /* All but the timestamp channel */
+       burst_length = (indio_dev->num_channels - 1) * sizeof(u16);
+       burst_length += adis->burst->extra_len;
+
+       adis->xfer = kcalloc(2, sizeof(*adis->xfer), GFP_KERNEL);
+       if (!adis->xfer)
+               return -ENOMEM;
+
+       adis->buffer = kzalloc(burst_length + sizeof(u16), GFP_KERNEL);
+       if (!adis->buffer)
+               return -ENOMEM;
+
+       tx = adis->buffer + burst_length;
+       tx[0] = ADIS_READ_REG(adis->burst->reg_cmd);
+       tx[1] = 0;
+
+       adis->xfer[0].tx_buf = tx;
+       adis->xfer[0].bits_per_word = 8;
+       adis->xfer[0].len = 2;
+       adis->xfer[1].rx_buf = adis->buffer;
+       adis->xfer[1].bits_per_word = 8;
+       adis->xfer[1].len = burst_length;
+
+       spi_message_init(&adis->msg);
+       spi_message_add_tail(&adis->xfer[0], &adis->msg);
+       spi_message_add_tail(&adis->xfer[1], &adis->msg);
+
+       return 0;
+}
+
 int adis_update_scan_mode(struct iio_dev *indio_dev,
        const unsigned long *scan_mask)
 {
@@ -32,6 +69,9 @@ int adis_update_scan_mode(struct iio_dev *indio_dev,
        kfree(adis->xfer);
        kfree(adis->buffer);
 
+       if (adis->burst && adis->burst->en)
+               return adis_update_scan_mode_burst(indio_dev, scan_mask);
+
        scan_count = indio_dev->scan_bytes / 2;
 
        adis->xfer = kcalloc(scan_count + 1, sizeof(*adis->xfer), GFP_KERNEL);