aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/usbhid
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/usbhid')
-rw-r--r--drivers/hid/usbhid/Makefile6
-rw-r--r--drivers/hid/usbhid/hid-core.c105
-rw-r--r--drivers/hid/usbhid/hid-pidff.c164
-rw-r--r--drivers/hid/usbhid/hid-quirks.c2
-rw-r--r--drivers/hid/usbhid/hiddev.c241
-rw-r--r--drivers/hid/usbhid/usbhid.h1
-rw-r--r--drivers/hid/usbhid/usbkbd.c24
7 files changed, 264 insertions, 279 deletions
diff --git a/drivers/hid/usbhid/Makefile b/drivers/hid/usbhid/Makefile
index 1329ecb37a1c..db3cf31c6fa1 100644
--- a/drivers/hid/usbhid/Makefile
+++ b/drivers/hid/usbhid/Makefile
@@ -3,15 +3,15 @@
3# 3#
4 4
5# Multipart objects. 5# Multipart objects.
6usbhid-objs := hid-core.o hid-quirks.o 6usbhid-y := hid-core.o hid-quirks.o
7 7
8# Optional parts of multipart objects. 8# Optional parts of multipart objects.
9 9
10ifeq ($(CONFIG_USB_HIDDEV),y) 10ifeq ($(CONFIG_USB_HIDDEV),y)
11 usbhid-objs += hiddev.o 11 usbhid-y += hiddev.o
12endif 12endif
13ifeq ($(CONFIG_HID_PID),y) 13ifeq ($(CONFIG_HID_PID),y)
14 usbhid-objs += hid-pidff.o 14 usbhid-y += hid-pidff.o
15endif 15endif
16 16
17obj-$(CONFIG_USB_HID) += usbhid.o 17obj-$(CONFIG_USB_HID) += usbhid.o
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 5489eab3a6bd..b336dd84036f 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -67,7 +67,6 @@ MODULE_PARM_DESC(quirks, "Add/modify USB HID quirks by specifying "
67 * Input submission and I/O error handler. 67 * Input submission and I/O error handler.
68 */ 68 */
69static DEFINE_MUTEX(hid_open_mut); 69static DEFINE_MUTEX(hid_open_mut);
70static struct workqueue_struct *resumption_waker;
71 70
72static void hid_io_error(struct hid_device *hid); 71static void hid_io_error(struct hid_device *hid);
73static int hid_submit_out(struct hid_device *hid); 72static int hid_submit_out(struct hid_device *hid);
@@ -136,10 +135,10 @@ static void hid_reset(struct work_struct *work)
136 hid_io_error(hid); 135 hid_io_error(hid);
137 break; 136 break;
138 default: 137 default:
139 err_hid("can't reset device, %s-%s/input%d, status %d", 138 hid_err(hid, "can't reset device, %s-%s/input%d, status %d\n",
140 hid_to_usb_dev(hid)->bus->bus_name, 139 hid_to_usb_dev(hid)->bus->bus_name,
141 hid_to_usb_dev(hid)->devpath, 140 hid_to_usb_dev(hid)->devpath,
142 usbhid->ifnum, rc); 141 usbhid->ifnum, rc);
143 /* FALLTHROUGH */ 142 /* FALLTHROUGH */
144 case -EHOSTUNREACH: 143 case -EHOSTUNREACH:
145 case -ENODEV: 144 case -ENODEV:
@@ -278,18 +277,18 @@ static void hid_irq_in(struct urb *urb)
278 hid_io_error(hid); 277 hid_io_error(hid);
279 return; 278 return;
280 default: /* error */ 279 default: /* error */
281 dev_warn(&urb->dev->dev, "input irq status %d " 280 hid_warn(urb->dev, "input irq status %d received\n",
282 "received\n", urb->status); 281 urb->status);
283 } 282 }
284 283
285 status = usb_submit_urb(urb, GFP_ATOMIC); 284 status = usb_submit_urb(urb, GFP_ATOMIC);
286 if (status) { 285 if (status) {
287 clear_bit(HID_IN_RUNNING, &usbhid->iofl); 286 clear_bit(HID_IN_RUNNING, &usbhid->iofl);
288 if (status != -EPERM) { 287 if (status != -EPERM) {
289 err_hid("can't resubmit intr, %s-%s/input%d, status %d", 288 hid_err(hid, "can't resubmit intr, %s-%s/input%d, status %d\n",
290 hid_to_usb_dev(hid)->bus->bus_name, 289 hid_to_usb_dev(hid)->bus->bus_name,
291 hid_to_usb_dev(hid)->devpath, 290 hid_to_usb_dev(hid)->devpath,
292 usbhid->ifnum, status); 291 usbhid->ifnum, status);
293 hid_io_error(hid); 292 hid_io_error(hid);
294 } 293 }
295 } 294 }
@@ -300,10 +299,19 @@ static int hid_submit_out(struct hid_device *hid)
300 struct hid_report *report; 299 struct hid_report *report;
301 char *raw_report; 300 char *raw_report;
302 struct usbhid_device *usbhid = hid->driver_data; 301 struct usbhid_device *usbhid = hid->driver_data;
302 int r;
303 303
304 report = usbhid->out[usbhid->outtail].report; 304 report = usbhid->out[usbhid->outtail].report;
305 raw_report = usbhid->out[usbhid->outtail].raw_report; 305 raw_report = usbhid->out[usbhid->outtail].raw_report;
306 306
307 r = usb_autopm_get_interface_async(usbhid->intf);
308 if (r < 0)
309 return -1;
310
311 /*
312 * if the device hasn't been woken, we leave the output
313 * to resume()
314 */
307 if (!test_bit(HID_REPORTED_IDLE, &usbhid->iofl)) { 315 if (!test_bit(HID_REPORTED_IDLE, &usbhid->iofl)) {
308 usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0); 316 usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0);
309 usbhid->urbout->dev = hid_to_usb_dev(hid); 317 usbhid->urbout->dev = hid_to_usb_dev(hid);
@@ -313,17 +321,11 @@ static int hid_submit_out(struct hid_device *hid)
313 dbg_hid("submitting out urb\n"); 321 dbg_hid("submitting out urb\n");
314 322
315 if (usb_submit_urb(usbhid->urbout, GFP_ATOMIC)) { 323 if (usb_submit_urb(usbhid->urbout, GFP_ATOMIC)) {
316 err_hid("usb_submit_urb(out) failed"); 324 hid_err(hid, "usb_submit_urb(out) failed\n");
325 usb_autopm_put_interface_async(usbhid->intf);
317 return -1; 326 return -1;
318 } 327 }
319 usbhid->last_out = jiffies; 328 usbhid->last_out = jiffies;
320 } else {
321 /*
322 * queue work to wake up the device.
323 * as the work queue is freezeable, this is safe
324 * with respect to STD and STR
325 */
326 queue_work(resumption_waker, &usbhid->restart_work);
327 } 329 }
328 330
329 return 0; 331 return 0;
@@ -334,13 +336,16 @@ static int hid_submit_ctrl(struct hid_device *hid)
334 struct hid_report *report; 336 struct hid_report *report;
335 unsigned char dir; 337 unsigned char dir;
336 char *raw_report; 338 char *raw_report;
337 int len; 339 int len, r;
338 struct usbhid_device *usbhid = hid->driver_data; 340 struct usbhid_device *usbhid = hid->driver_data;
339 341
340 report = usbhid->ctrl[usbhid->ctrltail].report; 342 report = usbhid->ctrl[usbhid->ctrltail].report;
341 raw_report = usbhid->ctrl[usbhid->ctrltail].raw_report; 343 raw_report = usbhid->ctrl[usbhid->ctrltail].raw_report;
342 dir = usbhid->ctrl[usbhid->ctrltail].dir; 344 dir = usbhid->ctrl[usbhid->ctrltail].dir;
343 345
346 r = usb_autopm_get_interface_async(usbhid->intf);
347 if (r < 0)
348 return -1;
344 if (!test_bit(HID_REPORTED_IDLE, &usbhid->iofl)) { 349 if (!test_bit(HID_REPORTED_IDLE, &usbhid->iofl)) {
345 len = ((report->size - 1) >> 3) + 1 + (report->id > 0); 350 len = ((report->size - 1) >> 3) + 1 + (report->id > 0);
346 if (dir == USB_DIR_OUT) { 351 if (dir == USB_DIR_OUT) {
@@ -375,17 +380,11 @@ static int hid_submit_ctrl(struct hid_device *hid)
375 usbhid->cr->wValue, usbhid->cr->wIndex, usbhid->cr->wLength); 380 usbhid->cr->wValue, usbhid->cr->wIndex, usbhid->cr->wLength);
376 381
377 if (usb_submit_urb(usbhid->urbctrl, GFP_ATOMIC)) { 382 if (usb_submit_urb(usbhid->urbctrl, GFP_ATOMIC)) {
378 err_hid("usb_submit_urb(ctrl) failed"); 383 usb_autopm_put_interface_async(usbhid->intf);
384 hid_err(hid, "usb_submit_urb(ctrl) failed\n");
379 return -1; 385 return -1;
380 } 386 }
381 usbhid->last_ctrl = jiffies; 387 usbhid->last_ctrl = jiffies;
382 } else {
383 /*
384 * queue work to wake up the device.
385 * as the work queue is freezeable, this is safe
386 * with respect to STD and STR
387 */
388 queue_work(resumption_waker, &usbhid->restart_work);
389 } 388 }
390 389
391 return 0; 390 return 0;
@@ -413,8 +412,8 @@ static void hid_irq_out(struct urb *urb)
413 case -ENOENT: 412 case -ENOENT:
414 break; 413 break;
415 default: /* error */ 414 default: /* error */
416 dev_warn(&urb->dev->dev, "output irq status %d " 415 hid_warn(urb->dev, "output irq status %d received\n",
417 "received\n", urb->status); 416 urb->status);
418 } 417 }
419 418
420 spin_lock_irqsave(&usbhid->lock, flags); 419 spin_lock_irqsave(&usbhid->lock, flags);
@@ -435,6 +434,7 @@ static void hid_irq_out(struct urb *urb)
435 434
436 clear_bit(HID_OUT_RUNNING, &usbhid->iofl); 435 clear_bit(HID_OUT_RUNNING, &usbhid->iofl);
437 spin_unlock_irqrestore(&usbhid->lock, flags); 436 spin_unlock_irqrestore(&usbhid->lock, flags);
437 usb_autopm_put_interface_async(usbhid->intf);
438 wake_up(&usbhid->wait); 438 wake_up(&usbhid->wait);
439} 439}
440 440
@@ -466,8 +466,7 @@ static void hid_ctrl(struct urb *urb)
466 case -EPIPE: /* report not available */ 466 case -EPIPE: /* report not available */
467 break; 467 break;
468 default: /* error */ 468 default: /* error */
469 dev_warn(&urb->dev->dev, "ctrl urb status %d " 469 hid_warn(urb->dev, "ctrl urb status %d received\n", status);
470 "received\n", status);
471 } 470 }
472 471
473 if (unplug) 472 if (unplug)
@@ -481,11 +480,13 @@ static void hid_ctrl(struct urb *urb)
481 wake_up(&usbhid->wait); 480 wake_up(&usbhid->wait);
482 } 481 }
483 spin_unlock(&usbhid->lock); 482 spin_unlock(&usbhid->lock);
483 usb_autopm_put_interface_async(usbhid->intf);
484 return; 484 return;
485 } 485 }
486 486
487 clear_bit(HID_CTRL_RUNNING, &usbhid->iofl); 487 clear_bit(HID_CTRL_RUNNING, &usbhid->iofl);
488 spin_unlock(&usbhid->lock); 488 spin_unlock(&usbhid->lock);
489 usb_autopm_put_interface_async(usbhid->intf);
489 wake_up(&usbhid->wait); 490 wake_up(&usbhid->wait);
490} 491}
491 492
@@ -501,13 +502,13 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re
501 502
502 if (usbhid->urbout && dir == USB_DIR_OUT && report->type == HID_OUTPUT_REPORT) { 503 if (usbhid->urbout && dir == USB_DIR_OUT && report->type == HID_OUTPUT_REPORT) {
503 if ((head = (usbhid->outhead + 1) & (HID_OUTPUT_FIFO_SIZE - 1)) == usbhid->outtail) { 504 if ((head = (usbhid->outhead + 1) & (HID_OUTPUT_FIFO_SIZE - 1)) == usbhid->outtail) {
504 dev_warn(&hid->dev, "output queue full\n"); 505 hid_warn(hid, "output queue full\n");
505 return; 506 return;
506 } 507 }
507 508
508 usbhid->out[usbhid->outhead].raw_report = kmalloc(len, GFP_ATOMIC); 509 usbhid->out[usbhid->outhead].raw_report = kmalloc(len, GFP_ATOMIC);
509 if (!usbhid->out[usbhid->outhead].raw_report) { 510 if (!usbhid->out[usbhid->outhead].raw_report) {
510 dev_warn(&hid->dev, "output queueing failed\n"); 511 hid_warn(hid, "output queueing failed\n");
511 return; 512 return;
512 } 513 }
513 hid_output_report(report, usbhid->out[usbhid->outhead].raw_report); 514 hid_output_report(report, usbhid->out[usbhid->outhead].raw_report);
@@ -532,14 +533,14 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re
532 } 533 }
533 534
534 if ((head = (usbhid->ctrlhead + 1) & (HID_CONTROL_FIFO_SIZE - 1)) == usbhid->ctrltail) { 535 if ((head = (usbhid->ctrlhead + 1) & (HID_CONTROL_FIFO_SIZE - 1)) == usbhid->ctrltail) {
535 dev_warn(&hid->dev, "control queue full\n"); 536 hid_warn(hid, "control queue full\n");
536 return; 537 return;
537 } 538 }
538 539
539 if (dir == USB_DIR_OUT) { 540 if (dir == USB_DIR_OUT) {
540 usbhid->ctrl[usbhid->ctrlhead].raw_report = kmalloc(len, GFP_ATOMIC); 541 usbhid->ctrl[usbhid->ctrlhead].raw_report = kmalloc(len, GFP_ATOMIC);
541 if (!usbhid->ctrl[usbhid->ctrlhead].raw_report) { 542 if (!usbhid->ctrl[usbhid->ctrlhead].raw_report) {
542 dev_warn(&hid->dev, "control queueing failed\n"); 543 hid_warn(hid, "control queueing failed\n");
543 return; 544 return;
544 } 545 }
545 hid_output_report(report, usbhid->ctrl[usbhid->ctrlhead].raw_report); 546 hid_output_report(report, usbhid->ctrl[usbhid->ctrlhead].raw_report);
@@ -590,7 +591,7 @@ static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, un
590 return -1; 591 return -1;
591 592
592 if ((offset = hidinput_find_field(hid, type, code, &field)) == -1) { 593 if ((offset = hidinput_find_field(hid, type, code, &field)) == -1) {
593 dev_warn(&dev->dev, "event field not found\n"); 594 hid_warn(dev, "event field not found\n");
594 return -1; 595 return -1;
595 } 596 }
596 597
@@ -656,7 +657,7 @@ int usbhid_open(struct hid_device *hid)
656 mutex_lock(&hid_open_mut); 657 mutex_lock(&hid_open_mut);
657 if (!hid->open++) { 658 if (!hid->open++) {
658 res = usb_autopm_get_interface(usbhid->intf); 659 res = usb_autopm_get_interface(usbhid->intf);
659 /* the device must be awake to reliable request remote wakeup */ 660 /* the device must be awake to reliably request remote wakeup */
660 if (res < 0) { 661 if (res < 0) {
661 hid->open--; 662 hid->open--;
662 mutex_unlock(&hid_open_mut); 663 mutex_unlock(&hid_open_mut);
@@ -722,7 +723,7 @@ void usbhid_init_reports(struct hid_device *hid)
722 } 723 }
723 724
724 if (err) 725 if (err)
725 dev_warn(&hid->dev, "timeout initializing reports\n"); 726 hid_warn(hid, "timeout initializing reports\n");
726} 727}
727 728
728/* 729/*
@@ -857,18 +858,6 @@ static void usbhid_restart_queues(struct usbhid_device *usbhid)
857 usbhid_restart_ctrl_queue(usbhid); 858 usbhid_restart_ctrl_queue(usbhid);
858} 859}
859 860
860static void __usbhid_restart_queues(struct work_struct *work)
861{
862 struct usbhid_device *usbhid =
863 container_of(work, struct usbhid_device, restart_work);
864 int r;
865
866 r = usb_autopm_get_interface(usbhid->intf);
867 if (r < 0)
868 return;
869 usb_autopm_put_interface(usbhid->intf);
870}
871
872static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) 861static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid)
873{ 862{
874 struct usbhid_device *usbhid = hid->driver_data; 863 struct usbhid_device *usbhid = hid->driver_data;
@@ -1140,8 +1129,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
1140 if (usb_endpoint_is_int_in(&interface->endpoint[n].desc)) 1129 if (usb_endpoint_is_int_in(&interface->endpoint[n].desc))
1141 has_in++; 1130 has_in++;
1142 if (!has_in) { 1131 if (!has_in) {
1143 dev_err(&intf->dev, "couldn't find an input interrupt " 1132 hid_err(intf, "couldn't find an input interrupt endpoint\n");
1144 "endpoint\n");
1145 return -ENODEV; 1133 return -ENODEV;
1146 } 1134 }
1147 1135
@@ -1206,14 +1194,13 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
1206 1194
1207 init_waitqueue_head(&usbhid->wait); 1195 init_waitqueue_head(&usbhid->wait);
1208 INIT_WORK(&usbhid->reset_work, hid_reset); 1196 INIT_WORK(&usbhid->reset_work, hid_reset);
1209 INIT_WORK(&usbhid->restart_work, __usbhid_restart_queues);
1210 setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); 1197 setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid);
1211 spin_lock_init(&usbhid->lock); 1198 spin_lock_init(&usbhid->lock);
1212 1199
1213 ret = hid_add_device(hid); 1200 ret = hid_add_device(hid);
1214 if (ret) { 1201 if (ret) {
1215 if (ret != -ENODEV) 1202 if (ret != -ENODEV)
1216 dev_err(&intf->dev, "can't add hid device: %d\n", ret); 1203 hid_err(intf, "can't add hid device: %d\n", ret);
1217 goto err_free; 1204 goto err_free;
1218 } 1205 }
1219 1206
@@ -1241,7 +1228,6 @@ static void usbhid_disconnect(struct usb_interface *intf)
1241static void hid_cancel_delayed_stuff(struct usbhid_device *usbhid) 1228static void hid_cancel_delayed_stuff(struct usbhid_device *usbhid)
1242{ 1229{
1243 del_timer_sync(&usbhid->io_retry); 1230 del_timer_sync(&usbhid->io_retry);
1244 cancel_work_sync(&usbhid->restart_work);
1245 cancel_work_sync(&usbhid->reset_work); 1231 cancel_work_sync(&usbhid->reset_work);
1246} 1232}
1247 1233
@@ -1262,7 +1248,6 @@ static int hid_pre_reset(struct usb_interface *intf)
1262 spin_lock_irq(&usbhid->lock); 1248 spin_lock_irq(&usbhid->lock);
1263 set_bit(HID_RESET_PENDING, &usbhid->iofl); 1249 set_bit(HID_RESET_PENDING, &usbhid->iofl);
1264 spin_unlock_irq(&usbhid->lock); 1250 spin_unlock_irq(&usbhid->lock);
1265 cancel_work_sync(&usbhid->restart_work);
1266 hid_cease_io(usbhid); 1251 hid_cease_io(usbhid);
1267 1252
1268 return 0; 1253 return 0;
@@ -1461,9 +1446,6 @@ static int __init hid_init(void)
1461{ 1446{
1462 int retval = -ENOMEM; 1447 int retval = -ENOMEM;
1463 1448
1464 resumption_waker = create_freezeable_workqueue("usbhid_resumer");
1465 if (!resumption_waker)
1466 goto no_queue;
1467 retval = hid_register_driver(&hid_usb_driver); 1449 retval = hid_register_driver(&hid_usb_driver);
1468 if (retval) 1450 if (retval)
1469 goto hid_register_fail; 1451 goto hid_register_fail;
@@ -1481,8 +1463,6 @@ usb_register_fail:
1481usbhid_quirks_init_fail: 1463usbhid_quirks_init_fail:
1482 hid_unregister_driver(&hid_usb_driver); 1464 hid_unregister_driver(&hid_usb_driver);
1483hid_register_fail: 1465hid_register_fail:
1484 destroy_workqueue(resumption_waker);
1485no_queue:
1486 return retval; 1466 return retval;
1487} 1467}
1488 1468
@@ -1491,7 +1471,6 @@ static void __exit hid_exit(void)
1491 usb_deregister(&hid_driver); 1471 usb_deregister(&hid_driver);
1492 usbhid_quirks_exit(); 1472 usbhid_quirks_exit();
1493 hid_unregister_driver(&hid_usb_driver); 1473 hid_unregister_driver(&hid_usb_driver);
1494 destroy_workqueue(resumption_waker);
1495} 1474}
1496 1475
1497module_init(hid_init); 1476module_init(hid_init);
diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c
index ef381d79cfa8..f91c136821f7 100644
--- a/drivers/hid/usbhid/hid-pidff.c
+++ b/drivers/hid/usbhid/hid-pidff.c
@@ -22,7 +22,7 @@
22 22
23/* #define DEBUG */ 23/* #define DEBUG */
24 24
25#define debug(format, arg...) pr_debug("hid-pidff: " format "\n" , ## arg) 25#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
26 26
27#include <linux/input.h> 27#include <linux/input.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
@@ -220,7 +220,7 @@ static int pidff_rescale_signed(int i, struct hid_field *field)
220static void pidff_set(struct pidff_usage *usage, u16 value) 220static void pidff_set(struct pidff_usage *usage, u16 value)
221{ 221{
222 usage->value[0] = pidff_rescale(value, 0xffff, usage->field); 222 usage->value[0] = pidff_rescale(value, 0xffff, usage->field);
223 debug("calculated from %d to %d", value, usage->value[0]); 223 pr_debug("calculated from %d to %d\n", value, usage->value[0]);
224} 224}
225 225
226static void pidff_set_signed(struct pidff_usage *usage, s16 value) 226static void pidff_set_signed(struct pidff_usage *usage, s16 value)
@@ -235,7 +235,7 @@ static void pidff_set_signed(struct pidff_usage *usage, s16 value)
235 usage->value[0] = 235 usage->value[0] =
236 pidff_rescale(value, 0x7fff, usage->field); 236 pidff_rescale(value, 0x7fff, usage->field);
237 } 237 }
238 debug("calculated from %d to %d", value, usage->value[0]); 238 pr_debug("calculated from %d to %d\n", value, usage->value[0]);
239} 239}
240 240
241/* 241/*
@@ -259,8 +259,9 @@ static void pidff_set_envelope_report(struct pidff_device *pidff,
259 pidff->set_envelope[PID_ATTACK_TIME].value[0] = envelope->attack_length; 259 pidff->set_envelope[PID_ATTACK_TIME].value[0] = envelope->attack_length;
260 pidff->set_envelope[PID_FADE_TIME].value[0] = envelope->fade_length; 260 pidff->set_envelope[PID_FADE_TIME].value[0] = envelope->fade_length;
261 261
262 debug("attack %u => %d", envelope->attack_level, 262 hid_dbg(pidff->hid, "attack %u => %d\n",
263 pidff->set_envelope[PID_ATTACK_LEVEL].value[0]); 263 envelope->attack_level,
264 pidff->set_envelope[PID_ATTACK_LEVEL].value[0]);
264 265
265 usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_ENVELOPE], 266 usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_ENVELOPE],
266 USB_DIR_OUT); 267 USB_DIR_OUT);
@@ -466,33 +467,33 @@ static int pidff_request_effect_upload(struct pidff_device *pidff, int efnum)
466 pidff->create_new_effect_type->value[0] = efnum; 467 pidff->create_new_effect_type->value[0] = efnum;
467 usbhid_submit_report(pidff->hid, pidff->reports[PID_CREATE_NEW_EFFECT], 468 usbhid_submit_report(pidff->hid, pidff->reports[PID_CREATE_NEW_EFFECT],
468 USB_DIR_OUT); 469 USB_DIR_OUT);
469 debug("create_new_effect sent, type: %d", efnum); 470 hid_dbg(pidff->hid, "create_new_effect sent, type: %d\n", efnum);
470 471
471 pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0] = 0; 472 pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0] = 0;
472 pidff->block_load_status->value[0] = 0; 473 pidff->block_load_status->value[0] = 0;
473 usbhid_wait_io(pidff->hid); 474 usbhid_wait_io(pidff->hid);
474 475
475 for (j = 0; j < 60; j++) { 476 for (j = 0; j < 60; j++) {
476 debug("pid_block_load requested"); 477 hid_dbg(pidff->hid, "pid_block_load requested\n");
477 usbhid_submit_report(pidff->hid, pidff->reports[PID_BLOCK_LOAD], 478 usbhid_submit_report(pidff->hid, pidff->reports[PID_BLOCK_LOAD],
478 USB_DIR_IN); 479 USB_DIR_IN);
479 usbhid_wait_io(pidff->hid); 480 usbhid_wait_io(pidff->hid);
480 if (pidff->block_load_status->value[0] == 481 if (pidff->block_load_status->value[0] ==
481 pidff->status_id[PID_BLOCK_LOAD_SUCCESS]) { 482 pidff->status_id[PID_BLOCK_LOAD_SUCCESS]) {
482 debug("device reported free memory: %d bytes", 483 hid_dbg(pidff->hid, "device reported free memory: %d bytes\n",
483 pidff->block_load[PID_RAM_POOL_AVAILABLE].value ? 484 pidff->block_load[PID_RAM_POOL_AVAILABLE].value ?
484 pidff->block_load[PID_RAM_POOL_AVAILABLE].value[0] : -1); 485 pidff->block_load[PID_RAM_POOL_AVAILABLE].value[0] : -1);
485 return 0; 486 return 0;
486 } 487 }
487 if (pidff->block_load_status->value[0] == 488 if (pidff->block_load_status->value[0] ==
488 pidff->status_id[PID_BLOCK_LOAD_FULL]) { 489 pidff->status_id[PID_BLOCK_LOAD_FULL]) {
489 debug("not enough memory free: %d bytes", 490 hid_dbg(pidff->hid, "not enough memory free: %d bytes\n",
490 pidff->block_load[PID_RAM_POOL_AVAILABLE].value ? 491 pidff->block_load[PID_RAM_POOL_AVAILABLE].value ?
491 pidff->block_load[PID_RAM_POOL_AVAILABLE].value[0] : -1); 492 pidff->block_load[PID_RAM_POOL_AVAILABLE].value[0] : -1);
492 return -ENOSPC; 493 return -ENOSPC;
493 } 494 }
494 } 495 }
495 printk(KERN_ERR "hid-pidff: pid_block_load failed 60 times\n"); 496 hid_err(pidff->hid, "pid_block_load failed 60 times\n");
496 return -EIO; 497 return -EIO;
497} 498}
498 499
@@ -546,7 +547,8 @@ static int pidff_erase_effect(struct input_dev *dev, int effect_id)
546 struct pidff_device *pidff = dev->ff->private; 547 struct pidff_device *pidff = dev->ff->private;
547 int pid_id = pidff->pid_id[effect_id]; 548 int pid_id = pidff->pid_id[effect_id];
548 549
549 debug("starting to erase %d/%d", effect_id, pidff->pid_id[effect_id]); 550 hid_dbg(pidff->hid, "starting to erase %d/%d\n",
551 effect_id, pidff->pid_id[effect_id]);
550 /* Wait for the queue to clear. We do not want a full fifo to 552 /* Wait for the queue to clear. We do not want a full fifo to
551 prevent the effect removal. */ 553 prevent the effect removal. */
552 usbhid_wait_io(pidff->hid); 554 usbhid_wait_io(pidff->hid);
@@ -604,8 +606,7 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,
604 type_id = PID_SAW_DOWN; 606 type_id = PID_SAW_DOWN;
605 break; 607 break;
606 default: 608 default:
607 printk(KERN_ERR 609 hid_err(pidff->hid, "invalid waveform\n");
608 "hid-pidff: invalid waveform\n");
609 return -EINVAL; 610 return -EINVAL;
610 } 611 }
611 612
@@ -696,7 +697,7 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,
696 break; 697 break;
697 698
698 default: 699 default:
699 printk(KERN_ERR "hid-pidff: invalid type\n"); 700 hid_err(pidff->hid, "invalid type\n");
700 return -EINVAL; 701 return -EINVAL;
701 } 702 }
702 703
@@ -704,7 +705,7 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,
704 pidff->pid_id[effect->id] = 705 pidff->pid_id[effect->id] =
705 pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0]; 706 pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0];
706 707
707 debug("uploaded"); 708 hid_dbg(pidff->hid, "uploaded\n");
708 709
709 return 0; 710 return 0;
710} 711}
@@ -770,14 +771,14 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table,
770 for (i = 0; i < report->maxfield; i++) { 771 for (i = 0; i < report->maxfield; i++) {
771 if (report->field[i]->maxusage != 772 if (report->field[i]->maxusage !=
772 report->field[i]->report_count) { 773 report->field[i]->report_count) {
773 debug("maxusage and report_count do not match, " 774 pr_debug("maxusage and report_count do not match, skipping\n");
774 "skipping");
775 continue; 775 continue;
776 } 776 }
777 for (j = 0; j < report->field[i]->maxusage; j++) { 777 for (j = 0; j < report->field[i]->maxusage; j++) {
778 if (report->field[i]->usage[j].hid == 778 if (report->field[i]->usage[j].hid ==
779 (HID_UP_PID | table[k])) { 779 (HID_UP_PID | table[k])) {
780 debug("found %d at %d->%d", k, i, j); 780 pr_debug("found %d at %d->%d\n",
781 k, i, j);
781 usage[k].field = report->field[i]; 782 usage[k].field = report->field[i];
782 usage[k].value = 783 usage[k].value =
783 &report->field[i]->value[j]; 784 &report->field[i]->value[j];
@@ -789,7 +790,7 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table,
789 break; 790 break;
790 } 791 }
791 if (!found && strict) { 792 if (!found && strict) {
792 debug("failed to locate %d", k); 793 pr_debug("failed to locate %d\n", k);
793 return -1; 794 return -1;
794 } 795 }
795 } 796 }
@@ -826,8 +827,8 @@ static void pidff_find_reports(struct hid_device *hid, int report_type,
826 continue; 827 continue;
827 ret = pidff_check_usage(report->field[0]->logical); 828 ret = pidff_check_usage(report->field[0]->logical);
828 if (ret != -1) { 829 if (ret != -1) {
829 debug("found usage 0x%02x from field->logical", 830 hid_dbg(hid, "found usage 0x%02x from field->logical\n",
830 pidff_reports[ret]); 831 pidff_reports[ret]);
831 pidff->reports[ret] = report; 832 pidff->reports[ret] = report;
832 continue; 833 continue;
833 } 834 }
@@ -845,8 +846,9 @@ static void pidff_find_reports(struct hid_device *hid, int report_type,
845 continue; 846 continue;
846 ret = pidff_check_usage(hid->collection[i - 1].usage); 847 ret = pidff_check_usage(hid->collection[i - 1].usage);
847 if (ret != -1 && !pidff->reports[ret]) { 848 if (ret != -1 && !pidff->reports[ret]) {
848 debug("found usage 0x%02x from collection array", 849 hid_dbg(hid,
849 pidff_reports[ret]); 850 "found usage 0x%02x from collection array\n",
851 pidff_reports[ret]);
850 pidff->reports[ret] = report; 852 pidff->reports[ret] = report;
851 } 853 }
852 } 854 }
@@ -861,7 +863,7 @@ static int pidff_reports_ok(struct pidff_device *pidff)
861 863
862 for (i = 0; i <= PID_REQUIRED_REPORTS; i++) { 864 for (i = 0; i <= PID_REQUIRED_REPORTS; i++) {
863 if (!pidff->reports[i]) { 865 if (!pidff->reports[i]) {
864 debug("%d missing", i); 866 hid_dbg(pidff->hid, "%d missing\n", i);
865 return 0; 867 return 0;
866 } 868 }
867 } 869 }
@@ -884,8 +886,7 @@ static struct hid_field *pidff_find_special_field(struct hid_report *report,
884 report->field[i]->logical_minimum == 1) 886 report->field[i]->logical_minimum == 1)
885 return report->field[i]; 887 return report->field[i];
886 else { 888 else {
887 printk(KERN_ERR "hid-pidff: logical_minimum " 889 pr_err("logical_minimum is not 1 as it should be\n");
888 "is not 1 as it should be\n");
889 return NULL; 890 return NULL;
890 } 891 }
891 } 892 }
@@ -924,7 +925,7 @@ static int pidff_find_special_keys(int *keys, struct hid_field *fld,
924 */ 925 */
925static int pidff_find_special_fields(struct pidff_device *pidff) 926static int pidff_find_special_fields(struct pidff_device *pidff)
926{ 927{
927 debug("finding special fields"); 928 hid_dbg(pidff->hid, "finding special fields\n");
928 929
929 pidff->create_new_effect_type = 930 pidff->create_new_effect_type =
930 pidff_find_special_field(pidff->reports[PID_CREATE_NEW_EFFECT], 931 pidff_find_special_field(pidff->reports[PID_CREATE_NEW_EFFECT],
@@ -945,32 +946,30 @@ static int pidff_find_special_fields(struct pidff_device *pidff)
945 pidff_find_special_field(pidff->reports[PID_EFFECT_OPERATION], 946 pidff_find_special_field(pidff->reports[PID_EFFECT_OPERATION],
946 0x78, 1); 947 0x78, 1);
947 948
948 debug("search done"); 949 hid_dbg(pidff->hid, "search done\n");
949 950
950 if (!pidff->create_new_effect_type || !pidff->set_effect_type) { 951 if (!pidff->create_new_effect_type || !pidff->set_effect_type) {
951 printk(KERN_ERR "hid-pidff: effect lists not found\n"); 952 hid_err(pidff->hid, "effect lists not found\n");
952 return -1; 953 return -1;
953 } 954 }
954 955
955 if (!pidff->effect_direction) { 956 if (!pidff->effect_direction) {
956 printk(KERN_ERR "hid-pidff: direction field not found\n"); 957 hid_err(pidff->hid, "direction field not found\n");
957 return -1; 958 return -1;
958 } 959 }
959 960
960 if (!pidff->device_control) { 961 if (!pidff->device_control) {
961 printk(KERN_ERR "hid-pidff: device control field not found\n"); 962 hid_err(pidff->hid, "device control field not found\n");
962 return -1; 963 return -1;
963 } 964 }
964 965
965 if (!pidff->block_load_status) { 966 if (!pidff->block_load_status) {
966 printk(KERN_ERR 967 hid_err(pidff->hid, "block load status field not found\n");
967 "hid-pidff: block load status field not found\n");
968 return -1; 968 return -1;
969 } 969 }
970 970
971 if (!pidff->effect_operation_status) { 971 if (!pidff->effect_operation_status) {
972 printk(KERN_ERR 972 hid_err(pidff->hid, "effect operation field not found\n");
973 "hid-pidff: effect operation field not found\n");
974 return -1; 973 return -1;
975 } 974 }
976 975
@@ -982,23 +981,22 @@ static int pidff_find_special_fields(struct pidff_device *pidff)
982 981
983 if (!PIDFF_FIND_SPECIAL_KEYS(type_id, create_new_effect_type, 982 if (!PIDFF_FIND_SPECIAL_KEYS(type_id, create_new_effect_type,
984 effect_types)) { 983 effect_types)) {
985 printk(KERN_ERR "hid-pidff: no effect types found\n"); 984 hid_err(pidff->hid, "no effect types found\n");
986 return -1; 985 return -1;
987 } 986 }
988 987
989 if (PIDFF_FIND_SPECIAL_KEYS(status_id, block_load_status, 988 if (PIDFF_FIND_SPECIAL_KEYS(status_id, block_load_status,
990 block_load_status) != 989 block_load_status) !=
991 sizeof(pidff_block_load_status)) { 990 sizeof(pidff_block_load_status)) {
992 printk(KERN_ERR 991 hid_err(pidff->hid,
993 "hidpidff: block load status identifiers not found\n"); 992 "block load status identifiers not found\n");
994 return -1; 993 return -1;
995 } 994 }
996 995
997 if (PIDFF_FIND_SPECIAL_KEYS(operation_id, effect_operation_status, 996 if (PIDFF_FIND_SPECIAL_KEYS(operation_id, effect_operation_status,
998 effect_operation_status) != 997 effect_operation_status) !=
999 sizeof(pidff_effect_operation_status)) { 998 sizeof(pidff_effect_operation_status)) {
1000 printk(KERN_ERR 999 hid_err(pidff->hid, "effect operation identifiers not found\n");
1001 "hidpidff: effect operation identifiers not found\n");
1002 return -1; 1000 return -1;
1003 } 1001 }
1004 1002
@@ -1017,8 +1015,8 @@ static int pidff_find_effects(struct pidff_device *pidff,
1017 int pidff_type = pidff->type_id[i]; 1015 int pidff_type = pidff->type_id[i];
1018 if (pidff->set_effect_type->usage[pidff_type].hid != 1016 if (pidff->set_effect_type->usage[pidff_type].hid !=
1019 pidff->create_new_effect_type->usage[pidff_type].hid) { 1017 pidff->create_new_effect_type->usage[pidff_type].hid) {
1020 printk(KERN_ERR "hid-pidff: " 1018 hid_err(pidff->hid,
1021 "effect type number %d is invalid\n", i); 1019 "effect type number %d is invalid\n", i);
1022 return -1; 1020 return -1;
1023 } 1021 }
1024 } 1022 }
@@ -1073,27 +1071,23 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev)
1073 int envelope_ok = 0; 1071 int envelope_ok = 0;
1074 1072
1075 if (PIDFF_FIND_FIELDS(set_effect, PID_SET_EFFECT, 1)) { 1073 if (PIDFF_FIND_FIELDS(set_effect, PID_SET_EFFECT, 1)) {
1076 printk(KERN_ERR 1074 hid_err(pidff->hid, "unknown set_effect report layout\n");
1077 "hid-pidff: unknown set_effect report layout\n");
1078 return -ENODEV; 1075 return -ENODEV;
1079 } 1076 }
1080 1077
1081 PIDFF_FIND_FIELDS(block_load, PID_BLOCK_LOAD, 0); 1078 PIDFF_FIND_FIELDS(block_load, PID_BLOCK_LOAD, 0);
1082 if (!pidff->block_load[PID_EFFECT_BLOCK_INDEX].value) { 1079 if (!pidff->block_load[PID_EFFECT_BLOCK_INDEX].value) {
1083 printk(KERN_ERR 1080 hid_err(pidff->hid, "unknown pid_block_load report layout\n");
1084 "hid-pidff: unknown pid_block_load report layout\n");
1085 return -ENODEV; 1081 return -ENODEV;
1086 } 1082 }
1087 1083
1088 if (PIDFF_FIND_FIELDS(effect_operation, PID_EFFECT_OPERATION, 1)) { 1084 if (PIDFF_FIND_FIELDS(effect_operation, PID_EFFECT_OPERATION, 1)) {
1089 printk(KERN_ERR 1085 hid_err(pidff->hid, "unknown effect_operation report layout\n");
1090 "hid-pidff: unknown effect_operation report layout\n");
1091 return -ENODEV; 1086 return -ENODEV;
1092 } 1087 }
1093 1088
1094 if (PIDFF_FIND_FIELDS(block_free, PID_BLOCK_FREE, 1)) { 1089 if (PIDFF_FIND_FIELDS(block_free, PID_BLOCK_FREE, 1)) {
1095 printk(KERN_ERR 1090 hid_err(pidff->hid, "unknown pid_block_free report layout\n");
1096 "hid-pidff: unknown pid_block_free report layout\n");
1097 return -ENODEV; 1091 return -ENODEV;
1098 } 1092 }
1099 1093
@@ -1105,27 +1099,26 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev)
1105 1099
1106 if (!envelope_ok) { 1100 if (!envelope_ok) {
1107 if (test_and_clear_bit(FF_CONSTANT, dev->ffbit)) 1101 if (test_and_clear_bit(FF_CONSTANT, dev->ffbit))
1108 printk(KERN_WARNING "hid-pidff: " 1102 hid_warn(pidff->hid,
1109 "has constant effect but no envelope\n"); 1103 "has constant effect but no envelope\n");
1110 if (test_and_clear_bit(FF_RAMP, dev->ffbit)) 1104 if (test_and_clear_bit(FF_RAMP, dev->ffbit))
1111 printk(KERN_WARNING "hid-pidff: " 1105 hid_warn(pidff->hid,
1112 "has ramp effect but no envelope\n"); 1106 "has ramp effect but no envelope\n");
1113 1107
1114 if (test_and_clear_bit(FF_PERIODIC, dev->ffbit)) 1108 if (test_and_clear_bit(FF_PERIODIC, dev->ffbit))
1115 printk(KERN_WARNING "hid-pidff: " 1109 hid_warn(pidff->hid,
1116 "has periodic effect but no envelope\n"); 1110 "has periodic effect but no envelope\n");
1117 } 1111 }
1118 1112
1119 if (test_bit(FF_CONSTANT, dev->ffbit) && 1113 if (test_bit(FF_CONSTANT, dev->ffbit) &&
1120 PIDFF_FIND_FIELDS(set_constant, PID_SET_CONSTANT, 1)) { 1114 PIDFF_FIND_FIELDS(set_constant, PID_SET_CONSTANT, 1)) {
1121 printk(KERN_WARNING 1115 hid_warn(pidff->hid, "unknown constant effect layout\n");
1122 "hid-pidff: unknown constant effect layout\n");
1123 clear_bit(FF_CONSTANT, dev->ffbit); 1116 clear_bit(FF_CONSTANT, dev->ffbit);
1124 } 1117 }
1125 1118
1126 if (test_bit(FF_RAMP, dev->ffbit) && 1119 if (test_bit(FF_RAMP, dev->ffbit) &&
1127 PIDFF_FIND_FIELDS(set_ramp, PID_SET_RAMP, 1)) { 1120 PIDFF_FIND_FIELDS(set_ramp, PID_SET_RAMP, 1)) {
1128 printk(KERN_WARNING "hid-pidff: unknown ramp effect layout\n"); 1121 hid_warn(pidff->hid, "unknown ramp effect layout\n");
1129 clear_bit(FF_RAMP, dev->ffbit); 1122 clear_bit(FF_RAMP, dev->ffbit);
1130 } 1123 }
1131 1124
@@ -1134,8 +1127,7 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev)
1134 test_bit(FF_FRICTION, dev->ffbit) || 1127 test_bit(FF_FRICTION, dev->ffbit) ||
1135 test_bit(FF_INERTIA, dev->ffbit)) && 1128 test_bit(FF_INERTIA, dev->ffbit)) &&
1136 PIDFF_FIND_FIELDS(set_condition, PID_SET_CONDITION, 1)) { 1129 PIDFF_FIND_FIELDS(set_condition, PID_SET_CONDITION, 1)) {
1137 printk(KERN_WARNING 1130 hid_warn(pidff->hid, "unknown condition effect layout\n");
1138 "hid-pidff: unknown condition effect layout\n");
1139 clear_bit(FF_SPRING, dev->ffbit); 1131 clear_bit(FF_SPRING, dev->ffbit);
1140 clear_bit(FF_DAMPER, dev->ffbit); 1132 clear_bit(FF_DAMPER, dev->ffbit);
1141 clear_bit(FF_FRICTION, dev->ffbit); 1133 clear_bit(FF_FRICTION, dev->ffbit);
@@ -1144,8 +1136,7 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev)
1144 1136
1145 if (test_bit(FF_PERIODIC, dev->ffbit) && 1137 if (test_bit(FF_PERIODIC, dev->ffbit) &&
1146 PIDFF_FIND_FIELDS(set_periodic, PID_SET_PERIODIC, 1)) { 1138 PIDFF_FIND_FIELDS(set_periodic, PID_SET_PERIODIC, 1)) {
1147 printk(KERN_WARNING 1139 hid_warn(pidff->hid, "unknown periodic effect layout\n");
1148 "hid-pidff: unknown periodic effect layout\n");
1149 clear_bit(FF_PERIODIC, dev->ffbit); 1140 clear_bit(FF_PERIODIC, dev->ffbit);
1150 } 1141 }
1151 1142
@@ -1184,12 +1175,12 @@ static void pidff_reset(struct pidff_device *pidff)
1184 if (pidff->pool[PID_SIMULTANEOUS_MAX].value) { 1175 if (pidff->pool[PID_SIMULTANEOUS_MAX].value) {
1185 while (pidff->pool[PID_SIMULTANEOUS_MAX].value[0] < 2) { 1176 while (pidff->pool[PID_SIMULTANEOUS_MAX].value[0] < 2) {
1186 if (i++ > 20) { 1177 if (i++ > 20) {
1187 printk(KERN_WARNING "hid-pidff: device reports " 1178 hid_warn(pidff->hid,
1188 "%d simultaneous effects\n", 1179 "device reports %d simultaneous effects\n",
1189 pidff->pool[PID_SIMULTANEOUS_MAX].value[0]); 1180 pidff->pool[PID_SIMULTANEOUS_MAX].value[0]);
1190 break; 1181 break;
1191 } 1182 }
1192 debug("pid_pool requested again"); 1183 hid_dbg(pidff->hid, "pid_pool requested again\n");
1193 usbhid_submit_report(hid, pidff->reports[PID_POOL], 1184 usbhid_submit_report(hid, pidff->reports[PID_POOL],
1194 USB_DIR_IN); 1185 USB_DIR_IN);
1195 usbhid_wait_io(hid); 1186 usbhid_wait_io(hid);
@@ -1215,7 +1206,7 @@ static int pidff_check_autocenter(struct pidff_device *pidff,
1215 1206
1216 error = pidff_request_effect_upload(pidff, 1); 1207 error = pidff_request_effect_upload(pidff, 1);
1217 if (error) { 1208 if (error) {
1218 printk(KERN_ERR "hid-pidff: upload request failed\n"); 1209 hid_err(pidff->hid, "upload request failed\n");
1219 return error; 1210 return error;
1220 } 1211 }
1221 1212
@@ -1224,8 +1215,8 @@ static int pidff_check_autocenter(struct pidff_device *pidff,
1224 pidff_autocenter(pidff, 0xffff); 1215 pidff_autocenter(pidff, 0xffff);
1225 set_bit(FF_AUTOCENTER, dev->ffbit); 1216 set_bit(FF_AUTOCENTER, dev->ffbit);
1226 } else { 1217 } else {
1227 printk(KERN_NOTICE "hid-pidff: " 1218 hid_notice(pidff->hid,
1228 "device has unknown autocenter control method\n"); 1219 "device has unknown autocenter control method\n");
1229 } 1220 }
1230 1221
1231 pidff_erase_pid(pidff, 1222 pidff_erase_pid(pidff,
@@ -1248,10 +1239,10 @@ int hid_pidff_init(struct hid_device *hid)
1248 int max_effects; 1239 int max_effects;
1249 int error; 1240 int error;
1250 1241
1251 debug("starting pid init"); 1242 hid_dbg(hid, "starting pid init\n");
1252 1243
1253 if (list_empty(&hid->report_enum[HID_OUTPUT_REPORT].report_list)) { 1244 if (list_empty(&hid->report_enum[HID_OUTPUT_REPORT].report_list)) {
1254 debug("not a PID device, no output report"); 1245 hid_dbg(hid, "not a PID device, no output report\n");
1255 return -ENODEV; 1246 return -ENODEV;
1256 } 1247 }
1257 1248
@@ -1265,7 +1256,7 @@ int hid_pidff_init(struct hid_device *hid)
1265 pidff_find_reports(hid, HID_FEATURE_REPORT, pidff); 1256 pidff_find_reports(hid, HID_FEATURE_REPORT, pidff);
1266 1257
1267 if (!pidff_reports_ok(pidff)) { 1258 if (!pidff_reports_ok(pidff)) {
1268 debug("reports not ok, aborting"); 1259 hid_dbg(hid, "reports not ok, aborting\n");
1269 error = -ENODEV; 1260 error = -ENODEV;
1270 goto fail; 1261 goto fail;
1271 } 1262 }
@@ -1278,8 +1269,8 @@ int hid_pidff_init(struct hid_device *hid)
1278 1269
1279 if (test_bit(FF_GAIN, dev->ffbit)) { 1270 if (test_bit(FF_GAIN, dev->ffbit)) {
1280 pidff_set(&pidff->device_gain[PID_DEVICE_GAIN_FIELD], 0xffff); 1271 pidff_set(&pidff->device_gain[PID_DEVICE_GAIN_FIELD], 0xffff);
1281 usbhid_submit_report(pidff->hid, pidff->reports[PID_DEVICE_GAIN], 1272 usbhid_submit_report(hid, pidff->reports[PID_DEVICE_GAIN],
1282 USB_DIR_OUT); 1273 USB_DIR_OUT);
1283 } 1274 }
1284 1275
1285 error = pidff_check_autocenter(pidff, dev); 1276 error = pidff_check_autocenter(pidff, dev);
@@ -1290,23 +1281,23 @@ int hid_pidff_init(struct hid_device *hid)
1290 pidff->block_load[PID_EFFECT_BLOCK_INDEX].field->logical_maximum - 1281 pidff->block_load[PID_EFFECT_BLOCK_INDEX].field->logical_maximum -
1291 pidff->block_load[PID_EFFECT_BLOCK_INDEX].field->logical_minimum + 1282 pidff->block_load[PID_EFFECT_BLOCK_INDEX].field->logical_minimum +
1292 1; 1283 1;
1293 debug("max effects is %d", max_effects); 1284 hid_dbg(hid, "max effects is %d\n", max_effects);
1294 1285
1295 if (max_effects > PID_EFFECTS_MAX) 1286 if (max_effects > PID_EFFECTS_MAX)
1296 max_effects = PID_EFFECTS_MAX; 1287 max_effects = PID_EFFECTS_MAX;
1297 1288
1298 if (pidff->pool[PID_SIMULTANEOUS_MAX].value) 1289 if (pidff->pool[PID_SIMULTANEOUS_MAX].value)
1299 debug("max simultaneous effects is %d", 1290 hid_dbg(hid, "max simultaneous effects is %d\n",
1300 pidff->pool[PID_SIMULTANEOUS_MAX].value[0]); 1291 pidff->pool[PID_SIMULTANEOUS_MAX].value[0]);
1301 1292
1302 if (pidff->pool[PID_RAM_POOL_SIZE].value) 1293 if (pidff->pool[PID_RAM_POOL_SIZE].value)
1303 debug("device memory size is %d bytes", 1294 hid_dbg(hid, "device memory size is %d bytes\n",
1304 pidff->pool[PID_RAM_POOL_SIZE].value[0]); 1295 pidff->pool[PID_RAM_POOL_SIZE].value[0]);
1305 1296
1306 if (pidff->pool[PID_DEVICE_MANAGED_POOL].value && 1297 if (pidff->pool[PID_DEVICE_MANAGED_POOL].value &&
1307 pidff->pool[PID_DEVICE_MANAGED_POOL].value[0] == 0) { 1298 pidff->pool[PID_DEVICE_MANAGED_POOL].value[0] == 0) {
1308 printk(KERN_NOTICE "hid-pidff: " 1299 hid_notice(hid,
1309 "device does not support device managed pool\n"); 1300 "device does not support device managed pool\n");
1310 goto fail; 1301 goto fail;
1311 } 1302 }
1312 1303
@@ -1322,8 +1313,7 @@ int hid_pidff_init(struct hid_device *hid)
1322 ff->set_autocenter = pidff_set_autocenter; 1313 ff->set_autocenter = pidff_set_autocenter;
1323 ff->playback = pidff_playback; 1314 ff->playback = pidff_playback;
1324 1315
1325 printk(KERN_INFO "Force feedback for USB HID PID devices by " 1316 hid_info(dev, "Force feedback for USB HID PID devices by Anssi Hannula <anssi.hannula@gmail.com>\n");
1326 "Anssi Hannula <anssi.hannula@gmail.com>\n");
1327 1317
1328 return 0; 1318 return 0;
1329 1319
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 2c185477eeb3..76b9a149c7df 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -85,7 +85,7 @@ static const struct hid_blacklist {
85 { USB_VENDOR_ID_PI_ENGINEERING, USB_DEVICE_ID_PI_ENGINEERING_VEC_USB_FOOTPEDAL, HID_QUIRK_HIDINPUT_FORCE }, 85 { USB_VENDOR_ID_PI_ENGINEERING, USB_DEVICE_ID_PI_ENGINEERING_VEC_USB_FOOTPEDAL, HID_QUIRK_HIDINPUT_FORCE },
86 86
87 { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_MULTI_TOUCH, HID_QUIRK_MULTI_INPUT }, 87 { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_MULTI_TOUCH, HID_QUIRK_MULTI_INPUT },
88 88 { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS, HID_QUIRK_MULTI_INPUT },
89 { 0, 0 } 89 { 0, 0 }
90}; 90};
91 91
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 984feb351a5a..af0a7c1002af 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -585,163 +585,168 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
585{ 585{
586 struct hiddev_list *list = file->private_data; 586 struct hiddev_list *list = file->private_data;
587 struct hiddev *hiddev = list->hiddev; 587 struct hiddev *hiddev = list->hiddev;
588 struct hid_device *hid = hiddev->hid; 588 struct hid_device *hid;
589 struct usb_device *dev;
590 struct hiddev_collection_info cinfo; 589 struct hiddev_collection_info cinfo;
591 struct hiddev_report_info rinfo; 590 struct hiddev_report_info rinfo;
592 struct hiddev_field_info finfo; 591 struct hiddev_field_info finfo;
593 struct hiddev_devinfo dinfo; 592 struct hiddev_devinfo dinfo;
594 struct hid_report *report; 593 struct hid_report *report;
595 struct hid_field *field; 594 struct hid_field *field;
596 struct usbhid_device *usbhid = hid->driver_data;
597 void __user *user_arg = (void __user *)arg; 595 void __user *user_arg = (void __user *)arg;
598 int i, r; 596 int i, r = -EINVAL;
599 597
600 /* Called without BKL by compat methods so no BKL taken */ 598 /* Called without BKL by compat methods so no BKL taken */
601 599
602 /* FIXME: Who or what stop this racing with a disconnect ?? */ 600 mutex_lock(&hiddev->existancelock);
603 if (!hiddev->exist || !hid) 601 if (!hiddev->exist) {
604 return -EIO; 602 r = -ENODEV;
603 goto ret_unlock;
604 }
605 605
606 dev = hid_to_usb_dev(hid); 606 hid = hiddev->hid;
607 607
608 switch (cmd) { 608 switch (cmd) {
609 609
610 case HIDIOCGVERSION: 610 case HIDIOCGVERSION:
611 return put_user(HID_VERSION, (int __user *)arg); 611 r = put_user(HID_VERSION, (int __user *)arg) ?
612 -EFAULT : 0;
613 break;
612 614
613 case HIDIOCAPPLICATION: 615 case HIDIOCAPPLICATION:
614 if (arg < 0 || arg >= hid->maxapplication) 616 if (arg < 0 || arg >= hid->maxapplication)
615 return -EINVAL; 617 break;
616 618
617 for (i = 0; i < hid->maxcollection; i++) 619 for (i = 0; i < hid->maxcollection; i++)
618 if (hid->collection[i].type == 620 if (hid->collection[i].type ==
619 HID_COLLECTION_APPLICATION && arg-- == 0) 621 HID_COLLECTION_APPLICATION && arg-- == 0)
620 break; 622 break;
621 623
622 if (i == hid->maxcollection) 624 if (i < hid->maxcollection)
623 return -EINVAL; 625 r = hid->collection[i].usage;
624 626 break;
625 return hid->collection[i].usage;
626 627
627 case HIDIOCGDEVINFO: 628 case HIDIOCGDEVINFO:
628 dinfo.bustype = BUS_USB; 629 {
629 dinfo.busnum = dev->bus->busnum; 630 struct usb_device *dev = hid_to_usb_dev(hid);
630 dinfo.devnum = dev->devnum; 631 struct usbhid_device *usbhid = hid->driver_data;
631 dinfo.ifnum = usbhid->ifnum; 632
632 dinfo.vendor = le16_to_cpu(dev->descriptor.idVendor); 633 dinfo.bustype = BUS_USB;
633 dinfo.product = le16_to_cpu(dev->descriptor.idProduct); 634 dinfo.busnum = dev->bus->busnum;
634 dinfo.version = le16_to_cpu(dev->descriptor.bcdDevice); 635 dinfo.devnum = dev->devnum;
635 dinfo.num_applications = hid->maxapplication; 636 dinfo.ifnum = usbhid->ifnum;
636 if (copy_to_user(user_arg, &dinfo, sizeof(dinfo))) 637 dinfo.vendor = le16_to_cpu(dev->descriptor.idVendor);
637 return -EFAULT; 638 dinfo.product = le16_to_cpu(dev->descriptor.idProduct);
638 639 dinfo.version = le16_to_cpu(dev->descriptor.bcdDevice);
639 return 0; 640 dinfo.num_applications = hid->maxapplication;
641
642 r = copy_to_user(user_arg, &dinfo, sizeof(dinfo)) ?
643 -EFAULT : 0;
644 break;
645 }
640 646
641 case HIDIOCGFLAG: 647 case HIDIOCGFLAG:
642 if (put_user(list->flags, (int __user *)arg)) 648 r = put_user(list->flags, (int __user *)arg) ?
643 return -EFAULT; 649 -EFAULT : 0;
644 650 break;
645 return 0;
646 651
647 case HIDIOCSFLAG: 652 case HIDIOCSFLAG:
648 { 653 {
649 int newflags; 654 int newflags;
650 if (get_user(newflags, (int __user *)arg)) 655
651 return -EFAULT; 656 if (get_user(newflags, (int __user *)arg)) {
657 r = -EFAULT;
658 break;
659 }
652 660
653 if ((newflags & ~HIDDEV_FLAGS) != 0 || 661 if ((newflags & ~HIDDEV_FLAGS) != 0 ||
654 ((newflags & HIDDEV_FLAG_REPORT) != 0 && 662 ((newflags & HIDDEV_FLAG_REPORT) != 0 &&
655 (newflags & HIDDEV_FLAG_UREF) == 0)) 663 (newflags & HIDDEV_FLAG_UREF) == 0))
656 return -EINVAL; 664 break;
657 665
658 list->flags = newflags; 666 list->flags = newflags;
659 667
660 return 0; 668 r = 0;
669 break;
661 } 670 }
662 671
663 case HIDIOCGSTRING: 672 case HIDIOCGSTRING:
664 mutex_lock(&hiddev->existancelock); 673 r = hiddev_ioctl_string(hiddev, cmd, user_arg);
665 if (hiddev->exist) 674 break;
666 r = hiddev_ioctl_string(hiddev, cmd, user_arg);
667 else
668 r = -ENODEV;
669 mutex_unlock(&hiddev->existancelock);
670 return r;
671 675
672 case HIDIOCINITREPORT: 676 case HIDIOCINITREPORT:
673 mutex_lock(&hiddev->existancelock);
674 if (!hiddev->exist) {
675 mutex_unlock(&hiddev->existancelock);
676 return -ENODEV;
677 }
678 usbhid_init_reports(hid); 677 usbhid_init_reports(hid);
679 mutex_unlock(&hiddev->existancelock); 678 r = 0;
680 679 break;
681 return 0;
682 680
683 case HIDIOCGREPORT: 681 case HIDIOCGREPORT:
684 if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) 682 if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) {
685 return -EFAULT; 683 r = -EFAULT;
684 break;
685 }
686 686
687 if (rinfo.report_type == HID_REPORT_TYPE_OUTPUT) 687 if (rinfo.report_type == HID_REPORT_TYPE_OUTPUT)
688 return -EINVAL; 688 break;
689 689
690 if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) 690 report = hiddev_lookup_report(hid, &rinfo);
691 return -EINVAL; 691 if (report == NULL)
692 break;
692 693
693 mutex_lock(&hiddev->existancelock); 694 usbhid_submit_report(hid, report, USB_DIR_IN);
694 if (hiddev->exist) { 695 usbhid_wait_io(hid);
695 usbhid_submit_report(hid, report, USB_DIR_IN);
696 usbhid_wait_io(hid);
697 }
698 mutex_unlock(&hiddev->existancelock);
699 696
700 return 0; 697 r = 0;
698 break;
701 699
702 case HIDIOCSREPORT: 700 case HIDIOCSREPORT:
703 if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) 701 if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) {
704 return -EFAULT; 702 r = -EFAULT;
703 break;
704 }
705 705
706 if (rinfo.report_type == HID_REPORT_TYPE_INPUT) 706 if (rinfo.report_type == HID_REPORT_TYPE_INPUT)
707 return -EINVAL; 707 break;
708 708
709 if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) 709 report = hiddev_lookup_report(hid, &rinfo);
710 return -EINVAL; 710 if (report == NULL)
711 break;
711 712
712 mutex_lock(&hiddev->existancelock); 713 usbhid_submit_report(hid, report, USB_DIR_OUT);
713 if (hiddev->exist) { 714 usbhid_wait_io(hid);
714 usbhid_submit_report(hid, report, USB_DIR_OUT);
715 usbhid_wait_io(hid);
716 }
717 mutex_unlock(&hiddev->existancelock);
718 715
719 return 0; 716 r = 0;
717 break;
720 718
721 case HIDIOCGREPORTINFO: 719 case HIDIOCGREPORTINFO:
722 if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) 720 if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) {
723 return -EFAULT; 721 r = -EFAULT;
722 break;
723 }
724 724
725 if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) 725 report = hiddev_lookup_report(hid, &rinfo);
726 return -EINVAL; 726 if (report == NULL)
727 break;
727 728
728 rinfo.num_fields = report->maxfield; 729 rinfo.num_fields = report->maxfield;
729 730
730 if (copy_to_user(user_arg, &rinfo, sizeof(rinfo))) 731 r = copy_to_user(user_arg, &rinfo, sizeof(rinfo)) ?
731 return -EFAULT; 732 -EFAULT : 0;
732 733 break;
733 return 0;
734 734
735 case HIDIOCGFIELDINFO: 735 case HIDIOCGFIELDINFO:
736 if (copy_from_user(&finfo, user_arg, sizeof(finfo))) 736 if (copy_from_user(&finfo, user_arg, sizeof(finfo))) {
737 return -EFAULT; 737 r = -EFAULT;
738 break;
739 }
740
738 rinfo.report_type = finfo.report_type; 741 rinfo.report_type = finfo.report_type;
739 rinfo.report_id = finfo.report_id; 742 rinfo.report_id = finfo.report_id;
740 if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) 743
741 return -EINVAL; 744 report = hiddev_lookup_report(hid, &rinfo);
745 if (report == NULL)
746 break;
742 747
743 if (finfo.field_index >= report->maxfield) 748 if (finfo.field_index >= report->maxfield)
744 return -EINVAL; 749 break;
745 750
746 field = report->field[finfo.field_index]; 751 field = report->field[finfo.field_index];
747 memset(&finfo, 0, sizeof(finfo)); 752 memset(&finfo, 0, sizeof(finfo));
@@ -760,10 +765,9 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
760 finfo.unit_exponent = field->unit_exponent; 765 finfo.unit_exponent = field->unit_exponent;
761 finfo.unit = field->unit; 766 finfo.unit = field->unit;
762 767
763 if (copy_to_user(user_arg, &finfo, sizeof(finfo))) 768 r = copy_to_user(user_arg, &finfo, sizeof(finfo)) ?
764 return -EFAULT; 769 -EFAULT : 0;
765 770 break;
766 return 0;
767 771
768 case HIDIOCGUCODE: 772 case HIDIOCGUCODE:
769 /* fall through */ 773 /* fall through */
@@ -772,57 +776,66 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
772 case HIDIOCGUSAGES: 776 case HIDIOCGUSAGES:
773 case HIDIOCSUSAGES: 777 case HIDIOCSUSAGES:
774 case HIDIOCGCOLLECTIONINDEX: 778 case HIDIOCGCOLLECTIONINDEX:
775 mutex_lock(&hiddev->existancelock); 779 r = hiddev_ioctl_usage(hiddev, cmd, user_arg);
776 if (hiddev->exist) 780 break;
777 r = hiddev_ioctl_usage(hiddev, cmd, user_arg);
778 else
779 r = -ENODEV;
780 mutex_unlock(&hiddev->existancelock);
781 return r;
782 781
783 case HIDIOCGCOLLECTIONINFO: 782 case HIDIOCGCOLLECTIONINFO:
784 if (copy_from_user(&cinfo, user_arg, sizeof(cinfo))) 783 if (copy_from_user(&cinfo, user_arg, sizeof(cinfo))) {
785 return -EFAULT; 784 r = -EFAULT;
785 break;
786 }
786 787
787 if (cinfo.index >= hid->maxcollection) 788 if (cinfo.index >= hid->maxcollection)
788 return -EINVAL; 789 break;
789 790
790 cinfo.type = hid->collection[cinfo.index].type; 791 cinfo.type = hid->collection[cinfo.index].type;
791 cinfo.usage = hid->collection[cinfo.index].usage; 792 cinfo.usage = hid->collection[cinfo.index].usage;
792 cinfo.level = hid->collection[cinfo.index].level; 793 cinfo.level = hid->collection[cinfo.index].level;
793 794
794 if (copy_to_user(user_arg, &cinfo, sizeof(cinfo))) 795 r = copy_to_user(user_arg, &cinfo, sizeof(cinfo)) ?
795 return -EFAULT; 796 -EFAULT : 0;
796 return 0; 797 break;
797 798
798 default: 799 default:
799
800 if (_IOC_TYPE(cmd) != 'H' || _IOC_DIR(cmd) != _IOC_READ) 800 if (_IOC_TYPE(cmd) != 'H' || _IOC_DIR(cmd) != _IOC_READ)
801 return -EINVAL; 801 break;
802 802
803 if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGNAME(0))) { 803 if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGNAME(0))) {
804 int len; 804 int len;
805 if (!hid->name) 805
806 return 0; 806 if (!hid->name) {
807 r = 0;
808 break;
809 }
810
807 len = strlen(hid->name) + 1; 811 len = strlen(hid->name) + 1;
808 if (len > _IOC_SIZE(cmd)) 812 if (len > _IOC_SIZE(cmd))
809 len = _IOC_SIZE(cmd); 813 len = _IOC_SIZE(cmd);
810 return copy_to_user(user_arg, hid->name, len) ? 814 r = copy_to_user(user_arg, hid->name, len) ?
811 -EFAULT : len; 815 -EFAULT : len;
816 break;
812 } 817 }
813 818
814 if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGPHYS(0))) { 819 if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGPHYS(0))) {
815 int len; 820 int len;
816 if (!hid->phys) 821
817 return 0; 822 if (!hid->phys) {
823 r = 0;
824 break;
825 }
826
818 len = strlen(hid->phys) + 1; 827 len = strlen(hid->phys) + 1;
819 if (len > _IOC_SIZE(cmd)) 828 if (len > _IOC_SIZE(cmd))
820 len = _IOC_SIZE(cmd); 829 len = _IOC_SIZE(cmd);
821 return copy_to_user(user_arg, hid->phys, len) ? 830 r = copy_to_user(user_arg, hid->phys, len) ?
822 -EFAULT : len; 831 -EFAULT : len;
832 break;
823 } 833 }
824 } 834 }
825 return -EINVAL; 835
836ret_unlock:
837 mutex_unlock(&hiddev->existancelock);
838 return r;
826} 839}
827 840
828#ifdef CONFIG_COMPAT 841#ifdef CONFIG_COMPAT
@@ -892,7 +905,7 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
892 hiddev->exist = 1; 905 hiddev->exist = 1;
893 retval = usb_register_dev(usbhid->intf, &hiddev_class); 906 retval = usb_register_dev(usbhid->intf, &hiddev_class);
894 if (retval) { 907 if (retval) {
895 err_hid("Not able to get a minor for this device."); 908 hid_err(hid, "Not able to get a minor for this device\n");
896 hid->hiddev = NULL; 909 hid->hiddev = NULL;
897 kfree(hiddev); 910 kfree(hiddev);
898 return -1; 911 return -1;
diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h
index 89d2e847dcc6..1673cac93d77 100644
--- a/drivers/hid/usbhid/usbhid.h
+++ b/drivers/hid/usbhid/usbhid.h
@@ -95,7 +95,6 @@ struct usbhid_device {
95 unsigned long stop_retry; /* Time to give up, in jiffies */ 95 unsigned long stop_retry; /* Time to give up, in jiffies */
96 unsigned int retry_delay; /* Delay length in ms */ 96 unsigned int retry_delay; /* Delay length in ms */
97 struct work_struct reset_work; /* Task context for resets */ 97 struct work_struct reset_work; /* Task context for resets */
98 struct work_struct restart_work; /* waking up for output to be done in a task */
99 wait_queue_head_t wait; /* For sleeping */ 98 wait_queue_head_t wait; /* For sleeping */
100 int ledcount; /* counting the number of active leds */ 99 int ledcount; /* counting the number of active leds */
101}; 100};
diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c
index a948605564fb..065817329f03 100644
--- a/drivers/hid/usbhid/usbkbd.c
+++ b/drivers/hid/usbhid/usbkbd.c
@@ -24,6 +24,8 @@
24 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic 24 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
25 */ 25 */
26 26
27#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
28
27#include <linux/kernel.h> 29#include <linux/kernel.h>
28#include <linux/slab.h> 30#include <linux/slab.h>
29#include <linux/module.h> 31#include <linux/module.h>
@@ -104,16 +106,18 @@ static void usb_kbd_irq(struct urb *urb)
104 if (usb_kbd_keycode[kbd->old[i]]) 106 if (usb_kbd_keycode[kbd->old[i]])
105 input_report_key(kbd->dev, usb_kbd_keycode[kbd->old[i]], 0); 107 input_report_key(kbd->dev, usb_kbd_keycode[kbd->old[i]], 0);
106 else 108 else
107 dev_info(&urb->dev->dev, 109 hid_info(urb->dev,
108 "Unknown key (scancode %#x) released.\n", kbd->old[i]); 110 "Unknown key (scancode %#x) released.\n",
111 kbd->old[i]);
109 } 112 }
110 113
111 if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) { 114 if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) {
112 if (usb_kbd_keycode[kbd->new[i]]) 115 if (usb_kbd_keycode[kbd->new[i]])
113 input_report_key(kbd->dev, usb_kbd_keycode[kbd->new[i]], 1); 116 input_report_key(kbd->dev, usb_kbd_keycode[kbd->new[i]], 1);
114 else 117 else
115 dev_info(&urb->dev->dev, 118 hid_info(urb->dev,
116 "Unknown key (scancode %#x) released.\n", kbd->new[i]); 119 "Unknown key (scancode %#x) released.\n",
120 kbd->new[i]);
117 } 121 }
118 } 122 }
119 123
@@ -124,9 +128,9 @@ static void usb_kbd_irq(struct urb *urb)
124resubmit: 128resubmit:
125 i = usb_submit_urb (urb, GFP_ATOMIC); 129 i = usb_submit_urb (urb, GFP_ATOMIC);
126 if (i) 130 if (i)
127 err_hid ("can't resubmit intr, %s-%s/input0, status %d", 131 hid_err(urb->dev, "can't resubmit intr, %s-%s/input0, status %d",
128 kbd->usbdev->bus->bus_name, 132 kbd->usbdev->bus->bus_name,
129 kbd->usbdev->devpath, i); 133 kbd->usbdev->devpath, i);
130} 134}
131 135
132static int usb_kbd_event(struct input_dev *dev, unsigned int type, 136static int usb_kbd_event(struct input_dev *dev, unsigned int type,
@@ -150,7 +154,7 @@ static int usb_kbd_event(struct input_dev *dev, unsigned int type,
150 *(kbd->leds) = kbd->newleds; 154 *(kbd->leds) = kbd->newleds;
151 kbd->led->dev = kbd->usbdev; 155 kbd->led->dev = kbd->usbdev;
152 if (usb_submit_urb(kbd->led, GFP_ATOMIC)) 156 if (usb_submit_urb(kbd->led, GFP_ATOMIC))
153 err_hid("usb_submit_urb(leds) failed"); 157 pr_err("usb_submit_urb(leds) failed\n");
154 158
155 return 0; 159 return 0;
156} 160}
@@ -160,7 +164,7 @@ static void usb_kbd_led(struct urb *urb)
160 struct usb_kbd *kbd = urb->context; 164 struct usb_kbd *kbd = urb->context;
161 165
162 if (urb->status) 166 if (urb->status)
163 dev_warn(&urb->dev->dev, "led urb status %d received\n", 167 hid_warn(urb->dev, "led urb status %d received\n",
164 urb->status); 168 urb->status);
165 169
166 if (*(kbd->leds) == kbd->newleds) 170 if (*(kbd->leds) == kbd->newleds)
@@ -169,7 +173,7 @@ static void usb_kbd_led(struct urb *urb)
169 *(kbd->leds) = kbd->newleds; 173 *(kbd->leds) = kbd->newleds;
170 kbd->led->dev = kbd->usbdev; 174 kbd->led->dev = kbd->usbdev;
171 if (usb_submit_urb(kbd->led, GFP_ATOMIC)) 175 if (usb_submit_urb(kbd->led, GFP_ATOMIC))
172 err_hid("usb_submit_urb(leds) failed"); 176 hid_err(urb->dev, "usb_submit_urb(leds) failed\n");
173} 177}
174 178
175static int usb_kbd_open(struct input_dev *dev) 179static int usb_kbd_open(struct input_dev *dev)