Skip to content

Commit

Permalink
HID: output event in debugfs even if hid_get_report() fails
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jiri Kosina committed Mar 18, 2010
1 parent a85821f commit 1caea61
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions drivers/hid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1096,27 +1096,25 @@ 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]);
hid_debug_event(hid, buf);
}
hid_debug_event(hid, "\n");

report = hid_get_report(report_enum, data);

if (!report) {
kfree(buf);
return -1;
}

kfree(buf);

nomem:
Expand Down

0 comments on commit 1caea61

Please sign in to comment.