mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] regulator: tps65185: handle gpiod_get_value_cansleep() error returns
@ 2026-07-24 12:58 kr494167
  2026-07-28 18:04 ` Andreas Kemnade
  2026-07-29 23:55 ` Mark Brown
  0 siblings, 2 replies; 3+ 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	[flat|nested] 3+ 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
  2026-07-29 23:55 ` Mark Brown
  1 sibling, 0 replies; 3+ 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] 3+ 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
@ 2026-07-29 23:55 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-07-29 23:55 UTC (permalink / raw)
  To: lgirdwood, kr494167; +Cc: andreas, linux-kernel

On Fri, 24 Jul 2026 18:28:57 +0530, kr494167@gmail.com wrote:
> regulator: tps65185: handle gpiod_get_value_cansleep() error returns

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-7.3

Thanks!

[1/1] regulator: tps65185: handle gpiod_get_value_cansleep() error returns
      https://git.kernel.org/broonie/regulator/c/623d9a55685c

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-30 11:24 UTC | newest]

Thread overview: 3+ 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
2026-07-29 23:55 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®