summaryrefslogtreecommitdiff
path: root/drivers/staging/iio/accel/adis16201_ring.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2012-11-13 13:28:00 (GMT)
committerJonathan Cameron <jic23@kernel.org>2012-11-19 22:22:05 (GMT)
commit6d78e862ac55d9c09403a613eae6bf609ad46ee3 (patch)
treeb01cda3b2e0bc8837ff75829713c635452bfe231 /drivers/staging/iio/accel/adis16201_ring.c
parentccd2b52f4ac69c34564434fb9e5153abcbc97109 (diff)
downloadlinux-fsl-qoriq-6d78e862ac55d9c09403a613eae6bf609ad46ee3.tar.xz
staging:iio:adis16201: Use adis library
Use the new adis library for the adis16201 driver. This allows us to completely scrap the adis16201 buffer and trigger code and more than half of the core driver code. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/staging/iio/accel/adis16201_ring.c')
-rw-r--r--drivers/staging/iio/accel/adis16201_ring.c136
1 files changed, 0 insertions, 136 deletions
diff --git a/drivers/staging/iio/accel/adis16201_ring.c b/drivers/staging/iio/accel/adis16201_ring.c
deleted file mode 100644
index e14ca60..0000000
--- a/drivers/staging/iio/accel/adis16201_ring.c
+++ /dev/null
@@ -1,136 +0,0 @@
-#include <linux/export.h>
-#include <linux/interrupt.h>
-#include <linux/mutex.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-
-#include <linux/iio/iio.h>
-#include "../ring_sw.h"
-#include <linux/iio/trigger_consumer.h>
-#include "adis16201.h"
-
-
-/**
- * adis16201_read_ring_data() read data registers which will be placed into ring
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
- * @rx: somewhere to pass back the value read
- **/
-static int adis16201_read_ring_data(struct iio_dev *indio_dev, u8 *rx)
-{
- struct spi_message msg;
- struct adis16201_state *st = iio_priv(indio_dev);
- struct spi_transfer xfers[ADIS16201_OUTPUTS + 1];
- int ret;
- int i;
-
- mutex_lock(&st->buf_lock);
-
- spi_message_init(&msg);
-
- memset(xfers, 0, sizeof(xfers));
- for (i = 0; i <= ADIS16201_OUTPUTS; i++) {
- xfers[i].bits_per_word = 8;
- xfers[i].cs_change = 1;
- xfers[i].len = 2;
- xfers[i].delay_usecs = 20;
- if (i < ADIS16201_OUTPUTS) {
- xfers[i].tx_buf = st->tx + 2 * i;
- st->tx[2 * i] = ADIS16201_READ_REG(ADIS16201_SUPPLY_OUT +
- 2 * i);
- st->tx[2 * i + 1] = 0;
- }
- if (i >= 1)
- xfers[i].rx_buf = rx + 2 * (i - 1);
- spi_message_add_tail(&xfers[i], &msg);
- }
-
- ret = spi_sync(st->us, &msg);
- if (ret)
- dev_err(&st->us->dev, "problem when burst reading");
-
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-/* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device
- * specific to be rolled into the core.
- */
-static irqreturn_t adis16201_trigger_handler(int irq, void *p)
-{
- struct iio_poll_func *pf = p;
- struct iio_dev *indio_dev = pf->indio_dev;
- struct adis16201_state *st = iio_priv(indio_dev);
-
- int i = 0;
- s16 *data;
-
- data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
- if (data == NULL) {
- dev_err(&st->us->dev, "memory alloc failed in ring bh");
- goto done;
- }
-
- if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)
- && adis16201_read_ring_data(indio_dev, st->rx) >= 0)
- for (; i < bitmap_weight(indio_dev->active_scan_mask,
- indio_dev->masklength); i++)
- data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2]));
-
- /* Guaranteed to be aligned with 8 byte boundary */
- if (indio_dev->scan_timestamp)
- *((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
-
- iio_push_to_buffers(indio_dev, (u8 *)data);
-
- kfree(data);
-done:
- iio_trigger_notify_done(indio_dev->trig);
-
- return IRQ_HANDLED;
-}
-
-void adis16201_unconfigure_ring(struct iio_dev *indio_dev)
-{
- iio_dealloc_pollfunc(indio_dev->pollfunc);
- iio_sw_rb_free(indio_dev->buffer);
-}
-
-static const struct iio_buffer_setup_ops adis16201_ring_setup_ops = {
- .preenable = &iio_sw_buffer_preenable,
- .postenable = &iio_triggered_buffer_postenable,
- .predisable = &iio_triggered_buffer_predisable,
-};
-
-int adis16201_configure_ring(struct iio_dev *indio_dev)
-{
- int ret = 0;
- struct iio_buffer *ring;
-
- ring = iio_sw_rb_allocate(indio_dev);
- if (!ring) {
- ret = -ENOMEM;
- return ret;
- }
- indio_dev->buffer = ring;
- ring->scan_timestamp = true;
- indio_dev->setup_ops = &adis16201_ring_setup_ops;
-
- indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
- &adis16201_trigger_handler,
- IRQF_ONESHOT,
- indio_dev,
- "adis16201_consumer%d",
- indio_dev->id);
- if (indio_dev->pollfunc == NULL) {
- ret = -ENOMEM;
- goto error_iio_sw_rb_free;
- }
-
- indio_dev->modes |= INDIO_BUFFER_TRIGGERED;
- return 0;
-error_iio_sw_rb_free:
- iio_sw_rb_free(indio_dev->buffer);
- return ret;
-}