From: kr494167@gmail.com
To: broonie@kernel.org, lgirdwood@gmail.com
Cc: andreas@kemnade.info, linux-kernel@vger.kernel.org,
Surendra Singh Chouhan <kr494167@gmail.com>
Subject: [PATCH] regulator: tps65185: handle gpiod_get_value_cansleep() error returns
Date: Fri, 24 Jul 2026 18:28:57 +0530 [thread overview]
Message-ID: <20260724125858.75635-1-kr494167@gmail.com> (raw)
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
next reply other threads:[~2026-07-24 12:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 12:58 kr494167 [this message]
2026-07-28 18:04 ` Andreas Kemnade
2026-07-29 23:55 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260724125858.75635-1-kr494167@gmail.com \
--to=kr494167@gmail.com \
--cc=andreas@kemnade.info \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®