diff mbox series

power: supply: max17040: Correct IRQ wake handling

Message ID 20200110100540.27371-1-m.szyprowski@samsung.com
State New
Headers show
Series power: supply: max17040: Correct IRQ wake handling | expand

Commit Message

Marek Szyprowski Jan. 10, 2020, 10:05 a.m. UTC
Don't disable IRQ wake feature without prior enabling it.

This fixes following warning observed on Exynos3250-based Rinato board:
------------[ cut here ]------------
WARNING: CPU: 0 PID: 1288 at kernel/irq/manage.c:724 irq_set_irq_wake+0xfc/0x134
Unbalanced IRQ 83 wake disable
Modules linked in:
CPU: 0 PID: 1288 Comm: rtcwake Not tainted 5.5.0-rc5-next-20200110-00031-g6289fffbb3f5 #7266
Hardware name: Samsung Exynos (Flattened Device Tree)
[<c0112e48>] (unwind_backtrace) from [<c010e090>] (show_stack+0x10/0x14)
[<c010e090>] (show_stack) from [<c0b25b28>] (dump_stack+0xa4/0xd0)
[<c0b25b28>] (dump_stack) from [<c0128088>] (__warn+0xf4/0x10c)
[<c0128088>] (__warn) from [<c0128114>] (warn_slowpath_fmt+0x74/0xb8)
[<c0128114>] (warn_slowpath_fmt) from [<c019e9a0>] (irq_set_irq_wake+0xfc/0x134)
[<c019e9a0>] (irq_set_irq_wake) from [<c0772708>] (max17040_suspend+0x50/0x58)
[<c0772708>] (max17040_suspend) from [<c05f55ac>] (dpm_run_callback+0xb4/0x400)
[<c05f55ac>] (dpm_run_callback) from [<c05f5e38>] (__device_suspend+0x140/0x814)
[<c05f5e38>] (__device_suspend) from [<c05f9548>] (dpm_suspend+0x16c/0x564)
[<c05f9548>] (dpm_suspend) from [<c05fa2e4>] (dpm_suspend_start+0x90/0x98)
[<c05fa2e4>] (dpm_suspend_start) from [<c01977f4>] (suspend_devices_and_enter+0xec/0xc0c)
[<c01977f4>] (suspend_devices_and_enter) from [<c019862c>] (pm_suspend+0x318/0x3e8)
[<c019862c>] (pm_suspend) from [<c01963cc>] (state_store+0x68/0xc8)
[<c01963cc>] (state_store) from [<c03531a4>] (kernfs_fop_write+0x10c/0x220)
[<c03531a4>] (kernfs_fop_write) from [<c02b44c4>] (__vfs_write+0x2c/0x1c4)
[<c02b44c4>] (__vfs_write) from [<c02b7288>] (vfs_write+0xa4/0x180)
[<c02b7288>] (vfs_write) from [<c02b74d0>] (ksys_write+0x58/0xcc)
[<c02b74d0>] (ksys_write) from [<c0101000>] (ret_fast_syscall+0x0/0x28)
Exception stack(0xd6e83fa8 to 0xd6e83ff0)
...
irq event stamp: 18028
hardirqs last  enabled at (18027): [<c014b99c>] cancel_delayed_work+0x84/0xf8
hardirqs last disabled at (18028): [<c0b49b1c>] _raw_spin_lock_irqsave+0x1c/0x58
softirqs last  enabled at (17876): [<c01026d8>] __do_softirq+0x4f0/0x5e4
softirqs last disabled at (17869): [<c0130d34>] irq_exit+0x16c/0x170
---[ end trace 0728005730004e60 ]---

Fixes: 2e17ed94de68 ("power: supply: max17040: Add IRQ handler for low SOC alert")
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 drivers/power/supply/max17040_battery.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c
index c1188e94cf54..8a1f0ee493aa 100644
--- a/drivers/power/supply/max17040_battery.c
+++ b/drivers/power/supply/max17040_battery.c
@@ -351,12 +351,8 @@  static int max17040_suspend(struct device *dev)
 
 	cancel_delayed_work(&chip->work);
 
-	if (client->irq) {
-		if (device_may_wakeup(dev))
-			enable_irq_wake(client->irq);
-		else
-			disable_irq_wake(client->irq);
-	}
+	if (client->irq && device_may_wakeup(dev))
+		enable_irq_wake(client->irq);
 
 	return 0;
 }
@@ -369,12 +365,8 @@  static int max17040_resume(struct device *dev)
 	queue_delayed_work(system_power_efficient_wq, &chip->work,
 			   MAX17040_DELAY);
 
-	if (client->irq) {
-		if (device_may_wakeup(dev))
-			disable_irq_wake(client->irq);
-		else
-			enable_irq_wake(client->irq);
-	}
+	if (client->irq && device_may_wakeup(dev))
+		disable_irq_wake(client->irq);
 
 	return 0;
 }