iio: at91-sama5d2: Fix incorrect sign extension
authorGwendal Grignou <gwendal@chromium.org>
Thu, 4 Nov 2021 08:24:08 +0000 (01:24 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Dec 2021 09:57:21 +0000 (10:57 +0100)
commit4071943a533c144f7d81bcd6de263cb85b78e80f
tree2fb95b5dd2fbc661b4f5c8ee732de748c77a7ddf
parenta862c731f7bc089cbee24145a1bad9b5b1eb001a
iio: at91-sama5d2: Fix incorrect sign extension

commit 652e7df485c6884d552085ae2c73efa6cfea3547 upstream.

Use scan_type when processing raw data which also fixes that the sign
extension was from the wrong bit.

Use channel definition as root of trust and replace constant
when reading elements directly using the raw sysfs attributes.

Fixes: 6794e23fa3fe ("iio: adc: at91-sama5d2_adc: add support for oversampling resolution")
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Eugen Hristev <eugen.hristev@microchip.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20211104082413.3681212-9-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/adc/at91-sama5d2_adc.c