]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
HID: hid-core: optimize in case of hidraw
authorMatthieu CASTET <matthieu.castet@parrot.com>
Thu, 28 Jun 2012 14:53:11 +0000 (16:53 +0200)
committerJiri Kosina <jkosina@suse.cz>
Fri, 20 Jul 2012 08:02:24 +0000 (10:02 +0200)
When using hidraw, hid buffer can be big and take lot's of
time to process (interrupt) kernel context.
Don't try to parse report if we are only interrested in hidraw.

Also don't prepare data for debug stuff if no debugfs file
are opened.

Signed-off-by: Matthieu CASTET <matthieu.castet@parrot.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-core.c
drivers/hid/hid-picolcd.c

index 4c87276c8ddba2f2a6f072cb536e84f8b7a6d256..71f87b1d71de1cd83a80d64aeb6199efaeb4de6d 100644 (file)
@@ -1194,8 +1194,10 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
                        goto out;
        }
 
-       for (a = 0; a < report->maxfield; a++)
-               hid_input_field(hid, report->field[a], cdata, interrupt);
+       if (hid->claimed != HID_CLAIMED_HIDRAW) {
+               for (a = 0; a < report->maxfield; a++)
+                       hid_input_field(hid, report->field[a], cdata, interrupt);
+       }
 
        if (hid->claimed & HID_CLAIMED_INPUT)
                hidinput_report_event(hid, report);
@@ -1243,6 +1245,10 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
                goto unlock;
        }
 
+       /* Avoid unnecessary overhead if debugfs is disabled */
+       if (list_empty(&hid->debug_list))
+               goto nomem;
+
        buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
 
        if (!buf)
index 45c3433f798699ec6749cee885a2b78d490e2b21..3e0a1e5d2ad54fd8521e1255af44cbc558425550 100644 (file)
@@ -1846,7 +1846,7 @@ static void picolcd_debug_out_report(struct picolcd_data *data,
 #define BUFF_SZ 256
 
        /* Avoid unnecessary overhead if debugfs is disabled */
-       if (!hdev->debug_events)
+       if (list_empty(&hdev->debug_list))
                return;
 
        buff = kmalloc(BUFF_SZ, GFP_ATOMIC);