[PATCH v2 2/3] Input: samsung-keypad - keep interrupt disabled while closed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2026-07-14 05:39:52
Also in:
lkml
Subsystem:
input (keyboard, mouse, joystick, touchscreen) drivers, the rest · Maintainers:
Dmitry Torokhov, Linus Torvalds
The driver requests the interrupt during probe, which by default enables
it. If the bootloader left the keypad interrupts enabled, or if a
spurious interrupt fires early before the driver is fully initialized
and clocks are enabled, the interrupt handler will attempt to read
registers and may cause a synchronous external abort.
Fix this by requesting the interrupt with IRQF_NO_AUTOEN, keeping it
disabled during probe. Enable the interrupt in samsung_keypad_start()
when the device is opened and ready, and disable it in
samsung_keypad_stop() when the device is closed. Remove the redundant
re-enabling of the interrupt at the end of samsung_keypad_stop().
Additionally, manually clear the pending interrupt status during system
resume when the device is closed to avoid immediate resume.
Fixes: 0fffed27f92d ("Input: samsung-keypad - Add samsung keypad driver")
Assisted-by: Antigravity:gemini-3.1-pro
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/keyboard/samsung-keypad.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c
index a578f429d100..a51f0f639e9e 100644
--- a/drivers/input/keyboard/samsung-keypad.c
+++ b/drivers/input/keyboard/samsung-keypad.c@@ -183,6 +183,8 @@ static void samsung_keypad_start(struct samsung_keypad *keypad) writel(0, keypad->base + SAMSUNG_KEYIFCOL); pm_runtime_put(&keypad->pdev->dev); + + enable_irq(keypad->irq); } static void samsung_keypad_stop(struct samsung_keypad *keypad)
@@ -206,12 +208,6 @@ static void samsung_keypad_stop(struct samsung_keypad *keypad) clk_disable(keypad->clk); - /* - * Now that chip should not generate interrupts we can safely - * re-enable the handler. - */ - enable_irq(keypad->irq); - pm_runtime_put(&keypad->pdev->dev); }
@@ -412,7 +408,8 @@ static int samsung_keypad_probe(struct platform_device *pdev) } error = devm_request_threaded_irq(&pdev->dev, keypad->irq, NULL, - samsung_keypad_irq, IRQF_ONESHOT, + samsung_keypad_irq, + IRQF_ONESHOT | IRQF_NO_AUTOEN, dev_name(&pdev->dev), keypad); if (error) { dev_err(&pdev->dev, "failed to register keypad interrupt\n");
@@ -499,6 +496,9 @@ static void samsung_keypad_toggle_wakeup(struct samsung_keypad *keypad, val &= ~SAMSUNG_KEYIFCON_WAKEUPEN; writel(val, keypad->base + SAMSUNG_KEYIFCON); disable_irq_wake(keypad->irq); + + if (!input_device_enabled(keypad->input_dev)) + writel(~0x0, keypad->base + SAMSUNG_KEYIFSTSCLR); } clk_disable(keypad->clk);
--
2.55.0.795.g602f6c329a-goog