[PATCH 07/26] Input: maple_keyb - implement open and close methods
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2026-07-04 05:57:45
Also in:
linux-sh, lkml
Subsystem:
input (keyboard, mouse, joystick, touchscreen) drivers, the rest · Maintainers:
Dmitry Torokhov, Linus Torvalds
Instead of polling the keyboard constantly from probe, implement open and close methods for the input device to only start polling when the device is actually opened by userspace, and stop polling when it is closed. This matches the behavior of maplemouse and maplecontrol drivers. Assisted-by: Antigravity:gemini-3.5-flash Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> --- drivers/input/keyboard/maple_keyb.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c
index 623d7951405b..a245774acc55 100644
--- a/drivers/input/keyboard/maple_keyb.c
+++ b/drivers/input/keyboard/maple_keyb.c@@ -140,6 +140,24 @@ static void dc_kbd_callback(struct mapleq *mq) } } +static int dc_kbd_open(struct input_dev *dev) +{ + struct maple_device *mdev = input_get_drvdata(dev); + + /* Maple polling is locked to VBLANK - which may be just 50/s */ + maple_getcond_callback(mdev, dc_kbd_callback, HZ / 50, + MAPLE_FUNC_KEYBOARD); + + return 0; +} + +static void dc_kbd_close(struct input_dev *dev) +{ + struct maple_device *mdev = input_get_drvdata(dev); + + maple_getcond_callback(mdev, NULL, 0, MAPLE_FUNC_KEYBOARD); +} + static int probe_maple_kbd(struct device *dev) { struct maple_device *mdev;
@@ -167,6 +185,7 @@ static int probe_maple_kbd(struct device *dev) memcpy(kbd->keycode, dc_kbd_keycode, sizeof(kbd->keycode)); maple_set_drvdata(mdev, kbd); + input_set_drvdata(idev, mdev); idev->name = mdev->product_name; idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
@@ -175,6 +194,8 @@ static int probe_maple_kbd(struct device *dev) idev->keycodemax = ARRAY_SIZE(kbd->keycode); idev->id.bustype = BUS_HOST; idev->dev.parent = &mdev->dev; + idev->open = dc_kbd_open; + idev->close = dc_kbd_close; for (i = 0; i < NR_SCANCODES; i++) __set_bit(dc_kbd_keycode[i], idev->keybit);
@@ -186,10 +207,6 @@ static int probe_maple_kbd(struct device *dev) if (error) goto fail_register; - /* Maple polling is locked to VBLANK - which may be just 50/s */ - maple_getcond_callback(mdev, dc_kbd_callback, HZ/50, - MAPLE_FUNC_KEYBOARD); - mdev->driver = mdrv; return error;
--
2.55.0.rc0.799.gd6f94ed593-goog