From e29242ad813c71e8e6a22c4f13f420a2297ac716 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Fri, 10 Jan 2020 11:05:40 +0100 Subject: [PATCH] power: supply: max17040: Correct IRQ wake handling 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) [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0xa4/0xd0) [] (dump_stack) from [] (__warn+0xf4/0x10c) [] (__warn) from [] (warn_slowpath_fmt+0x74/0xb8) [] (warn_slowpath_fmt) from [] (irq_set_irq_wake+0xfc/0x134) [] (irq_set_irq_wake) from [] (max17040_suspend+0x50/0x58) [] (max17040_suspend) from [] (dpm_run_callback+0xb4/0x400) [] (dpm_run_callback) from [] (__device_suspend+0x140/0x814) [] (__device_suspend) from [] (dpm_suspend+0x16c/0x564) [] (dpm_suspend) from [] (dpm_suspend_start+0x90/0x98) [] (dpm_suspend_start) from [] (suspend_devices_and_enter+0xec/0xc0c) [] (suspend_devices_and_enter) from [] (pm_suspend+0x318/0x3e8) [] (pm_suspend) from [] (state_store+0x68/0xc8) [] (state_store) from [] (kernfs_fop_write+0x10c/0x220) [] (kernfs_fop_write) from [] (__vfs_write+0x2c/0x1c4) [] (__vfs_write) from [] (vfs_write+0xa4/0x180) [] (vfs_write) from [] (ksys_write+0x58/0xcc) [] (ksys_write) from [] (ret_fast_syscall+0x0/0x28) Exception stack(0xd6e83fa8 to 0xd6e83ff0) ... irq event stamp: 18028 hardirqs last enabled at (18027): [] cancel_delayed_work+0x84/0xf8 hardirqs last disabled at (18028): [] _raw_spin_lock_irqsave+0x1c/0x58 softirqs last enabled at (17876): [] __do_softirq+0x4f0/0x5e4 softirqs last disabled at (17869): [] irq_exit+0x16c/0x170 ---[ end trace 0728005730004e60 ]--- Fixes: 2e17ed94de68 ("power: supply: max17040: Add IRQ handler for low SOC alert") Signed-off-by: Marek Szyprowski Reviewed-by: Krzysztof Kozlowski Signed-off-by: Sebastian Reichel --- drivers/power/supply/max17040_battery.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c index c1188e9..8a1f0ee 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; } -- 2.7.4