diff options
author | Jonathan Cameron <jic23@cam.ac.uk> | 2011-05-18 14:42:34 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-05-19 16:15:05 -0700 |
commit | 8d213f24f2291a3edc7f94ac2bec8c85015aed96 (patch) | |
tree | 3bcefb4531f2d31edec8c694ae70e6735e86fa65 /drivers/staging/iio/accel/lis3l02dq_ring.c | |
parent | c74b0de1666f8b8f6c65e1e944deff71fed0769a (diff) |
staging:iio: ring core cleanups + check if read_last available in lis3l02dq
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/iio/accel/lis3l02dq_ring.c')
-rw-r--r-- | drivers/staging/iio/accel/lis3l02dq_ring.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index 5029c51fe919..c8f29bc73f68 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -50,9 +50,13 @@ ssize_t lis3l02dq_read_accel_from_ring(struct iio_ring_buffer *ring, { int ret; s16 *data; + if (!iio_scan_mask_query(ring, index)) return -EINVAL; + if (!ring->access->read_last) + return -EBUSY; + data = kmalloc(ring->access->get_bytes_per_datum(ring), GFP_KERNEL); if (data == NULL) @@ -61,9 +65,10 @@ ssize_t lis3l02dq_read_accel_from_ring(struct iio_ring_buffer *ring, ret = ring->access->read_last(ring, (u8 *)data); if (ret) goto error_free_data; - *val = data[iio_scan_mask_count_to_right(ring, index)]; + *val = data[bitmap_weight(&ring->scan_mask, index)]; error_free_data: kfree(data); + return ret; } |