From dbd0d90aa90bb8a8ab905cfe6d033270cc4cef29 Mon Sep 17 00:00:00 2001 From: Sophie Tauchert <999eagle@999eagle.moe> Date: Sun, 3 Jan 2021 13:20:06 +0100 Subject: [PATCH] razeraccessory: only match with one interface This prevents the driver to be bound to multiple interfaces which is both unneccessary and is not supposed to happen. --- driver/razeraccessory_driver.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/driver/razeraccessory_driver.c b/driver/razeraccessory_driver.c index 833ca112..05d55c12 100644 --- a/driver/razeraccessory_driver.c +++ b/driver/razeraccessory_driver.c @@ -1041,6 +1041,26 @@ static int razer_input_mapping(struct hid_device *hdev, struct hid_input *hi, st return 0; } +/** + * Match method checks whether this driver should be used for a given HID device + */ +static bool razer_accessory_match(struct hid_device *hdev, bool ignore_special_driver) +{ + struct usb_interface *intf = to_usb_interface(hdev->dev.parent); + struct usb_device *usb_dev = interface_to_usbdev(intf); + + switch (usb_dev->descriptor.idProduct) { + case USB_DEVICE_ID_RAZER_KRAKEN_KITTY_EDITION: + case USB_DEVICE_ID_RAZER_MOUSE_BUNGEE_V3_CHROMA: + if (intf->cur_altsetting->desc.bInterfaceNumber != 0) { + dev_info(&intf->dev, "skipping secondary interface\n"); + return false; + } + } + + return true; +} + /** * Probe method is ran whenever a device is binded to the driver */ @@ -1348,6 +1368,7 @@ MODULE_DEVICE_TABLE(hid, razer_devices); static struct hid_driver razer_accessory_driver = { .name = "razeraccessory", .id_table = razer_devices, + .match = razer_accessory_match, .probe = razer_accessory_probe, .remove = razer_accessory_disconnect, .raw_event = razer_raw_event, -- GitLab