]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: adc: ti-ads7950: normalize return value of gpio_get
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Thu, 5 Mar 2026 19:21:52 +0000 (11:21 -0800)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 7 Mar 2026 11:40:17 +0000 (11:40 +0000)
The GPIO get callback is expected to return 0 or 1 (or a negative error
code). Ensure that the value returned by ti_ads7950_get() for output
pins is normalized to the [0, 1] range.

Fixes: 86ef402d805d ("gpiolib: sanitize the return value of gpio_chip::get()")
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ti-ads7950.c

index bbe1ce57778958bb295ad9759676b81896c86bad..b8cc39fc39fba9cca09650c324d6d1ec41e7f0dd 100644 (file)
@@ -433,7 +433,7 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
 
        /* If set as output, return the output */
        if (st->gpio_cmd_settings_bitmask & BIT(offset)) {
-               ret = st->cmd_settings_bitmask & BIT(offset);
+               ret = (st->cmd_settings_bitmask & BIT(offset)) ? 1 : 0;
                goto out;
        }