staging:iio:ad7298: Do not perform endianness conversion in buffered mode
authorLars-Peter Clausen <lars@metafoo.de>
Thu, 15 Nov 2012 13:15:00 +0000 (13:15 +0000)
committerJonathan Cameron <jic23@kernel.org>
Mon, 19 Nov 2012 22:22:13 +0000 (22:22 +0000)
For buffered mode we do not want to perform endianness conversion in the kernel,
but rather offload it to user space, since it is not always required to do a
conversion at all. It also greatly simplifies the kernel code since no
post-processing has to be done and may allow future optimizations like streaming
data directly to a storage device or over the network via DMA.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/staging/iio/adc/ad7298.h
drivers/staging/iio/adc/ad7298_core.c
drivers/staging/iio/adc/ad7298_ring.c

index 18f27872300207b66cff69e32ba4021772209954..0ce9031bec90ef00f0eadef3aa3afa51d49f49c9 100644 (file)
@@ -48,7 +48,7 @@ struct ad7298_state {
         * DMA (thus cache coherency maintenance) requires the
         * transfer buffers to live in their own cache lines.
         */
-       unsigned short                  rx_buf[8] ____cacheline_aligned;
+       unsigned short                  rx_buf[12] ____cacheline_aligned;
        unsigned short                  tx_buf[2];
 };
 
index 4c75114e7d7cbb6d4890acafc74f50e5a0ab17af..67082ade18508ef1ef79081ce2505175fc98ca1f 100644 (file)
@@ -35,6 +35,7 @@
                        .sign = 'u',                                    \
                        .realbits = 12,                                 \
                        .storagebits = 16,                              \
+                       .endianness = IIO_BE,                           \
                },                                                      \
        }
 
index b3dd514b9627fc4f5a1c38ceea42dc3cdcde9387..e3877129222b0e2d8f715d302cf6f4077ee08d8b 100644 (file)
@@ -76,8 +76,7 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)
        struct iio_dev *indio_dev = pf->indio_dev;
        struct ad7298_state *st = iio_priv(indio_dev);
        s64 time_ns = 0;
-       __u16 buf[16];
-       int b_sent, i;
+       int b_sent;
 
        b_sent = spi_sync(st->spi, &st->ring_msg);
        if (b_sent)
@@ -85,15 +84,11 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)
 
        if (indio_dev->scan_timestamp) {
                time_ns = iio_get_time_ns();
-               memcpy((u8 *)buf + indio_dev->scan_bytes - sizeof(s64),
+               memcpy((u8 *)st->rx_buf + indio_dev->scan_bytes - sizeof(s64),
                        &time_ns, sizeof(time_ns));
        }
 
-       for (i = 0; i < bitmap_weight(indio_dev->active_scan_mask,
-                                                indio_dev->masklength); i++)
-               buf[i] = be16_to_cpu(st->rx_buf[i]);
-
-       iio_push_to_buffers(indio_dev, (u8 *)buf);
+       iio_push_to_buffers(indio_dev, (u8 *)st->rx_buf);
 
 done:
        iio_trigger_notify_done(indio_dev->trig);