Skip to contentSkip to conversation

power: supply: generic-adc-battery: Propagate charged GPIO errors

PATCH Applied [email protected] 3 participants 3 messages Oct 9 – Oct 17 Power supply

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power: supply: generic-adc-battery: Propagate charged GPIO errors

From: bui duc phuc <[email protected]>

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")
---
 drivers/power/supply/generic-adc-battery.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/power/supply/generic-adc-battery.c +3 -0
index 185f55d2fd70..f3ca3ebb2533 100644
@@ -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;
 
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · On Fri, Oct 9, 2026 at 1:24 PM <[email protected]> wrote:

From: bui duc phuc <[email protected]>

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")

That's right.

Yours,
Linus Walleij

#2 lore raw
In reply to [email protected]
Quoted 8 lines · On Fri, 09 Oct 2026 18:24:29 +0700, [email protected] wrote:

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.

[...]

Applied, thanks!

[1/1] power: supply: generic-adc-battery: Propagate charged GPIO errors

      commit: 36b0abe904ac9cbdce6161d9c7c0bcac963bb3fe

Best regards,

Signature · 1 line
Sebastian Reichel <[email protected]>