From 031ef062ac01af9f2ff4b41dde9a89e460f8168d Mon Sep 17 00:00:00 2001 From: Kimplul Date: Tue, 16 Apr 2024 00:21:50 +0300 Subject: test duplicating driver --- hid-tminit.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 hid-tminit.c (limited to 'hid-tminit.c') 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 +#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 "); +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Driver to initialize some steering wheel joysticks from Thrustmaster"); -- cgit v1.3