diff options
author | 2011-12-05 22:18:15 +0000 | |
---|---|---|
committer | 2011-12-08 12:11:08 -0800 | |
commit | 550268ca1111a5b4737f15f7bf646cede9d1f0cd (patch) | |
tree | 593257fd8d248bf80efe27e23908bb8d9a80c177 /drivers/staging/iio/imu/adis16400_ring.c | |
parent | staging:iio:buffer move setup ops from buffer instance to iio_dev (diff) | |
download | linux-dev-550268ca1111a5b4737f15f7bf646cede9d1f0cd.tar.xz linux-dev-550268ca1111a5b4737f15f7bf646cede9d1f0cd.zip |
staging:iio: scrap scan_count and ensure all drivers use active_scan_mask
Obviously drivers should only use this for pushing to buffers.
They need buffer->scan_mask for pulling from them post demux.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/iio/imu/adis16400_ring.c')
-rw-r--r-- | drivers/staging/iio/imu/adis16400_ring.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c index e8aaa84c613f..249d11f98e10 100644 --- a/drivers/staging/iio/imu/adis16400_ring.c +++ b/drivers/staging/iio/imu/adis16400_ring.c @@ -79,14 +79,16 @@ static int adis16350_spi_read_all(struct device *dev, u8 *rx) struct spi_message msg; int i, j = 0, ret; struct spi_transfer *xfers; + int scan_count = bitmap_weight(indio_dev->active_scan_mask, + indio_dev->masklength); - xfers = kzalloc(sizeof(*xfers)*indio_dev->buffer->scan_count + 1, + xfers = kzalloc(sizeof(*xfers)*(scan_count + 1), GFP_KERNEL); if (xfers == NULL) return -ENOMEM; for (i = 0; i < ARRAY_SIZE(read_all_tx_array); i++) - if (test_bit(i, indio_dev->buffer->scan_mask)) { + if (test_bit(i, indio_dev->active_scan_mask)) { xfers[j].tx_buf = &read_all_tx_array[i]; xfers[j].bits_per_word = 16; xfers[j].len = 2; @@ -97,7 +99,7 @@ static int adis16350_spi_read_all(struct device *dev, u8 *rx) xfers[j].len = 2; spi_message_init(&msg); - for (j = 0; j < indio_dev->buffer->scan_count + 1; j++) + for (j = 0; j < scan_count + 1; j++) spi_message_add_tail(&xfers[j], &msg); ret = spi_sync(st->us, &msg); @@ -119,26 +121,27 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p) s16 *data; size_t datasize = ring->access->get_bytes_per_datum(ring); /* Asumption that long is enough for maximum channels */ - unsigned long mask = *ring->scan_mask; - + unsigned long mask = *indio_dev->active_scan_mask; + int scan_count = bitmap_weight(indio_dev->active_scan_mask, + indio_dev->masklength); data = kmalloc(datasize , GFP_KERNEL); if (data == NULL) { dev_err(&st->us->dev, "memory alloc failed in ring bh"); return -ENOMEM; } - if (ring->scan_count) { + if (scan_count) { if (st->variant->flags & ADIS16400_NO_BURST) { ret = adis16350_spi_read_all(&indio_dev->dev, st->rx); if (ret < 0) goto err; - for (; i < ring->scan_count; i++) + for (; i < scan_count; i++) data[i] = *(s16 *)(st->rx + i*2); } else { ret = adis16400_spi_read_burst(&indio_dev->dev, st->rx); if (ret < 0) goto err; - for (; i < indio_dev->buffer->scan_count; i++) { + for (; i < scan_count; i++) { j = __ffs(mask); mask &= ~(1 << j); data[i] = be16_to_cpup( |