Re: [PATCH] regulator: tps65185: handle gpiod_get_value_cansleep() error returns

From: Andreas Kemnade

Date: Wed Jul 29 2026 - 02:53:03 EST


On Fri, Jul 24, 2026 at 06:28:57PM +0530, kr494167@xxxxxxxxx wrote:
> From: Surendra Singh Chouhan <kr494167@xxxxxxxxx>
>
> tps65185_vposneg_enable() evaluated:
> if (gpiod_get_value_cansleep(data->pgood_gpio) != 1)
> return -ETIMEDOUT;
>
> gpiod_get_value_cansleep() returns 1 if active, 0 if inactive, and a
> negative error code (e.g. -EIO or -EINVAL) on failure. Evaluating != 1
> treats a negative error code as non-equal, swallowing GPIO read errors and
> masking them as -ETIMEDOUT.
>
> Fix this by capturing the return value of gpiod_get_value_cansleep(). If
> it returns a negative error code, propagate that error immediately; if
> it returns 0 (inactive), return -ETIMEDOUT.
>
> Fixes: b0fc1e770194 ("regulator: Add TPS65185 driver")
> Signed-off-by: Surendra Singh Chouhan <kr494167@xxxxxxxxx>

Reviewed-by: Andreas Kemnade <andreas@xxxxxxxxxxxx>