summaryrefslogtreecommitdiff
path: root/drivers/iio
diff options
context:
space:
mode:
authorMarcus Folkesson <marcus.folkesson@gmail.com>2022-07-22 16:07:18 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-09-08 12:11:36 +0300
commite6aeb8be85716d63589414a862bf233483c3e6fe (patch)
tree03f127c265cd070cb8e90beedf364b44d0219109 /drivers/iio
parentb69e05b1e830526f81b75aa87f99d467556d845d (diff)
downloadlinux-e6aeb8be85716d63589414a862bf233483c3e6fe.tar.xz
iio: adc: mcp3911: make use of the sign bit
[ Upstream commit 8f89e33bf040bbef66386c426198622180233178 ] The device supports negative values as well. Fixes: 3a89b289df5d ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/adc/mcp3911.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/iio/adc/mcp3911.c b/drivers/iio/adc/mcp3911.c
index e573da5397bb..81eeb0084211 100644
--- a/drivers/iio/adc/mcp3911.c
+++ b/drivers/iio/adc/mcp3911.c
@@ -111,6 +111,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;