Re: [PATCH 1/7] gpio: bd9571mwv: normalize return value of gpio_get

From: Bartosz Golaszewski

Date: Wed Feb 18 2026 - 15:24:17 EST


On Wed, Feb 18, 2026 at 8:07 PM Dmitry Torokhov
<dmitry.torokhov@xxxxxxxxx> wrote:
>
> The GPIO get callback is expected to return 0 or 1 (or a negative error
> code). Ensure that the value returned by bd9571mwv_gpio_get() is
> normalized to the [0, 1] range.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
> ---
> drivers/gpio/gpio-bd9571mwv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-bd9571mwv.c b/drivers/gpio/gpio-bd9571mwv.c
> index 7c95bb36511e..cc5b1746f2fe 100644
> --- a/drivers/gpio/gpio-bd9571mwv.c
> +++ b/drivers/gpio/gpio-bd9571mwv.c
> @@ -69,7 +69,7 @@ static int bd9571mwv_gpio_get(struct gpio_chip *chip, unsigned int offset)
> if (ret < 0)
> return ret;
>
> - return val & BIT(offset);
> + return !!(val & BIT(offset));
> }
>
> static int bd9571mwv_gpio_set(struct gpio_chip *chip, unsigned int offset,
> --
> 2.53.0.335.g19a08e0c02-goog
>

Thanks for doing this. I think it would make sense to backport them
all the way to commit 86ef402d805d ("gpiolib: sanitize the return
value of gpio_chip::get()")?

Bartosz