From c26573d77369c042dc2b9a881a7f2ff88ddc0dd9 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 4 Jan 2026 21:49:58 +0200 Subject: use on_hid_hw_open instead of input_dev->open + Seems some applications can mess with input_dev->open, still unclear how but on_hid_hw_open seems to be a bit more reliable so use it for now at least --- src/hid-tmff2.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'src/hid-tmff2.c') diff --git a/src/hid-tmff2.c b/src/hid-tmff2.c index 162a30a..3b3c0cc 100644 --- a/src/hid-tmff2.c +++ b/src/hid-tmff2.c @@ -486,24 +486,26 @@ static int tmff2_play(struct input_dev *dev, int effect_id, int value) return 0; } -static int tmff2_open(struct input_dev *dev) +static void tmff2_open(struct hid_device *hdev) { - struct tmff2_device_entry *tmff2 = tmff2_from_input(dev); + struct tmff2_device_entry *tmff2 = hid_get_drvdata(hdev); - if (!tmff2) - return -ENODEV; + pr_err("entering tmff2_open\n"); + + if (!tmff2) { + pr_err("no device entry\n"); + return; + } if (tmff2->open) return tmff2->open(tmff2->data, open_mode); - - hid_err(tmff2->hdev, "no open callback set\n"); - return -EINVAL; } -static void tmff2_close(struct input_dev *dev) +static void tmff2_close(struct hid_device *hdev) { - struct tmff2_device_entry *tmff2 = tmff2_from_input(dev); + struct tmff2_device_entry *tmff2 = hid_get_drvdata(hdev); + pr_err("entering tmff2_close\n"); if (!tmff2) return; @@ -512,12 +514,8 @@ static void tmff2_close(struct input_dev *dev) * time */ cancel_delayed_work_sync(&tmff2->work); - if (tmff2->close) { - tmff2->close(tmff2->data, open_mode); - return; - } - - hid_err(tmff2->hdev, "no close callback set\n"); + if (tmff2->close) + return tmff2->close(tmff2->data, open_mode); } static int tmff2_create_files(struct tmff2_device_entry *tmff2) @@ -634,12 +632,6 @@ static int tmff2_wheel_init(struct tmff2_device_entry *tmff2) ff->upload = tmff2_upload; ff->playback = tmff2_play; - if (tmff2->open) - tmff2->input_dev->open = tmff2_open; - - if (tmff2->close) - tmff2->input_dev->close = tmff2_close; - /* set defaults wherever possible */ if (tmff2->set_gain) { ff->set_gain = tmff2_set_gain; @@ -825,6 +817,8 @@ static struct hid_driver tmff2_driver = { .probe = tmff2_probe, .remove = tmff2_remove, .report_fixup = tmff2_report_fixup, + .on_hid_hw_open = tmff2_open, + .on_hid_hw_close = tmff2_close }; module_hid_driver(tmff2_driver); -- cgit v1.3