Lines Matching refs:hidg

282 	struct f_hidg *hidg = file->private_data;  in f_hidg_intout_read()  local
291 spin_lock_irqsave(&hidg->read_spinlock, flags); in f_hidg_intout_read()
293 #define READ_COND_INTOUT (!list_empty(&hidg->completed_out_req)) in f_hidg_intout_read()
297 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in f_hidg_intout_read()
301 if (wait_event_interruptible(hidg->read_queue, READ_COND_INTOUT)) in f_hidg_intout_read()
304 spin_lock_irqsave(&hidg->read_spinlock, flags); in f_hidg_intout_read()
308 list = list_first_entry(&hidg->completed_out_req, in f_hidg_intout_read()
319 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in f_hidg_intout_read()
334 req->length = hidg->report_length; in f_hidg_intout_read()
335 ret = usb_ep_queue(hidg->out_ep, req, GFP_KERNEL); in f_hidg_intout_read()
337 free_ep_req(hidg->out_ep, req); in f_hidg_intout_read()
341 spin_lock_irqsave(&hidg->read_spinlock, flags); in f_hidg_intout_read()
342 list_add(&list->list, &hidg->completed_out_req); in f_hidg_intout_read()
343 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in f_hidg_intout_read()
345 wake_up(&hidg->read_queue); in f_hidg_intout_read()
351 #define READ_COND_SSREPORT (hidg->set_report_buf != NULL)
356 struct f_hidg *hidg = file->private_data; in f_hidg_ssreport_read() local
363 spin_lock_irqsave(&hidg->read_spinlock, flags); in f_hidg_ssreport_read()
366 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in f_hidg_ssreport_read()
370 if (wait_event_interruptible(hidg->read_queue, READ_COND_SSREPORT)) in f_hidg_ssreport_read()
373 spin_lock_irqsave(&hidg->read_spinlock, flags); in f_hidg_ssreport_read()
376 count = min_t(unsigned int, count, hidg->set_report_length); in f_hidg_ssreport_read()
377 tmp_buf = hidg->set_report_buf; in f_hidg_ssreport_read()
378 hidg->set_report_buf = NULL; in f_hidg_ssreport_read()
380 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in f_hidg_ssreport_read()
389 wake_up(&hidg->read_queue); in f_hidg_ssreport_read()
397 struct f_hidg *hidg = file->private_data; in f_hidg_read() local
399 if (hidg->use_out_ep) in f_hidg_read()
407 struct f_hidg *hidg = (struct f_hidg *)ep->driver_data; in f_hidg_req_complete() local
411 ERROR(hidg->func.config->cdev, in f_hidg_req_complete()
415 spin_lock_irqsave(&hidg->write_spinlock, flags); in f_hidg_req_complete()
416 hidg->write_pending = 0; in f_hidg_req_complete()
417 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_req_complete()
418 wake_up(&hidg->write_queue); in f_hidg_req_complete()
424 struct f_hidg *hidg = file->private_data; in f_hidg_write() local
429 spin_lock_irqsave(&hidg->write_spinlock, flags); in f_hidg_write()
431 if (!hidg->req) { in f_hidg_write()
432 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_write()
436 #define WRITE_COND (!hidg->write_pending) in f_hidg_write()
440 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_write()
445 hidg->write_queue, WRITE_COND)) in f_hidg_write()
448 spin_lock_irqsave(&hidg->write_spinlock, flags); in f_hidg_write()
451 hidg->write_pending = 1; in f_hidg_write()
452 req = hidg->req; in f_hidg_write()
453 count = min_t(unsigned, count, hidg->report_length); in f_hidg_write()
455 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_write()
458 ERROR(hidg->func.config->cdev, "hidg->req is NULL\n"); in f_hidg_write()
465 ERROR(hidg->func.config->cdev, in f_hidg_write()
471 spin_lock_irqsave(&hidg->write_spinlock, flags); in f_hidg_write()
474 if (!hidg->req) { in f_hidg_write()
475 free_ep_req(hidg->in_ep, req); in f_hidg_write()
487 req->context = hidg; in f_hidg_write()
489 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_write()
491 if (!hidg->in_ep->enabled) { in f_hidg_write()
492 ERROR(hidg->func.config->cdev, "in_ep is disabled\n"); in f_hidg_write()
497 status = usb_ep_queue(hidg->in_ep, req, GFP_ATOMIC); in f_hidg_write()
505 spin_lock_irqsave(&hidg->write_spinlock, flags); in f_hidg_write()
506 hidg->write_pending = 0; in f_hidg_write()
507 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_write()
509 wake_up(&hidg->write_queue); in f_hidg_write()
516 struct f_hidg *hidg = file->private_data; in f_hidg_poll() local
519 poll_wait(file, &hidg->read_queue, wait); in f_hidg_poll()
520 poll_wait(file, &hidg->write_queue, wait); in f_hidg_poll()
525 if (hidg->use_out_ep) { in f_hidg_poll()
548 struct f_hidg *hidg = in f_hidg_open() local
551 fd->private_data = hidg; in f_hidg_open()
567 struct f_hidg *hidg = (struct f_hidg *) req->context; in hidg_intout_complete() local
568 struct usb_composite_dev *cdev = hidg->func.config->cdev; in hidg_intout_complete()
582 spin_lock_irqsave(&hidg->read_spinlock, flags); in hidg_intout_complete()
583 list_add_tail(&req_list->list, &hidg->completed_out_req); in hidg_intout_complete()
584 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in hidg_intout_complete()
586 wake_up(&hidg->read_queue); in hidg_intout_complete()
602 struct f_hidg *hidg = (struct f_hidg *)req->context; in hidg_ssreport_complete() local
603 struct usb_composite_dev *cdev = hidg->func.config->cdev; in hidg_ssreport_complete()
614 spin_lock_irqsave(&hidg->read_spinlock, flags); in hidg_ssreport_complete()
616 new_buf = krealloc(hidg->set_report_buf, req->actual, GFP_ATOMIC); in hidg_ssreport_complete()
618 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in hidg_ssreport_complete()
621 hidg->set_report_buf = new_buf; in hidg_ssreport_complete()
623 hidg->set_report_length = req->actual; in hidg_ssreport_complete()
624 memcpy(hidg->set_report_buf, req->buf, req->actual); in hidg_ssreport_complete()
626 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in hidg_ssreport_complete()
628 wake_up(&hidg->read_queue); in hidg_ssreport_complete()
634 struct f_hidg *hidg = func_to_hidg(f); in hidg_setup() local
653 length = min_t(unsigned, length, hidg->report_length); in hidg_setup()
663 ((u8 *) req->buf)[0] = hidg->protocol; in hidg_setup()
671 ((u8 *) req->buf)[0] = hidg->idle; in hidg_setup()
678 if (hidg->use_out_ep) in hidg_setup()
681 req->context = hidg; in hidg_setup()
695 if (hidg->bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) { in hidg_setup()
696 hidg->protocol = value; in hidg_setup()
706 hidg->idle = value >> 8; in hidg_setup()
720 cpu_to_le16(hidg->report_desc_length); in hidg_setup()
731 hidg->report_desc_length); in hidg_setup()
732 memcpy(req->buf, hidg->report_desc, length); in hidg_setup()
765 struct f_hidg *hidg = func_to_hidg(f); in hidg_disable() local
769 usb_ep_disable(hidg->in_ep); in hidg_disable()
771 if (hidg->out_ep) { in hidg_disable()
772 usb_ep_disable(hidg->out_ep); in hidg_disable()
774 spin_lock_irqsave(&hidg->read_spinlock, flags); in hidg_disable()
775 list_for_each_entry_safe(list, next, &hidg->completed_out_req, list) { in hidg_disable()
776 free_ep_req(hidg->out_ep, list->req); in hidg_disable()
780 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in hidg_disable()
783 spin_lock_irqsave(&hidg->write_spinlock, flags); in hidg_disable()
784 if (!hidg->write_pending) { in hidg_disable()
785 free_ep_req(hidg->in_ep, hidg->req); in hidg_disable()
786 hidg->write_pending = 1; in hidg_disable()
789 hidg->req = NULL; in hidg_disable()
790 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in hidg_disable()
796 struct f_hidg *hidg = func_to_hidg(f); in hidg_set_alt() local
803 if (hidg->in_ep != NULL) { in hidg_set_alt()
805 usb_ep_disable(hidg->in_ep); in hidg_set_alt()
808 hidg->in_ep); in hidg_set_alt()
813 status = usb_ep_enable(hidg->in_ep); in hidg_set_alt()
818 hidg->in_ep->driver_data = hidg; in hidg_set_alt()
820 req_in = hidg_alloc_ep_req(hidg->in_ep, hidg->report_length); in hidg_set_alt()
827 if (hidg->use_out_ep && hidg->out_ep != NULL) { in hidg_set_alt()
829 usb_ep_disable(hidg->out_ep); in hidg_set_alt()
832 hidg->out_ep); in hidg_set_alt()
837 status = usb_ep_enable(hidg->out_ep); in hidg_set_alt()
842 hidg->out_ep->driver_data = hidg; in hidg_set_alt()
847 for (i = 0; i < hidg->qlen && status == 0; i++) { in hidg_set_alt()
849 hidg_alloc_ep_req(hidg->out_ep, in hidg_set_alt()
850 hidg->report_length); in hidg_set_alt()
853 req->context = hidg; in hidg_set_alt()
854 status = usb_ep_queue(hidg->out_ep, req, in hidg_set_alt()
858 hidg->out_ep->name, status); in hidg_set_alt()
859 free_ep_req(hidg->out_ep, req); in hidg_set_alt()
868 if (hidg->in_ep != NULL) { in hidg_set_alt()
869 spin_lock_irqsave(&hidg->write_spinlock, flags); in hidg_set_alt()
870 hidg->req = req_in; in hidg_set_alt()
871 hidg->write_pending = 0; in hidg_set_alt()
872 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in hidg_set_alt()
874 wake_up(&hidg->write_queue); in hidg_set_alt()
878 if (hidg->out_ep) in hidg_set_alt()
879 usb_ep_disable(hidg->out_ep); in hidg_set_alt()
882 free_ep_req(hidg->in_ep, req_in); in hidg_set_alt()
885 if (hidg->in_ep) in hidg_set_alt()
886 usb_ep_disable(hidg->in_ep); in hidg_set_alt()
905 struct f_hidg *hidg = func_to_hidg(f); in hidg_bind() local
929 hidg->in_ep = ep; in hidg_bind()
931 hidg->out_ep = NULL; in hidg_bind()
932 if (hidg->use_out_ep) { in hidg_bind()
936 hidg->out_ep = ep; in hidg_bind()
940 hidg->set_report_buf = NULL; in hidg_bind()
943 hidg_interface_desc.bInterfaceSubClass = hidg->bInterfaceSubClass; in hidg_bind()
944 hidg_interface_desc.bInterfaceProtocol = hidg->bInterfaceProtocol; in hidg_bind()
945 hidg_interface_desc.bNumEndpoints = hidg->use_out_ep ? 2 : 1; in hidg_bind()
946 hidg->protocol = HID_REPORT_PROTOCOL; in hidg_bind()
947 hidg->idle = 1; in hidg_bind()
948 hidg_ss_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
950 cpu_to_le16(hidg->report_length); in hidg_bind()
951 hidg_hs_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
952 hidg_fs_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
953 hidg_ss_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
955 cpu_to_le16(hidg->report_length); in hidg_bind()
956 hidg_hs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
957 hidg_fs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
964 cpu_to_le16(hidg->report_desc_length); in hidg_bind()
976 if (hidg->use_out_ep) in hidg_bind()
992 spin_lock_init(&hidg->write_spinlock); in hidg_bind()
993 hidg->write_pending = 1; in hidg_bind()
994 hidg->req = NULL; in hidg_bind()
995 spin_lock_init(&hidg->read_spinlock); in hidg_bind()
996 init_waitqueue_head(&hidg->write_queue); in hidg_bind()
997 init_waitqueue_head(&hidg->read_queue); in hidg_bind()
998 INIT_LIST_HEAD(&hidg->completed_out_req); in hidg_bind()
1001 cdev_init(&hidg->cdev, &f_hidg_fops); in hidg_bind()
1002 dev = MKDEV(major, hidg->minor); in hidg_bind()
1003 status = cdev_add(&hidg->cdev, dev, 1); in hidg_bind()
1008 "%s%d", "hidg", hidg->minor); in hidg_bind()
1016 cdev_del(&hidg->cdev); in hidg_bind()
1021 if (hidg->req != NULL) in hidg_bind()
1022 free_ep_req(hidg->in_ep, hidg->req); in hidg_bind()
1242 struct f_hidg *hidg; in hidg_free() local
1245 hidg = func_to_hidg(f); in hidg_free()
1247 kfree(hidg->report_desc); in hidg_free()
1248 kfree(hidg->set_report_buf); in hidg_free()
1249 kfree(hidg); in hidg_free()
1257 struct f_hidg *hidg = func_to_hidg(f); in hidg_unbind() local
1259 device_destroy(hidg_class, MKDEV(major, hidg->minor)); in hidg_unbind()
1260 cdev_del(&hidg->cdev); in hidg_unbind()
1267 struct f_hidg *hidg; in hidg_alloc() local
1271 hidg = kzalloc(sizeof(*hidg), GFP_KERNEL); in hidg_alloc()
1272 if (!hidg) in hidg_alloc()
1280 hidg->minor = opts->minor; in hidg_alloc()
1281 hidg->bInterfaceSubClass = opts->subclass; in hidg_alloc()
1282 hidg->bInterfaceProtocol = opts->protocol; in hidg_alloc()
1283 hidg->report_length = opts->report_length; in hidg_alloc()
1284 hidg->report_desc_length = opts->report_desc_length; in hidg_alloc()
1286 hidg->report_desc = kmemdup(opts->report_desc, in hidg_alloc()
1289 if (!hidg->report_desc) { in hidg_alloc()
1290 kfree(hidg); in hidg_alloc()
1295 hidg->use_out_ep = !opts->no_out_endpoint; in hidg_alloc()
1299 hidg->func.name = "hid"; in hidg_alloc()
1300 hidg->func.bind = hidg_bind; in hidg_alloc()
1301 hidg->func.unbind = hidg_unbind; in hidg_alloc()
1302 hidg->func.set_alt = hidg_set_alt; in hidg_alloc()
1303 hidg->func.disable = hidg_disable; in hidg_alloc()
1304 hidg->func.setup = hidg_setup; in hidg_alloc()
1305 hidg->func.free_func = hidg_free; in hidg_alloc()
1308 hidg->qlen = 4; in hidg_alloc()
1310 return &hidg->func; in hidg_alloc()