mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] power: supply: generic-adc-battery: Propagate charged GPIO errors
@ 2026-10-09 11:24 phucduc.bui
  2026-10-09 12:20 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: phucduc.bui @ 2026-10-09 11:24 UTC (permalink / raw)
  To: Sebastian Reichel, Linus Walleij; +Cc: linux-pm, linux-kernel, bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

devm_gpiod_get_optional() may return an error pointer such as
-EPROBE_DEFER, but gab_probe() only checks for NULL. The error
pointer is then passed to gpiod_to_irq() and the original error,
including -EPROBE_DEFER, is lost.

Check the return value and propagate errors from the charged GPIO lookup.

Fixes: b0327ffb133f ("power: supply: generic-adc-battery: Use GPIO descriptors")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 drivers/power/supply/generic-adc-battery.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/power/supply/generic-adc-battery.c b/drivers/power/supply/generic-adc-battery.c
index 185f55d2fd70..f3ca3ebb2533 100644
--- a/drivers/power/supply/generic-adc-battery.c
+++ b/drivers/power/supply/generic-adc-battery.c
@@ -238,6 +238,9 @@ static int gab_probe(struct platform_device *pdev)
 		return dev_err_probe(&pdev->dev, ret, "Failed to register delayed work\n");
 
 	adc_bat->charge_finished = devm_gpiod_get_optional(&pdev->dev, "charged", GPIOD_IN);
+	if (IS_ERR(adc_bat->charge_finished))
+		return dev_err_probe(&pdev->dev, PTR_ERR(adc_bat->charge_finished),
+				     "failed to get charged GPIO\n");
 	if (adc_bat->charge_finished) {
 		int irq;
 
-- 
2.43.0


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

* Re: [PATCH] power: supply: generic-adc-battery: Propagate charged GPIO errors
  2026-10-09 11:24 [PATCH] power: supply: generic-adc-battery: Propagate charged GPIO errors phucduc.bui
@ 2026-10-09 12:20 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2026-10-09 12:20 UTC (permalink / raw)
  To: phucduc.bui; +Cc: Sebastian Reichel, linux-pm, linux-kernel

On Fri, Oct 9, 2026 at 1:24 PM <phucduc.bui@gmail.com> wrote:

> From: bui duc phuc <phucduc.bui@gmail.com>
>
> devm_gpiod_get_optional() may return an error pointer such as
> -EPROBE_DEFER, but gab_probe() only checks for NULL. The error
> pointer is then passed to gpiod_to_irq() and the original error,
> including -EPROBE_DEFER, is lost.
>
> Check the return value and propagate errors from the charged GPIO lookup.
>
> Fixes: b0327ffb133f ("power: supply: generic-adc-battery: Use GPIO descriptors")
> Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>

That's right.
Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij

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

end of thread, other threads:[~2026-10-09 12:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-09 11:24 [PATCH] power: supply: generic-adc-battery: Propagate charged GPIO errors phucduc.bui
2026-10-09 12:20 ` Linus Walleij

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®