Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d5d3e202 authored by Benjamin Tissoires's avatar Benjamin Tissoires Committed by Jiri Kosina
Browse files

HID: core: move the dynamic quirks handling in core



usbhid has a list of dynamic quirks in addition to a list of static quirks.
There is not much USB specific in that, so move this part of the module
in core so we can have one central place for quirks.

Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 20df1578
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
#
# Makefile for the HID driver
#
hid-y			:= hid-core.o hid-input.o
hid-y			:= hid-core.o hid-input.o hid-quirks.o
hid-$(CONFIG_DEBUG_FS)		+= hid-debug.o

obj-$(CONFIG_HID)		+= hid.o
+7 −3
Original line number Diff line number Diff line
@@ -1597,7 +1597,7 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
}
EXPORT_SYMBOL_GPL(hid_input_report);

static bool hid_match_one_id(struct hid_device *hdev,
bool hid_match_one_id(const struct hid_device *hdev,
		      const struct hid_device_id *id)
{
	return (id->bus == HID_BUS_ANY || id->bus == hdev->bus) &&
@@ -1606,7 +1606,7 @@ static bool hid_match_one_id(struct hid_device *hdev,
		(id->product == HID_ANY_ID || id->product == hdev->product);
}

const struct hid_device_id *hid_match_id(struct hid_device *hdev,
const struct hid_device_id *hid_match_id(const struct hid_device *hdev,
		const struct hid_device_id *id)
{
	for (; id->bus; id++)
@@ -2613,6 +2613,7 @@ static struct bus_type hid_bus_type = {
	.remove		= hid_device_remove,
	.uevent		= hid_uevent,
};
EXPORT_SYMBOL(hid_bus_type);

/* a list of devices that shouldn't be handled by HID core at all */
static const struct hid_device_id hid_ignore_list[] = {
@@ -2931,6 +2932,8 @@ int hid_add_device(struct hid_device *hdev)
	if (WARN_ON(hdev->status & HID_STAT_ADDED))
		return -EBUSY;

	hdev->quirks = hid_lookup_quirk(hdev);

	/* we need to kill them here, otherwise they will stay allocated to
	 * wait for coming driver */
	if (hid_ignore(hdev))
@@ -3117,6 +3120,7 @@ static void __exit hid_exit(void)
	hid_debug_exit();
	hidraw_exit();
	bus_unregister(&hid_bus_type);
	hid_quirks_exit(HID_BUS_ANY);
}

module_init(hid_init);
+399 −0

File added.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
# Makefile for the USB input drivers
#

usbhid-y	:= hid-core.o hid-quirks.o
usbhid-y	:= hid-core.o
usbhid-$(CONFIG_USB_HIDDEV)	+= hiddev.o
usbhid-$(CONFIG_HID_PID)	+= hid-pidff.o

+4 −6
Original line number Diff line number Diff line
@@ -978,8 +978,7 @@ static int usbhid_parse(struct hid_device *hid)
	int num_descriptors;
	size_t offset = offsetof(struct hid_descriptor, desc);

	quirks = usbhid_lookup_quirk(le16_to_cpu(dev->descriptor.idVendor),
			le16_to_cpu(dev->descriptor.idProduct));
	quirks = hid_lookup_quirk(hid);

	if (quirks & HID_QUIRK_IGNORE)
		return -ENODEV;
@@ -1329,7 +1328,6 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
	hid->vendor = le16_to_cpu(dev->descriptor.idVendor);
	hid->product = le16_to_cpu(dev->descriptor.idProduct);
	hid->name[0] = 0;
	hid->quirks = usbhid_lookup_quirk(hid->vendor, hid->product);
	if (intf->cur_altsetting->desc.bInterfaceProtocol ==
			USB_INTERFACE_PROTOCOL_MOUSE)
		hid->type = HID_TYPE_USBMOUSE;
@@ -1641,7 +1639,7 @@ static int __init hid_init(void)
{
	int retval = -ENOMEM;

	retval = usbhid_quirks_init(quirks_param);
	retval = hid_quirks_init(quirks_param, BUS_USB, MAX_USBHID_BOOT_QUIRKS);
	if (retval)
		goto usbhid_quirks_init_fail;
	retval = usb_register(&hid_driver);
@@ -1651,7 +1649,7 @@ static int __init hid_init(void)

	return 0;
usb_register_fail:
	usbhid_quirks_exit();
	hid_quirks_exit(BUS_USB);
usbhid_quirks_init_fail:
	return retval;
}
@@ -1659,7 +1657,7 @@ static int __init hid_init(void)
static void __exit hid_exit(void)
{
	usb_deregister(&hid_driver);
	usbhid_quirks_exit();
	hid_quirks_exit(BUS_USB);
}

module_init(hid_init);
Loading