[PATCH] power: supply: bq24190_charger: use the wake irq API
From: Ryan Brue
Date: Tue Sep 08 2026 - 01:38:10 EST
bq24190_probe() calls enable_irq_wake() on the charger interrupt and
never calls disable_irq_wake(). That is wrong in three ways.
It is unbalanced. free_irq() does not touch desc->wake_depth -- only
irq_set_irq_wake() does -- so after the driver is unbound the descriptor
is still one wake reference deep and the irqchip is still configured for
wake, forever, for an interrupt nobody owns any more.
It ignores the device's wakeup policy. The chip is made a system wake
source whether or not anyone asked for it, and because
device_init_wakeup() is never called there is no power/wakeup attribute
for userspace to say otherwise. A board that would rather not be woken
by its charger has no way to express that.
And it arms the interrupt for wake permanently, from probe onwards,
rather than for the sleep it is meant to cover.
Use the wake irq API instead: devm_device_init_wakeup() to make the
device wakeup-capable and enabled -- preserving today's behaviour -- and
devm_pm_set_wake_irq() to hand the interrupt to the PM core, which arms
it in dpm_suspend_noirq() (only if device_may_wakeup(), immediately
before suspend_device_irqs()) and disarms it on resume. Both are unwound
by devm, so the reference is balanced on unbind, and userspace gets the
power/wakeup control it should have had.
No intended change in behaviour: charger events still wake the system by
default.
The same conversion was made to another charger driver for the same
reason, in commit 6c5393771c50 ("power: supply: qcom_pmi8998_charger: fix
wakeirq").
Fixes: f385e6e2a153 ("power: bq24190_charger: Use PM runtime autosuspend")
Assisted-by: LLM
Signed-off-by: Ryan Brue <ryanbrue.dev@xxxxxxxxx>
---
drivers/power/supply/bq24190_charger.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
index 4bea6fd83c36..376b0b06a096 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -10,6 +10,7 @@
#include <linux/delay.h>
#include <linux/devm-helpers.h>
#include <linux/pm_runtime.h>
+#include <linux/pm_wakeirq.h>
#include <linux/power_supply.h>
#include <linux/power/bq24190_charger.h>
#include <linux/regulator/driver.h>
@@ -2168,7 +2169,13 @@ static int bq24190_probe(struct i2c_client *client)
if (ret < 0)
goto out_charger;
- enable_irq_wake(client->irq);
+ ret = devm_device_init_wakeup(dev);
+ if (ret < 0)
+ goto out_charger;
+
+ ret = devm_pm_set_wake_irq(dev, client->irq);
+ if (ret < 0)
+ goto out_charger;
pm_runtime_put_autosuspend(dev);
---
base-commit: df2908090cda368b01ff43709f51890076c56157
change-id: 20260908-rbrue-suez-upstreaming-bq24190_charger-use-wake-irq-api-bde60f815307
Best regards,
--
Ryan Brue <ryanbrue.dev@xxxxxxxxx>