aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2013-04-17 13:38:13 -0400
committerJiri Kosina <jkosina@suse.cz>2013-04-30 04:09:06 -0400
commita5f04b9df1113e0c16271afe5e43028f0d763f13 (patch)
treecf051c3219bcd6d1b782ad51c9a94c5ca2735467
parent014642cb0a08d1b12c6089c48c7ba6002a0f6811 (diff)
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: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-core.c25
-rw-r--r--drivers/hid/hid-debug.c30
-rw-r--r--include/linux/hid-debug.h6
3 files changed, 36 insertions, 25 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index aa341d135867..f86dd9708ca5 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1260,8 +1260,6 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
1260 struct hid_report_enum *report_enum; 1260 struct hid_report_enum *report_enum;
1261 struct hid_driver *hdrv; 1261 struct hid_driver *hdrv;
1262 struct hid_report *report; 1262 struct hid_report *report;
1263 char *buf;
1264 unsigned int i;
1265 int ret = 0; 1263 int ret = 0;
1266 1264
1267 if (!hid) 1265 if (!hid)
@@ -1284,28 +1282,9 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
1284 } 1282 }
1285 1283
1286 /* Avoid unnecessary overhead if debugfs is disabled */ 1284 /* Avoid unnecessary overhead if debugfs is disabled */
1287 if (list_empty(&hid->debug_list)) 1285 if (!list_empty(&hid->debug_list))
1288 goto nomem; 1286 hid_dump_report(hid, type, data, size);
1289
1290 buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
1291
1292 if (!buf)
1293 goto nomem;
1294
1295 /* dump the report */
1296 snprintf(buf, HID_DEBUG_BUFSIZE - 1,
1297 "\nreport (size %u) (%snumbered) = ", size, report_enum->numbered ? "" : "un");
1298 hid_debug_event(hid, buf);
1299
1300 for (i = 0; i < size; i++) {
1301 snprintf(buf, HID_DEBUG_BUFSIZE - 1,
1302 " %02x", data[i]);
1303 hid_debug_event(hid, buf);
1304 }
1305 hid_debug_event(hid, "\n");
1306 kfree(buf);
1307 1287
1308nomem:
1309 report = hid_get_report(report_enum, data); 1288 report = hid_get_report(report_enum, data);
1310 1289
1311 if (!report) { 1290 if (!report) {
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 933fff0fff1f..094cbcfe1e1a 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -591,6 +591,36 @@ void hid_debug_event(struct hid_device *hdev, char *buf)
591} 591}
592EXPORT_SYMBOL_GPL(hid_debug_event); 592EXPORT_SYMBOL_GPL(hid_debug_event);
593 593
594void hid_dump_report(struct hid_device *hid, int type, u8 *data,
595 int size)
596{
597 struct hid_report_enum *report_enum;
598 char *buf;
599 unsigned int i;
600
601 buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
602
603 if (!buf)
604 return;
605
606 report_enum = hid->report_enum + type;
607
608 /* dump the report */
609 snprintf(buf, HID_DEBUG_BUFSIZE - 1,
610 "\nreport (size %u) (%snumbered) = ", size,
611 report_enum->numbered ? "" : "un");
612 hid_debug_event(hid, buf);
613
614 for (i = 0; i < size; i++) {
615 snprintf(buf, HID_DEBUG_BUFSIZE - 1,
616 " %02x", data[i]);
617 hid_debug_event(hid, buf);
618 }
619 hid_debug_event(hid, "\n");
620 kfree(buf);
621}
622EXPORT_SYMBOL_GPL(hid_dump_report);
623
594void hid_dump_input(struct hid_device *hdev, struct hid_usage *usage, __s32 value) 624void hid_dump_input(struct hid_device *hdev, struct hid_usage *usage, __s32 value)
595{ 625{
596 char *buf; 626 char *buf;
diff --git a/include/linux/hid-debug.h b/include/linux/hid-debug.h
index 53744fa1c8b7..8663f216c563 100644
--- a/include/linux/hid-debug.h
+++ b/include/linux/hid-debug.h
@@ -22,11 +22,12 @@
22 * 22 *
23 */ 23 */
24 24
25#define HID_DEBUG_BUFSIZE 512
26
27#ifdef CONFIG_DEBUG_FS 25#ifdef CONFIG_DEBUG_FS
28 26
27#define HID_DEBUG_BUFSIZE 512
28
29void hid_dump_input(struct hid_device *, struct hid_usage *, __s32); 29void hid_dump_input(struct hid_device *, struct hid_usage *, __s32);
30void hid_dump_report(struct hid_device *, int , u8 *, int);
30void hid_dump_device(struct hid_device *, struct seq_file *); 31void hid_dump_device(struct hid_device *, struct seq_file *);
31void hid_dump_field(struct hid_field *, int, struct seq_file *); 32void hid_dump_field(struct hid_field *, int, struct seq_file *);
32char *hid_resolv_usage(unsigned, struct seq_file *); 33char *hid_resolv_usage(unsigned, struct seq_file *);
@@ -50,6 +51,7 @@ struct hid_debug_list {
50#else 51#else
51 52
52#define hid_dump_input(a,b,c) do { } while (0) 53#define hid_dump_input(a,b,c) do { } while (0)
54#define hid_dump_report(a,b,c,d) do { } while (0)
53#define hid_dump_device(a,b) do { } while (0) 55#define hid_dump_device(a,b) do { } while (0)
54#define hid_dump_field(a,b,c) do { } while (0) 56#define hid_dump_field(a,b,c) do { } while (0)
55#define hid_resolv_usage(a,b) do { } while (0) 57#define hid_resolv_usage(a,b) do { } while (0)