Skip to contentSkip to conversation

HID: check for HID_QUIRK_IGNORE during probing

PATCH In review Jindrich Makovicka 2 participants 5 messages May 23, 2010 – May 31, 2010 HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: check for HID_QUIRK_IGNORE during probing

While the hardcoded ignore list is checked in usbhid_probe(), the user supplied ignore flags are not. Thus, the IGNORE quirk (0x0004) cannot be used to stop usbhid from binding devices like iBuddy, which has been recently removed from the ignore list due to product ID conflict.

This patch adds the user quirk check to usb_probe(), and makes usb_probe() return -ENODEV when HID_QUIRK_IGNORE bit is set.

With the patch, iBuddy works properly using libusb when the following option is added to modprobe.d:

options usbhid quirks=0x1130:0x0002:0x0004

Signature · 1 line
Jindrich Makovicka
hid-core.c renamed from hid-core.c.orig +8 -2
@@ -864,8 +864,7 @@ static int usbhid_parse(struct hid_devic
 	quirks = usbhid_lookup_quirk(le16_to_cpu(dev->descriptor.idVendor),
 			le16_to_cpu(dev->descriptor.idProduct));
 
-	if (quirks & HID_QUIRK_IGNORE)
-		return -ENODEV;
+	WARN_ON(quirks & HID_QUIRK_IGNORE);
 
 	/* Many keyboards and mice don't like to be polled for reports,
 	 * so we will always set the HID_QUIRK_NOGET flag for them. */
@@ -1098,6 +1097,7 @@ static int usbhid_probe(struct usb_inter
 	struct usb_device *dev = interface_to_usbdev(intf);
 	struct usbhid_device *usbhid;
 	struct hid_device *hid;
+	u32 quirks = 0;
 	unsigned int n, has_in = 0;
 	size_t len;
 	int ret;
@@ -1114,6 +1114,12 @@ static int usbhid_probe(struct usb_inter
 		return -ENODEV;
 	}
 
+	quirks = usbhid_lookup_quirk(le16_to_cpu(dev->descriptor.idVendor),
+			le16_to_cpu(dev->descriptor.idProduct));
+
+	if (quirks & HID_QUIRK_IGNORE)
+		return -ENODEV;
+
 	hid = hid_allocate_device();
 	if (IS_ERR(hid))
 		return PTR_ERR(hid);
#1 lore raw

Updated to current git:

hid-core.c renamed from hid-core.c.orig +0 -0
@@ -1759,7 +1759,8 @@
 
 	/* we need to kill them here, otherwise they will stay

allocated to
* wait for coming driver */
- if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) && hid_ignore(hdev))
+ if (!(hdev->quirks & HID_QUIRK_NO_IGNORE)
+ && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE)))
return -ENODEV;

/* XXX hack, any other cleaner solution after the driver core

Signature · 1 line
Jindrich Makovicka
#2 lore raw
Quoted 8 lines · Jindrich Makovicka

Updated to current git:

hid-core.c renamed from hid-core.c.orig +0 -0
@@ -1759,7 +1759,8 @@
 
 	/* we need to kill them here, otherwise they will stay

allocated to

hid-core.c

Quoted 7 lines
hid-core.c renamed from hid-core.c.orig +2 -1
 	 * wait for coming driver */
-	if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) && hid_ignore(hdev))
+	if (!(hdev->quirks & HID_QUIRK_NO_IGNORE)
+            && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE)))
 		return -ENODEV;
 
 	/* XXX hack, any other cleaner solution after the driver core

Wouldn't that mean that a device with HID_QUIRK_IGNORE for which we pass HID_QUIRK_NO_IGNORE, would still be ignored?

If so, that's not what we want to do...

#3 lore raw
Quoted 16 lines · On Tue, 25 May 2010 23:41:02 +0100 Bastien Nocera <[email protected]> wrote:
Quoted 15 lines · Jindrich Makovicka

Updated to current git:

hid-core.c renamed from hid-core.c.orig +0 -0
@@ -1759,7 +1759,8 @@
 
 	/* we need to kill them here, otherwise they will stay

allocated to

hid-core.c renamed from hid-core.c.orig +0 -1
 	 * wait for coming driver */
-	if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) &&

hid_ignore(hdev))

hid-core.c renamed from hid-core.c.orig +2 -0
+	if (!(hdev->quirks & HID_QUIRK_NO_IGNORE)
+            && (hid_ignore(hdev) || (hdev->quirks &

HID_QUIRK_IGNORE))) return -ENODEV;

Quoted 5 lines
Quoted 2 lines

/* XXX hack, any other cleaner solution after the driver
core

Wouldn't that mean that a device with HID_QUIRK_IGNORE for which we pass HID_QUIRK_NO_IGNORE, would still be ignored?

With HID_QUIRK_NO_IGNORE, the whole expression will be FALSE, and the part after && wouldn't be even evaluated in both current and patched version. So, NO_IGNORE takes precedence over IGNORE.

Signature · 1 line
Jindrich Makovicka
#4 lore raw
Quoted 25 lines · On Wed, 26 May 2010 08:24:23 +0200 Jindrich Makovicka <[email protected]>…
Quoted 16 lines · On Tue, 25 May 2010 23:41:02 +0100 Bastien Nocera <[email protected]> wrote:
Quoted 15 lines · Jindrich Makovicka

Updated to current git:

hid-core.c renamed from hid-core.c.orig +0 -0
@@ -1759,7 +1759,8 @@
 
 	/* we need to kill them here, otherwise they will stay

allocated to

hid-core.c renamed from hid-core.c.orig +0 -1
 	 * wait for coming driver */
-	if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) &&

hid_ignore(hdev))

hid-core.c renamed from hid-core.c.orig +2 -0
+	if (!(hdev->quirks & HID_QUIRK_NO_IGNORE)
+            && (hid_ignore(hdev) || (hdev->quirks &

HID_QUIRK_IGNORE))) return -ENODEV;

Quoted 5 lines
Quoted 2 lines

/* XXX hack, any other cleaner solution after the driver
core

Wouldn't that mean that a device with HID_QUIRK_IGNORE for which we pass HID_QUIRK_NO_IGNORE, would still be ignored?

Quoted 4 lines

With HID_QUIRK_NO_IGNORE, the whole expression will be FALSE, and the part after && wouldn't be even evaluated in both current and patched version. So, NO_IGNORE takes precedence over IGNORE.

Ping?

Signature · 1 line
Jindrich Makovicka