]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/staging/iio/adc/ad7887_ring.c
staging:iio: Switch the channel masks to bitmaps so as to allow for more channels.
[mirror_ubuntu-bionic-kernel.git] / drivers / staging / iio / adc / ad7887_ring.c
index 0ac7c0b9d71d081ccddcebf265ee5b6c708cf456..36e118cf32e2b95728fe3a0773f6272a92418a4a 100644 (file)
@@ -8,27 +8,24 @@
  */
 
 #include <linux/interrupt.h>
-#include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
-#include <linux/sysfs.h>
 #include <linux/spi/spi.h>
 
 #include "../iio.h"
 #include "../ring_generic.h"
 #include "../ring_sw.h"
-#include "../trigger.h"
-#include "../sysfs.h"
+#include "../trigger_consumer.h"
 
 #include "ad7887.h"
 
-int ad7887_scan_from_ring(struct ad7887_state *st, long mask)
+int ad7887_scan_from_ring(struct ad7887_state *st, int channum)
 {
        struct iio_ring_buffer *ring = iio_priv_to_dev(st)->ring;
        int count = 0, ret;
        u16 *ring_data;
 
-       if (!(ring->scan_mask & mask)) {
+       if (!(test_bit(channum, ring->scan_mask))) {
                ret = -EBUSY;
                goto error_ret;
        }
@@ -44,7 +41,8 @@ int ad7887_scan_from_ring(struct ad7887_state *st, long mask)
                goto error_free_ring_data;
 
        /* for single channel scan the result is stored with zero offset */
-       if ((ring->scan_mask == ((1 << 1) | (1 << 0))) && (mask == (1 << 1)))
+       if ((test_bit(1, ring->scan_mask) || test_bit(0, ring->scan_mask)) &&
+           (channum == 1))
                count = 1;
 
        ret = be16_to_cpu(ring_data[count]);
@@ -81,7 +79,8 @@ static int ad7887_ring_preenable(struct iio_dev *indio_dev)
                indio_dev->ring->access->set_bytes_per_datum(indio_dev->ring,
                                                            st->d_size);
 
-       switch (ring->scan_mask) {
+       /* We know this is a single long so can 'cheat' */
+       switch (*ring->scan_mask) {
        case (1 << 0):
                st->ring_msg = &st->msg[AD7887_CH0];
                break;
@@ -115,7 +114,7 @@ static int ad7887_ring_postdisable(struct iio_dev *indio_dev)
 static irqreturn_t ad7887_trigger_handler(int irq, void *p)
 {
        struct iio_poll_func *pf = p;
-       struct iio_dev *indio_dev = pf->private_data;
+       struct iio_dev *indio_dev = pf->indio_dev;
        struct ad7887_state *st = iio_priv(indio_dev);
        struct iio_ring_buffer *ring = indio_dev->ring;
        s64 time_ns;
@@ -191,12 +190,6 @@ error_ret:
 
 void ad7887_ring_cleanup(struct iio_dev *indio_dev)
 {
-       /* ensure that the trigger has been detached */
-       if (indio_dev->trig) {
-               iio_put_trigger(indio_dev->trig);
-               iio_trigger_dettach_poll_func(indio_dev->trig,
-                                             indio_dev->pollfunc);
-       }
        iio_dealloc_pollfunc(indio_dev->pollfunc);
        iio_sw_rb_free(indio_dev->ring);
 }