]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: adc: rtq6056: Correct the sign bit index
authorChiYuan Huang <cy_huang@richtek.com>
Mon, 1 Dec 2025 21:23:04 +0000 (16:23 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 6 Dec 2025 21:12:45 +0000 (06:12 +0900)
[ Upstream commit 9b45744bf09fc2a3287e05287141d6e123c125a7 ]

The vshunt/current reported register is a signed 16bit integer. The
sign bit index should be '15', not '16'.

Fixes: 4396f45d211b ("iio: adc: Add rtq6056 support")
Reported-by: Andy Hsu <andy_ya_hsu@wiwynn.com>
Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
[ adapted switch statement to existing if-else structure for sign_extend32() fix ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/adc/rtq6056.c

index c1b2e8dc9a26687c20ca565abe6a7e6600a1a5f3..04ce542f8ab3f11abb81f883b506a42352d9dc34 100644 (file)
@@ -171,7 +171,7 @@ static int rtq6056_adc_read_channel(struct rtq6056_priv *priv,
        if (addr == RTQ6056_REG_BUSVOLT || addr == RTQ6056_REG_POWER)
                *val = regval;
        else
-               *val = sign_extend32(regval, 16);
+               *val = sign_extend32(regval, 15);
 
        return IIO_VAL_INT;
 }