Re: [PATCH v2] iio: adc: ti-ads7950: use iio_push_to_buffers_with_ts_unaligned()

David Lechner
2026-03-16T14:58:49Z

On 3/16/26 6:26 AM, Andy Shevchenko wrote:
> On Sat, Mar 14, 2026 at 04:12:24PM -0500, David Lechner wrote:
>> Use iio_push_to_buffers_with_ts_unaligned() to avoid unaligned access
>> when writing the timestamp in the rx_buf.
>>
>> The previous implementation would have been fine on architectures that
>> support 4-byte alignment of 64-bit integers but could cause issues on
>> architectures that require 8-byte alignment.
>
> ...
>
>> + u16 rx_buf[TI_ADS7950_MAX_CHAN + 2] __aligned(IIO_DMA_MINALIGN);
>> u16 tx_buf[TI_ADS7950_MAX_CHAN + 2];
>
> ...
>
>> - iio_push_to_buffers_with_timestamp(indio_dev, &st->rx_buf[2],
>> - iio_get_time_ns(indio_dev));
>> + iio_push_to_buffers_with_ts_unaligned(indio_dev, &st->rx_buf[2],
>> + sizeof(*st->rx_buf) *
>> + TI_ADS7950_MAX_CHAN,
>
> Hmm... Wouldn't this benefit from array_size() macro?

I don't think so. This is a compile-time constant. array_size() is
a function that handles overflow, and there is no risk of overflow
since it is a constant.

>
>> + iio_get_time_ns(indio_dev));
>