From 623d9a55685c52b10b995d8dbde9da6283170220 Mon Sep 17 00:00:00 2001 From: Surendra Singh Chouhan Date: Fri, 24 Jul 2026 18:28:57 +0530 Subject: [PATCH] regulator: tps65185: handle gpiod_get_value_cansleep() error returns 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 Reviewed-by: Andreas Kemnade Link: https://patch.msgid.link/20260724125858.75635-1-kr494167@gmail.com Signed-off-by: Mark Brown --- drivers/regulator/tps65185.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/tps65185.c b/drivers/regulator/tps65185.c index 786622d8d598..1f13e4156cab 100644 --- a/drivers/regulator/tps65185.c +++ b/drivers/regulator/tps65185.c @@ -183,7 +183,10 @@ static int tps65185_vposneg_enable(struct regulator_dev *rdev) wait_for_completion_timeout(&data->pgood_completion, msecs_to_jiffies(PGOOD_TIMEOUT_MSECS)); dev_dbg(data->dev, "turned on"); - if (gpiod_get_value_cansleep(data->pgood_gpio) != 1) + ret = gpiod_get_value_cansleep(data->pgood_gpio); + if (ret < 0) + return ret; + if (!ret) return -ETIMEDOUT; return 0;