]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: adc: ti-ads1119: fix sample size in scan struct for triggered buffer
authorJavier Carrasco <javier.carrasco.cruz@gmail.com>
Mon, 2 Dec 2024 19:18:44 +0000 (20:18 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Jan 2025 12:40:57 +0000 (13:40 +0100)
commit 54d394905c92b9ecc65c1f9b2692c8e10716d8e1 upstream.

This device returns signed, 16-bit samples as stated in its datasheet
(see 8.5.2 Data Format). That is in line with the scan_type definition
for the IIO_VOLTAGE channel, but 'unsigned int' is being used to read
and push the data to userspace.

Given that the size of that type depends on the architecture (at least
2 bytes to store values up to 65535, but its actual size is often 4
bytes), use the 's16' type to provide the same structure in all cases.

Fixes: a9306887eba4 ("iio: adc: ti-ads1119: Add driver")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Link: https://patch.msgid.link/20241202-ti-ads1119_s16_chan-v1-1-fafe3136dc90@gmail.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/adc/ti-ads1119.c

index 533610ac214eee09c5d5de2ee06503331f9dca0e..6637cb6a6dda4a9a1cf62050fd85a5140b34378d 100644 (file)
@@ -500,7 +500,7 @@ static irqreturn_t ads1119_trigger_handler(int irq, void *private)
        struct iio_dev *indio_dev = pf->indio_dev;
        struct ads1119_state *st = iio_priv(indio_dev);
        struct {
-               unsigned int sample;
+               s16 sample;
                s64 timestamp __aligned(8);
        } scan;
        unsigned int index;