[PATCH v2 2/2] power: supply: max17040: fail probe when requesting the alert IRQ fails

From: Jianing Li

Date: Mon Nov 02 2026 - 05:57:36 EST


MAX17048 and MAX17049 use the SOC alert interrupt instead of polling when
an IRQ is provided. If max17040_enable_alert_irq() fails, the probe
function currently clears client->irq and continues successfully.

The suspend and resume callbacks then see no IRQ and try to operate on
the polling work, which was never initialized for these variants.

Return the IRQ setup error from probe so the device is not registered in
this incomplete state. The devm cleanup handlers release the resources
already acquired by probe.

Fixes: ee2d433cb473 ("power: supply: max17040: Support soc alert")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Jianing Li <m13940358460@xxxxxxx>
---
drivers/power/supply/max17040_battery.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c
index f415876..6f97051 100644
--- a/drivers/power/supply/max17040_battery.c
+++ b/drivers/power/supply/max17040_battery.c
@@ -562,11 +562,9 @@ static int max17040_probe(struct i2c_client *client)

if (enable_irq) {
ret = max17040_enable_alert_irq(chip);
- if (ret) {
- client->irq = 0;
- dev_warn(&client->dev,
- "Failed to get IRQ err %d\n", ret);
- }
+ if (ret)
+ return dev_err_probe(&client->dev, ret,
+ "Failed to get IRQ\n");
}

return 0;