HID: add HID_QUIRK_HIDDEV_FORCE and HID_QUIRK_NO_IGNORE
authorBastien Nocera <hadess@hadess.net>
Fri, 16 Apr 2010 16:19:50 +0000 (17:19 +0100)
committerJiri Kosina <jkosina@suse.cz>
Mon, 19 Apr 2010 11:11:43 +0000 (13:11 +0200)
Add two quirks to make it possible for usbhid module options to
override whether a device is ignored (HID_QUIRK_NO_IGNORE) and
whether to connect a hiddev device (HID_QUIRK_HIDDEV_FORCE).

Passing HID_QUIRK_NO_IGNORE for your device means that it will
not be ignored by the HID layer, even if present in a blacklist.

HID_QUIRK_HIDDEV_FORCE will force the creation of a hiddev for that
device, making it accessible from user-space.

Tested with an Apple IR Receiver, switching it from using appleir
to using lirc's macmini driver.

Signed-off-by: Bastien Nocera <hadess@hadess.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-core.c
drivers/hid/usbhid/hid-core.c
include/linux/hid.h

index 8617aa97a9c872cc94774106548b82fe5f080179..468c6c2d4ad52b338779164b42709c3d3d2f4a6b 100644 (file)
@@ -1168,6 +1168,8 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
        unsigned int i;
        int len;
 
+       if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE)
+               connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV);
        if (hdev->bus != BUS_USB)
                connect_mask &= ~HID_CONNECT_HIDDEV;
        if (hid_hiddev(hdev))
@@ -1757,7 +1759,7 @@ int hid_add_device(struct hid_device *hdev)
 
        /* we need to kill them here, otherwise they will stay allocated to
         * wait for coming driver */
-       if (hid_ignore(hdev))
+       if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) && hid_ignore(hdev))
                return -ENODEV;
 
        /* XXX hack, any other cleaner solution after the driver core
index 9cd61a52e9e36f512356ac59a32610b21ebffa8a..245aef0de8f22e6f04a5a9432d6bb2c3347565bc 100644 (file)
@@ -1143,6 +1143,7 @@ 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;
index b1344ec4b7fc9fe93305eaf2d96cfed494bb3de7..f1f2b6f0d1c44d1a8e762e723587b2833b1a625b 100644 (file)
@@ -308,11 +308,13 @@ struct hid_item {
 #define HID_QUIRK_NOTOUCH                      0x00000002
 #define HID_QUIRK_IGNORE                       0x00000004
 #define HID_QUIRK_NOGET                                0x00000008
+#define HID_QUIRK_HIDDEV_FORCE                 0x00000010
 #define HID_QUIRK_BADPAD                       0x00000020
 #define HID_QUIRK_MULTI_INPUT                  0x00000040
 #define HID_QUIRK_SKIP_OUTPUT_REPORTS          0x00010000
 #define HID_QUIRK_FULLSPEED_INTERVAL           0x10000000
 #define HID_QUIRK_NO_INIT_REPORTS              0x20000000
+#define HID_QUIRK_NO_IGNORE                    0x40000000
 
 /*
  * This is the global environment of the parser. This information is