aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/hid-debug.c')
-rw-r--r--drivers/hid/hid-debug.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 933fff0fff1f..7e56cb3855e3 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -580,17 +580,49 @@ void hid_debug_event(struct hid_device *hdev, char *buf)
580 int i; 580 int i;
581 struct hid_debug_list *list; 581 struct hid_debug_list *list;
582 582
583 mutex_lock(&hdev->debug_list_lock);
583 list_for_each_entry(list, &hdev->debug_list, node) { 584 list_for_each_entry(list, &hdev->debug_list, node) {
584 for (i = 0; i < strlen(buf); i++) 585 for (i = 0; i < strlen(buf); i++)
585 list->hid_debug_buf[(list->tail + i) % HID_DEBUG_BUFSIZE] = 586 list->hid_debug_buf[(list->tail + i) % HID_DEBUG_BUFSIZE] =
586 buf[i]; 587 buf[i];
587 list->tail = (list->tail + i) % HID_DEBUG_BUFSIZE; 588 list->tail = (list->tail + i) % HID_DEBUG_BUFSIZE;
588 } 589 }
590 mutex_unlock(&hdev->debug_list_lock);
589 591
590 wake_up_interruptible(&hdev->debug_wait); 592 wake_up_interruptible(&hdev->debug_wait);
591} 593}
592EXPORT_SYMBOL_GPL(hid_debug_event); 594EXPORT_SYMBOL_GPL(hid_debug_event);
593 595
596void hid_dump_report(struct hid_device *hid, int type, u8 *data,
597 int size)
598{
599 struct hid_report_enum *report_enum;
600 char *buf;
601 unsigned int i;
602
603 buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
604
605 if (!buf)
606 return;
607
608 report_enum = hid->report_enum + type;
609
610 /* dump the report */
611 snprintf(buf, HID_DEBUG_BUFSIZE - 1,
612 "\nreport (size %u) (%snumbered) = ", size,
613 report_enum->numbered ? "" : "un");
614 hid_debug_event(hid, buf);
615
616 for (i = 0; i < size; i++) {
617 snprintf(buf, HID_DEBUG_BUFSIZE - 1,
618 " %02x", data[i]);
619 hid_debug_event(hid, buf);
620 }
621 hid_debug_event(hid, "\n");
622 kfree(buf);
623}
624EXPORT_SYMBOL_GPL(hid_dump_report);
625
594void hid_dump_input(struct hid_device *hdev, struct hid_usage *usage, __s32 value) 626void hid_dump_input(struct hid_device *hdev, struct hid_usage *usage, __s32 value)
595{ 627{
596 char *buf; 628 char *buf;
@@ -960,7 +992,9 @@ static int hid_debug_events_open(struct inode *inode, struct file *file)
960 file->private_data = list; 992 file->private_data = list;
961 mutex_init(&list->read_mutex); 993 mutex_init(&list->read_mutex);
962 994
995 mutex_lock(&list->hdev->debug_list_lock);
963 list_add_tail(&list->node, &list->hdev->debug_list); 996 list_add_tail(&list->node, &list->hdev->debug_list);
997 mutex_unlock(&list->hdev->debug_list_lock);
964 998
965out: 999out:
966 return err; 1000 return err;
@@ -1055,7 +1089,9 @@ static int hid_debug_events_release(struct inode *inode, struct file *file)
1055{ 1089{
1056 struct hid_debug_list *list = file->private_data; 1090 struct hid_debug_list *list = file->private_data;
1057 1091
1092 mutex_lock(&list->hdev->debug_list_lock);
1058 list_del(&list->node); 1093 list_del(&list->node);
1094 mutex_unlock(&list->hdev->debug_list_lock);
1059 kfree(list->hid_debug_buf); 1095 kfree(list->hid_debug_buf);
1060 kfree(list); 1096 kfree(list);
1061 1097