HID: output event in debugfs even if hid_get_report() fails
authorJiri Kosina <jkosina@suse.cz>
Thu, 18 Mar 2010 11:09:53 +0000 (12:09 +0100)
committerJiri Kosina <jkosina@suse.cz>
Thu, 18 Mar 2010 11:09:53 +0000 (12:09 +0100)
if hid_get_report() fails for whatever reason, the raw output of
the report doesn't make it into 'events' file in debugfs at all, because
we leave hid_input_report() too soon.

We want the report to be always present for debugging reasons. Move the
code around, so that the event makes it to 'events' file all the time,
even if we are going to discard the report.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-core.c

index 368fbb0c4ca6b161d2acea66d7a10bdf4c6a36f5..c49aaa21e1a7b27393772ef2881d5ee317c13179 100644 (file)
@@ -1096,20 +1096,11 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
                goto nomem;
        }
 
-       snprintf(buf, HID_DEBUG_BUFSIZE - 1,
-                       "\nreport (size %u) (%snumbered)\n", size, report_enum->numbered ? "" : "un");
-       hid_debug_event(hid, buf);
-
-       report = hid_get_report(report_enum, data);
-       if (!report) {
-               kfree(buf);
-               return -1;
-       }
-
        /* dump the report */
        snprintf(buf, HID_DEBUG_BUFSIZE - 1,
-                       "report %d (size %u) = ", report->id, size);
+                       "\nreport (size %u) (%snumbered) = ", size, report_enum->numbered ? "" : "un");
        hid_debug_event(hid, buf);
+
        for (i = 0; i < size; i++) {
                snprintf(buf, HID_DEBUG_BUFSIZE - 1,
                                " %02x", data[i]);
@@ -1117,6 +1108,13 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
        }
        hid_debug_event(hid, "\n");
 
+       report = hid_get_report(report_enum, data);
+
+       if (!report) {
+               kfree(buf);
+               return -1;
+       }
+
        kfree(buf);
 
 nomem:
This page took 0.039641 seconds and 5 git commands to generate.