Skip to content

Commit a1caeeb

Browse files
committed
iio: adc: ad7768-1: Fix too small buffer passed to iio_push_to_buffers_with_timestamp()
Add space for the timestamp to be inserted. Also ensure correct alignment for passing to iio_push_to_buffers_with_timestamp() Fixes: a5f8c7d ("iio: adc: Add AD7768-1 ADC basic support") Signed-off-by: Jonathan Cameron <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]>
1 parent 98b7b0c commit a1caeeb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/iio/adc/ad7768-1.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ struct ad7768_state {
167167
* transfer buffers to live in their own cache lines.
168168
*/
169169
union {
170+
struct {
171+
__be32 chan;
172+
s64 timestamp;
173+
} scan;
170174
__be32 d32;
171175
u8 d8[2];
172176
} data ____cacheline_aligned;
@@ -469,11 +473,11 @@ static irqreturn_t ad7768_trigger_handler(int irq, void *p)
469473

470474
mutex_lock(&st->lock);
471475

472-
ret = spi_read(st->spi, &st->data.d32, 3);
476+
ret = spi_read(st->spi, &st->data.scan.chan, 3);
473477
if (ret < 0)
474478
goto err_unlock;
475479

476-
iio_push_to_buffers_with_timestamp(indio_dev, &st->data.d32,
480+
iio_push_to_buffers_with_timestamp(indio_dev, &st->data.scan,
477481
iio_get_time_ns(indio_dev));
478482

479483
iio_trigger_notify_done(indio_dev->trig);

0 commit comments

Comments
 (0)