From: Zhian Liang <liangzhan5dev@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Zhian Liang <liangzhan5dev@gmail.com>
Subject: [PATCH 1/2] Input: tca8418_keypad - Add devm cleanup to disable interrupts on unload
Date: Fri, 4 Sep 2026 03:29:41 +0800 [thread overview]
Message-ID: <20260903192942.21906-1-liangzhan5dev@gmail.com> (raw)
tca8418_configure() enables TCA8418 interrupts by writing the CFG
register. If input_register_device() fails afterwards, probe returns
an error and devres releases the IRQ handler, but the hardware is
left with interrupts still enabled.
Fix it by registering a devm action that clears the CFG register
when the device is released, disabling
all interrupts on both probe failure and driver unbind.
Signed-off-by: Zhian Liang <liangzhan5dev@gmail.com>
---
drivers/input/keyboard/tca8418_keypad.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/drivers/input/keyboard/tca8418_keypad.c b/drivers/input/keyboard/tca8418_keypad.c
index 36d4a7c38bb1..9f0aace6bd21 100644
--- a/drivers/input/keyboard/tca8418_keypad.c
+++ b/drivers/input/keyboard/tca8418_keypad.c
@@ -270,6 +270,20 @@ static int tca8418_configure(struct tca8418_keypad *keypad_data,
return error;
}
+static void tca8418_disable_hw(void *data)
+{
+ struct tca8418_keypad *keypad_data = data;
+ int error;
+
+ error = tca84818_write_byte(keypad_data, REG_CFG, 0);
+ if (error)
+ dev_warn(&keypad_data->client->dev, "unable to disable interrupts: %d\n", error);
+
+ error = tca8418_write_byte(keypad_data, REG_INT_STAT, 0xff);
+ if (error)
+ dev_warn(&keypad_data->client->dev, "unable to clear interrupt status: %d\n", error);
+}
+
static int tca8418_keypad_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
@@ -356,6 +370,10 @@ static int tca8418_keypad_probe(struct i2c_client *client)
if (error < 0)
return error;
+ error = devm_add_action_or_reset(dev, tca8418_diable_hw, keypad_data);
+ if (error)
+ return error;
+
error = input_register_device(input);
if (error) {
dev_err(dev, "Unable to register input device, error: %d\n",
--
2.34.1
next reply other threads:[~2026-09-03 19:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 19:29 Zhian Liang [this message]
2026-09-03 19:29 ` [PATCH 2/2] Input: tca8418_keypad - fix race condition in interrupt handler Zhian Liang
2026-09-03 19:41 ` sashiko-bot
2026-09-03 20:38 ` Zhian Liang
2026-09-03 19:42 ` [PATCH 1/2] Input: tca8418_keypad - Add devm cleanup to disable interrupts on unload sashiko-bot
2026-09-03 21:06 ` [PATCH v2] " Zhian Liang
2026-09-03 21:18 ` sashiko-bot
2026-09-05 9:37 ` [PATCH 1/2] " Dmitry Torokhov
2026-09-06 6:54 ` Zhian Liang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260903192942.21906-1-liangzhan5dev@gmail.com \
--to=liangzhan5dev@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.