power: supply: generic-adc-battery: Propagate charged GPIO errors
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.
--- drivers/power/supply/generic-adc-battery.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/power/supply/generic-adc-battery.c +3 -0
@@ -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
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, butgab_probe()only checks for NULL. The error pointer is then passed togpiod_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 <[email protected]>
That's right.
Yours,
Linus Walleij
Sebastian Reichel
AppliedQuoted 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, butgab_probe()only checks for NULL. The error pointer is then passed togpiod_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]>