aboutsummaryrefslogtreecommitdiff
path: root/hid-tminit.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-04-16 00:21:50 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-04-16 01:08:50 +0300
commit031ef062ac01af9f2ff4b41dde9a89e460f8168d (patch)
treef946fc45b80f94c9dee1869417c5d22416475d18 /hid-tminit.c
parent9cd09c9dadbdd01f159e34142841954a7e41a09b (diff)
downloadhid-tminit-031ef062ac01af9f2ff4b41dde9a89e460f8168d.tar.gz
hid-tminit-031ef062ac01af9f2ff4b41dde9a89e460f8168d.zip
test duplicating driver
Diffstat (limited to 'hid-tminit.c')
-rw-r--r--hid-tminit.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/hid-tminit.c b/hid-tminit.c
new file mode 100644
index 0000000..a8b103e
--- /dev/null
+++ b/hid-tminit.c
@@ -0,0 +1,66 @@
+#include <linux/hid.h>
+#include "tminit.h"
+
+static int thrustmaster_hid_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+ int ret = 0;
+ struct tm_wheel *tm_wheel = kzalloc(sizeof(struct tm_wheel), GFP_KERNEL);
+ struct usb_interface *interface = to_usb_interface(hdev->dev.parent);
+
+ if (!tm_wheel) {
+ return -ENOMEM;
+ }
+
+ ret = hid_parse(hdev);
+ if (ret) {
+ hid_err(hdev, "parse failed with error %d\n", ret);
+ goto error;
+ }
+
+ ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
+ if (ret) {
+ hid_err(hdev, "hw start failed with error %d\n", ret);
+ goto error;
+ }
+
+ hid_set_drvdata(hdev, tm_wheel);
+ ret = thrustmaster_probe(tm_wheel, interface);
+ if (ret) {
+ goto error1;
+ }
+
+ return ret;
+
+error1: hid_hw_stop(hdev);
+error: kfree(tm_wheel);
+ return ret;
+}
+
+static void thrustmaster_hid_disconnect(struct hid_device *hdev)
+{
+ struct tm_wheel *tm_wheel = hid_get_drvdata(hdev);
+ thrustmaster_disconnect(tm_wheel);
+ hid_hw_stop(hdev);
+}
+
+static const struct hid_device_id thrustmaster_hid_devices[] = {
+ { HID_USB_DEVICE(0x044f, 0xb65d) },
+ { HID_USB_DEVICE(0x044f, 0xb664) },
+ { HID_USB_DEVICE(0x044f, 0xb69c) },
+ {}
+};
+
+MODULE_DEVICE_TABLE(hid, thrustmaster_hid_devices);
+
+static struct hid_driver thrustmaster_driver = {
+ .name = "hid-thrustmaster",
+ .id_table = thrustmaster_hid_devices,
+ .probe = thrustmaster_hid_probe,
+ .remove = thrustmaster_hid_disconnect,
+};
+
+module_hid_driver(thrustmaster_driver);
+
+MODULE_AUTHOR("Dario Pagani <dario.pagani.146+linuxk@gmail.com>");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Driver to initialize some steering wheel joysticks from Thrustmaster");