Commit a5f04b9d authored by Benjamin Tissoires's avatar Benjamin Tissoires Committed by Jiri Kosina

HID: debug: break out hid_dump_report() into hid-debug

No semantic changes, but hid_dump_report should be in hid-debug.c, not
in hid-core.c
Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 014642cb
...@@ -1260,8 +1260,6 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i ...@@ -1260,8 +1260,6 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
struct hid_report_enum *report_enum; struct hid_report_enum *report_enum;
struct hid_driver *hdrv; struct hid_driver *hdrv;
struct hid_report *report; struct hid_report *report;
char *buf;
unsigned int i;
int ret = 0; int ret = 0;
if (!hid) if (!hid)
...@@ -1284,28 +1282,9 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i ...@@ -1284,28 +1282,9 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
} }
/* Avoid unnecessary overhead if debugfs is disabled */ /* Avoid unnecessary overhead if debugfs is disabled */
if (list_empty(&hid->debug_list)) if (!list_empty(&hid->debug_list))
goto nomem; hid_dump_report(hid, type, data, size);
buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
if (!buf)
goto nomem;
/* dump the report */
snprintf(buf, HID_DEBUG_BUFSIZE - 1,
"\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");
kfree(buf);
nomem:
report = hid_get_report(report_enum, data); report = hid_get_report(report_enum, data);
if (!report) { if (!report) {
......
...@@ -591,6 +591,36 @@ void hid_debug_event(struct hid_device *hdev, char *buf) ...@@ -591,6 +591,36 @@ void hid_debug_event(struct hid_device *hdev, char *buf)
} }
EXPORT_SYMBOL_GPL(hid_debug_event); EXPORT_SYMBOL_GPL(hid_debug_event);
void hid_dump_report(struct hid_device *hid, int type, u8 *data,
int size)
{
struct hid_report_enum *report_enum;
char *buf;
unsigned int i;
buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
if (!buf)
return;
report_enum = hid->report_enum + type;
/* dump the report */
snprintf(buf, HID_DEBUG_BUFSIZE - 1,
"\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");
kfree(buf);
}
EXPORT_SYMBOL_GPL(hid_dump_report);
void hid_dump_input(struct hid_device *hdev, struct hid_usage *usage, __s32 value) void hid_dump_input(struct hid_device *hdev, struct hid_usage *usage, __s32 value)
{ {
char *buf; char *buf;
......
...@@ -22,11 +22,12 @@ ...@@ -22,11 +22,12 @@
* *
*/ */
#define HID_DEBUG_BUFSIZE 512
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
#define HID_DEBUG_BUFSIZE 512
void hid_dump_input(struct hid_device *, struct hid_usage *, __s32); void hid_dump_input(struct hid_device *, struct hid_usage *, __s32);
void hid_dump_report(struct hid_device *, int , u8 *, int);
void hid_dump_device(struct hid_device *, struct seq_file *); void hid_dump_device(struct hid_device *, struct seq_file *);
void hid_dump_field(struct hid_field *, int, struct seq_file *); void hid_dump_field(struct hid_field *, int, struct seq_file *);
char *hid_resolv_usage(unsigned, struct seq_file *); char *hid_resolv_usage(unsigned, struct seq_file *);
...@@ -50,6 +51,7 @@ struct hid_debug_list { ...@@ -50,6 +51,7 @@ struct hid_debug_list {
#else #else
#define hid_dump_input(a,b,c) do { } while (0) #define hid_dump_input(a,b,c) do { } while (0)
#define hid_dump_report(a,b,c,d) do { } while (0)
#define hid_dump_device(a,b) do { } while (0) #define hid_dump_device(a,b) do { } while (0)
#define hid_dump_field(a,b,c) do { } while (0) #define hid_dump_field(a,b,c) do { } while (0)
#define hid_resolv_usage(a,b) do { } while (0) #define hid_resolv_usage(a,b) do { } while (0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment