* [PATCH] regulator: tps65185: handle gpiod_get_value_cansleep() error returns
@ 2026-07-24 12:58 kr494167
2026-07-28 18:04 ` Andreas Kemnade
0 siblings, 1 reply; 2+ messages in thread
From: kr494167 @ 2026-07-24 12:58 UTC (permalink / raw)
To: broonie, lgirdwood; +Cc: andreas, linux-kernel, Surendra Singh Chouhan
From: Surendra Singh Chouhan <kr494167@gmail.com>
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@gmail.com>
---
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;
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] regulator: tps65185: handle gpiod_get_value_cansleep() error returns
2026-07-24 12:58 [PATCH] regulator: tps65185: handle gpiod_get_value_cansleep() error returns kr494167
@ 2026-07-28 18:04 ` Andreas Kemnade
0 siblings, 0 replies; 2+ messages in thread
From: Andreas Kemnade @ 2026-07-28 18:04 UTC (permalink / raw)
To: kr494167; +Cc: broonie, lgirdwood, linux-kernel
On Fri, Jul 24, 2026 at 06:28:57PM +0530, kr494167@gmail.com wrote:
> From: Surendra Singh Chouhan <kr494167@gmail.com>
>
> 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@gmail.com>
Reviewed-by: Andreas Kemnade <andreas@kemnade.info>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-29 6:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 12:58 [PATCH] regulator: tps65185: handle gpiod_get_value_cansleep() error returns kr494167
2026-07-28 18:04 ` Andreas Kemnade
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox