HID: remove initial reading of reports at connect
[muen/linux.git] / drivers / hid / usbhid / hiddev.c
index 700145b1508894f30a018aef278d15cfc458ef3a..667171829f65c3abcc0303d2a9f05c38401e6718 100644 (file)
@@ -54,6 +54,7 @@ struct hiddev {
        struct hid_device *hid;
        struct list_head list;
        spinlock_t list_lock;
        struct hid_device *hid;
        struct list_head list;
        spinlock_t list_lock;
+       bool initialized;
 };
 
 struct hiddev_list {
 };
 
 struct hiddev_list {
@@ -689,6 +690,7 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
        case HIDIOCINITREPORT:
                usbhid_init_reports(hid);
 
        case HIDIOCINITREPORT:
                usbhid_init_reports(hid);
+               hiddev->initialized = true;
                r = 0;
                break;
 
                r = 0;
                break;
 
@@ -790,6 +792,10 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        case HIDIOCGUSAGES:
        case HIDIOCSUSAGES:
        case HIDIOCGCOLLECTIONINDEX:
        case HIDIOCGUSAGES:
        case HIDIOCSUSAGES:
        case HIDIOCGCOLLECTIONINDEX:
+               if (!hiddev->initialized) {
+                       usbhid_init_reports(hid);
+                       hiddev->initialized = true;
+               }
                r = hiddev_ioctl_usage(hiddev, cmd, user_arg);
                break;
 
                r = hiddev_ioctl_usage(hiddev, cmd, user_arg);
                break;
 
@@ -910,6 +916,13 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
                kfree(hiddev);
                return -1;
        }
                kfree(hiddev);
                return -1;
        }
+
+       /*
+        * If HID_QUIRK_NO_INIT_REPORTS is set, make sure we don't initialize
+        * the reports.
+        */
+       hiddev->initialized = hid->quirks & HID_QUIRK_NO_INIT_REPORTS;
+
        return 0;
 }
 
        return 0;
 }