mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-21 05:14:52 +08:00
iio: adc: ti-adc108s102: Fix alignment of buffer pushed to iio buffers.
Use the newly introduce iio_push_to_buffers_with_ts_unaligned() function
to ensure a bounce buffer is used to provide the required alignment and
space padding needed by the IIO core which requires the timestamp
is naturally aligned. There will be a performance cost to this change
but it will ensure the driver works on platforms that do not support
unaligned 8 byte assignments, and with consumer drivers that may
assume natural alignment of the timestamp.
Issue found as part of an audit of all calls to
iio_push_to_buffers_with_timestamp()
Fixes: 7e87d11c9b
("iio: adc: Add support for TI ADC108S102 and ADC128S102")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Link: https://lore.kernel.org/r/20210613151039.569883-3-jic23@kernel.org
This commit is contained in:
parent
95ec3fdf2b
commit
cbe5c69776
@ -75,9 +75,9 @@ struct adc108s102_state {
|
||||
* rx_buf: |XX|R0|R1|R2|R3|R4|R5|R6|R7|tt|tt|tt|tt|
|
||||
*
|
||||
* tx_buf: 8 channel read commands, plus 1 dummy command
|
||||
* rx_buf: 1 dummy response, 8 channel responses, plus 64-bit timestamp
|
||||
* rx_buf: 1 dummy response, 8 channel responses
|
||||
*/
|
||||
__be16 rx_buf[13] ____cacheline_aligned;
|
||||
__be16 rx_buf[9] ____cacheline_aligned;
|
||||
__be16 tx_buf[9] ____cacheline_aligned;
|
||||
};
|
||||
|
||||
@ -149,9 +149,10 @@ static irqreturn_t adc108s102_trigger_handler(int irq, void *p)
|
||||
goto out_notify;
|
||||
|
||||
/* Skip the dummy response in the first slot */
|
||||
iio_push_to_buffers_with_timestamp(indio_dev,
|
||||
(u8 *)&st->rx_buf[1],
|
||||
iio_get_time_ns(indio_dev));
|
||||
iio_push_to_buffers_with_ts_unaligned(indio_dev,
|
||||
&st->rx_buf[1],
|
||||
st->ring_xfer.len - sizeof(st->rx_buf[1]),
|
||||
iio_get_time_ns(indio_dev));
|
||||
|
||||
out_notify:
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
|
Loading…
Reference in New Issue
Block a user