Lines Matching +full:report +full:- +full:speed +full:- +full:hz

1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
7 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
8 * Copyright (c) 2007-2008 Oliver Neukum
9 * Copyright (c) 2006-2010 Jiri Kosina
35 #include <linux/hid-debug.h>
71 " 0x-prefixed hex");
85 struct usbhid_device *usbhid = hid->driver_data; in hid_start_in()
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()
95 if (rc == -ENOSPC) 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()
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()
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()
132 "clear-halt failed: %d\n", rc); 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()
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()
186 struct usb_interface *intf = usbhid->intf; in usbhid_mark_busy()
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()
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()
274 struct hid_device *hid = urb->context; in hid_irq_in()
275 struct usbhid_device *usbhid = hid->driver_data; in hid_irq_in()
278 switch (urb->status) { in hid_irq_in()
280 usbhid->retry_delay = 0; in hid_irq_in()
281 if (!test_bit(HID_OPENED, &usbhid->iofl)) in hid_irq_in()
284 if (!test_bit(HID_RESUME_RUNNING, &usbhid->iofl)) { in hid_irq_in()
285 hid_input_report(urb->context, HID_INPUT_REPORT, in hid_irq_in()
286 urb->transfer_buffer, in hid_irq_in()
287 urb->actual_length, 1); 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()
299 case -EPIPE: /* stall */ 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()
305 case -ECONNRESET: /* unlink */ in hid_irq_in()
306 case -ENOENT: in hid_irq_in()
307 case -ESHUTDOWN: /* unplug */ in hid_irq_in()
308 clear_bit(HID_IN_RUNNING, &usbhid->iofl); in hid_irq_in()
310 case -EILSEQ: /* protocol error or unplug */ in hid_irq_in()
311 case -EPROTO: /* protocol error or unplug */ in hid_irq_in()
312 case -ETIME: /* protocol error or unplug */ in hid_irq_in()
313 case -ETIMEDOUT: /* Should never happen, but... */ in hid_irq_in()
315 clear_bit(HID_IN_RUNNING, &usbhid->iofl); in hid_irq_in()
319 hid_warn(urb->dev, "input irq status %d received\n", in hid_irq_in()
320 urb->status); in hid_irq_in()
325 clear_bit(HID_IN_RUNNING, &usbhid->iofl); in hid_irq_in()
326 if (status != -EPERM) { in hid_irq_in()
327 hid_err(hid, "can't resubmit intr, %s-%s/input%d, status %d\n", in hid_irq_in()
328 hid_to_usb_dev(hid)->bus->bus_name, in hid_irq_in()
329 hid_to_usb_dev(hid)->devpath, in hid_irq_in()
330 usbhid->ifnum, status); in hid_irq_in()
338 struct hid_report *report; in hid_submit_out() local
340 struct usbhid_device *usbhid = hid->driver_data; in hid_submit_out()
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()
368 struct hid_report *report; in hid_submit_ctrl() local
372 struct usbhid_device *usbhid = hid->driver_data; in hid_submit_ctrl()
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()
378 len = hid_report_len(report); 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()
392 len += (len == 0); /* Don't allow 0-length reports */ 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()
404 report->id); 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()
428 struct hid_device *hid = urb->context; in hid_irq_out()
429 struct usbhid_device *usbhid = hid->driver_data; in hid_irq_out()
433 switch (urb->status) { in hid_irq_out()
436 case -ESHUTDOWN: /* unplug */ in hid_irq_out()
439 case -EILSEQ: /* protocol error or unplug */ in hid_irq_out()
440 case -EPROTO: /* protocol error or unplug */ in hid_irq_out()
441 case -ECONNRESET: /* unlink */ in hid_irq_out()
442 case -ENOENT: in hid_irq_out()
445 hid_warn(urb->dev, "output irq status %d received\n", in hid_irq_out()
446 urb->status); in hid_irq_out()
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()
476 struct hid_device *hid = urb->context; in hid_ctrl()
477 struct usbhid_device *usbhid = hid->driver_data; in hid_ctrl()
479 int unplug = 0, status = urb->status; in hid_ctrl()
483 if (usbhid->ctrl[usbhid->ctrltail].dir == USB_DIR_IN) in hid_ctrl()
484 hid_input_report(urb->context, in hid_ctrl()
485 usbhid->ctrl[usbhid->ctrltail].report->type, in hid_ctrl()
486 urb->transfer_buffer, urb->actual_length, 0); in hid_ctrl()
488 case -ESHUTDOWN: /* unplug */ in hid_ctrl()
491 case -EILSEQ: /* protocol error or unplug */ in hid_ctrl()
492 case -EPROTO: /* protocol error or unplug */ in hid_ctrl()
493 case -ECONNRESET: /* unlink */ in hid_ctrl()
494 case -ENOENT: in hid_ctrl()
495 case -EPIPE: /* report not available */ in hid_ctrl()
498 hid_warn(urb->dev, "ctrl urb status %d received\n", status); 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()
522 static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *report, in __usbhid_submit_report() argument
526 struct usbhid_device *usbhid = hid->driver_data; in __usbhid_submit_report()
528 if (((hid->quirks & HID_QUIRK_NOGET) && dir == USB_DIR_IN) || in __usbhid_submit_report()
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()
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()
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()
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()
627 usb_autopm_put_interface_async(usbhid->intf); in __usbhid_submit_report()
631 static void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char d… in usbhid_submit_report() argument
633 struct usbhid_device *usbhid = hid->driver_data; in usbhid_submit_report()
636 spin_lock_irqsave(&usbhid->lock, flags); in usbhid_submit_report()
637 __usbhid_submit_report(hid, report, dir); 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()
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()
648 10*HZ)) { in usbhid_wait_io()
650 return -1; in usbhid_wait_io()
656 static int hid_set_idle(struct usb_device *dev, int ifnum, int report, int idle) in hid_set_idle() argument
659 HID_REQ_SET_IDLE, USB_TYPE_CLASS | USB_RECIP_INTERFACE, (idle << 8) | report, in hid_set_idle()
674 retries--; in hid_get_class_descriptor()
681 struct usbhid_device *usbhid = hid->driver_data; in usbhid_open()
684 mutex_lock(&usbhid->mutex); in usbhid_open()
686 set_bit(HID_OPENED, &usbhid->iofl); in usbhid_open()
688 if (hid->quirks & HID_QUIRK_ALWAYS_POLL) { in usbhid_open()
693 res = usb_autopm_get_interface(usbhid->intf); in usbhid_open()
696 clear_bit(HID_OPENED, &usbhid->iofl); in usbhid_open()
697 res = -EIO; 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()
708 if (res != -ENOSPC) { in usbhid_open()
713 res = -EBUSY; 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()
724 * some are released when the device is re-opened. 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()
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()
751 if (!(hid->quirks & HID_QUIRK_ALWAYS_POLL)) in usbhid_close()
752 clear_bit(HID_IN_POLLING, &usbhid->iofl); in usbhid_close()
753 spin_unlock_irq(&usbhid->lock); in usbhid_close()
755 if (!(hid->quirks & HID_QUIRK_ALWAYS_POLL)) { 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()
770 struct hid_report *report; in usbhid_init_reports() local
771 struct usbhid_device *usbhid = hid->driver_data; in usbhid_init_reports()
775 report_enum = &hid->report_enum[HID_INPUT_REPORT]; in usbhid_init_reports()
776 list_for_each_entry(report, &report_enum->report_list, list) in usbhid_init_reports()
777 usbhid_submit_report(hid, report, USB_DIR_IN); in usbhid_init_reports()
779 report_enum = &hid->report_enum[HID_FEATURE_REPORT]; in usbhid_init_reports()
780 list_for_each_entry(report, &report_enum->report_list, list) in usbhid_init_reports()
781 usbhid_submit_report(hid, report, USB_DIR_IN); in usbhid_init_reports()
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()
804 struct hid_report *report; in hid_find_field_early() local
809 list_for_each_entry(report, &hid->report_enum[HID_OUTPUT_REPORT].report_list, list) { in hid_find_field_early()
810 for (i = 0; i < report->maxfield; i++) { in hid_find_field_early()
811 field = report->field[i]; in hid_find_field_early()
812 for (j = 0; j < field->maxusage; j++) { in hid_find_field_early()
813 usage = &field->usage[j]; in hid_find_field_early()
814 if ((usage->hid & HID_USAGE_PAGE) == page && in hid_find_field_early()
815 (usage->hid & 0xFFFF) == hid_code) { in hid_find_field_early()
822 return -1; in hid_find_field_early()
830 if ((offset = hid_find_field_early(hid, HID_UP_LED, 0x01, &field)) != -1) { in usbhid_set_leds()
832 usbhid_submit_report(hid, field->report, USB_DIR_OUT); in usbhid_set_leds()
842 struct hid_report *report; in hid_find_max_report() local
845 list_for_each_entry(report, &hid->report_enum[type].report_list, list) { in hid_find_max_report()
846 size = ((report->size - 1) >> 3) + 1 + hid->report_enum[type].numbered; in hid_find_max_report()
854 struct usbhid_device *usbhid = hid->driver_data; in hid_alloc_buffers()
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()
865 return -1; in hid_alloc_buffers()
874 struct usbhid_device *usbhid = hid->driver_data; in usbhid_get_raw_report()
876 struct usb_interface *intf = usbhid->intf; in usbhid_get_raw_report()
877 struct usb_host_interface *interface = intf->cur_altsetting; in usbhid_get_raw_report()
881 /* Byte 0 is the report number. Report data starts at byte 1.*/ in usbhid_get_raw_report()
884 /* Offset the return buffer by 1, so that the report ID in usbhid_get_raw_report()
887 count--; in usbhid_get_raw_report()
894 interface->desc.bInterfaceNumber, buf, count, in usbhid_get_raw_report()
897 /* count also the report id */ in usbhid_get_raw_report()
907 struct usbhid_device *usbhid = hid->driver_data; in usbhid_set_raw_report()
909 struct usb_interface *intf = usbhid->intf; in usbhid_set_raw_report()
910 struct usb_host_interface *interface = intf->cur_altsetting; in usbhid_set_raw_report()
913 /* Byte 0 is the report number. Report data starts at byte 1.*/ in usbhid_set_raw_report()
915 (hid->quirks & HID_QUIRK_SKIP_OUTPUT_REPORT_ID)) in usbhid_set_raw_report()
921 /* Don't send the Report ID */ in usbhid_set_raw_report()
923 count--; in usbhid_set_raw_report()
931 interface->desc.bInterfaceNumber, buf, count, in usbhid_set_raw_report()
933 /* count also the report id, if this was a numbered report. */ in usbhid_set_raw_report()
942 struct usbhid_device *usbhid = hid->driver_data; in usbhid_output_report()
946 if (!usbhid->urbout) in usbhid_output_report()
947 return -ENOSYS; in usbhid_output_report()
950 /* Don't send the Report ID */ in usbhid_output_report()
952 count--; in usbhid_output_report()
956 ret = usb_interrupt_msg(dev, usbhid->urbout->pipe, in usbhid_output_report()
962 /* count also the report id */ in usbhid_output_report()
972 struct usbhid_device *usbhid = hid->driver_data; in hid_free_buffers()
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()
982 struct usb_interface *intf = to_usb_interface(hid->dev.parent); in usbhid_parse()
983 struct usb_host_interface *interface = intf->cur_altsetting; in usbhid_parse()
996 return -ENODEV; in usbhid_parse()
1000 if (interface->desc.bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) { in usbhid_parse()
1001 if (interface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_KEYBOARD || in usbhid_parse()
1002 interface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE) in usbhid_parse()
1007 (!interface->desc.bNumEndpoints || in usbhid_parse()
1008 usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { in usbhid_parse()
1010 return -ENODEV; in usbhid_parse()
1013 if (hdesc->bLength < sizeof(struct hid_descriptor)) { in usbhid_parse()
1015 return -EINVAL; in usbhid_parse()
1018 hid->version = le16_to_cpu(hdesc->bcdHID); in usbhid_parse()
1019 hid->country = hdesc->bCountryCode; in usbhid_parse()
1021 num_descriptors = min_t(int, hdesc->bNumDescriptors, in usbhid_parse()
1022 (hdesc->bLength - offset) / sizeof(struct hid_class_descriptor)); in usbhid_parse()
1025 if (hdesc->desc[n].bDescriptorType == HID_DT_REPORT) in usbhid_parse()
1026 rsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength); in usbhid_parse()
1029 dbg_hid("weird size of report descriptor (%u)\n", rsize); in usbhid_parse()
1030 return -EINVAL; in usbhid_parse()
1035 return -ENOMEM; in usbhid_parse()
1037 hid_set_idle(dev, interface->desc.bInterfaceNumber, 0, 0); in usbhid_parse()
1039 ret = hid_get_class_descriptor(dev, interface->desc.bInterfaceNumber, in usbhid_parse()
1042 dbg_hid("reading report descriptor failed\n"); in usbhid_parse()
1050 dbg_hid("parsing report descriptor failed\n"); in usbhid_parse()
1054 hid->quirks |= quirks; in usbhid_parse()
1063 struct usb_interface *intf = to_usb_interface(hid->dev.parent); in usbhid_start()
1064 struct usb_host_interface *interface = intf->cur_altsetting; in usbhid_start()
1066 struct usbhid_device *usbhid = hid->driver_data; in usbhid_start()
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()
1088 ret = -ENOMEM; in usbhid_start()
1092 for (n = 0; n < interface->desc.bNumEndpoints; n++) { in usbhid_start()
1097 endpoint = &interface->endpoint[n].desc; in usbhid_start()
1101 interval = endpoint->bInterval; in usbhid_start()
1104 if (hid->quirks & HID_QUIRK_FULLSPEED_INTERVAL && in usbhid_start()
1105 dev->speed == USB_SPEED_HIGH) { in usbhid_start()
1106 interval = fls(endpoint->bInterval*8); in usbhid_start()
1107 pr_info("%s: Fixing fullspeed to highspeed interval: %d -> %d\n", in usbhid_start()
1108 hid->name, endpoint->bInterval, interval); in usbhid_start()
1114 switch (hid->collection->usage) { in usbhid_start()
1129 ret = -ENOMEM; in usbhid_start()
1131 if (usbhid->urbin) in usbhid_start()
1133 if (!(usbhid->urbin = usb_alloc_urb(0, GFP_KERNEL))) in usbhid_start()
1135 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 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()
1145 pipe = usb_sndintpipe(dev, endpoint->bEndpointAddress); 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()
1155 ret = -ENOMEM; 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()
1166 if (hid->quirks & HID_QUIRK_ALWAYS_POLL) { 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()
1174 dev_err(&hid->dev, in usbhid_start()
1177 usb_autopm_put_interface(usbhid->intf); in usbhid_start()
1186 if (interface->desc.bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT && in usbhid_start()
1187 interface->desc.bInterfaceProtocol == in usbhid_start()
1190 device_set_wakeup_enable(&dev->dev, 1); 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()
1215 if (hid->quirks & HID_QUIRK_ALWAYS_POLL) { 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()
1233 (HID_CONTROL_FIFO_SIZE - 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()
1243 hid->claimed = 0; 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()
1264 r = usb_autopm_get_interface(usbhid->intf); in usbhid_power()
1268 usb_autopm_put_interface(usbhid->intf); in usbhid_power()
1297 return -EIO; in usbhid_raw_request()
1301 static int usbhid_idle(struct hid_device *hid, int report, int idle, in usbhid_idle() argument
1305 struct usb_interface *intf = to_usb_interface(hid->dev.parent); in usbhid_idle()
1306 struct usb_host_interface *interface = intf->cur_altsetting; in usbhid_idle()
1307 int ifnum = interface->desc.bInterfaceNumber; in usbhid_idle()
1310 return -EINVAL; in usbhid_idle()
1312 return hid_set_idle(dev, ifnum, report, idle); in usbhid_idle()
1319 return device_may_wakeup(&dev->dev); in usbhid_may_wakeup()
1339 return hdev->ll_driver == &usb_hid_driver; in hid_is_usb()
1345 struct usb_host_interface *interface = intf->cur_altsetting; in usbhid_probe()
1354 intf->altsetting->desc.bInterfaceNumber); in usbhid_probe()
1356 for (n = 0; n < interface->desc.bNumEndpoints; n++) in usbhid_probe()
1357 if (usb_endpoint_is_int_in(&interface->endpoint[n].desc)) in usbhid_probe()
1361 return -ENODEV; in usbhid_probe()
1369 hid->ll_driver = &usb_hid_driver; in usbhid_probe()
1370 hid->ff_init = hid_pidff_init; in usbhid_probe()
1372 hid->hiddev_connect = hiddev_connect; in usbhid_probe()
1373 hid->hiddev_disconnect = hiddev_disconnect; in usbhid_probe()
1374 hid->hiddev_hid_event = hiddev_hid_event; in usbhid_probe()
1375 hid->hiddev_report_event = hiddev_report_event; in usbhid_probe()
1377 hid->dev.parent = &intf->dev; in usbhid_probe()
1378 device_set_node(&hid->dev, dev_fwnode(&intf->dev)); in usbhid_probe()
1379 hid->bus = BUS_USB; in usbhid_probe()
1380 hid->vendor = le16_to_cpu(dev->descriptor.idVendor); in usbhid_probe()
1381 hid->product = le16_to_cpu(dev->descriptor.idProduct); in usbhid_probe()
1382 hid->version = le16_to_cpu(dev->descriptor.bcdDevice); in usbhid_probe()
1383 hid->name[0] = 0; in usbhid_probe()
1384 if (intf->cur_altsetting->desc.bInterfaceProtocol == in usbhid_probe()
1386 hid->type = HID_TYPE_USBMOUSE; in usbhid_probe()
1387 else if (intf->cur_altsetting->desc.bInterfaceProtocol == 0) in usbhid_probe()
1388 hid->type = HID_TYPE_USBNONE; in usbhid_probe()
1390 if (dev->manufacturer) in usbhid_probe()
1391 strscpy(hid->name, dev->manufacturer, sizeof(hid->name)); in usbhid_probe()
1393 if (dev->product) { in usbhid_probe()
1394 if (dev->manufacturer) in usbhid_probe()
1395 strlcat(hid->name, " ", sizeof(hid->name)); in usbhid_probe()
1396 strlcat(hid->name, dev->product, sizeof(hid->name)); in usbhid_probe()
1399 if (!strlen(hid->name)) in usbhid_probe()
1400 snprintf(hid->name, sizeof(hid->name), "HID %04x:%04x", in usbhid_probe()
1401 le16_to_cpu(dev->descriptor.idVendor), in usbhid_probe()
1402 le16_to_cpu(dev->descriptor.idProduct)); in usbhid_probe()
1404 usb_make_path(dev, hid->phys, sizeof(hid->phys)); in usbhid_probe()
1405 strlcat(hid->phys, "/input", sizeof(hid->phys)); in usbhid_probe()
1406 len = strlen(hid->phys); in usbhid_probe()
1407 if (len < sizeof(hid->phys) - 1) in usbhid_probe()
1408 snprintf(hid->phys + len, sizeof(hid->phys) - len, in usbhid_probe()
1409 "%d", intf->altsetting[0].desc.bInterfaceNumber); in usbhid_probe()
1411 if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) in usbhid_probe()
1412 hid->uniq[0] = 0; in usbhid_probe()
1416 ret = -ENOMEM; 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()
1433 if (ret != -ENODEV) in usbhid_probe()
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()
1464 del_timer_sync(&usbhid->io_retry); in hid_cancel_delayed_stuff()
1465 cancel_work_sync(&usbhid->reset_work); in hid_cancel_delayed_stuff()
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()
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()
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()
1502 if (!test_bit(HID_CTRL_RUNNING, &usbhid->iofl)) 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()
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()
1526 struct usbhid_device *usbhid = hid->driver_data; in hid_post_reset()
1527 struct usb_host_interface *interface = intf->cur_altsetting; in hid_post_reset()
1531 /* Fetch and examine the HID report descriptor. If this in hid_post_reset()
1534 * the size of the HID report descriptor has not changed. in hid_post_reset()
1536 rdesc = kmalloc(hid->dev_rsize, GFP_KERNEL); in hid_post_reset()
1538 return -ENOMEM; in hid_post_reset()
1541 interface->desc.bInterfaceNumber, in hid_post_reset()
1542 HID_DT_REPORT, rdesc, hid->dev_rsize); in hid_post_reset()
1544 dbg_hid("reading report descriptor failed (post_reset)\n"); in hid_post_reset()
1548 status = memcmp(rdesc, hid->dev_rdesc, hid->dev_rsize); in hid_post_reset()
1551 dbg_hid("report descriptor changed\n"); in hid_post_reset()
1552 return -EPERM; in hid_post_reset()
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()
1560 hid_set_idle(dev, intf->cur_altsetting->desc.bInterfaceNumber, 0, 0); in hid_post_reset()
1580 struct usbhid_device *usbhid = hid->driver_data; in hid_suspend()
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()
1603 spin_unlock_irq(&usbhid->lock); in hid_suspend()
1604 return -EBUSY; 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()
1615 status = -EIO; in hid_suspend()
1621 if (PMSG_IS_AUTO(message) && test_bit(HID_KEYS_PRESSED, &usbhid->iofl)) { in hid_suspend()
1623 status = -EBUSY; in hid_suspend()
1626 dev_dbg(&intf->dev, "suspend\n"); in hid_suspend()
1640 dev_dbg(&intf->dev, "resume status %d\n", status); in hid_resume()