aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-core.c
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2009-06-12 09:20:57 -0400
committerJiri Kosina <jkosina@suse.cz>2009-06-12 09:20:57 -0400
commitcd667ce24796700e1a0e6e7528efc61c96ff832e (patch)
tree6279001dbecb476588873402668aa761ee2f4a8f /drivers/hid/hid-core.c
parenta635f9dd83f3382577f4544a96df12356e951a40 (diff)
HID: use debugfs for events/reports dumping
This is a followup patch to the one implemeting rdesc representation in debugfs rather than being dependent on compile-time CONFIG_HID_DEBUG setting. The API of the appropriate formatting functions is slightly modified -- if they are passed seq_file pointer, the one-shot output for 'rdesc' file mode is used, and therefore the message is formatted into the corresponding seq_file immediately. Otherwise the called function allocated a new buffer, formats the text into the buffer and returns the pointer to it, so that it can be queued into the ring-buffer of the processess blocked waiting on input on 'events' file in debugfs. 'debug' parameter to the 'hid' module is now used solely for the prupose of inetrnal driver state debugging (parser, transport, etc). Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-core.c')
-rw-r--r--drivers/hid/hid-core.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index d4317db85b54..449bd747d116 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -46,7 +46,7 @@
46 46
47int hid_debug = 0; 47int hid_debug = 0;
48module_param_named(debug, hid_debug, int, 0600); 48module_param_named(debug, hid_debug, int, 0600);
49MODULE_PARM_DESC(debug, "HID debugging (0=off, 1=probing info, 2=continuous data dumping)"); 49MODULE_PARM_DESC(debug, "toggle HID debugging messages");
50EXPORT_SYMBOL_GPL(hid_debug); 50EXPORT_SYMBOL_GPL(hid_debug);
51 51
52/* 52/*
@@ -859,7 +859,7 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field,
859 struct hid_driver *hdrv = hid->driver; 859 struct hid_driver *hdrv = hid->driver;
860 int ret; 860 int ret;
861 861
862 hid_dump_input(usage, value); 862 hid_dump_input(hid, usage, value);
863 863
864 if (hdrv && hdrv->event && hid_match_usage(hid, usage)) { 864 if (hdrv && hdrv->event && hid_match_usage(hid, usage)) {
865 ret = hdrv->event(hid, field, usage, value); 865 ret = hdrv->event(hid, field, usage, value);
@@ -981,7 +981,7 @@ int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
981{ 981{
982 unsigned size = field->report_size; 982 unsigned size = field->report_size;
983 983
984 hid_dump_input(field->usage + offset, value); 984 hid_dump_input(field->report->device, field->usage + offset, value);
985 985
986 if (offset >= field->report_count) { 986 if (offset >= field->report_count) {
987 dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count); 987 dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count);
@@ -1075,6 +1075,7 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
1075 struct hid_report_enum *report_enum = hid->report_enum + type; 1075 struct hid_report_enum *report_enum = hid->report_enum + type;
1076 struct hid_driver *hdrv = hid->driver; 1076 struct hid_driver *hdrv = hid->driver;
1077 struct hid_report *report; 1077 struct hid_report *report;
1078 char *buf;
1078 unsigned int i; 1079 unsigned int i;
1079 int ret; 1080 int ret;
1080 1081
@@ -1086,18 +1087,36 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
1086 return -1; 1087 return -1;
1087 } 1088 }
1088 1089
1089 dbg_hid("report (size %u) (%snumbered)\n", size, report_enum->numbered ? "" : "un"); 1090 buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE,
1091 interrupt ? GFP_ATOMIC : GFP_KERNEL);
1092
1093 if (!buf) {
1094 report = hid_get_report(report_enum, data);
1095 goto nomem;
1096 }
1097
1098 snprintf(buf, HID_DEBUG_BUFSIZE - 1,
1099 "\nreport (size %u) (%snumbered)\n", size, report_enum->numbered ? "" : "un");
1100 hid_debug_event(hid, buf);
1090 1101
1091 report = hid_get_report(report_enum, data); 1102 report = hid_get_report(report_enum, data);
1092 if (!report) 1103 if (!report)
1093 return -1; 1104 return -1;
1094 1105
1095 /* dump the report */ 1106 /* dump the report */
1096 dbg_hid("report %d (size %u) = ", report->id, size); 1107 snprintf(buf, HID_DEBUG_BUFSIZE - 1,
1097 for (i = 0; i < size; i++) 1108 "report %d (size %u) = ", report->id, size);
1098 dbg_hid_line(" %02x", data[i]); 1109 hid_debug_event(hid, buf);
1099 dbg_hid_line("\n"); 1110 for (i = 0; i < size; i++) {
1111 snprintf(buf, HID_DEBUG_BUFSIZE - 1,
1112 " %02x", data[i]);
1113 hid_debug_event(hid, buf);
1114 }
1115 hid_debug_event(hid, "\n");
1116
1117 kfree(buf);
1100 1118
1119nomem:
1101 if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) { 1120 if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) {
1102 ret = hdrv->raw_event(hid, report, data, size); 1121 ret = hdrv->raw_event(hid, report, data, size);
1103 if (ret != 0) 1122 if (ret != 0)
@@ -1756,6 +1775,9 @@ struct hid_device *hid_allocate_device(void)
1756 for (i = 0; i < HID_REPORT_TYPES; i++) 1775 for (i = 0; i < HID_REPORT_TYPES; i++)
1757 INIT_LIST_HEAD(&hdev->report_enum[i].report_list); 1776 INIT_LIST_HEAD(&hdev->report_enum[i].report_list);
1758 1777
1778 init_waitqueue_head(&hdev->debug_wait);
1779 INIT_LIST_HEAD(&hdev->debug_list);
1780
1759 return hdev; 1781 return hdev;
1760err: 1782err:
1761 put_device(&hdev->dev); 1783 put_device(&hdev->dev);
@@ -1844,8 +1866,8 @@ static int __init hid_init(void)
1844 int ret; 1866 int ret;
1845 1867
1846 if (hid_debug) 1868 if (hid_debug)
1847 printk(KERN_WARNING "HID: hid_debug parameter has been deprecated. " 1869 printk(KERN_WARNING "HID: hid_debug is now used solely for parser and driver debugging.\n"
1848 "Debugging data are now provided via debugfs\n"); 1870 "HID: debugfs is now used for inspecting the device (report descriptor, reports)\n");
1849 1871
1850 ret = bus_register(&hid_bus_type); 1872 ret = bus_register(&hid_bus_type);
1851 if (ret) { 1873 if (ret) {