regulator: tps65185: handle gpiod_get_value_cansleep() error returns
PATCH 1/1 regulator: tps65185: handle gpiod_get_value_cansleep() error returns
From: Surendra Singh Chouhan <[email protected]>
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.
--- drivers/regulator/tps65185.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/regulator/tps65185.c +4 -1
@@ -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 ;
Signature · 1 line
2.55.0
Quoted 11 lines · On Fri, Jul 24, 2026 at 06:28:57PM +0530, [email protected] wrote:
From: Surendra Singh Chouhan <[email protected]>
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.-EIOor-EINVAL) on failure. Evaluating != 1 treats a negative error code as non-equal, swallowing GPIO read errors and masking them as-ETIMEDOUT.
Quoted 6 lines
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 <[email protected]>
Mark Brown
maintainerQuoted 1 line · On Fri, 24 Jul 2026 18:28:57 +0530, [email protected] 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