Lines Matching refs:hidg

93 	struct f_hidg *hidg = container_of(dev, struct f_hidg, dev);  in hidg_release()  local
95 kfree(hidg->set_report_buf); in hidg_release()
96 kfree(hidg); in hidg_release()
294 struct f_hidg *hidg = file->private_data; in f_hidg_intout_read() local
303 spin_lock_irqsave(&hidg->read_spinlock, flags); in f_hidg_intout_read()
305 #define READ_COND_INTOUT (!list_empty(&hidg->completed_out_req)) in f_hidg_intout_read()
309 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in f_hidg_intout_read()
313 if (wait_event_interruptible(hidg->read_queue, READ_COND_INTOUT)) in f_hidg_intout_read()
316 spin_lock_irqsave(&hidg->read_spinlock, flags); in f_hidg_intout_read()
320 list = list_first_entry(&hidg->completed_out_req, in f_hidg_intout_read()
331 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in f_hidg_intout_read()
346 req->length = hidg->report_length; in f_hidg_intout_read()
347 ret = usb_ep_queue(hidg->out_ep, req, GFP_KERNEL); in f_hidg_intout_read()
349 free_ep_req(hidg->out_ep, req); in f_hidg_intout_read()
353 spin_lock_irqsave(&hidg->read_spinlock, flags); in f_hidg_intout_read()
354 list_add(&list->list, &hidg->completed_out_req); in f_hidg_intout_read()
355 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in f_hidg_intout_read()
357 wake_up(&hidg->read_queue); in f_hidg_intout_read()
363 #define READ_COND_SSREPORT (hidg->set_report_buf != NULL)
368 struct f_hidg *hidg = file->private_data; in f_hidg_ssreport_read() local
375 spin_lock_irqsave(&hidg->read_spinlock, flags); in f_hidg_ssreport_read()
378 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in f_hidg_ssreport_read()
382 if (wait_event_interruptible(hidg->read_queue, READ_COND_SSREPORT)) in f_hidg_ssreport_read()
385 spin_lock_irqsave(&hidg->read_spinlock, flags); in f_hidg_ssreport_read()
388 count = min_t(unsigned int, count, hidg->set_report_length); in f_hidg_ssreport_read()
389 tmp_buf = hidg->set_report_buf; in f_hidg_ssreport_read()
390 hidg->set_report_buf = NULL; in f_hidg_ssreport_read()
392 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in f_hidg_ssreport_read()
401 wake_up(&hidg->read_queue); in f_hidg_ssreport_read()
409 struct f_hidg *hidg = file->private_data; in f_hidg_read() local
411 if (hidg->use_out_ep) in f_hidg_read()
419 struct f_hidg *hidg = (struct f_hidg *)ep->driver_data; in f_hidg_req_complete() local
423 ERROR(hidg->func.config->cdev, in f_hidg_req_complete()
427 spin_lock_irqsave(&hidg->write_spinlock, flags); in f_hidg_req_complete()
428 hidg->write_pending = 0; in f_hidg_req_complete()
429 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_req_complete()
430 wake_up(&hidg->write_queue); in f_hidg_req_complete()
436 struct f_hidg *hidg = file->private_data; in f_hidg_write() local
441 spin_lock_irqsave(&hidg->write_spinlock, flags); in f_hidg_write()
443 if (!hidg->req) { in f_hidg_write()
444 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_write()
448 #define WRITE_COND (!hidg->write_pending) in f_hidg_write()
452 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_write()
457 hidg->write_queue, WRITE_COND)) in f_hidg_write()
460 spin_lock_irqsave(&hidg->write_spinlock, flags); in f_hidg_write()
463 hidg->write_pending = 1; in f_hidg_write()
464 req = hidg->req; in f_hidg_write()
465 count = min_t(unsigned, count, hidg->report_length); in f_hidg_write()
467 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_write()
470 ERROR(hidg->func.config->cdev, "hidg->req is NULL\n"); in f_hidg_write()
477 ERROR(hidg->func.config->cdev, in f_hidg_write()
483 spin_lock_irqsave(&hidg->write_spinlock, flags); in f_hidg_write()
486 if (!hidg->req) { in f_hidg_write()
487 free_ep_req(hidg->in_ep, req); in f_hidg_write()
499 req->context = hidg; in f_hidg_write()
501 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_write()
503 if (!hidg->in_ep->enabled) { in f_hidg_write()
504 ERROR(hidg->func.config->cdev, "in_ep is disabled\n"); in f_hidg_write()
509 status = usb_ep_queue(hidg->in_ep, req, GFP_ATOMIC); in f_hidg_write()
517 spin_lock_irqsave(&hidg->write_spinlock, flags); in f_hidg_write()
518 hidg->write_pending = 0; in f_hidg_write()
519 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in f_hidg_write()
521 wake_up(&hidg->write_queue); in f_hidg_write()
528 struct f_hidg *hidg = file->private_data; in f_hidg_poll() local
531 poll_wait(file, &hidg->read_queue, wait); in f_hidg_poll()
532 poll_wait(file, &hidg->write_queue, wait); in f_hidg_poll()
537 if (hidg->use_out_ep) { in f_hidg_poll()
560 struct f_hidg *hidg = in f_hidg_open() local
563 fd->private_data = hidg; in f_hidg_open()
579 struct f_hidg *hidg = (struct f_hidg *) req->context; in hidg_intout_complete() local
580 struct usb_composite_dev *cdev = hidg->func.config->cdev; in hidg_intout_complete()
594 spin_lock_irqsave(&hidg->read_spinlock, flags); in hidg_intout_complete()
595 list_add_tail(&req_list->list, &hidg->completed_out_req); in hidg_intout_complete()
596 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in hidg_intout_complete()
598 wake_up(&hidg->read_queue); in hidg_intout_complete()
614 struct f_hidg *hidg = (struct f_hidg *)req->context; in hidg_ssreport_complete() local
615 struct usb_composite_dev *cdev = hidg->func.config->cdev; in hidg_ssreport_complete()
626 spin_lock_irqsave(&hidg->read_spinlock, flags); in hidg_ssreport_complete()
628 new_buf = krealloc(hidg->set_report_buf, req->actual, GFP_ATOMIC); in hidg_ssreport_complete()
630 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in hidg_ssreport_complete()
633 hidg->set_report_buf = new_buf; in hidg_ssreport_complete()
635 hidg->set_report_length = req->actual; in hidg_ssreport_complete()
636 memcpy(hidg->set_report_buf, req->buf, req->actual); in hidg_ssreport_complete()
638 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in hidg_ssreport_complete()
640 wake_up(&hidg->read_queue); in hidg_ssreport_complete()
646 struct f_hidg *hidg = func_to_hidg(f); in hidg_setup() local
665 length = min_t(unsigned, length, hidg->report_length); in hidg_setup()
675 ((u8 *) req->buf)[0] = hidg->protocol; in hidg_setup()
683 ((u8 *) req->buf)[0] = hidg->idle; in hidg_setup()
690 if (hidg->use_out_ep) in hidg_setup()
693 req->context = hidg; in hidg_setup()
707 if (hidg->bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) { in hidg_setup()
708 hidg->protocol = value; in hidg_setup()
718 hidg->idle = value >> 8; in hidg_setup()
732 cpu_to_le16(hidg->report_desc_length); in hidg_setup()
743 hidg->report_desc_length); in hidg_setup()
744 memcpy(req->buf, hidg->report_desc, length); in hidg_setup()
777 struct f_hidg *hidg = func_to_hidg(f); in hidg_disable() local
781 usb_ep_disable(hidg->in_ep); in hidg_disable()
783 if (hidg->out_ep) { in hidg_disable()
784 usb_ep_disable(hidg->out_ep); in hidg_disable()
786 spin_lock_irqsave(&hidg->read_spinlock, flags); in hidg_disable()
787 list_for_each_entry_safe(list, next, &hidg->completed_out_req, list) { in hidg_disable()
788 free_ep_req(hidg->out_ep, list->req); in hidg_disable()
792 spin_unlock_irqrestore(&hidg->read_spinlock, flags); in hidg_disable()
795 spin_lock_irqsave(&hidg->write_spinlock, flags); in hidg_disable()
796 if (!hidg->write_pending) { in hidg_disable()
797 free_ep_req(hidg->in_ep, hidg->req); in hidg_disable()
798 hidg->write_pending = 1; in hidg_disable()
801 hidg->req = NULL; in hidg_disable()
802 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in hidg_disable()
808 struct f_hidg *hidg = func_to_hidg(f); in hidg_set_alt() local
815 if (hidg->in_ep != NULL) { in hidg_set_alt()
817 usb_ep_disable(hidg->in_ep); in hidg_set_alt()
820 hidg->in_ep); in hidg_set_alt()
825 status = usb_ep_enable(hidg->in_ep); in hidg_set_alt()
830 hidg->in_ep->driver_data = hidg; in hidg_set_alt()
832 req_in = hidg_alloc_ep_req(hidg->in_ep, hidg->report_length); in hidg_set_alt()
839 if (hidg->use_out_ep && hidg->out_ep != NULL) { in hidg_set_alt()
841 usb_ep_disable(hidg->out_ep); in hidg_set_alt()
844 hidg->out_ep); in hidg_set_alt()
849 status = usb_ep_enable(hidg->out_ep); in hidg_set_alt()
854 hidg->out_ep->driver_data = hidg; in hidg_set_alt()
859 for (i = 0; i < hidg->qlen && status == 0; i++) { in hidg_set_alt()
861 hidg_alloc_ep_req(hidg->out_ep, in hidg_set_alt()
862 hidg->report_length); in hidg_set_alt()
865 req->context = hidg; in hidg_set_alt()
866 status = usb_ep_queue(hidg->out_ep, req, in hidg_set_alt()
870 hidg->out_ep->name, status); in hidg_set_alt()
871 free_ep_req(hidg->out_ep, req); in hidg_set_alt()
880 if (hidg->in_ep != NULL) { in hidg_set_alt()
881 spin_lock_irqsave(&hidg->write_spinlock, flags); in hidg_set_alt()
882 hidg->req = req_in; in hidg_set_alt()
883 hidg->write_pending = 0; in hidg_set_alt()
884 spin_unlock_irqrestore(&hidg->write_spinlock, flags); in hidg_set_alt()
886 wake_up(&hidg->write_queue); in hidg_set_alt()
890 if (hidg->out_ep) in hidg_set_alt()
891 usb_ep_disable(hidg->out_ep); in hidg_set_alt()
894 free_ep_req(hidg->in_ep, req_in); in hidg_set_alt()
897 if (hidg->in_ep) in hidg_set_alt()
898 usb_ep_disable(hidg->in_ep); in hidg_set_alt()
917 struct f_hidg *hidg = func_to_hidg(f); in hidg_bind() local
939 hidg->in_ep = ep; in hidg_bind()
941 hidg->out_ep = NULL; in hidg_bind()
942 if (hidg->use_out_ep) { in hidg_bind()
946 hidg->out_ep = ep; in hidg_bind()
950 hidg->set_report_buf = NULL; in hidg_bind()
953 hidg_interface_desc.bInterfaceSubClass = hidg->bInterfaceSubClass; in hidg_bind()
954 hidg_interface_desc.bInterfaceProtocol = hidg->bInterfaceProtocol; in hidg_bind()
955 hidg_interface_desc.bNumEndpoints = hidg->use_out_ep ? 2 : 1; in hidg_bind()
956 hidg->protocol = HID_REPORT_PROTOCOL; in hidg_bind()
957 hidg->idle = 1; in hidg_bind()
958 hidg_ss_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
960 cpu_to_le16(hidg->report_length); in hidg_bind()
961 hidg_hs_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
962 hidg_fs_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
963 hidg_ss_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
965 cpu_to_le16(hidg->report_length); in hidg_bind()
966 hidg_hs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
967 hidg_fs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
974 cpu_to_le16(hidg->report_desc_length); in hidg_bind()
986 if (hidg->use_out_ep) in hidg_bind()
1002 spin_lock_init(&hidg->write_spinlock); in hidg_bind()
1003 hidg->write_pending = 1; in hidg_bind()
1004 hidg->req = NULL; in hidg_bind()
1005 spin_lock_init(&hidg->read_spinlock); in hidg_bind()
1006 init_waitqueue_head(&hidg->write_queue); in hidg_bind()
1007 init_waitqueue_head(&hidg->read_queue); in hidg_bind()
1008 INIT_LIST_HEAD(&hidg->completed_out_req); in hidg_bind()
1011 cdev_init(&hidg->cdev, &f_hidg_fops); in hidg_bind()
1012 status = cdev_device_add(&hidg->cdev, &hidg->dev); 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 put_device(&hidg->dev); in hidg_free()
1255 struct f_hidg *hidg = func_to_hidg(f); in hidg_unbind() local
1257 cdev_device_del(&hidg->cdev, &hidg->dev); in hidg_unbind()
1264 struct f_hidg *hidg; in hidg_alloc() local
1269 hidg = kzalloc(sizeof(*hidg), GFP_KERNEL); in hidg_alloc()
1270 if (!hidg) in hidg_alloc()
1277 device_initialize(&hidg->dev); in hidg_alloc()
1278 hidg->dev.release = hidg_release; in hidg_alloc()
1279 hidg->dev.class = &hidg_class; in hidg_alloc()
1280 hidg->dev.devt = MKDEV(major, opts->minor); in hidg_alloc()
1281 ret = dev_set_name(&hidg->dev, "hidg%d", opts->minor); in hidg_alloc()
1285 hidg->bInterfaceSubClass = opts->subclass; in hidg_alloc()
1286 hidg->bInterfaceProtocol = opts->protocol; in hidg_alloc()
1287 hidg->report_length = opts->report_length; in hidg_alloc()
1288 hidg->report_desc_length = opts->report_desc_length; in hidg_alloc()
1290 hidg->report_desc = devm_kmemdup(&hidg->dev, opts->report_desc, in hidg_alloc()
1293 if (!hidg->report_desc) { in hidg_alloc()
1298 hidg->use_out_ep = !opts->no_out_endpoint; in hidg_alloc()
1303 hidg->func.name = "hid"; in hidg_alloc()
1304 hidg->func.bind = hidg_bind; in hidg_alloc()
1305 hidg->func.unbind = hidg_unbind; in hidg_alloc()
1306 hidg->func.set_alt = hidg_set_alt; in hidg_alloc()
1307 hidg->func.disable = hidg_disable; in hidg_alloc()
1308 hidg->func.setup = hidg_setup; in hidg_alloc()
1309 hidg->func.free_func = hidg_free; in hidg_alloc()
1312 hidg->qlen = 4; in hidg_alloc()
1314 return &hidg->func; in hidg_alloc()
1317 put_device(&hidg->dev); in hidg_alloc()