Lines Matching full:usbhid

37 #include "usbhid.h"
78 static void hid_cancel_delayed_stuff(struct usbhid_device *usbhid);
85 struct usbhid_device *usbhid = hid->driver_data; in hid_start_in() local
87 spin_lock_irqsave(&usbhid->lock, flags); in hid_start_in()
88 if (test_bit(HID_IN_POLLING, &usbhid->iofl) && in hid_start_in()
89 !test_bit(HID_DISCONNECTED, &usbhid->iofl) && in hid_start_in()
90 !test_bit(HID_SUSPENDED, &usbhid->iofl) && in hid_start_in()
91 !test_and_set_bit(HID_IN_RUNNING, &usbhid->iofl)) { in hid_start_in()
92 rc = usb_submit_urb(usbhid->urbin, GFP_ATOMIC); in hid_start_in()
94 clear_bit(HID_IN_RUNNING, &usbhid->iofl); in hid_start_in()
96 set_bit(HID_NO_BANDWIDTH, &usbhid->iofl); in hid_start_in()
98 clear_bit(HID_NO_BANDWIDTH, &usbhid->iofl); in hid_start_in()
101 spin_unlock_irqrestore(&usbhid->lock, flags); in hid_start_in()
108 struct usbhid_device *usbhid = from_timer(usbhid, t, io_retry); in hid_retry_timeout() local
109 struct hid_device *hid = usbhid->hid; in hid_retry_timeout()
111 dev_dbg(&usbhid->intf->dev, "retrying intr urb\n"); in hid_retry_timeout()
119 struct usbhid_device *usbhid = in hid_reset() local
121 struct hid_device *hid = usbhid->hid; in hid_reset()
124 if (test_bit(HID_CLEAR_HALT, &usbhid->iofl)) { in hid_reset()
125 dev_dbg(&usbhid->intf->dev, "clear halt\n"); in hid_reset()
126 rc = usb_clear_halt(hid_to_usb_dev(hid), usbhid->urbin->pipe); in hid_reset()
127 clear_bit(HID_CLEAR_HALT, &usbhid->iofl); in hid_reset()
131 dev_dbg(&usbhid->intf->dev, in hid_reset()
133 set_bit(HID_RESET_PENDING, &usbhid->iofl); in hid_reset()
137 if (test_bit(HID_RESET_PENDING, &usbhid->iofl)) { in hid_reset()
138 dev_dbg(&usbhid->intf->dev, "resetting device\n"); in hid_reset()
139 usb_queue_reset_device(usbhid->intf); in hid_reset()
147 struct usbhid_device *usbhid = hid->driver_data; in hid_io_error() local
149 spin_lock_irqsave(&usbhid->lock, flags); in hid_io_error()
152 if (test_bit(HID_DISCONNECTED, &usbhid->iofl)) in hid_io_error()
157 if (time_after(jiffies, usbhid->stop_retry + HZ/2)) in hid_io_error()
158 usbhid->retry_delay = 0; in hid_io_error()
161 if (usbhid->retry_delay == 0) { in hid_io_error()
162 usbhid->retry_delay = 13; /* Then 26, 52, 104, 104, ... */ in hid_io_error()
163 usbhid->stop_retry = jiffies + msecs_to_jiffies(1000); in hid_io_error()
164 } else if (usbhid->retry_delay < 100) in hid_io_error()
165 usbhid->retry_delay *= 2; in hid_io_error()
167 if (time_after(jiffies, usbhid->stop_retry)) { in hid_io_error()
170 if (!test_bit(HID_NO_BANDWIDTH, &usbhid->iofl) in hid_io_error()
171 && !test_and_set_bit(HID_RESET_PENDING, &usbhid->iofl)) { in hid_io_error()
173 schedule_work(&usbhid->reset_work); in hid_io_error()
178 mod_timer(&usbhid->io_retry, in hid_io_error()
179 jiffies + msecs_to_jiffies(usbhid->retry_delay)); in hid_io_error()
181 spin_unlock_irqrestore(&usbhid->lock, flags); in hid_io_error()
184 static void usbhid_mark_busy(struct usbhid_device *usbhid) in usbhid_mark_busy() argument
186 struct usb_interface *intf = usbhid->intf; in usbhid_mark_busy()
191 static int usbhid_restart_out_queue(struct usbhid_device *usbhid) in usbhid_restart_out_queue() argument
193 struct hid_device *hid = usb_get_intfdata(usbhid->intf); in usbhid_restart_out_queue()
197 if (!hid || test_bit(HID_RESET_PENDING, &usbhid->iofl) || in usbhid_restart_out_queue()
198 test_bit(HID_SUSPENDED, &usbhid->iofl)) in usbhid_restart_out_queue()
201 if ((kicked = (usbhid->outhead != usbhid->outtail))) { in usbhid_restart_out_queue()
202 hid_dbg(hid, "Kicking head %d tail %d", usbhid->outhead, usbhid->outtail); in usbhid_restart_out_queue()
205 r = usb_autopm_get_interface_async(usbhid->intf); in usbhid_restart_out_queue()
213 if (test_bit(HID_SUSPENDED, &usbhid->iofl)) { in usbhid_restart_out_queue()
214 usb_autopm_put_interface_no_suspend(usbhid->intf); in usbhid_restart_out_queue()
219 set_bit(HID_OUT_RUNNING, &usbhid->iofl); in usbhid_restart_out_queue()
221 clear_bit(HID_OUT_RUNNING, &usbhid->iofl); in usbhid_restart_out_queue()
222 usb_autopm_put_interface_async(usbhid->intf); in usbhid_restart_out_queue()
224 wake_up(&usbhid->wait); in usbhid_restart_out_queue()
229 static int usbhid_restart_ctrl_queue(struct usbhid_device *usbhid) in usbhid_restart_ctrl_queue() argument
231 struct hid_device *hid = usb_get_intfdata(usbhid->intf); in usbhid_restart_ctrl_queue()
236 if (!hid || test_bit(HID_RESET_PENDING, &usbhid->iofl) || in usbhid_restart_ctrl_queue()
237 test_bit(HID_SUSPENDED, &usbhid->iofl)) in usbhid_restart_ctrl_queue()
240 if ((kicked = (usbhid->ctrlhead != usbhid->ctrltail))) { in usbhid_restart_ctrl_queue()
241 hid_dbg(hid, "Kicking head %d tail %d", usbhid->ctrlhead, usbhid->ctrltail); in usbhid_restart_ctrl_queue()
244 r = usb_autopm_get_interface_async(usbhid->intf); in usbhid_restart_ctrl_queue()
252 if (test_bit(HID_SUSPENDED, &usbhid->iofl)) { in usbhid_restart_ctrl_queue()
253 usb_autopm_put_interface_no_suspend(usbhid->intf); in usbhid_restart_ctrl_queue()
258 set_bit(HID_CTRL_RUNNING, &usbhid->iofl); in usbhid_restart_ctrl_queue()
260 clear_bit(HID_CTRL_RUNNING, &usbhid->iofl); in usbhid_restart_ctrl_queue()
261 usb_autopm_put_interface_async(usbhid->intf); in usbhid_restart_ctrl_queue()
263 wake_up(&usbhid->wait); in usbhid_restart_ctrl_queue()
275 struct usbhid_device *usbhid = hid->driver_data; in hid_irq_in() local
280 usbhid->retry_delay = 0; in hid_irq_in()
281 if (!test_bit(HID_OPENED, &usbhid->iofl)) in hid_irq_in()
283 usbhid_mark_busy(usbhid); in hid_irq_in()
284 if (!test_bit(HID_RESUME_RUNNING, &usbhid->iofl)) { in hid_irq_in()
294 set_bit(HID_KEYS_PRESSED, &usbhid->iofl); in hid_irq_in()
296 clear_bit(HID_KEYS_PRESSED, &usbhid->iofl); in hid_irq_in()
300 usbhid_mark_busy(usbhid); in hid_irq_in()
301 clear_bit(HID_IN_RUNNING, &usbhid->iofl); in hid_irq_in()
302 set_bit(HID_CLEAR_HALT, &usbhid->iofl); in hid_irq_in()
303 schedule_work(&usbhid->reset_work); in hid_irq_in()
308 clear_bit(HID_IN_RUNNING, &usbhid->iofl); in hid_irq_in()
314 usbhid_mark_busy(usbhid); in hid_irq_in()
315 clear_bit(HID_IN_RUNNING, &usbhid->iofl); in hid_irq_in()
325 clear_bit(HID_IN_RUNNING, &usbhid->iofl); in hid_irq_in()
330 usbhid->ifnum, status); in hid_irq_in()
340 struct usbhid_device *usbhid = hid->driver_data; in hid_submit_out() local
343 report = usbhid->out[usbhid->outtail].report; in hid_submit_out()
344 raw_report = usbhid->out[usbhid->outtail].raw_report; in hid_submit_out()
346 usbhid->urbout->transfer_buffer_length = hid_report_len(report); in hid_submit_out()
347 usbhid->urbout->dev = hid_to_usb_dev(hid); in hid_submit_out()
349 memcpy(usbhid->outbuf, raw_report, in hid_submit_out()
350 usbhid->urbout->transfer_buffer_length); in hid_submit_out()
352 usbhid->out[usbhid->outtail].raw_report = NULL; in hid_submit_out()
357 r = usb_submit_urb(usbhid->urbout, GFP_ATOMIC); in hid_submit_out()
362 usbhid->last_out = jiffies; in hid_submit_out()
372 struct usbhid_device *usbhid = hid->driver_data; in hid_submit_ctrl() local
374 report = usbhid->ctrl[usbhid->ctrltail].report; in hid_submit_ctrl()
375 raw_report = usbhid->ctrl[usbhid->ctrltail].raw_report; in hid_submit_ctrl()
376 dir = usbhid->ctrl[usbhid->ctrltail].dir; in hid_submit_ctrl()
380 usbhid->urbctrl->pipe = usb_sndctrlpipe(hid_to_usb_dev(hid), 0); in hid_submit_ctrl()
382 memcpy(usbhid->ctrlbuf, raw_report, len); in hid_submit_ctrl()
384 usbhid->ctrl[usbhid->ctrltail].raw_report = NULL; in hid_submit_ctrl()
389 usbhid->urbctrl->pipe = usb_rcvctrlpipe(hid_to_usb_dev(hid), 0); in hid_submit_ctrl()
391 usbhid->urbctrl->pipe); in hid_submit_ctrl()
394 if (len > usbhid->bufsize) in hid_submit_ctrl()
395 len = usbhid->bufsize; in hid_submit_ctrl()
397 usbhid->urbctrl->transfer_buffer_length = len; in hid_submit_ctrl()
398 usbhid->urbctrl->dev = hid_to_usb_dev(hid); in hid_submit_ctrl()
400 usbhid->cr->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE | dir; in hid_submit_ctrl()
401 usbhid->cr->bRequest = (dir == USB_DIR_OUT) ? HID_REQ_SET_REPORT : in hid_submit_ctrl()
403 usbhid->cr->wValue = cpu_to_le16(((report->type + 1) << 8) | in hid_submit_ctrl()
405 usbhid->cr->wIndex = cpu_to_le16(usbhid->ifnum); in hid_submit_ctrl()
406 usbhid->cr->wLength = cpu_to_le16(len); in hid_submit_ctrl()
409 usbhid->cr->bRequest == HID_REQ_SET_REPORT ? "Set_Report" : in hid_submit_ctrl()
411 usbhid->cr->wValue, usbhid->cr->wIndex, usbhid->cr->wLength); in hid_submit_ctrl()
413 r = usb_submit_urb(usbhid->urbctrl, GFP_ATOMIC); in hid_submit_ctrl()
418 usbhid->last_ctrl = jiffies; in hid_submit_ctrl()
429 struct usbhid_device *usbhid = hid->driver_data; in hid_irq_out() local
449 spin_lock_irqsave(&usbhid->lock, flags); in hid_irq_out()
452 usbhid->outtail = usbhid->outhead; in hid_irq_out()
454 usbhid->outtail = (usbhid->outtail + 1) & (HID_OUTPUT_FIFO_SIZE - 1); in hid_irq_out()
456 if (usbhid->outhead != usbhid->outtail && in hid_irq_out()
459 spin_unlock_irqrestore(&usbhid->lock, flags); in hid_irq_out()
464 clear_bit(HID_OUT_RUNNING, &usbhid->iofl); in hid_irq_out()
465 spin_unlock_irqrestore(&usbhid->lock, flags); in hid_irq_out()
466 usb_autopm_put_interface_async(usbhid->intf); in hid_irq_out()
467 wake_up(&usbhid->wait); in hid_irq_out()
477 struct usbhid_device *usbhid = hid->driver_data; in hid_ctrl() local
483 if (usbhid->ctrl[usbhid->ctrltail].dir == USB_DIR_IN) in hid_ctrl()
485 usbhid->ctrl[usbhid->ctrltail].report->type, in hid_ctrl()
501 spin_lock_irqsave(&usbhid->lock, flags); in hid_ctrl()
504 usbhid->ctrltail = usbhid->ctrlhead; in hid_ctrl()
505 } else if (usbhid->ctrlhead != usbhid->ctrltail) { in hid_ctrl()
506 usbhid->ctrltail = (usbhid->ctrltail + 1) & (HID_CONTROL_FIFO_SIZE - 1); in hid_ctrl()
508 if (usbhid->ctrlhead != usbhid->ctrltail && in hid_ctrl()
511 spin_unlock_irqrestore(&usbhid->lock, flags); in hid_ctrl()
516 clear_bit(HID_CTRL_RUNNING, &usbhid->iofl); in hid_ctrl()
517 spin_unlock_irqrestore(&usbhid->lock, flags); in hid_ctrl()
518 usb_autopm_put_interface_async(usbhid->intf); in hid_ctrl()
519 wake_up(&usbhid->wait); in hid_ctrl()
526 struct usbhid_device *usbhid = hid->driver_data; in __usbhid_submit_report() local
529 test_bit(HID_DISCONNECTED, &usbhid->iofl)) in __usbhid_submit_report()
532 if (usbhid->urbout && dir == USB_DIR_OUT && report->type == HID_OUTPUT_REPORT) { in __usbhid_submit_report()
533 if ((head = (usbhid->outhead + 1) & (HID_OUTPUT_FIFO_SIZE - 1)) == usbhid->outtail) { in __usbhid_submit_report()
538 usbhid->out[usbhid->outhead].raw_report = hid_alloc_report_buf(report, GFP_ATOMIC); in __usbhid_submit_report()
539 if (!usbhid->out[usbhid->outhead].raw_report) { in __usbhid_submit_report()
543 hid_output_report(report, usbhid->out[usbhid->outhead].raw_report); in __usbhid_submit_report()
544 usbhid->out[usbhid->outhead].report = report; in __usbhid_submit_report()
545 usbhid->outhead = head; in __usbhid_submit_report()
548 if (!test_bit(HID_OUT_RUNNING, &usbhid->iofl)) { in __usbhid_submit_report()
549 usbhid_restart_out_queue(usbhid); in __usbhid_submit_report()
552 } else if (time_after(jiffies, usbhid->last_out + HZ * 5)) { in __usbhid_submit_report()
555 usb_autopm_get_interface_no_resume(usbhid->intf); in __usbhid_submit_report()
562 usb_block_urb(usbhid->urbout); in __usbhid_submit_report()
565 spin_unlock(&usbhid->lock); in __usbhid_submit_report()
567 usb_unlink_urb(usbhid->urbout); in __usbhid_submit_report()
568 spin_lock(&usbhid->lock); in __usbhid_submit_report()
569 usb_unblock_urb(usbhid->urbout); in __usbhid_submit_report()
572 if (!test_bit(HID_OUT_RUNNING, &usbhid->iofl)) in __usbhid_submit_report()
573 usbhid_restart_out_queue(usbhid); in __usbhid_submit_report()
576 usb_autopm_put_interface_async(usbhid->intf); in __usbhid_submit_report()
581 if ((head = (usbhid->ctrlhead + 1) & (HID_CONTROL_FIFO_SIZE - 1)) == usbhid->ctrltail) { in __usbhid_submit_report()
587 usbhid->ctrl[usbhid->ctrlhead].raw_report = hid_alloc_report_buf(report, GFP_ATOMIC); in __usbhid_submit_report()
588 if (!usbhid->ctrl[usbhid->ctrlhead].raw_report) { in __usbhid_submit_report()
592 hid_output_report(report, usbhid->ctrl[usbhid->ctrlhead].raw_report); in __usbhid_submit_report()
594 usbhid->ctrl[usbhid->ctrlhead].report = report; in __usbhid_submit_report()
595 usbhid->ctrl[usbhid->ctrlhead].dir = dir; in __usbhid_submit_report()
596 usbhid->ctrlhead = head; in __usbhid_submit_report()
599 if (!test_bit(HID_CTRL_RUNNING, &usbhid->iofl)) { in __usbhid_submit_report()
600 usbhid_restart_ctrl_queue(usbhid); in __usbhid_submit_report()
603 } else if (time_after(jiffies, usbhid->last_ctrl + HZ * 5)) { in __usbhid_submit_report()
606 usb_autopm_get_interface_no_resume(usbhid->intf); in __usbhid_submit_report()
613 usb_block_urb(usbhid->urbctrl); in __usbhid_submit_report()
616 spin_unlock(&usbhid->lock); in __usbhid_submit_report()
618 usb_unlink_urb(usbhid->urbctrl); in __usbhid_submit_report()
619 spin_lock(&usbhid->lock); in __usbhid_submit_report()
620 usb_unblock_urb(usbhid->urbctrl); in __usbhid_submit_report()
623 if (!test_bit(HID_CTRL_RUNNING, &usbhid->iofl)) in __usbhid_submit_report()
624 usbhid_restart_ctrl_queue(usbhid); in __usbhid_submit_report()
627 usb_autopm_put_interface_async(usbhid->intf); in __usbhid_submit_report()
633 struct usbhid_device *usbhid = hid->driver_data; in usbhid_submit_report() local
636 spin_lock_irqsave(&usbhid->lock, flags); in usbhid_submit_report()
638 spin_unlock_irqrestore(&usbhid->lock, flags); in usbhid_submit_report()
643 struct usbhid_device *usbhid = hid->driver_data; in usbhid_wait_io() local
645 if (!wait_event_timeout(usbhid->wait, in usbhid_wait_io()
646 (!test_bit(HID_CTRL_RUNNING, &usbhid->iofl) && in usbhid_wait_io()
647 !test_bit(HID_OUT_RUNNING, &usbhid->iofl)), in usbhid_wait_io()
681 struct usbhid_device *usbhid = hid->driver_data; in usbhid_open() local
684 mutex_lock(&usbhid->mutex); in usbhid_open()
686 set_bit(HID_OPENED, &usbhid->iofl); in usbhid_open()
693 res = usb_autopm_get_interface(usbhid->intf); in usbhid_open()
696 clear_bit(HID_OPENED, &usbhid->iofl); in usbhid_open()
701 usbhid->intf->needs_remote_wakeup = 1; in usbhid_open()
703 set_bit(HID_RESUME_RUNNING, &usbhid->iofl); in usbhid_open()
704 set_bit(HID_IN_POLLING, &usbhid->iofl); in usbhid_open()
714 clear_bit(HID_OPENED, &usbhid->iofl); in usbhid_open()
715 clear_bit(HID_IN_POLLING, &usbhid->iofl); in usbhid_open()
716 usbhid->intf->needs_remote_wakeup = 0; in usbhid_open()
720 usb_autopm_put_interface(usbhid->intf); in usbhid_open()
731 clear_bit(HID_RESUME_RUNNING, &usbhid->iofl); in usbhid_open()
734 mutex_unlock(&usbhid->mutex); in usbhid_open()
740 struct usbhid_device *usbhid = hid->driver_data; in usbhid_close() local
742 mutex_lock(&usbhid->mutex); in usbhid_close()
749 spin_lock_irq(&usbhid->lock); in usbhid_close()
750 clear_bit(HID_OPENED, &usbhid->iofl); in usbhid_close()
752 clear_bit(HID_IN_POLLING, &usbhid->iofl); in usbhid_close()
753 spin_unlock_irq(&usbhid->lock); in usbhid_close()
756 hid_cancel_delayed_stuff(usbhid); in usbhid_close()
757 usb_kill_urb(usbhid->urbin); in usbhid_close()
758 usbhid->intf->needs_remote_wakeup = 0; in usbhid_close()
761 mutex_unlock(&usbhid->mutex); in usbhid_close()
771 struct usbhid_device *usbhid = hid->driver_data; in usbhid_init_reports() local
787 if (test_bit(HID_CTRL_RUNNING, &usbhid->iofl)) in usbhid_init_reports()
788 usb_kill_urb(usbhid->urbctrl); in usbhid_init_reports()
789 if (test_bit(HID_OUT_RUNNING, &usbhid->iofl)) in usbhid_init_reports()
790 usb_kill_urb(usbhid->urbout); in usbhid_init_reports()
854 struct usbhid_device *usbhid = hid->driver_data; in hid_alloc_buffers() local
856 usbhid->inbuf = usb_alloc_coherent(dev, usbhid->bufsize, GFP_KERNEL, in hid_alloc_buffers()
857 &usbhid->inbuf_dma); in hid_alloc_buffers()
858 usbhid->outbuf = usb_alloc_coherent(dev, usbhid->bufsize, GFP_KERNEL, in hid_alloc_buffers()
859 &usbhid->outbuf_dma); in hid_alloc_buffers()
860 usbhid->cr = kmalloc(sizeof(*usbhid->cr), GFP_KERNEL); in hid_alloc_buffers()
861 usbhid->ctrlbuf = usb_alloc_coherent(dev, usbhid->bufsize, GFP_KERNEL, in hid_alloc_buffers()
862 &usbhid->ctrlbuf_dma); in hid_alloc_buffers()
863 if (!usbhid->inbuf || !usbhid->outbuf || !usbhid->cr || in hid_alloc_buffers()
864 !usbhid->ctrlbuf) in hid_alloc_buffers()
874 struct usbhid_device *usbhid = hid->driver_data; in usbhid_get_raw_report() local
876 struct usb_interface *intf = usbhid->intf; in usbhid_get_raw_report()
907 struct usbhid_device *usbhid = hid->driver_data; in usbhid_set_raw_report() local
909 struct usb_interface *intf = usbhid->intf; in usbhid_set_raw_report()
942 struct usbhid_device *usbhid = hid->driver_data; in usbhid_output_report() local
946 if (!usbhid->urbout) in usbhid_output_report()
956 ret = usb_interrupt_msg(dev, usbhid->urbout->pipe, in usbhid_output_report()
972 struct usbhid_device *usbhid = hid->driver_data; in hid_free_buffers() local
974 usb_free_coherent(dev, usbhid->bufsize, usbhid->inbuf, usbhid->inbuf_dma); in hid_free_buffers()
975 usb_free_coherent(dev, usbhid->bufsize, usbhid->outbuf, usbhid->outbuf_dma); in hid_free_buffers()
976 kfree(usbhid->cr); in hid_free_buffers()
977 usb_free_coherent(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma); in hid_free_buffers()
1066 struct usbhid_device *usbhid = hid->driver_data; in usbhid_start() local
1070 mutex_lock(&usbhid->mutex); in usbhid_start()
1072 clear_bit(HID_DISCONNECTED, &usbhid->iofl); in usbhid_start()
1074 usbhid->bufsize = HID_MIN_BUFFER_SIZE; in usbhid_start()
1075 hid_find_max_report(hid, HID_INPUT_REPORT, &usbhid->bufsize); in usbhid_start()
1076 hid_find_max_report(hid, HID_OUTPUT_REPORT, &usbhid->bufsize); in usbhid_start()
1077 hid_find_max_report(hid, HID_FEATURE_REPORT, &usbhid->bufsize); in usbhid_start()
1079 if (usbhid->bufsize > HID_MAX_BUFFER_SIZE) in usbhid_start()
1080 usbhid->bufsize = HID_MAX_BUFFER_SIZE; in usbhid_start()
1131 if (usbhid->urbin) in usbhid_start()
1133 if (!(usbhid->urbin = usb_alloc_urb(0, GFP_KERNEL))) in usbhid_start()
1136 usb_fill_int_urb(usbhid->urbin, dev, pipe, usbhid->inbuf, insize, in usbhid_start()
1138 usbhid->urbin->transfer_dma = usbhid->inbuf_dma; in usbhid_start()
1139 usbhid->urbin->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in usbhid_start()
1141 if (usbhid->urbout) in usbhid_start()
1143 if (!(usbhid->urbout = usb_alloc_urb(0, GFP_KERNEL))) in usbhid_start()
1146 usb_fill_int_urb(usbhid->urbout, dev, pipe, usbhid->outbuf, 0, in usbhid_start()
1148 usbhid->urbout->transfer_dma = usbhid->outbuf_dma; in usbhid_start()
1149 usbhid->urbout->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in usbhid_start()
1153 usbhid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); in usbhid_start()
1154 if (!usbhid->urbctrl) { in usbhid_start()
1159 usb_fill_control_urb(usbhid->urbctrl, dev, 0, (void *) usbhid->cr, in usbhid_start()
1160 usbhid->ctrlbuf, 1, hid_ctrl, hid); in usbhid_start()
1161 usbhid->urbctrl->transfer_dma = usbhid->ctrlbuf_dma; in usbhid_start()
1162 usbhid->urbctrl->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in usbhid_start()
1164 set_bit(HID_STARTED, &usbhid->iofl); in usbhid_start()
1167 ret = usb_autopm_get_interface(usbhid->intf); in usbhid_start()
1170 set_bit(HID_IN_POLLING, &usbhid->iofl); in usbhid_start()
1171 usbhid->intf->needs_remote_wakeup = 1; in usbhid_start()
1177 usb_autopm_put_interface(usbhid->intf); in usbhid_start()
1193 mutex_unlock(&usbhid->mutex); in usbhid_start()
1197 usb_free_urb(usbhid->urbin); in usbhid_start()
1198 usb_free_urb(usbhid->urbout); in usbhid_start()
1199 usb_free_urb(usbhid->urbctrl); in usbhid_start()
1200 usbhid->urbin = NULL; in usbhid_start()
1201 usbhid->urbout = NULL; in usbhid_start()
1202 usbhid->urbctrl = NULL; in usbhid_start()
1204 mutex_unlock(&usbhid->mutex); in usbhid_start()
1210 struct usbhid_device *usbhid = hid->driver_data; in usbhid_stop() local
1212 if (WARN_ON(!usbhid)) in usbhid_stop()
1216 clear_bit(HID_IN_POLLING, &usbhid->iofl); in usbhid_stop()
1217 usbhid->intf->needs_remote_wakeup = 0; in usbhid_stop()
1220 mutex_lock(&usbhid->mutex); in usbhid_stop()
1222 clear_bit(HID_STARTED, &usbhid->iofl); in usbhid_stop()
1224 spin_lock_irq(&usbhid->lock); /* Sync with error and led handlers */ in usbhid_stop()
1225 set_bit(HID_DISCONNECTED, &usbhid->iofl); in usbhid_stop()
1226 while (usbhid->ctrltail != usbhid->ctrlhead) { in usbhid_stop()
1227 if (usbhid->ctrl[usbhid->ctrltail].dir == USB_DIR_OUT) { in usbhid_stop()
1228 kfree(usbhid->ctrl[usbhid->ctrltail].raw_report); in usbhid_stop()
1229 usbhid->ctrl[usbhid->ctrltail].raw_report = NULL; in usbhid_stop()
1232 usbhid->ctrltail = (usbhid->ctrltail + 1) & in usbhid_stop()
1235 spin_unlock_irq(&usbhid->lock); in usbhid_stop()
1237 usb_kill_urb(usbhid->urbin); in usbhid_stop()
1238 usb_kill_urb(usbhid->urbout); in usbhid_stop()
1239 usb_kill_urb(usbhid->urbctrl); in usbhid_stop()
1241 hid_cancel_delayed_stuff(usbhid); in usbhid_stop()
1245 usb_free_urb(usbhid->urbin); in usbhid_stop()
1246 usb_free_urb(usbhid->urbctrl); in usbhid_stop()
1247 usb_free_urb(usbhid->urbout); in usbhid_stop()
1248 usbhid->urbin = NULL; /* don't mess up next start */ in usbhid_stop()
1249 usbhid->urbctrl = NULL; in usbhid_stop()
1250 usbhid->urbout = NULL; in usbhid_stop()
1254 mutex_unlock(&usbhid->mutex); in usbhid_stop()
1259 struct usbhid_device *usbhid = hid->driver_data; in usbhid_power() local
1264 r = usb_autopm_get_interface(usbhid->intf); in usbhid_power()
1268 usb_autopm_put_interface(usbhid->intf); in usbhid_power()
1347 struct usbhid_device *usbhid; in usbhid_probe() local
1414 usbhid = kzalloc(sizeof(*usbhid), GFP_KERNEL); in usbhid_probe()
1415 if (usbhid == NULL) { in usbhid_probe()
1420 hid->driver_data = usbhid; in usbhid_probe()
1421 usbhid->hid = hid; in usbhid_probe()
1422 usbhid->intf = intf; in usbhid_probe()
1423 usbhid->ifnum = interface->desc.bInterfaceNumber; in usbhid_probe()
1425 init_waitqueue_head(&usbhid->wait); in usbhid_probe()
1426 INIT_WORK(&usbhid->reset_work, hid_reset); in usbhid_probe()
1427 timer_setup(&usbhid->io_retry, hid_retry_timeout, 0); in usbhid_probe()
1428 spin_lock_init(&usbhid->lock); in usbhid_probe()
1429 mutex_init(&usbhid->mutex); in usbhid_probe()
1440 kfree(usbhid); in usbhid_probe()
1449 struct usbhid_device *usbhid; in usbhid_disconnect() local
1454 usbhid = hid->driver_data; in usbhid_disconnect()
1455 spin_lock_irq(&usbhid->lock); /* Sync with error and led handlers */ in usbhid_disconnect()
1456 set_bit(HID_DISCONNECTED, &usbhid->iofl); in usbhid_disconnect()
1457 spin_unlock_irq(&usbhid->lock); in usbhid_disconnect()
1459 kfree(usbhid); in usbhid_disconnect()
1462 static void hid_cancel_delayed_stuff(struct usbhid_device *usbhid) in hid_cancel_delayed_stuff() argument
1464 del_timer_sync(&usbhid->io_retry); in hid_cancel_delayed_stuff()
1465 cancel_work_sync(&usbhid->reset_work); in hid_cancel_delayed_stuff()
1468 static void hid_cease_io(struct usbhid_device *usbhid) in hid_cease_io() argument
1470 del_timer_sync(&usbhid->io_retry); in hid_cease_io()
1471 usb_kill_urb(usbhid->urbin); in hid_cease_io()
1472 usb_kill_urb(usbhid->urbctrl); in hid_cease_io()
1473 usb_kill_urb(usbhid->urbout); in hid_cease_io()
1478 struct usbhid_device *usbhid = hid->driver_data; in hid_restart_io() local
1479 int clear_halt = test_bit(HID_CLEAR_HALT, &usbhid->iofl); in hid_restart_io()
1480 int reset_pending = test_bit(HID_RESET_PENDING, &usbhid->iofl); in hid_restart_io()
1482 spin_lock_irq(&usbhid->lock); in hid_restart_io()
1483 clear_bit(HID_SUSPENDED, &usbhid->iofl); in hid_restart_io()
1484 usbhid_mark_busy(usbhid); in hid_restart_io()
1487 schedule_work(&usbhid->reset_work); in hid_restart_io()
1488 usbhid->retry_delay = 0; in hid_restart_io()
1489 spin_unlock_irq(&usbhid->lock); in hid_restart_io()
1491 if (reset_pending || !test_bit(HID_STARTED, &usbhid->iofl)) in hid_restart_io()
1499 spin_lock_irq(&usbhid->lock); in hid_restart_io()
1500 if (usbhid->urbout && !test_bit(HID_OUT_RUNNING, &usbhid->iofl)) in hid_restart_io()
1501 usbhid_restart_out_queue(usbhid); in hid_restart_io()
1502 if (!test_bit(HID_CTRL_RUNNING, &usbhid->iofl)) in hid_restart_io()
1503 usbhid_restart_ctrl_queue(usbhid); in hid_restart_io()
1504 spin_unlock_irq(&usbhid->lock); in hid_restart_io()
1511 struct usbhid_device *usbhid = hid->driver_data; in hid_pre_reset() local
1513 spin_lock_irq(&usbhid->lock); in hid_pre_reset()
1514 set_bit(HID_RESET_PENDING, &usbhid->iofl); in hid_pre_reset()
1515 spin_unlock_irq(&usbhid->lock); in hid_pre_reset()
1516 hid_cease_io(usbhid); in hid_pre_reset()
1526 struct usbhid_device *usbhid = hid->driver_data; in hid_post_reset() local
1556 spin_lock_irq(&usbhid->lock); in hid_post_reset()
1557 clear_bit(HID_RESET_PENDING, &usbhid->iofl); in hid_post_reset()
1558 clear_bit(HID_CLEAR_HALT, &usbhid->iofl); in hid_post_reset()
1559 spin_unlock_irq(&usbhid->lock); in hid_post_reset()
1580 struct usbhid_device *usbhid = hid->driver_data; in hid_suspend() local
1587 spin_lock_irq(&usbhid->lock); /* Sync with error handler */ in hid_suspend()
1588 if (!test_bit(HID_RESET_PENDING, &usbhid->iofl) in hid_suspend()
1589 && !test_bit(HID_CLEAR_HALT, &usbhid->iofl) in hid_suspend()
1590 && !test_bit(HID_OUT_RUNNING, &usbhid->iofl) in hid_suspend()
1591 && !test_bit(HID_CTRL_RUNNING, &usbhid->iofl) in hid_suspend()
1592 && !test_bit(HID_KEYS_PRESSED, &usbhid->iofl) in hid_suspend()
1595 set_bit(HID_SUSPENDED, &usbhid->iofl); in hid_suspend()
1596 spin_unlock_irq(&usbhid->lock); in hid_suspend()
1602 usbhid_mark_busy(usbhid); in hid_suspend()
1603 spin_unlock_irq(&usbhid->lock); in hid_suspend()
1611 spin_lock_irq(&usbhid->lock); in hid_suspend()
1612 set_bit(HID_SUSPENDED, &usbhid->iofl); in hid_suspend()
1613 spin_unlock_irq(&usbhid->lock); in hid_suspend()
1618 hid_cancel_delayed_stuff(usbhid); in hid_suspend()
1619 hid_cease_io(usbhid); in hid_suspend()
1621 if (PMSG_IS_AUTO(message) && test_bit(HID_KEYS_PRESSED, &usbhid->iofl)) { in hid_suspend()
1667 .name = "usbhid",