diff options
author | Jonathan Cameron <jic23@kernel.org> | 2012-04-21 11:09:36 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-04-24 20:23:37 +0200 |
commit | 2150489ffbd1cd6f5d1091c1738b1adfbdf34a43 (patch) | |
tree | 57add6a87c6b53dd6f5bdc23a957a2ed11c1a17a | |
parent | staging:iio: add caching of the number of bytes in a scan. (diff) | |
download | linux-2150489ffbd1cd6f5d1091c1738b1adfbdf34a43.tar.xz linux-2150489ffbd1cd6f5d1091c1738b1adfbdf34a43.zip |
staging:iio:adc:ad7192 make use of iio_sw_buffer_preenable.
This is not a fast path, so although the original code was more consise
use the generic case to cut down on code repitition.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/iio/adc/ad7192.c | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index feb81f639447..25ef3c370d1f 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -456,31 +456,19 @@ out: static int ad7192_ring_preenable(struct iio_dev *indio_dev) { struct ad7192_state *st = iio_priv(indio_dev); - struct iio_buffer *ring = indio_dev->buffer; - size_t d_size; unsigned channel; + int ret; if (bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) return -EINVAL; + ret = iio_sw_buffer_preenable(indio_dev); + if (ret < 0) + return ret; + channel = find_first_bit(indio_dev->active_scan_mask, indio_dev->masklength); - d_size = bitmap_weight(indio_dev->active_scan_mask, - indio_dev->masklength) * - indio_dev->channels[0].scan_type.storagebits / 8; - - if (ring->scan_timestamp) { - d_size += sizeof(s64); - - if (d_size % sizeof(s64)) - d_size += sizeof(s64) - (d_size % sizeof(s64)); - } - - if (indio_dev->buffer->access->set_bytes_per_datum) - indio_dev->buffer->access-> - set_bytes_per_datum(indio_dev->buffer, d_size); - st->mode = (st->mode & ~AD7192_MODE_SEL(-1)) | AD7192_MODE_SEL(AD7192_MODE_CONT); st->conf = (st->conf & ~AD7192_CONF_CHAN(-1)) | |