aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/usbhid
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2007-05-30 09:07:13 -0400
committerJiri Kosina <jkosina@suse.cz>2007-07-09 08:03:35 -0400
commit58037eb961f859607b161c50d9d4ecb374de1e8f (patch)
treec192854fa4cfc16cce272b800a0393e21429191e /drivers/hid/usbhid
parent7dcca30a32aadb0520417521b0c44f42d09fe05c (diff)
HID: make debugging output runtime-configurable
There have been many reports recently about broken HID devices, the diagnosis of which required users to recompile their kernels in order to be able to provide debugging output needed for coding a quirk for a particular device. This patch makes CONFIG_HID_DEBUG default y if !EMBEDDED and makes it possible to control debugging output produced by HID code by supplying 'debug=1' module parameter. Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/usbhid')
-rw-r--r--drivers/hid/usbhid/hid-core.c38
-rw-r--r--drivers/hid/usbhid/hid-lgff.c10
-rw-r--r--drivers/hid/usbhid/hid-quirks.c8
-rw-r--r--drivers/hid/usbhid/hid-tmff.c2
-rw-r--r--drivers/hid/usbhid/hid-zpff.c8
-rw-r--r--drivers/hid/usbhid/hiddev.c2
-rw-r--r--drivers/hid/usbhid/usbkbd.c6
7 files changed, 34 insertions, 40 deletions
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index d91b9dac6dff..1eb2c64bc44a 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -127,7 +127,7 @@ static void hid_reset(struct work_struct *work)
127 hid_io_error(hid); 127 hid_io_error(hid);
128 break; 128 break;
129 default: 129 default:
130 err("can't reset device, %s-%s/input%d, status %d", 130 err_hid("can't reset device, %s-%s/input%d, status %d",
131 hid_to_usb_dev(hid)->bus->bus_name, 131 hid_to_usb_dev(hid)->bus->bus_name,
132 hid_to_usb_dev(hid)->devpath, 132 hid_to_usb_dev(hid)->devpath,
133 usbhid->ifnum, rc); 133 usbhid->ifnum, rc);
@@ -220,7 +220,7 @@ static void hid_irq_in(struct urb *urb)
220 if (status) { 220 if (status) {
221 clear_bit(HID_IN_RUNNING, &usbhid->iofl); 221 clear_bit(HID_IN_RUNNING, &usbhid->iofl);
222 if (status != -EPERM) { 222 if (status != -EPERM) {
223 err("can't resubmit intr, %s-%s/input%d, status %d", 223 err_hid("can't resubmit intr, %s-%s/input%d, status %d",
224 hid_to_usb_dev(hid)->bus->bus_name, 224 hid_to_usb_dev(hid)->bus->bus_name,
225 hid_to_usb_dev(hid)->devpath, 225 hid_to_usb_dev(hid)->devpath,
226 usbhid->ifnum, status); 226 usbhid->ifnum, status);
@@ -240,10 +240,10 @@ static int hid_submit_out(struct hid_device *hid)
240 usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0); 240 usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0);
241 usbhid->urbout->dev = hid_to_usb_dev(hid); 241 usbhid->urbout->dev = hid_to_usb_dev(hid);
242 242
243 dbg("submitting out urb"); 243 dbg_hid("submitting out urb\n");
244 244
245 if (usb_submit_urb(usbhid->urbout, GFP_ATOMIC)) { 245 if (usb_submit_urb(usbhid->urbout, GFP_ATOMIC)) {
246 err("usb_submit_urb(out) failed"); 246 err_hid("usb_submit_urb(out) failed");
247 return -1; 247 return -1;
248 } 248 }
249 249
@@ -287,12 +287,12 @@ static int hid_submit_ctrl(struct hid_device *hid)
287 usbhid->cr->wIndex = cpu_to_le16(usbhid->ifnum); 287 usbhid->cr->wIndex = cpu_to_le16(usbhid->ifnum);
288 usbhid->cr->wLength = cpu_to_le16(len); 288 usbhid->cr->wLength = cpu_to_le16(len);
289 289
290 dbg("submitting ctrl urb: %s wValue=0x%04x wIndex=0x%04x wLength=%u", 290 dbg_hid("submitting ctrl urb: %s wValue=0x%04x wIndex=0x%04x wLength=%u\n",
291 usbhid->cr->bRequest == HID_REQ_SET_REPORT ? "Set_Report" : "Get_Report", 291 usbhid->cr->bRequest == HID_REQ_SET_REPORT ? "Set_Report" : "Get_Report",
292 usbhid->cr->wValue, usbhid->cr->wIndex, usbhid->cr->wLength); 292 usbhid->cr->wValue, usbhid->cr->wIndex, usbhid->cr->wLength);
293 293
294 if (usb_submit_urb(usbhid->urbctrl, GFP_ATOMIC)) { 294 if (usb_submit_urb(usbhid->urbctrl, GFP_ATOMIC)) {
295 err("usb_submit_urb(ctrl) failed"); 295 err_hid("usb_submit_urb(ctrl) failed");
296 return -1; 296 return -1;
297 } 297 }
298 298
@@ -474,7 +474,7 @@ int usbhid_wait_io(struct hid_device *hid)
474 if (!wait_event_timeout(hid->wait, (!test_bit(HID_CTRL_RUNNING, &usbhid->iofl) && 474 if (!wait_event_timeout(hid->wait, (!test_bit(HID_CTRL_RUNNING, &usbhid->iofl) &&
475 !test_bit(HID_OUT_RUNNING, &usbhid->iofl)), 475 !test_bit(HID_OUT_RUNNING, &usbhid->iofl)),
476 10*HZ)) { 476 10*HZ)) {
477 dbg("timeout waiting for ctrl or out queue to clear"); 477 dbg_hid("timeout waiting for ctrl or out queue to clear\n");
478 return -1; 478 return -1;
479 } 479 }
480 480
@@ -667,7 +667,7 @@ static void hid_fixup_sony_ps3_controller(struct usb_device *dev, int ifnum)
667 USB_CTRL_GET_TIMEOUT); 667 USB_CTRL_GET_TIMEOUT);
668 668
669 if (result < 0) 669 if (result < 0)
670 err("%s failed: %d\n", __func__, result); 670 err_hid("%s failed: %d\n", __func__, result);
671 671
672 kfree(buf); 672 kfree(buf);
673} 673}
@@ -746,7 +746,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
746 if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && 746 if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) &&
747 (!interface->desc.bNumEndpoints || 747 (!interface->desc.bNumEndpoints ||
748 usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { 748 usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) {
749 dbg("class descriptor not present\n"); 749 dbg_hid("class descriptor not present\n");
750 return NULL; 750 return NULL;
751 } 751 }
752 752
@@ -755,19 +755,19 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
755 rsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength); 755 rsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength);
756 756
757 if (!rsize || rsize > HID_MAX_DESCRIPTOR_SIZE) { 757 if (!rsize || rsize > HID_MAX_DESCRIPTOR_SIZE) {
758 dbg("weird size of report descriptor (%u)", rsize); 758 dbg_hid("weird size of report descriptor (%u)\n", rsize);
759 return NULL; 759 return NULL;
760 } 760 }
761 761
762 if (!(rdesc = kmalloc(rsize, GFP_KERNEL))) { 762 if (!(rdesc = kmalloc(rsize, GFP_KERNEL))) {
763 dbg("couldn't allocate rdesc memory"); 763 dbg_hid("couldn't allocate rdesc memory\n");
764 return NULL; 764 return NULL;
765 } 765 }
766 766
767 hid_set_idle(dev, interface->desc.bInterfaceNumber, 0, 0); 767 hid_set_idle(dev, interface->desc.bInterfaceNumber, 0, 0);
768 768
769 if ((n = hid_get_class_descriptor(dev, interface->desc.bInterfaceNumber, HID_DT_REPORT, rdesc, rsize)) < 0) { 769 if ((n = hid_get_class_descriptor(dev, interface->desc.bInterfaceNumber, HID_DT_REPORT, rdesc, rsize)) < 0) {
770 dbg("reading report descriptor failed"); 770 dbg_hid("reading report descriptor failed\n");
771 kfree(rdesc); 771 kfree(rdesc);
772 return NULL; 772 return NULL;
773 } 773 }
@@ -781,15 +781,13 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
781 if (quirks & HID_QUIRK_SWAPPED_MIN_MAX) 781 if (quirks & HID_QUIRK_SWAPPED_MIN_MAX)
782 hid_fixup_cypress_descriptor(rdesc, rsize); 782 hid_fixup_cypress_descriptor(rdesc, rsize);
783 783
784#ifdef CONFIG_HID_DEBUG 784 dbg_hid("report descriptor (size %u, read %d) = ", rsize, n);
785 printk(KERN_DEBUG __FILE__ ": report descriptor (size %u, read %d) = ", rsize, n);
786 for (n = 0; n < rsize; n++) 785 for (n = 0; n < rsize; n++)
787 printk(" %02x", (unsigned char) rdesc[n]); 786 dbg_hid_line(" %02x", (unsigned char) rdesc[n]);
788 printk("\n"); 787 dbg_hid_line("\n");
789#endif
790 788
791 if (!(hid = hid_parse_report(rdesc, n))) { 789 if (!(hid = hid_parse_report(rdesc, n))) {
792 dbg("parsing report descriptor failed"); 790 dbg_hid("parsing report descriptor failed\n");
793 kfree(rdesc); 791 kfree(rdesc);
794 return NULL; 792 return NULL;
795 } 793 }
@@ -861,7 +859,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
861 } 859 }
862 860
863 if (!usbhid->urbin) { 861 if (!usbhid->urbin) {
864 err("couldn't find an input interrupt endpoint"); 862 err_hid("couldn't find an input interrupt endpoint");
865 goto fail; 863 goto fail;
866 } 864 }
867 865
@@ -978,7 +976,7 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id)
978 int i; 976 int i;
979 char *c; 977 char *c;
980 978
981 dbg("HID probe called for ifnum %d", 979 dbg_hid("HID probe called for ifnum %d\n",
982 intf->altsetting->desc.bInterfaceNumber); 980 intf->altsetting->desc.bInterfaceNumber);
983 981
984 if (!(hid = usb_hid_configure(intf))) 982 if (!(hid = usb_hid_configure(intf)))
diff --git a/drivers/hid/usbhid/hid-lgff.c b/drivers/hid/usbhid/hid-lgff.c
index c5cd4107d6af..4b7ab6a46d93 100644
--- a/drivers/hid/usbhid/hid-lgff.c
+++ b/drivers/hid/usbhid/hid-lgff.c
@@ -78,7 +78,7 @@ static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *ef
78 report->field[0]->value[1] = 0x08; 78 report->field[0]->value[1] = 0x08;
79 report->field[0]->value[2] = x; 79 report->field[0]->value[2] = x;
80 report->field[0]->value[3] = y; 80 report->field[0]->value[3] = y;
81 dbg("(x, y)=(%04x, %04x)", x, y); 81 dbg_hid("(x, y)=(%04x, %04x)\n", x, y);
82 usbhid_submit_report(hid, report, USB_DIR_OUT); 82 usbhid_submit_report(hid, report, USB_DIR_OUT);
83 break; 83 break;
84 84
@@ -93,7 +93,7 @@ static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *ef
93 report->field[0]->value[1] = 0x00; 93 report->field[0]->value[1] = 0x00;
94 report->field[0]->value[2] = left; 94 report->field[0]->value[2] = left;
95 report->field[0]->value[3] = right; 95 report->field[0]->value[3] = right;
96 dbg("(left, right)=(%04x, %04x)", left, right); 96 dbg_hid("(left, right)=(%04x, %04x)\n", left, right);
97 usbhid_submit_report(hid, report, USB_DIR_OUT); 97 usbhid_submit_report(hid, report, USB_DIR_OUT);
98 break; 98 break;
99 } 99 }
@@ -113,20 +113,20 @@ int hid_lgff_init(struct hid_device* hid)
113 113
114 /* Find the report to use */ 114 /* Find the report to use */
115 if (list_empty(report_list)) { 115 if (list_empty(report_list)) {
116 err("No output report found"); 116 err_hid("No output report found");
117 return -1; 117 return -1;
118 } 118 }
119 119
120 /* Check that the report looks ok */ 120 /* Check that the report looks ok */
121 report = list_entry(report_list->next, struct hid_report, list); 121 report = list_entry(report_list->next, struct hid_report, list);
122 if (!report) { 122 if (!report) {
123 err("NULL output report"); 123 err_hid("NULL output report");
124 return -1; 124 return -1;
125 } 125 }
126 126
127 field = report->field[0]; 127 field = report->field[0];
128 if (!field) { 128 if (!field) {
129 err("NULL field"); 129 err_hid("NULL field");
130 return -1; 130 return -1;
131 } 131 }
132 132
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index f6c4145dc202..a418ebfe39b8 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -493,7 +493,7 @@ static struct hid_blacklist *usbhid_exists_dquirk(const u16 idVendor,
493 } 493 }
494 494
495 if (bl_entry != NULL) 495 if (bl_entry != NULL)
496 dbg("Found dynamic quirk 0x%x for USB HID vendor 0x%hx prod 0x%hx\n", 496 dbg_hid("Found dynamic quirk 0x%x for USB HID vendor 0x%hx prod 0x%hx\n",
497 bl_entry->quirks, bl_entry->idVendor, 497 bl_entry->quirks, bl_entry->idVendor,
498 bl_entry->idProduct); 498 bl_entry->idProduct);
499 499
@@ -521,13 +521,13 @@ int usbhid_modify_dquirk(const u16 idVendor, const u16 idProduct,
521 int list_edited = 0; 521 int list_edited = 0;
522 522
523 if (!idVendor) { 523 if (!idVendor) {
524 dbg("Cannot add a quirk with idVendor = 0"); 524 dbg_hid("Cannot add a quirk with idVendor = 0\n");
525 return -EINVAL; 525 return -EINVAL;
526 } 526 }
527 527
528 q_new = kmalloc(sizeof(struct quirks_list_struct), GFP_KERNEL); 528 q_new = kmalloc(sizeof(struct quirks_list_struct), GFP_KERNEL);
529 if (!q_new) { 529 if (!q_new) {
530 dbg("Could not allocate quirks_list_struct"); 530 dbg_hid("Could not allocate quirks_list_struct\n");
531 return -ENOMEM; 531 return -ENOMEM;
532 } 532 }
533 533
@@ -643,7 +643,7 @@ static const struct hid_blacklist *usbhid_exists_squirk(const u16 idVendor,
643 bl_entry = &hid_blacklist[n]; 643 bl_entry = &hid_blacklist[n];
644 644
645 if (bl_entry != NULL) 645 if (bl_entry != NULL)
646 dbg("Found squirk 0x%x for USB HID vendor 0x%hx prod 0x%hx\n", 646 dbg_hid("Found squirk 0x%x for USB HID vendor 0x%hx prod 0x%hx\n",
647 bl_entry->quirks, bl_entry->idVendor, 647 bl_entry->quirks, bl_entry->idVendor,
648 bl_entry->idProduct); 648 bl_entry->idProduct);
649 return bl_entry; 649 return bl_entry;
diff --git a/drivers/hid/usbhid/hid-tmff.c b/drivers/hid/usbhid/hid-tmff.c
index ab5ba6ef891c..555bb48b4295 100644
--- a/drivers/hid/usbhid/hid-tmff.c
+++ b/drivers/hid/usbhid/hid-tmff.c
@@ -70,7 +70,7 @@ static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *ef
70 70
71 tmff->rumble->value[0] = left; 71 tmff->rumble->value[0] = left;
72 tmff->rumble->value[1] = right; 72 tmff->rumble->value[1] = right;
73 dbg("(left,right)=(%08x, %08x)", left, right); 73 dbg_hid("(left,right)=(%08x, %08x)\n", left, right);
74 usbhid_submit_report(hid, tmff->report, USB_DIR_OUT); 74 usbhid_submit_report(hid, tmff->report, USB_DIR_OUT);
75 75
76 return 0; 76 return 0;
diff --git a/drivers/hid/usbhid/hid-zpff.c b/drivers/hid/usbhid/hid-zpff.c
index a7fbffcdaf36..5a688274f6a3 100644
--- a/drivers/hid/usbhid/hid-zpff.c
+++ b/drivers/hid/usbhid/hid-zpff.c
@@ -21,10 +21,6 @@
21 */ 21 */
22 22
23 23
24/* #define DEBUG */
25
26#define debug(format, arg...) pr_debug("hid-zpff: " format "\n" , ## arg)
27
28#include <linux/input.h> 24#include <linux/input.h>
29#include <linux/usb.h> 25#include <linux/usb.h>
30#include <linux/hid.h> 26#include <linux/hid.h>
@@ -49,14 +45,14 @@ static int hid_zpff_play(struct input_dev *dev, void *data,
49 45
50 left = effect->u.rumble.strong_magnitude; 46 left = effect->u.rumble.strong_magnitude;
51 right = effect->u.rumble.weak_magnitude; 47 right = effect->u.rumble.weak_magnitude;
52 debug("called with 0x%04x 0x%04x", left, right); 48 dbg_hid("called with 0x%04x 0x%04x\n", left, right);
53 49
54 left = left * 0x7f / 0xffff; 50 left = left * 0x7f / 0xffff;
55 right = right * 0x7f / 0xffff; 51 right = right * 0x7f / 0xffff;
56 52
57 zpff->report->field[2]->value[0] = left; 53 zpff->report->field[2]->value[0] = left;
58 zpff->report->field[3]->value[0] = right; 54 zpff->report->field[3]->value[0] = right;
59 debug("running with 0x%02x 0x%02x", left, right); 55 dbg_hid("running with 0x%02x 0x%02x\n", left, right);
60 usbhid_submit_report(hid, zpff->report, USB_DIR_OUT); 56 usbhid_submit_report(hid, zpff->report, USB_DIR_OUT);
61 57
62 return 0; 58 return 0;
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 488d61bdbf2c..e793127f971e 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -779,7 +779,7 @@ int hiddev_connect(struct hid_device *hid)
779 779
780 retval = usb_register_dev(usbhid->intf, &hiddev_class); 780 retval = usb_register_dev(usbhid->intf, &hiddev_class);
781 if (retval) { 781 if (retval) {
782 err("Not able to get a minor for this device."); 782 err_hid("Not able to get a minor for this device.");
783 kfree(hiddev); 783 kfree(hiddev);
784 return -1; 784 return -1;
785 } 785 }
diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c
index 130978780713..b76b02f7b52d 100644
--- a/drivers/hid/usbhid/usbkbd.c
+++ b/drivers/hid/usbhid/usbkbd.c
@@ -125,7 +125,7 @@ static void usb_kbd_irq(struct urb *urb)
125resubmit: 125resubmit:
126 i = usb_submit_urb (urb, GFP_ATOMIC); 126 i = usb_submit_urb (urb, GFP_ATOMIC);
127 if (i) 127 if (i)
128 err ("can't resubmit intr, %s-%s/input0, status %d", 128 err_hid ("can't resubmit intr, %s-%s/input0, status %d",
129 kbd->usbdev->bus->bus_name, 129 kbd->usbdev->bus->bus_name,
130 kbd->usbdev->devpath, i); 130 kbd->usbdev->devpath, i);
131} 131}
@@ -151,7 +151,7 @@ static int usb_kbd_event(struct input_dev *dev, unsigned int type,
151 *(kbd->leds) = kbd->newleds; 151 *(kbd->leds) = kbd->newleds;
152 kbd->led->dev = kbd->usbdev; 152 kbd->led->dev = kbd->usbdev;
153 if (usb_submit_urb(kbd->led, GFP_ATOMIC)) 153 if (usb_submit_urb(kbd->led, GFP_ATOMIC))
154 err("usb_submit_urb(leds) failed"); 154 err_hid("usb_submit_urb(leds) failed");
155 155
156 return 0; 156 return 0;
157} 157}
@@ -169,7 +169,7 @@ static void usb_kbd_led(struct urb *urb)
169 *(kbd->leds) = kbd->newleds; 169 *(kbd->leds) = kbd->newleds;
170 kbd->led->dev = kbd->usbdev; 170 kbd->led->dev = kbd->usbdev;
171 if (usb_submit_urb(kbd->led, GFP_ATOMIC)) 171 if (usb_submit_urb(kbd->led, GFP_ATOMIC))
172 err("usb_submit_urb(leds) failed"); 172 err_hid("usb_submit_urb(leds) failed");
173} 173}
174 174
175static int usb_kbd_open(struct input_dev *dev) 175static int usb_kbd_open(struct input_dev *dev)