mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 14:33:24 -04:00
Input: samsung-keypad - clean up wakeup configuration logic
When checking if the device can wake the system, we should pull the device_may_wakeup() check to the caller instead of repeating it inside the toggle_wakeup() handler. Furthermore, when configuring the wakeup, we should safely ensure we write to the registers in the correct order: configure the interrupt receiver before enabling the peripheral's wake functionality, and vice-versa. Assisted-by: Antigravity:gemini-3.1-pro Link: https://patch.msgid.link/20260713-samsung-kp-irq-v2-1-acc84b6daf9a@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
@@ -492,15 +492,14 @@ static void samsung_keypad_toggle_wakeup(struct samsung_keypad *keypad,
|
||||
|
||||
val = readl(keypad->base + SAMSUNG_KEYIFCON);
|
||||
if (enable) {
|
||||
enable_irq_wake(keypad->irq);
|
||||
val |= SAMSUNG_KEYIFCON_WAKEUPEN;
|
||||
if (device_may_wakeup(&keypad->pdev->dev))
|
||||
enable_irq_wake(keypad->irq);
|
||||
writel(val, keypad->base + SAMSUNG_KEYIFCON);
|
||||
} else {
|
||||
val &= ~SAMSUNG_KEYIFCON_WAKEUPEN;
|
||||
if (device_may_wakeup(&keypad->pdev->dev))
|
||||
disable_irq_wake(keypad->irq);
|
||||
writel(val, keypad->base + SAMSUNG_KEYIFCON);
|
||||
disable_irq_wake(keypad->irq);
|
||||
}
|
||||
writel(val, keypad->base + SAMSUNG_KEYIFCON);
|
||||
|
||||
clk_disable(keypad->clk);
|
||||
}
|
||||
@@ -516,7 +515,8 @@ static int samsung_keypad_suspend(struct device *dev)
|
||||
if (input_device_enabled(input_dev))
|
||||
samsung_keypad_stop(keypad);
|
||||
|
||||
samsung_keypad_toggle_wakeup(keypad, true);
|
||||
if (device_may_wakeup(dev))
|
||||
samsung_keypad_toggle_wakeup(keypad, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -529,7 +529,8 @@ static int samsung_keypad_resume(struct device *dev)
|
||||
|
||||
guard(mutex)(&input_dev->mutex);
|
||||
|
||||
samsung_keypad_toggle_wakeup(keypad, false);
|
||||
if (device_may_wakeup(dev))
|
||||
samsung_keypad_toggle_wakeup(keypad, false);
|
||||
|
||||
if (input_device_enabled(input_dev))
|
||||
samsung_keypad_start(keypad);
|
||||
|
||||
Reference in New Issue
Block a user