]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
iio: adc: ad4000: fix reading unsigned data
authorDavid Lechner <dlechner@baylibre.com>
Wed, 30 Oct 2024 21:09:41 +0000 (16:09 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 31 Oct 2024 21:41:00 +0000 (21:41 +0000)
Fix reading unsigned data from the AD4000 ADC via the _raw sysfs
attribute by ensuring that *val is set before returning from
ad4000_single_conversion(). This was not being set in any code path
and was causing the attribute to return a random value.

Fixes: 938fd562b974 ("iio: adc: Add support for AD4000")
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20241030-iio-adc-ad4000-fix-reading-unsigned-data-v1-1-2e28dd75fe29@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ad4000.c

index 6ea49124508499b37c3536cbf6ae3e200a1f4138..fc9c9807f89d2604e760bdb54368d34d148c739b 100644 (file)
@@ -344,6 +344,8 @@ static int ad4000_single_conversion(struct iio_dev *indio_dev,
 
        if (chan->scan_type.sign == 's')
                *val = sign_extend32(sample, chan->scan_type.realbits - 1);
+       else
+               *val = sample;
 
        return IIO_VAL_INT;
 }