mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
Input: maple_keyb - implement open and close methods
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 Link: https://patch.msgid.link/20260703-b4-maple-cleanup-v1-7-41e424964da5@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
fe676cb1e4
commit
988e3ddd59
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user