Skip to content

Commit 652e7df

Browse files
gwendalcrjic23
authored andcommitted
iio: at91-sama5d2: Fix incorrect sign extension
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: 6794e23 ("iio: adc: at91-sama5d2_adc: add support for oversampling resolution") Signed-off-by: Gwendal Grignou <[email protected]> Reviewed-by: Eugen Hristev <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 92beafb commit 652e7df

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/iio/adc/at91-sama5d2_adc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1586,7 +1586,8 @@ static int at91_adc_read_info_raw(struct iio_dev *indio_dev,
15861586
*val = st->conversion_value;
15871587
ret = at91_adc_adjust_val_osr(st, val);
15881588
if (chan->scan_type.sign == 's')
1589-
*val = sign_extend32(*val, 11);
1589+
*val = sign_extend32(*val,
1590+
chan->scan_type.realbits - 1);
15901591
st->conversion_done = false;
15911592
}
15921593

0 commit comments

Comments
 (0)