Lines Matching refs:hidg
246 struct f_hidg *hidg = file->private_data; in f_hidg_read() local
258 spin_lock_irqsave(&hidg->read_spinlock, flags); in f_hidg_read()
260 #define READ_COND (!list_empty(&hidg->completed_out_req)) in f_hidg_read()
264 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in f_hidg_read()
268 if (wait_event_interruptible(hidg->read_queue, READ_COND)) in f_hidg_read()
271 spin_lock_irqsave(&hidg->read_spinlock, flags); in f_hidg_read()
275 list = list_first_entry(&hidg->completed_out_req, in f_hidg_read()
286 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in f_hidg_read()
301 req->length = hidg->report_length; in f_hidg_read()
302 ret = usb_ep_queue(hidg->out_ep, req, GFP_KERNEL); in f_hidg_read()
304 free_ep_req(hidg->out_ep, req); in f_hidg_read()
308 spin_lock_irqsave(&hidg->read_spinlock, flags); in f_hidg_read()
309 list_add(&list->list, &hidg->completed_out_req); in f_hidg_read()
310 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in f_hidg_read()
312 wake_up(&hidg->read_queue); in f_hidg_read()
320 struct f_hidg *hidg = (struct f_hidg *)ep->driver_data; in f_hidg_req_complete() local
324 ERROR(hidg->func.config->cdev, in f_hidg_req_complete()
328 spin_lock_irqsave(&hidg->write_spinlock, flags); in f_hidg_req_complete()
329 hidg->write_pending = 0; in f_hidg_req_complete()
330 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_req_complete()
331 wake_up(&hidg->write_queue); in f_hidg_req_complete()
337 struct f_hidg *hidg = file->private_data; in f_hidg_write() local
345 spin_lock_irqsave(&hidg->write_spinlock, flags); in f_hidg_write()
347 #define WRITE_COND (!hidg->write_pending) in f_hidg_write()
351 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_write()
356 hidg->write_queue, WRITE_COND)) in f_hidg_write()
359 spin_lock_irqsave(&hidg->write_spinlock, flags); in f_hidg_write()
362 hidg->write_pending = 1; in f_hidg_write()
363 req = hidg->req; in f_hidg_write()
364 count = min_t(unsigned, count, hidg->report_length); in f_hidg_write()
366 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_write()
370 ERROR(hidg->func.config->cdev, in f_hidg_write()
376 spin_lock_irqsave(&hidg->write_spinlock, flags); in f_hidg_write()
379 if (!hidg->req) { in f_hidg_write()
380 free_ep_req(hidg->in_ep, req); in f_hidg_write()
392 req->context = hidg; in f_hidg_write()
394 status = usb_ep_queue(hidg->in_ep, req, GFP_ATOMIC); in f_hidg_write()
396 ERROR(hidg->func.config->cdev, in f_hidg_write()
402 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_write()
406 spin_lock_irqsave(&hidg->write_spinlock, flags); in f_hidg_write()
408 hidg->write_pending = 0; in f_hidg_write()
409 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_write()
411 wake_up(&hidg->write_queue); in f_hidg_write()
418 struct f_hidg *hidg = file->private_data; in f_hidg_poll() local
421 poll_wait(file, &hidg->read_queue, wait); in f_hidg_poll()
422 poll_wait(file, &hidg->write_queue, wait); in f_hidg_poll()
444 struct f_hidg *hidg = in f_hidg_open() local
447 fd->private_data = hidg; in f_hidg_open()
463 struct f_hidg *hidg = (struct f_hidg *) req->context; in hidg_set_report_complete() local
464 struct usb_composite_dev *cdev = hidg->func.config->cdev; in hidg_set_report_complete()
478 spin_lock_irqsave(&hidg->read_spinlock, flags); in hidg_set_report_complete()
479 list_add_tail(&req_list->list, &hidg->completed_out_req); in hidg_set_report_complete()
480 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in hidg_set_report_complete()
482 wake_up(&hidg->read_queue); in hidg_set_report_complete()
499 struct f_hidg *hidg = func_to_hidg(f); in hidg_setup() local
518 length = min_t(unsigned, length, hidg->report_length); in hidg_setup()
528 ((u8 *) req->buf)[0] = hidg->protocol; in hidg_setup()
548 if (hidg->bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) { in hidg_setup()
549 hidg->protocol = value; in hidg_setup()
565 cpu_to_le16(hidg->report_desc_length); in hidg_setup()
576 hidg->report_desc_length); in hidg_setup()
577 memcpy(req->buf, hidg->report_desc, length); in hidg_setup()
610 struct f_hidg *hidg = func_to_hidg(f); in hidg_disable() local
614 usb_ep_disable(hidg->in_ep); in hidg_disable()
615 usb_ep_disable(hidg->out_ep); in hidg_disable()
617 spin_lock_irqsave(&hidg->read_spinlock, flags); in hidg_disable()
618 list_for_each_entry_safe(list, next, &hidg->completed_out_req, list) { in hidg_disable()
619 free_ep_req(hidg->out_ep, list->req); in hidg_disable()
623 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in hidg_disable()
625 spin_lock_irqsave(&hidg->write_spinlock, flags); in hidg_disable()
626 if (!hidg->write_pending) { in hidg_disable()
627 free_ep_req(hidg->in_ep, hidg->req); in hidg_disable()
628 hidg->write_pending = 1; in hidg_disable()
631 hidg->req = NULL; in hidg_disable()
632 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in hidg_disable()
638 struct f_hidg *hidg = func_to_hidg(f); in hidg_set_alt() local
645 if (hidg->in_ep != NULL) { in hidg_set_alt()
647 usb_ep_disable(hidg->in_ep); in hidg_set_alt()
650 hidg->in_ep); in hidg_set_alt()
655 status = usb_ep_enable(hidg->in_ep); in hidg_set_alt()
660 hidg->in_ep->driver_data = hidg; in hidg_set_alt()
662 req_in = hidg_alloc_ep_req(hidg->in_ep, hidg->report_length); in hidg_set_alt()
670 if (hidg->out_ep != NULL) { in hidg_set_alt()
672 usb_ep_disable(hidg->out_ep); in hidg_set_alt()
675 hidg->out_ep); in hidg_set_alt()
680 status = usb_ep_enable(hidg->out_ep); in hidg_set_alt()
685 hidg->out_ep->driver_data = hidg; in hidg_set_alt()
690 for (i = 0; i < hidg->qlen && status == 0; i++) { in hidg_set_alt()
692 hidg_alloc_ep_req(hidg->out_ep, in hidg_set_alt()
693 hidg->report_length); in hidg_set_alt()
696 req->context = hidg; in hidg_set_alt()
697 status = usb_ep_queue(hidg->out_ep, req, in hidg_set_alt()
701 hidg->out_ep->name, status); in hidg_set_alt()
702 free_ep_req(hidg->out_ep, req); in hidg_set_alt()
711 if (hidg->in_ep != NULL) { in hidg_set_alt()
712 spin_lock_irqsave(&hidg->write_spinlock, flags); in hidg_set_alt()
713 hidg->req = req_in; in hidg_set_alt()
714 hidg->write_pending = 0; in hidg_set_alt()
715 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in hidg_set_alt()
717 wake_up(&hidg->write_queue); in hidg_set_alt()
721 usb_ep_disable(hidg->out_ep); in hidg_set_alt()
724 free_ep_req(hidg->in_ep, req_in); in hidg_set_alt()
727 if (hidg->in_ep) in hidg_set_alt()
728 usb_ep_disable(hidg->in_ep); in hidg_set_alt()
747 struct f_hidg *hidg = func_to_hidg(f); in hidg_bind() local
771 hidg->in_ep = ep; in hidg_bind()
776 hidg->out_ep = ep; in hidg_bind()
779 hidg_interface_desc.bInterfaceSubClass = hidg->bInterfaceSubClass; in hidg_bind()
780 hidg_interface_desc.bInterfaceProtocol = hidg->bInterfaceProtocol; in hidg_bind()
781 hidg->protocol = HID_REPORT_PROTOCOL; in hidg_bind()
782 hidg_ss_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
784 cpu_to_le16(hidg->report_length); in hidg_bind()
785 hidg_hs_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
786 hidg_fs_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
787 hidg_ss_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
789 cpu_to_le16(hidg->report_length); in hidg_bind()
790 hidg_hs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
791 hidg_fs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
798 cpu_to_le16(hidg->report_desc_length); in hidg_bind()
815 spin_lock_init(&hidg->write_spinlock); in hidg_bind()
816 hidg->write_pending = 1; in hidg_bind()
817 hidg->req = NULL; in hidg_bind()
818 spin_lock_init(&hidg->read_spinlock); in hidg_bind()
819 init_waitqueue_head(&hidg->write_queue); in hidg_bind()
820 init_waitqueue_head(&hidg->read_queue); in hidg_bind()
821 INIT_LIST_HEAD(&hidg->completed_out_req); in hidg_bind()
824 cdev_init(&hidg->cdev, &f_hidg_fops); in hidg_bind()
825 dev = MKDEV(major, hidg->minor); in hidg_bind()
826 status = cdev_add(&hidg->cdev, dev, 1); in hidg_bind()
831 "%s%d", "hidg", hidg->minor); in hidg_bind()
839 cdev_del(&hidg->cdev); in hidg_bind()
844 if (hidg->req != NULL) in hidg_bind()
845 free_ep_req(hidg->in_ep, hidg->req); in hidg_bind()
1063 struct f_hidg *hidg; in hidg_free() local
1066 hidg = func_to_hidg(f); in hidg_free()
1068 kfree(hidg->report_desc); in hidg_free()
1069 kfree(hidg); in hidg_free()
1077 struct f_hidg *hidg = func_to_hidg(f); in hidg_unbind() local
1079 device_destroy(hidg_class, MKDEV(major, hidg->minor)); in hidg_unbind()
1080 cdev_del(&hidg->cdev); in hidg_unbind()
1087 struct f_hidg *hidg; in hidg_alloc() local
1091 hidg = kzalloc(sizeof(*hidg), GFP_KERNEL); in hidg_alloc()
1092 if (!hidg) in hidg_alloc()
1100 hidg->minor = opts->minor; in hidg_alloc()
1101 hidg->bInterfaceSubClass = opts->subclass; in hidg_alloc()
1102 hidg->bInterfaceProtocol = opts->protocol; in hidg_alloc()
1103 hidg->report_length = opts->report_length; in hidg_alloc()
1104 hidg->report_desc_length = opts->report_desc_length; in hidg_alloc()
1106 hidg->report_desc = kmemdup(opts->report_desc, in hidg_alloc()
1109 if (!hidg->report_desc) { in hidg_alloc()
1110 kfree(hidg); in hidg_alloc()
1118 hidg->func.name = "hid"; in hidg_alloc()
1119 hidg->func.bind = hidg_bind; in hidg_alloc()
1120 hidg->func.unbind = hidg_unbind; in hidg_alloc()
1121 hidg->func.set_alt = hidg_set_alt; in hidg_alloc()
1122 hidg->func.disable = hidg_disable; in hidg_alloc()
1123 hidg->func.setup = hidg_setup; in hidg_alloc()
1124 hidg->func.free_func = hidg_free; in hidg_alloc()
1127 hidg->qlen = 4; in hidg_alloc()
1129 return &hidg->func; in hidg_alloc()