diff options
author | Michael Hennerich <michael.hennerich@analog.com> | 2011-03-21 11:44:38 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-04-05 15:37:11 -0400 |
commit | 0fea4d6192cb82789e28905240d3c1dac6529c7c (patch) | |
tree | 20efd402f97e0b23ac61757e7eee6147e8140310 | |
parent | b181119723d62b19904e1f12e467e996631c5a29 (diff) |
staging: IIO: IMU: ADIS16400: Make sure only enabled scan_elements are pushed into the ring
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
CC: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/iio/imu/adis16400_ring.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c index ac381ca126fc..da28cb4288af 100644 --- a/drivers/staging/iio/imu/adis16400_ring.c +++ b/drivers/staging/iio/imu/adis16400_ring.c | |||
@@ -160,9 +160,10 @@ static void adis16400_trigger_bh_to_ring(struct work_struct *work_s) | |||
160 | work_trigger_to_ring); | 160 | work_trigger_to_ring); |
161 | struct iio_ring_buffer *ring = st->indio_dev->ring; | 161 | struct iio_ring_buffer *ring = st->indio_dev->ring; |
162 | 162 | ||
163 | int i = 0; | 163 | int i = 0, j; |
164 | s16 *data; | 164 | s16 *data; |
165 | size_t datasize = ring->access.get_bytes_per_datum(ring); | 165 | size_t datasize = ring->access.get_bytes_per_datum(ring); |
166 | unsigned long mask = ring->scan_mask; | ||
166 | 167 | ||
167 | data = kmalloc(datasize , GFP_KERNEL); | 168 | data = kmalloc(datasize , GFP_KERNEL); |
168 | if (data == NULL) { | 169 | if (data == NULL) { |
@@ -172,9 +173,12 @@ static void adis16400_trigger_bh_to_ring(struct work_struct *work_s) | |||
172 | 173 | ||
173 | if (ring->scan_count) | 174 | if (ring->scan_count) |
174 | if (adis16400_spi_read_burst(&st->indio_dev->dev, st->rx) >= 0) | 175 | if (adis16400_spi_read_burst(&st->indio_dev->dev, st->rx) >= 0) |
175 | for (; i < ring->scan_count; i++) | 176 | for (; i < ring->scan_count; i++) { |
177 | j = __ffs(mask); | ||
178 | mask &= ~(1 << j); | ||
176 | data[i] = be16_to_cpup( | 179 | data[i] = be16_to_cpup( |
177 | (__be16 *)&(st->rx[i*2])); | 180 | (__be16 *)&(st->rx[j*2])); |
181 | } | ||
178 | 182 | ||
179 | /* Guaranteed to be aligned with 8 byte boundary */ | 183 | /* Guaranteed to be aligned with 8 byte boundary */ |
180 | if (ring->scan_timestamp) | 184 | if (ring->scan_timestamp) |