aboutsummaryrefslogtreecommitdiff
path: root/src/hid-tmff2.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2026-01-26 18:21:43 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2026-01-26 18:21:43 +0200
commit66e522e26549afab26d032e900ae9f6576c83b9d (patch)
tree273ab042080b42f273d9a5f6bff9e7273daf076c /src/hid-tmff2.c
parent816a23aa8f6924517bf784f3d72fbae42f100493 (diff)
downloadhid-tmff2-66e522e26549afab26d032e900ae9f6576c83b9d.tar.gz
hid-tmff2-66e522e26549afab26d032e900ae9f6576c83b9d.zip
Revert "use on_hid_hw_open instead of input_dev->open"
This reverts commit c26573d77369c042dc2b9a881a7f2ff88ddc0dd9. + `on_hid_hw_open` is apparently new enough that common distros don't have it yet, so let's wait a few years and try again. The old method works well enough and if not, just set `open_mode=0`.
Diffstat (limited to 'src/hid-tmff2.c')
-rw-r--r--src/hid-tmff2.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/hid-tmff2.c b/src/hid-tmff2.c
index 3b3c0cc..162a30a 100644
--- a/src/hid-tmff2.c
+++ b/src/hid-tmff2.c
@@ -486,26 +486,24 @@ static int tmff2_play(struct input_dev *dev, int effect_id, int value)
return 0;
}
-static void tmff2_open(struct hid_device *hdev)
+static int tmff2_open(struct input_dev *dev)
{
- struct tmff2_device_entry *tmff2 = hid_get_drvdata(hdev);
-
- pr_err("entering tmff2_open\n");
+ struct tmff2_device_entry *tmff2 = tmff2_from_input(dev);
- if (!tmff2) {
- pr_err("no device entry\n");
- return;
- }
+ if (!tmff2)
+ return -ENODEV;
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 hid_device *hdev)
+static void tmff2_close(struct input_dev *dev)
{
- struct tmff2_device_entry *tmff2 = hid_get_drvdata(hdev);
+ struct tmff2_device_entry *tmff2 = tmff2_from_input(dev);
- pr_err("entering tmff2_close\n");
if (!tmff2)
return;
@@ -514,8 +512,12 @@ static void tmff2_close(struct hid_device *hdev)
* time */
cancel_delayed_work_sync(&tmff2->work);
- if (tmff2->close)
- return tmff2->close(tmff2->data, open_mode);
+ if (tmff2->close) {
+ tmff2->close(tmff2->data, open_mode);
+ return;
+ }
+
+ hid_err(tmff2->hdev, "no close callback set\n");
}
static int tmff2_create_files(struct tmff2_device_entry *tmff2)
@@ -632,6 +634,12 @@ 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;
@@ -817,8 +825,6 @@ 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);