Skip to content

Commit

Permalink
iio: adc: mcp3911: make use of the sign bit
Browse files Browse the repository at this point in the history
The device supports negative values as well.

Fixes: 3a89b28 ("iio: adc: add support for mcp3911")
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220722130726.7627-2-marcus.folkesson@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
  • Loading branch information
marcusfolkesson authored and jic23 committed Aug 15, 2022
1 parent 568035b commit 8f89e33
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/iio/adc/mcp3911.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ static int mcp3911_read_raw(struct iio_dev *indio_dev,
if (ret)
goto out;

*val = sign_extend32(*val, 23);

ret = IIO_VAL_INT;
break;

Expand Down

0 comments on commit 8f89e33

Please sign in to comment.