]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/hid/usbhid/hid-core.c
Merge branches 'for-3.12/devm', 'for-3.12/i2c-hid', 'for-3.12/i2c-hid-dt', 'for-3...
[karo-tx-linux.git] / drivers / hid / usbhid / hid-core.c
index 8c3235705679222d7e74051b6a43ab853f4bb60c..44df131d390a0e5cbb92d5701cab2f01a872fc9a 100644 (file)
@@ -535,7 +535,6 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re
 {
        int head;
        struct usbhid_device *usbhid = hid->driver_data;
-       int len = ((report->size - 1) >> 3) + 1 + (report->id > 0);
 
        if ((hid->quirks & HID_QUIRK_NOGET) && dir == USB_DIR_IN)
                return;
@@ -546,7 +545,7 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re
                        return;
                }
 
-               usbhid->out[usbhid->outhead].raw_report = kmalloc(len, GFP_ATOMIC);
+               usbhid->out[usbhid->outhead].raw_report = hid_alloc_report_buf(report, GFP_ATOMIC);
                if (!usbhid->out[usbhid->outhead].raw_report) {
                        hid_warn(hid, "output queueing failed\n");
                        return;
@@ -595,7 +594,7 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re
        }
 
        if (dir == USB_DIR_OUT) {
-               usbhid->ctrl[usbhid->ctrlhead].raw_report = kmalloc(len, GFP_ATOMIC);
+               usbhid->ctrl[usbhid->ctrlhead].raw_report = hid_alloc_report_buf(report, GFP_ATOMIC);
                if (!usbhid->ctrl[usbhid->ctrlhead].raw_report) {
                        hid_warn(hid, "control queueing failed\n");
                        return;
@@ -751,12 +750,17 @@ void usbhid_init_reports(struct hid_device *hid)
 {
        struct hid_report *report;
        struct usbhid_device *usbhid = hid->driver_data;
+       struct hid_report_enum *report_enum;
        int err, ret;
 
-       list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list)
-               usbhid_submit_report(hid, report, USB_DIR_IN);
+       if (!(hid->quirks & HID_QUIRK_NO_INIT_INPUT_REPORTS)) {
+               report_enum = &hid->report_enum[HID_INPUT_REPORT];
+               list_for_each_entry(report, &report_enum->report_list, list)
+                       usbhid_submit_report(hid, report, USB_DIR_IN);
+       }
 
-       list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list)
+       report_enum = &hid->report_enum[HID_FEATURE_REPORT];
+       list_for_each_entry(report, &report_enum->report_list, list)
                usbhid_submit_report(hid, report, USB_DIR_IN);
 
        err = 0;