]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commit
iio: adc: ti-adc161s626: fix buffer read on big-endian
authorDavid Lechner <dlechner@baylibre.com>
Sat, 14 Mar 2026 23:13:31 +0000 (18:13 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 21 Mar 2026 20:41:45 +0000 (20:41 +0000)
commit24869650dff34a6fc8fd1cc91b2058a72f9abc95
tree4a7ca53d0deef51b6bcc66630d6f1dcb5fd5ca97
parentdd154646d292cce7de952f216760c58c35cfecde
iio: adc: ti-adc161s626: fix buffer read on big-endian

Rework ti_adc_trigger_handler() to properly handle data on big-endian
architectures. The scan data format is 16-bit CPU-endian, so we can't
cast it to a int * on big-endian and expect it to work. Instead, we
introduce a local int variable to read the data into, and then copy it
to the buffer.

Since the buffer isn't passed to any SPI functions, we don't need it to
be DMA-safe. So we can drop it from the driver data struct and just
use stack memory for the scan data.

Since there is only one data value (plus timestamp), we don't need an
array and can just declare a struct with the correct data type instead.

Also fix alignment of iio_get_time_ns() to ( while we are touching this.

Fixes: 4d671b71beef ("iio: adc: ti-adc161s626: add support for TI 1-channel differential ADCs")
Signed-off-by: David Lechner <dlechner@baylibre.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ti-adc161s626.c