diff mbox series

[v2,09/10] iio: adc: mcp3911: make use of the sign bit

Message ID 20220625103853.2470346-9-marcus.folkesson@gmail.com (mailing list archive)
State Changes Requested
Headers show
Series [v2,01/10] iio: adc: mcp3911: correct "microchip,device-addr" property | expand

Commit Message

Marcus Folkesson June 25, 2022, 10:38 a.m. UTC
The device supports negative values as well.

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---

Notes:
    v2:
        - No changes

 drivers/iio/adc/mcp3911.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jonathan Cameron June 25, 2022, 12:48 p.m. UTC | #1
On Sat, 25 Jun 2022 12:38:52 +0200
Marcus Folkesson <marcus.folkesson@gmail.com> wrote:

> The device supports negative values as well.
> 
> Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
This looks like a fix to me.  So fixes tag and move it to the start
of the series.

Jonathan

> ---
> 
> Notes:
>     v2:
>         - No changes
> 
>  drivers/iio/adc/mcp3911.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/adc/mcp3911.c b/drivers/iio/adc/mcp3911.c
> index a0609d7663e1..a019264e73e3 100644
> --- a/drivers/iio/adc/mcp3911.c
> +++ b/drivers/iio/adc/mcp3911.c
> @@ -144,6 +144,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;
>
diff mbox series

Patch

diff --git a/drivers/iio/adc/mcp3911.c b/drivers/iio/adc/mcp3911.c
index a0609d7663e1..a019264e73e3 100644
--- a/drivers/iio/adc/mcp3911.c
+++ b/drivers/iio/adc/mcp3911.c
@@ -144,6 +144,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;