[PATCH 2/2] power: supply: max17040: fail probe when requesting the alert IRQ fails
From: Jianing Li
Date: Mon Nov 02 2026 - 02:34:57 EST
MAX17048 and MAX17049 skip polling work initialization when an IRQ is
available because SOC alerts replace polling. If requesting that IRQ
fails, max17040_probe() clears client->irq and returns success anyway.
The driver then has neither an interrupt handler nor a polling worker.
Clearing client->irq also makes the suspend and resume callbacks take
the polling path, which operates on an uninitialized delayed work item.
Propagate the IRQ request error instead of registering a device with
inconsistent interrupt and polling state. The managed resources unwind
the already registered power supply and, for polling models, cancel any
queued work.
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;
--
2.23.0.windows.1