lkml.org 
[lkml]   [2022]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.10 06/80] iio: adc: mcp3911: make use of the sign bit
    Date
    From: Marcus Folkesson <marcus.folkesson@gmail.com>

    [ 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>
    ---
    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 e573da5397bb3..81eeb00842112 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;

    --
    2.35.1


    \
     
     \ /
      Last update: 2022-09-06 15:35    [W:4.185 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site