diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/hid/usbhid | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/hid/usbhid')
-rw-r--r-- | drivers/hid/usbhid/Kconfig | 2 | ||||
-rw-r--r-- | drivers/hid/usbhid/Makefile | 6 | ||||
-rw-r--r-- | drivers/hid/usbhid/hid-core.c | 149 | ||||
-rw-r--r-- | drivers/hid/usbhid/hid-pidff.c | 164 | ||||
-rw-r--r-- | drivers/hid/usbhid/hid-quirks.c | 13 | ||||
-rw-r--r-- | drivers/hid/usbhid/hiddev.c | 297 | ||||
-rw-r--r-- | drivers/hid/usbhid/usbhid.h | 1 | ||||
-rw-r--r-- | drivers/hid/usbhid/usbkbd.c | 24 |
8 files changed, 318 insertions, 338 deletions
diff --git a/drivers/hid/usbhid/Kconfig b/drivers/hid/usbhid/Kconfig index 4edb3bef94a6..0f20fd17cf06 100644 --- a/drivers/hid/usbhid/Kconfig +++ b/drivers/hid/usbhid/Kconfig | |||
@@ -45,7 +45,7 @@ config USB_HIDDEV | |||
45 | If unsure, say Y. | 45 | If unsure, say Y. |
46 | 46 | ||
47 | menu "USB HID Boot Protocol drivers" | 47 | menu "USB HID Boot Protocol drivers" |
48 | depends on USB!=n && USB_HID!=y && EMBEDDED | 48 | depends on USB!=n && USB_HID!=y && EXPERT |
49 | 49 | ||
50 | config USB_KBD | 50 | config USB_KBD |
51 | tristate "USB HIDBP Keyboard (simple Boot) support" | 51 | tristate "USB HIDBP Keyboard (simple Boot) support" |
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. |
6 | usbhid-objs := hid-core.o hid-quirks.o | 6 | usbhid-y := hid-core.o hid-quirks.o |
7 | 7 | ||
8 | # Optional parts of multipart objects. | 8 | # Optional parts of multipart objects. |
9 | 9 | ||
10 | ifeq ($(CONFIG_USB_HIDDEV),y) | 10 | ifeq ($(CONFIG_USB_HIDDEV),y) |
11 | usbhid-objs += hiddev.o | 11 | usbhid-y += hiddev.o |
12 | endif | 12 | endif |
13 | ifeq ($(CONFIG_HID_PID),y) | 13 | ifeq ($(CONFIG_HID_PID),y) |
14 | usbhid-objs += hid-pidff.o | 14 | usbhid-y += hid-pidff.o |
15 | endif | 15 | endif |
16 | 16 | ||
17 | obj-$(CONFIG_USB_HID) += usbhid.o | 17 | obj-$(CONFIG_USB_HID) += usbhid.o |
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 599041a7f670..38c261a40c74 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 | */ |
69 | static DEFINE_MUTEX(hid_open_mut); | 69 | static DEFINE_MUTEX(hid_open_mut); |
70 | static struct workqueue_struct *resumption_waker; | ||
71 | 70 | ||
72 | static void hid_io_error(struct hid_device *hid); | 71 | static void hid_io_error(struct hid_device *hid); |
73 | static int hid_submit_out(struct hid_device *hid); | 72 | static 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 | /* |
@@ -798,6 +799,40 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) | |||
798 | return 0; | 799 | return 0; |
799 | } | 800 | } |
800 | 801 | ||
802 | static int usbhid_get_raw_report(struct hid_device *hid, | ||
803 | unsigned char report_number, __u8 *buf, size_t count, | ||
804 | unsigned char report_type) | ||
805 | { | ||
806 | struct usbhid_device *usbhid = hid->driver_data; | ||
807 | struct usb_device *dev = hid_to_usb_dev(hid); | ||
808 | struct usb_interface *intf = usbhid->intf; | ||
809 | struct usb_host_interface *interface = intf->cur_altsetting; | ||
810 | int skipped_report_id = 0; | ||
811 | int ret; | ||
812 | |||
813 | /* Byte 0 is the report number. Report data starts at byte 1.*/ | ||
814 | buf[0] = report_number; | ||
815 | if (report_number == 0x0) { | ||
816 | /* Offset the return buffer by 1, so that the report ID | ||
817 | will remain in byte 0. */ | ||
818 | buf++; | ||
819 | count--; | ||
820 | skipped_report_id = 1; | ||
821 | } | ||
822 | ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), | ||
823 | HID_REQ_GET_REPORT, | ||
824 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
825 | ((report_type + 1) << 8) | report_number, | ||
826 | interface->desc.bInterfaceNumber, buf, count, | ||
827 | USB_CTRL_SET_TIMEOUT); | ||
828 | |||
829 | /* count also the report id */ | ||
830 | if (ret > 0 && skipped_report_id) | ||
831 | ret++; | ||
832 | |||
833 | return ret; | ||
834 | } | ||
835 | |||
801 | static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t count, | 836 | static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t count, |
802 | unsigned char report_type) | 837 | unsigned char report_type) |
803 | { | 838 | { |
@@ -807,9 +842,10 @@ static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t co | |||
807 | struct usb_host_interface *interface = intf->cur_altsetting; | 842 | struct usb_host_interface *interface = intf->cur_altsetting; |
808 | int ret; | 843 | int ret; |
809 | 844 | ||
810 | if (usbhid->urbout) { | 845 | if (usbhid->urbout && report_type != HID_FEATURE_REPORT) { |
811 | int actual_length; | 846 | int actual_length; |
812 | int skipped_report_id = 0; | 847 | int skipped_report_id = 0; |
848 | |||
813 | if (buf[0] == 0x0) { | 849 | if (buf[0] == 0x0) { |
814 | /* Don't send the Report ID */ | 850 | /* Don't send the Report ID */ |
815 | buf++; | 851 | buf++; |
@@ -856,18 +892,6 @@ static void usbhid_restart_queues(struct usbhid_device *usbhid) | |||
856 | usbhid_restart_ctrl_queue(usbhid); | 892 | usbhid_restart_ctrl_queue(usbhid); |
857 | } | 893 | } |
858 | 894 | ||
859 | static void __usbhid_restart_queues(struct work_struct *work) | ||
860 | { | ||
861 | struct usbhid_device *usbhid = | ||
862 | container_of(work, struct usbhid_device, restart_work); | ||
863 | int r; | ||
864 | |||
865 | r = usb_autopm_get_interface(usbhid->intf); | ||
866 | if (r < 0) | ||
867 | return; | ||
868 | usb_autopm_put_interface(usbhid->intf); | ||
869 | } | ||
870 | |||
871 | static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) | 895 | static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) |
872 | { | 896 | { |
873 | struct usbhid_device *usbhid = hid->driver_data; | 897 | struct usbhid_device *usbhid = hid->driver_data; |
@@ -1139,8 +1163,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * | |||
1139 | if (usb_endpoint_is_int_in(&interface->endpoint[n].desc)) | 1163 | if (usb_endpoint_is_int_in(&interface->endpoint[n].desc)) |
1140 | has_in++; | 1164 | has_in++; |
1141 | if (!has_in) { | 1165 | if (!has_in) { |
1142 | dev_err(&intf->dev, "couldn't find an input interrupt " | 1166 | hid_err(intf, "couldn't find an input interrupt endpoint\n"); |
1143 | "endpoint\n"); | ||
1144 | return -ENODEV; | 1167 | return -ENODEV; |
1145 | } | 1168 | } |
1146 | 1169 | ||
@@ -1150,6 +1173,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * | |||
1150 | 1173 | ||
1151 | usb_set_intfdata(intf, hid); | 1174 | usb_set_intfdata(intf, hid); |
1152 | hid->ll_driver = &usb_hid_driver; | 1175 | hid->ll_driver = &usb_hid_driver; |
1176 | hid->hid_get_raw_report = usbhid_get_raw_report; | ||
1153 | hid->hid_output_raw_report = usbhid_output_raw_report; | 1177 | hid->hid_output_raw_report = usbhid_output_raw_report; |
1154 | hid->ff_init = hid_pidff_init; | 1178 | hid->ff_init = hid_pidff_init; |
1155 | #ifdef CONFIG_USB_HIDDEV | 1179 | #ifdef CONFIG_USB_HIDDEV |
@@ -1205,14 +1229,13 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * | |||
1205 | 1229 | ||
1206 | init_waitqueue_head(&usbhid->wait); | 1230 | init_waitqueue_head(&usbhid->wait); |
1207 | INIT_WORK(&usbhid->reset_work, hid_reset); | 1231 | INIT_WORK(&usbhid->reset_work, hid_reset); |
1208 | INIT_WORK(&usbhid->restart_work, __usbhid_restart_queues); | ||
1209 | setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); | 1232 | setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); |
1210 | spin_lock_init(&usbhid->lock); | 1233 | spin_lock_init(&usbhid->lock); |
1211 | 1234 | ||
1212 | ret = hid_add_device(hid); | 1235 | ret = hid_add_device(hid); |
1213 | if (ret) { | 1236 | if (ret) { |
1214 | if (ret != -ENODEV) | 1237 | if (ret != -ENODEV) |
1215 | dev_err(&intf->dev, "can't add hid device: %d\n", ret); | 1238 | hid_err(intf, "can't add hid device: %d\n", ret); |
1216 | goto err_free; | 1239 | goto err_free; |
1217 | } | 1240 | } |
1218 | 1241 | ||
@@ -1240,7 +1263,6 @@ static void usbhid_disconnect(struct usb_interface *intf) | |||
1240 | static void hid_cancel_delayed_stuff(struct usbhid_device *usbhid) | 1263 | static void hid_cancel_delayed_stuff(struct usbhid_device *usbhid) |
1241 | { | 1264 | { |
1242 | del_timer_sync(&usbhid->io_retry); | 1265 | del_timer_sync(&usbhid->io_retry); |
1243 | cancel_work_sync(&usbhid->restart_work); | ||
1244 | cancel_work_sync(&usbhid->reset_work); | 1266 | cancel_work_sync(&usbhid->reset_work); |
1245 | } | 1267 | } |
1246 | 1268 | ||
@@ -1261,7 +1283,6 @@ static int hid_pre_reset(struct usb_interface *intf) | |||
1261 | spin_lock_irq(&usbhid->lock); | 1283 | spin_lock_irq(&usbhid->lock); |
1262 | set_bit(HID_RESET_PENDING, &usbhid->iofl); | 1284 | set_bit(HID_RESET_PENDING, &usbhid->iofl); |
1263 | spin_unlock_irq(&usbhid->lock); | 1285 | spin_unlock_irq(&usbhid->lock); |
1264 | cancel_work_sync(&usbhid->restart_work); | ||
1265 | hid_cease_io(usbhid); | 1286 | hid_cease_io(usbhid); |
1266 | 1287 | ||
1267 | return 0; | 1288 | return 0; |
@@ -1460,18 +1481,12 @@ static int __init hid_init(void) | |||
1460 | { | 1481 | { |
1461 | int retval = -ENOMEM; | 1482 | int retval = -ENOMEM; |
1462 | 1483 | ||
1463 | resumption_waker = create_freezeable_workqueue("usbhid_resumer"); | ||
1464 | if (!resumption_waker) | ||
1465 | goto no_queue; | ||
1466 | retval = hid_register_driver(&hid_usb_driver); | 1484 | retval = hid_register_driver(&hid_usb_driver); |
1467 | if (retval) | 1485 | if (retval) |
1468 | goto hid_register_fail; | 1486 | goto hid_register_fail; |
1469 | retval = usbhid_quirks_init(quirks_param); | 1487 | retval = usbhid_quirks_init(quirks_param); |
1470 | if (retval) | 1488 | if (retval) |
1471 | goto usbhid_quirks_init_fail; | 1489 | goto usbhid_quirks_init_fail; |
1472 | retval = hiddev_init(); | ||
1473 | if (retval) | ||
1474 | goto hiddev_init_fail; | ||
1475 | retval = usb_register(&hid_driver); | 1490 | retval = usb_register(&hid_driver); |
1476 | if (retval) | 1491 | if (retval) |
1477 | goto usb_register_fail; | 1492 | goto usb_register_fail; |
@@ -1479,24 +1494,18 @@ static int __init hid_init(void) | |||
1479 | 1494 | ||
1480 | return 0; | 1495 | return 0; |
1481 | usb_register_fail: | 1496 | usb_register_fail: |
1482 | hiddev_exit(); | ||
1483 | hiddev_init_fail: | ||
1484 | usbhid_quirks_exit(); | 1497 | usbhid_quirks_exit(); |
1485 | usbhid_quirks_init_fail: | 1498 | usbhid_quirks_init_fail: |
1486 | hid_unregister_driver(&hid_usb_driver); | 1499 | hid_unregister_driver(&hid_usb_driver); |
1487 | hid_register_fail: | 1500 | hid_register_fail: |
1488 | destroy_workqueue(resumption_waker); | ||
1489 | no_queue: | ||
1490 | return retval; | 1501 | return retval; |
1491 | } | 1502 | } |
1492 | 1503 | ||
1493 | static void __exit hid_exit(void) | 1504 | static void __exit hid_exit(void) |
1494 | { | 1505 | { |
1495 | usb_deregister(&hid_driver); | 1506 | usb_deregister(&hid_driver); |
1496 | hiddev_exit(); | ||
1497 | usbhid_quirks_exit(); | 1507 | usbhid_quirks_exit(); |
1498 | hid_unregister_driver(&hid_usb_driver); | 1508 | hid_unregister_driver(&hid_usb_driver); |
1499 | destroy_workqueue(resumption_waker); | ||
1500 | } | 1509 | } |
1501 | 1510 | ||
1502 | module_init(hid_init); | 1511 | module_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) | |||
220 | static void pidff_set(struct pidff_usage *usage, u16 value) | 220 | static 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 | ||
226 | static void pidff_set_signed(struct pidff_usage *usage, s16 value) | 226 | static 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 | */ |
925 | static int pidff_find_special_fields(struct pidff_device *pidff) | 926 | static 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 f0260c699adb..621959d5cc42 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c | |||
@@ -34,9 +34,7 @@ static const struct hid_blacklist { | |||
34 | { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, | 34 | { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, |
35 | { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, | 35 | { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, |
36 | { USB_VENDOR_ID_DWAV, USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER, HID_QUIRK_MULTI_INPUT | HID_QUIRK_NOGET }, | 36 | { USB_VENDOR_ID_DWAV, USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER, HID_QUIRK_MULTI_INPUT | HID_QUIRK_NOGET }, |
37 | { USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH, HID_QUIRK_MULTI_INPUT }, | ||
38 | { USB_VENDOR_ID_MOJO, USB_DEVICE_ID_RETRO_ADAPTER, HID_QUIRK_MULTI_INPUT }, | 37 | { USB_VENDOR_ID_MOJO, USB_DEVICE_ID_RETRO_ADAPTER, HID_QUIRK_MULTI_INPUT }, |
39 | { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART, HID_QUIRK_MULTI_INPUT }, | ||
40 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, | 38 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, |
41 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, | 39 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, |
42 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, | 40 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, |
@@ -61,17 +59,26 @@ static const struct hid_blacklist { | |||
61 | { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_COMBATSTICK, HID_QUIRK_NOGET }, | 59 | { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_COMBATSTICK, HID_QUIRK_NOGET }, |
62 | { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_ECLIPSE_YOKE, HID_QUIRK_NOGET }, | 60 | { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_ECLIPSE_YOKE, HID_QUIRK_NOGET }, |
63 | { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE, HID_QUIRK_NOGET }, | 61 | { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE, HID_QUIRK_NOGET }, |
62 | { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_THROTTLE, HID_QUIRK_NOGET }, | ||
64 | { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_PEDALS, HID_QUIRK_NOGET }, | 63 | { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_PEDALS, HID_QUIRK_NOGET }, |
65 | { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK, HID_QUIRK_NOGET }, | 64 | { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK, HID_QUIRK_NOGET }, |
65 | { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET }, | ||
66 | { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, | 66 | { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, |
67 | { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, | 67 | { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, |
68 | { USB_VENDOR_ID_PRODIGE, USB_DEVICE_ID_PRODIGE_CORDLESS, HID_QUIRK_NOGET }, | 68 | { USB_VENDOR_ID_PRODIGE, USB_DEVICE_ID_PRODIGE_CORDLESS, HID_QUIRK_NOGET }, |
69 | { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NOGET }, | 69 | { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NOGET }, |
70 | { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, | 70 | { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, |
71 | { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_1, HID_QUIRK_NOGET }, | ||
72 | { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_2, HID_QUIRK_NOGET }, | ||
71 | { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, | 73 | { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, |
72 | { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209, HID_QUIRK_MULTI_INPUT }, | 74 | { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209, HID_QUIRK_MULTI_INPUT }, |
73 | { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U, HID_QUIRK_MULTI_INPUT }, | 75 | { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U, HID_QUIRK_MULTI_INPUT }, |
74 | { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_KNA5, HID_QUIRK_MULTI_INPUT }, | 76 | { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_KNA5, HID_QUIRK_MULTI_INPUT }, |
77 | { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_TWA60, HID_QUIRK_MULTI_INPUT }, | ||
78 | { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U, HID_QUIRK_MULTI_INPUT }, | ||
79 | { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U, HID_QUIRK_MULTI_INPUT }, | ||
80 | { USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH, HID_QUIRK_MULTI_INPUT }, | ||
81 | { USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH, HID_QUIRK_MULTI_INPUT }, | ||
75 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, | 82 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, |
76 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, | 83 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, |
77 | 84 | ||
@@ -81,7 +88,7 @@ static const struct hid_blacklist { | |||
81 | { USB_VENDOR_ID_PI_ENGINEERING, USB_DEVICE_ID_PI_ENGINEERING_VEC_USB_FOOTPEDAL, HID_QUIRK_HIDINPUT_FORCE }, | 88 | { USB_VENDOR_ID_PI_ENGINEERING, USB_DEVICE_ID_PI_ENGINEERING_VEC_USB_FOOTPEDAL, HID_QUIRK_HIDINPUT_FORCE }, |
82 | 89 | ||
83 | { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_MULTI_TOUCH, HID_QUIRK_MULTI_INPUT }, | 90 | { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_MULTI_TOUCH, HID_QUIRK_MULTI_INPUT }, |
84 | 91 | { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS, HID_QUIRK_MULTI_INPUT }, | |
85 | { 0, 0 } | 92 | { 0, 0 } |
86 | }; | 93 | }; |
87 | 94 | ||
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c index 681e620eb95b..7c1188b53c3e 100644 --- a/drivers/hid/usbhid/hiddev.c +++ b/drivers/hid/usbhid/hiddev.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/smp_lock.h> | ||
33 | #include <linux/input.h> | 32 | #include <linux/input.h> |
34 | #include <linux/usb.h> | 33 | #include <linux/usb.h> |
35 | #include <linux/hid.h> | 34 | #include <linux/hid.h> |
@@ -67,8 +66,6 @@ struct hiddev_list { | |||
67 | struct mutex thread_lock; | 66 | struct mutex thread_lock; |
68 | }; | 67 | }; |
69 | 68 | ||
70 | static struct usb_driver hiddev_driver; | ||
71 | |||
72 | /* | 69 | /* |
73 | * Find a report, given the report's type and ID. The ID can be specified | 70 | * Find a report, given the report's type and ID. The ID can be specified |
74 | * indirectly by REPORT_ID_FIRST (which returns the first report of the given | 71 | * indirectly by REPORT_ID_FIRST (which returns the first report of the given |
@@ -245,15 +242,20 @@ static int hiddev_release(struct inode * inode, struct file * file) | |||
245 | list_del(&list->node); | 242 | list_del(&list->node); |
246 | spin_unlock_irqrestore(&list->hiddev->list_lock, flags); | 243 | spin_unlock_irqrestore(&list->hiddev->list_lock, flags); |
247 | 244 | ||
245 | mutex_lock(&list->hiddev->existancelock); | ||
248 | if (!--list->hiddev->open) { | 246 | if (!--list->hiddev->open) { |
249 | if (list->hiddev->exist) { | 247 | if (list->hiddev->exist) { |
250 | usbhid_close(list->hiddev->hid); | 248 | usbhid_close(list->hiddev->hid); |
251 | usbhid_put_power(list->hiddev->hid); | 249 | usbhid_put_power(list->hiddev->hid); |
252 | } else { | 250 | } else { |
251 | mutex_unlock(&list->hiddev->existancelock); | ||
253 | kfree(list->hiddev); | 252 | kfree(list->hiddev); |
253 | kfree(list); | ||
254 | return 0; | ||
254 | } | 255 | } |
255 | } | 256 | } |
256 | 257 | ||
258 | mutex_unlock(&list->hiddev->existancelock); | ||
257 | kfree(list); | 259 | kfree(list); |
258 | 260 | ||
259 | return 0; | 261 | return 0; |
@@ -303,17 +305,21 @@ static int hiddev_open(struct inode *inode, struct file *file) | |||
303 | list_add_tail(&list->node, &hiddev->list); | 305 | list_add_tail(&list->node, &hiddev->list); |
304 | spin_unlock_irq(&list->hiddev->list_lock); | 306 | spin_unlock_irq(&list->hiddev->list_lock); |
305 | 307 | ||
308 | mutex_lock(&hiddev->existancelock); | ||
306 | if (!list->hiddev->open++) | 309 | if (!list->hiddev->open++) |
307 | if (list->hiddev->exist) { | 310 | if (list->hiddev->exist) { |
308 | struct hid_device *hid = hiddev->hid; | 311 | struct hid_device *hid = hiddev->hid; |
309 | res = usbhid_get_power(hid); | 312 | res = usbhid_get_power(hid); |
310 | if (res < 0) { | 313 | if (res < 0) { |
311 | res = -EIO; | 314 | res = -EIO; |
312 | goto bail; | 315 | goto bail_unlock; |
313 | } | 316 | } |
314 | usbhid_open(hid); | 317 | usbhid_open(hid); |
315 | } | 318 | } |
319 | mutex_unlock(&hiddev->existancelock); | ||
316 | return 0; | 320 | return 0; |
321 | bail_unlock: | ||
322 | mutex_unlock(&hiddev->existancelock); | ||
317 | bail: | 323 | bail: |
318 | file->private_data = NULL; | 324 | file->private_data = NULL; |
319 | kfree(list); | 325 | kfree(list); |
@@ -370,8 +376,10 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun | |||
370 | /* let O_NONBLOCK tasks run */ | 376 | /* let O_NONBLOCK tasks run */ |
371 | mutex_unlock(&list->thread_lock); | 377 | mutex_unlock(&list->thread_lock); |
372 | schedule(); | 378 | schedule(); |
373 | if (mutex_lock_interruptible(&list->thread_lock)) | 379 | if (mutex_lock_interruptible(&list->thread_lock)) { |
380 | finish_wait(&list->hiddev->wait, &wait); | ||
374 | return -EINTR; | 381 | return -EINTR; |
382 | } | ||
375 | set_current_state(TASK_INTERRUPTIBLE); | 383 | set_current_state(TASK_INTERRUPTIBLE); |
376 | } | 384 | } |
377 | finish_wait(&list->hiddev->wait, &wait); | 385 | finish_wait(&list->hiddev->wait, &wait); |
@@ -512,7 +520,7 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd, | |||
512 | (uref_multi->num_values > HID_MAX_MULTI_USAGES || | 520 | (uref_multi->num_values > HID_MAX_MULTI_USAGES || |
513 | uref->usage_index + uref_multi->num_values > field->report_count)) | 521 | uref->usage_index + uref_multi->num_values > field->report_count)) |
514 | goto inval; | 522 | goto inval; |
515 | } | 523 | } |
516 | 524 | ||
517 | switch (cmd) { | 525 | switch (cmd) { |
518 | case HIDIOCGUSAGE: | 526 | case HIDIOCGUSAGE: |
@@ -588,163 +596,168 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
588 | { | 596 | { |
589 | struct hiddev_list *list = file->private_data; | 597 | struct hiddev_list *list = file->private_data; |
590 | struct hiddev *hiddev = list->hiddev; | 598 | struct hiddev *hiddev = list->hiddev; |
591 | struct hid_device *hid = hiddev->hid; | 599 | struct hid_device *hid; |
592 | struct usb_device *dev; | ||
593 | struct hiddev_collection_info cinfo; | 600 | struct hiddev_collection_info cinfo; |
594 | struct hiddev_report_info rinfo; | 601 | struct hiddev_report_info rinfo; |
595 | struct hiddev_field_info finfo; | 602 | struct hiddev_field_info finfo; |
596 | struct hiddev_devinfo dinfo; | 603 | struct hiddev_devinfo dinfo; |
597 | struct hid_report *report; | 604 | struct hid_report *report; |
598 | struct hid_field *field; | 605 | struct hid_field *field; |
599 | struct usbhid_device *usbhid = hid->driver_data; | ||
600 | void __user *user_arg = (void __user *)arg; | 606 | void __user *user_arg = (void __user *)arg; |
601 | int i, r; | 607 | int i, r = -EINVAL; |
602 | 608 | ||
603 | /* Called without BKL by compat methods so no BKL taken */ | 609 | /* Called without BKL by compat methods so no BKL taken */ |
604 | 610 | ||
605 | /* FIXME: Who or what stop this racing with a disconnect ?? */ | 611 | mutex_lock(&hiddev->existancelock); |
606 | if (!hiddev->exist || !hid) | 612 | if (!hiddev->exist) { |
607 | return -EIO; | 613 | r = -ENODEV; |
614 | goto ret_unlock; | ||
615 | } | ||
608 | 616 | ||
609 | dev = hid_to_usb_dev(hid); | 617 | hid = hiddev->hid; |
610 | 618 | ||
611 | switch (cmd) { | 619 | switch (cmd) { |
612 | 620 | ||
613 | case HIDIOCGVERSION: | 621 | case HIDIOCGVERSION: |
614 | return put_user(HID_VERSION, (int __user *)arg); | 622 | r = put_user(HID_VERSION, (int __user *)arg) ? |
623 | -EFAULT : 0; | ||
624 | break; | ||
615 | 625 | ||
616 | case HIDIOCAPPLICATION: | 626 | case HIDIOCAPPLICATION: |
617 | if (arg < 0 || arg >= hid->maxapplication) | 627 | if (arg < 0 || arg >= hid->maxapplication) |
618 | return -EINVAL; | 628 | break; |
619 | 629 | ||
620 | for (i = 0; i < hid->maxcollection; i++) | 630 | for (i = 0; i < hid->maxcollection; i++) |
621 | if (hid->collection[i].type == | 631 | if (hid->collection[i].type == |
622 | HID_COLLECTION_APPLICATION && arg-- == 0) | 632 | HID_COLLECTION_APPLICATION && arg-- == 0) |
623 | break; | 633 | break; |
624 | 634 | ||
625 | if (i == hid->maxcollection) | 635 | if (i < hid->maxcollection) |
626 | return -EINVAL; | 636 | r = hid->collection[i].usage; |
627 | 637 | break; | |
628 | return hid->collection[i].usage; | ||
629 | 638 | ||
630 | case HIDIOCGDEVINFO: | 639 | case HIDIOCGDEVINFO: |
631 | dinfo.bustype = BUS_USB; | 640 | { |
632 | dinfo.busnum = dev->bus->busnum; | 641 | struct usb_device *dev = hid_to_usb_dev(hid); |
633 | dinfo.devnum = dev->devnum; | 642 | struct usbhid_device *usbhid = hid->driver_data; |
634 | dinfo.ifnum = usbhid->ifnum; | 643 | |
635 | dinfo.vendor = le16_to_cpu(dev->descriptor.idVendor); | 644 | dinfo.bustype = BUS_USB; |
636 | dinfo.product = le16_to_cpu(dev->descriptor.idProduct); | 645 | dinfo.busnum = dev->bus->busnum; |
637 | dinfo.version = le16_to_cpu(dev->descriptor.bcdDevice); | 646 | dinfo.devnum = dev->devnum; |
638 | dinfo.num_applications = hid->maxapplication; | 647 | dinfo.ifnum = usbhid->ifnum; |
639 | if (copy_to_user(user_arg, &dinfo, sizeof(dinfo))) | 648 | dinfo.vendor = le16_to_cpu(dev->descriptor.idVendor); |
640 | return -EFAULT; | 649 | dinfo.product = le16_to_cpu(dev->descriptor.idProduct); |
641 | 650 | dinfo.version = le16_to_cpu(dev->descriptor.bcdDevice); | |
642 | return 0; | 651 | dinfo.num_applications = hid->maxapplication; |
652 | |||
653 | r = copy_to_user(user_arg, &dinfo, sizeof(dinfo)) ? | ||
654 | -EFAULT : 0; | ||
655 | break; | ||
656 | } | ||
643 | 657 | ||
644 | case HIDIOCGFLAG: | 658 | case HIDIOCGFLAG: |
645 | if (put_user(list->flags, (int __user *)arg)) | 659 | r = put_user(list->flags, (int __user *)arg) ? |
646 | return -EFAULT; | 660 | -EFAULT : 0; |
647 | 661 | break; | |
648 | return 0; | ||
649 | 662 | ||
650 | case HIDIOCSFLAG: | 663 | case HIDIOCSFLAG: |
651 | { | 664 | { |
652 | int newflags; | 665 | int newflags; |
653 | if (get_user(newflags, (int __user *)arg)) | 666 | |
654 | return -EFAULT; | 667 | if (get_user(newflags, (int __user *)arg)) { |
668 | r = -EFAULT; | ||
669 | break; | ||
670 | } | ||
655 | 671 | ||
656 | if ((newflags & ~HIDDEV_FLAGS) != 0 || | 672 | if ((newflags & ~HIDDEV_FLAGS) != 0 || |
657 | ((newflags & HIDDEV_FLAG_REPORT) != 0 && | 673 | ((newflags & HIDDEV_FLAG_REPORT) != 0 && |
658 | (newflags & HIDDEV_FLAG_UREF) == 0)) | 674 | (newflags & HIDDEV_FLAG_UREF) == 0)) |
659 | return -EINVAL; | 675 | break; |
660 | 676 | ||
661 | list->flags = newflags; | 677 | list->flags = newflags; |
662 | 678 | ||
663 | return 0; | 679 | r = 0; |
680 | break; | ||
664 | } | 681 | } |
665 | 682 | ||
666 | case HIDIOCGSTRING: | 683 | case HIDIOCGSTRING: |
667 | mutex_lock(&hiddev->existancelock); | 684 | r = hiddev_ioctl_string(hiddev, cmd, user_arg); |
668 | if (hiddev->exist) | 685 | break; |
669 | r = hiddev_ioctl_string(hiddev, cmd, user_arg); | ||
670 | else | ||
671 | r = -ENODEV; | ||
672 | mutex_unlock(&hiddev->existancelock); | ||
673 | return r; | ||
674 | 686 | ||
675 | case HIDIOCINITREPORT: | 687 | case HIDIOCINITREPORT: |
676 | mutex_lock(&hiddev->existancelock); | ||
677 | if (!hiddev->exist) { | ||
678 | mutex_unlock(&hiddev->existancelock); | ||
679 | return -ENODEV; | ||
680 | } | ||
681 | usbhid_init_reports(hid); | 688 | usbhid_init_reports(hid); |
682 | mutex_unlock(&hiddev->existancelock); | 689 | r = 0; |
683 | 690 | break; | |
684 | return 0; | ||
685 | 691 | ||
686 | case HIDIOCGREPORT: | 692 | case HIDIOCGREPORT: |
687 | if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) | 693 | if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) { |
688 | return -EFAULT; | 694 | r = -EFAULT; |
695 | break; | ||
696 | } | ||
689 | 697 | ||
690 | if (rinfo.report_type == HID_REPORT_TYPE_OUTPUT) | 698 | if (rinfo.report_type == HID_REPORT_TYPE_OUTPUT) |
691 | return -EINVAL; | 699 | break; |
692 | 700 | ||
693 | if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) | 701 | report = hiddev_lookup_report(hid, &rinfo); |
694 | return -EINVAL; | 702 | if (report == NULL) |
703 | break; | ||
695 | 704 | ||
696 | mutex_lock(&hiddev->existancelock); | 705 | usbhid_submit_report(hid, report, USB_DIR_IN); |
697 | if (hiddev->exist) { | 706 | usbhid_wait_io(hid); |
698 | usbhid_submit_report(hid, report, USB_DIR_IN); | ||
699 | usbhid_wait_io(hid); | ||
700 | } | ||
701 | mutex_unlock(&hiddev->existancelock); | ||
702 | 707 | ||
703 | return 0; | 708 | r = 0; |
709 | break; | ||
704 | 710 | ||
705 | case HIDIOCSREPORT: | 711 | case HIDIOCSREPORT: |
706 | if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) | 712 | if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) { |
707 | return -EFAULT; | 713 | r = -EFAULT; |
714 | break; | ||
715 | } | ||
708 | 716 | ||
709 | if (rinfo.report_type == HID_REPORT_TYPE_INPUT) | 717 | if (rinfo.report_type == HID_REPORT_TYPE_INPUT) |
710 | return -EINVAL; | 718 | break; |
711 | 719 | ||
712 | if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) | 720 | report = hiddev_lookup_report(hid, &rinfo); |
713 | return -EINVAL; | 721 | if (report == NULL) |
722 | break; | ||
714 | 723 | ||
715 | mutex_lock(&hiddev->existancelock); | 724 | usbhid_submit_report(hid, report, USB_DIR_OUT); |
716 | if (hiddev->exist) { | 725 | usbhid_wait_io(hid); |
717 | usbhid_submit_report(hid, report, USB_DIR_OUT); | ||
718 | usbhid_wait_io(hid); | ||
719 | } | ||
720 | mutex_unlock(&hiddev->existancelock); | ||
721 | 726 | ||
722 | return 0; | 727 | r = 0; |
728 | break; | ||
723 | 729 | ||
724 | case HIDIOCGREPORTINFO: | 730 | case HIDIOCGREPORTINFO: |
725 | if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) | 731 | if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) { |
726 | return -EFAULT; | 732 | r = -EFAULT; |
733 | break; | ||
734 | } | ||
727 | 735 | ||
728 | if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) | 736 | report = hiddev_lookup_report(hid, &rinfo); |
729 | return -EINVAL; | 737 | if (report == NULL) |
738 | break; | ||
730 | 739 | ||
731 | rinfo.num_fields = report->maxfield; | 740 | rinfo.num_fields = report->maxfield; |
732 | 741 | ||
733 | if (copy_to_user(user_arg, &rinfo, sizeof(rinfo))) | 742 | r = copy_to_user(user_arg, &rinfo, sizeof(rinfo)) ? |
734 | return -EFAULT; | 743 | -EFAULT : 0; |
735 | 744 | break; | |
736 | return 0; | ||
737 | 745 | ||
738 | case HIDIOCGFIELDINFO: | 746 | case HIDIOCGFIELDINFO: |
739 | if (copy_from_user(&finfo, user_arg, sizeof(finfo))) | 747 | if (copy_from_user(&finfo, user_arg, sizeof(finfo))) { |
740 | return -EFAULT; | 748 | r = -EFAULT; |
749 | break; | ||
750 | } | ||
751 | |||
741 | rinfo.report_type = finfo.report_type; | 752 | rinfo.report_type = finfo.report_type; |
742 | rinfo.report_id = finfo.report_id; | 753 | rinfo.report_id = finfo.report_id; |
743 | if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) | 754 | |
744 | return -EINVAL; | 755 | report = hiddev_lookup_report(hid, &rinfo); |
756 | if (report == NULL) | ||
757 | break; | ||
745 | 758 | ||
746 | if (finfo.field_index >= report->maxfield) | 759 | if (finfo.field_index >= report->maxfield) |
747 | return -EINVAL; | 760 | break; |
748 | 761 | ||
749 | field = report->field[finfo.field_index]; | 762 | field = report->field[finfo.field_index]; |
750 | memset(&finfo, 0, sizeof(finfo)); | 763 | memset(&finfo, 0, sizeof(finfo)); |
@@ -763,10 +776,9 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
763 | finfo.unit_exponent = field->unit_exponent; | 776 | finfo.unit_exponent = field->unit_exponent; |
764 | finfo.unit = field->unit; | 777 | finfo.unit = field->unit; |
765 | 778 | ||
766 | if (copy_to_user(user_arg, &finfo, sizeof(finfo))) | 779 | r = copy_to_user(user_arg, &finfo, sizeof(finfo)) ? |
767 | return -EFAULT; | 780 | -EFAULT : 0; |
768 | 781 | break; | |
769 | return 0; | ||
770 | 782 | ||
771 | case HIDIOCGUCODE: | 783 | case HIDIOCGUCODE: |
772 | /* fall through */ | 784 | /* fall through */ |
@@ -775,57 +787,52 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
775 | case HIDIOCGUSAGES: | 787 | case HIDIOCGUSAGES: |
776 | case HIDIOCSUSAGES: | 788 | case HIDIOCSUSAGES: |
777 | case HIDIOCGCOLLECTIONINDEX: | 789 | case HIDIOCGCOLLECTIONINDEX: |
778 | mutex_lock(&hiddev->existancelock); | 790 | r = hiddev_ioctl_usage(hiddev, cmd, user_arg); |
779 | if (hiddev->exist) | 791 | break; |
780 | r = hiddev_ioctl_usage(hiddev, cmd, user_arg); | ||
781 | else | ||
782 | r = -ENODEV; | ||
783 | mutex_unlock(&hiddev->existancelock); | ||
784 | return r; | ||
785 | 792 | ||
786 | case HIDIOCGCOLLECTIONINFO: | 793 | case HIDIOCGCOLLECTIONINFO: |
787 | if (copy_from_user(&cinfo, user_arg, sizeof(cinfo))) | 794 | if (copy_from_user(&cinfo, user_arg, sizeof(cinfo))) { |
788 | return -EFAULT; | 795 | r = -EFAULT; |
796 | break; | ||
797 | } | ||
789 | 798 | ||
790 | if (cinfo.index >= hid->maxcollection) | 799 | if (cinfo.index >= hid->maxcollection) |
791 | return -EINVAL; | 800 | break; |
792 | 801 | ||
793 | cinfo.type = hid->collection[cinfo.index].type; | 802 | cinfo.type = hid->collection[cinfo.index].type; |
794 | cinfo.usage = hid->collection[cinfo.index].usage; | 803 | cinfo.usage = hid->collection[cinfo.index].usage; |
795 | cinfo.level = hid->collection[cinfo.index].level; | 804 | cinfo.level = hid->collection[cinfo.index].level; |
796 | 805 | ||
797 | if (copy_to_user(user_arg, &cinfo, sizeof(cinfo))) | 806 | r = copy_to_user(user_arg, &cinfo, sizeof(cinfo)) ? |
798 | return -EFAULT; | 807 | -EFAULT : 0; |
799 | return 0; | 808 | break; |
800 | 809 | ||
801 | default: | 810 | default: |
802 | |||
803 | if (_IOC_TYPE(cmd) != 'H' || _IOC_DIR(cmd) != _IOC_READ) | 811 | if (_IOC_TYPE(cmd) != 'H' || _IOC_DIR(cmd) != _IOC_READ) |
804 | return -EINVAL; | 812 | break; |
805 | 813 | ||
806 | if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGNAME(0))) { | 814 | if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGNAME(0))) { |
807 | int len; | 815 | int len = strlen(hid->name) + 1; |
808 | if (!hid->name) | ||
809 | return 0; | ||
810 | len = strlen(hid->name) + 1; | ||
811 | if (len > _IOC_SIZE(cmd)) | 816 | if (len > _IOC_SIZE(cmd)) |
812 | len = _IOC_SIZE(cmd); | 817 | len = _IOC_SIZE(cmd); |
813 | return copy_to_user(user_arg, hid->name, len) ? | 818 | r = copy_to_user(user_arg, hid->name, len) ? |
814 | -EFAULT : len; | 819 | -EFAULT : len; |
820 | break; | ||
815 | } | 821 | } |
816 | 822 | ||
817 | if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGPHYS(0))) { | 823 | if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGPHYS(0))) { |
818 | int len; | 824 | int len = strlen(hid->phys) + 1; |
819 | if (!hid->phys) | ||
820 | return 0; | ||
821 | len = strlen(hid->phys) + 1; | ||
822 | if (len > _IOC_SIZE(cmd)) | 825 | if (len > _IOC_SIZE(cmd)) |
823 | len = _IOC_SIZE(cmd); | 826 | len = _IOC_SIZE(cmd); |
824 | return copy_to_user(user_arg, hid->phys, len) ? | 827 | r = copy_to_user(user_arg, hid->phys, len) ? |
825 | -EFAULT : len; | 828 | -EFAULT : len; |
829 | break; | ||
826 | } | 830 | } |
827 | } | 831 | } |
828 | return -EINVAL; | 832 | |
833 | ret_unlock: | ||
834 | mutex_unlock(&hiddev->existancelock); | ||
835 | return r; | ||
829 | } | 836 | } |
830 | 837 | ||
831 | #ifdef CONFIG_COMPAT | 838 | #ifdef CONFIG_COMPAT |
@@ -847,6 +854,7 @@ static const struct file_operations hiddev_fops = { | |||
847 | #ifdef CONFIG_COMPAT | 854 | #ifdef CONFIG_COMPAT |
848 | .compat_ioctl = hiddev_compat_ioctl, | 855 | .compat_ioctl = hiddev_compat_ioctl, |
849 | #endif | 856 | #endif |
857 | .llseek = noop_llseek, | ||
850 | }; | 858 | }; |
851 | 859 | ||
852 | static char *hiddev_devnode(struct device *dev, mode_t *mode) | 860 | static char *hiddev_devnode(struct device *dev, mode_t *mode) |
@@ -894,7 +902,7 @@ int hiddev_connect(struct hid_device *hid, unsigned int force) | |||
894 | hiddev->exist = 1; | 902 | hiddev->exist = 1; |
895 | retval = usb_register_dev(usbhid->intf, &hiddev_class); | 903 | retval = usb_register_dev(usbhid->intf, &hiddev_class); |
896 | if (retval) { | 904 | if (retval) { |
897 | err_hid("Not able to get a minor for this device."); | 905 | hid_err(hid, "Not able to get a minor for this device\n"); |
898 | hid->hiddev = NULL; | 906 | hid->hiddev = NULL; |
899 | kfree(hiddev); | 907 | kfree(hiddev); |
900 | return -1; | 908 | return -1; |
@@ -914,52 +922,15 @@ void hiddev_disconnect(struct hid_device *hid) | |||
914 | 922 | ||
915 | mutex_lock(&hiddev->existancelock); | 923 | mutex_lock(&hiddev->existancelock); |
916 | hiddev->exist = 0; | 924 | hiddev->exist = 0; |
917 | mutex_unlock(&hiddev->existancelock); | ||
918 | 925 | ||
919 | usb_deregister_dev(usbhid->intf, &hiddev_class); | 926 | usb_deregister_dev(usbhid->intf, &hiddev_class); |
920 | 927 | ||
921 | if (hiddev->open) { | 928 | if (hiddev->open) { |
929 | mutex_unlock(&hiddev->existancelock); | ||
922 | usbhid_close(hiddev->hid); | 930 | usbhid_close(hiddev->hid); |
923 | wake_up_interruptible(&hiddev->wait); | 931 | wake_up_interruptible(&hiddev->wait); |
924 | } else { | 932 | } else { |
933 | mutex_unlock(&hiddev->existancelock); | ||
925 | kfree(hiddev); | 934 | kfree(hiddev); |
926 | } | 935 | } |
927 | } | 936 | } |
928 | |||
929 | /* Currently this driver is a USB driver. It's not a conventional one in | ||
930 | * the sense that it doesn't probe at the USB level. Instead it waits to | ||
931 | * be connected by HID through the hiddev_connect / hiddev_disconnect | ||
932 | * routines. The reason to register as a USB device is to gain part of the | ||
933 | * minor number space from the USB major. | ||
934 | * | ||
935 | * In theory, should the HID code be generalized to more than one physical | ||
936 | * medium (say, IEEE 1384), this driver will probably need to register its | ||
937 | * own major number, and in doing so, no longer need to register with USB. | ||
938 | * At that point the probe routine and hiddev_driver struct below will no | ||
939 | * longer be useful. | ||
940 | */ | ||
941 | |||
942 | |||
943 | /* We never attach in this manner, and rely on HID to connect us. This | ||
944 | * is why there is no disconnect routine defined in the usb_driver either. | ||
945 | */ | ||
946 | static int hiddev_usbd_probe(struct usb_interface *intf, | ||
947 | const struct usb_device_id *hiddev_info) | ||
948 | { | ||
949 | return -ENODEV; | ||
950 | } | ||
951 | |||
952 | static /* const */ struct usb_driver hiddev_driver = { | ||
953 | .name = "hiddev", | ||
954 | .probe = hiddev_usbd_probe, | ||
955 | }; | ||
956 | |||
957 | int __init hiddev_init(void) | ||
958 | { | ||
959 | return usb_register(&hiddev_driver); | ||
960 | } | ||
961 | |||
962 | void hiddev_exit(void) | ||
963 | { | ||
964 | usb_deregister(&hiddev_driver); | ||
965 | } | ||
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) | |||
124 | resubmit: | 128 | resubmit: |
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 | ||
132 | static int usb_kbd_event(struct input_dev *dev, unsigned int type, | 136 | static 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 | ||
175 | static int usb_kbd_open(struct input_dev *dev) | 179 | static int usb_kbd_open(struct input_dev *dev) |