Lines Matching refs:hidg
195 struct f_hidg *hidg = file->private_data; in f_hidg_read() local
207 spin_lock_irqsave(&hidg->spinlock, flags); in f_hidg_read()
209 #define READ_COND (!list_empty(&hidg->completed_out_req)) in f_hidg_read()
213 spin_unlock_irqrestore(&hidg->spinlock, flags); in f_hidg_read()
217 if (wait_event_interruptible(hidg->read_queue, READ_COND)) in f_hidg_read()
220 spin_lock_irqsave(&hidg->spinlock, flags); in f_hidg_read()
224 list = list_first_entry(&hidg->completed_out_req, in f_hidg_read()
228 spin_unlock_irqrestore(&hidg->spinlock, flags); in f_hidg_read()
241 spin_lock_irqsave(&hidg->spinlock, flags); in f_hidg_read()
244 spin_unlock_irqrestore(&hidg->spinlock, flags); in f_hidg_read()
246 req->length = hidg->report_length; in f_hidg_read()
247 ret = usb_ep_queue(hidg->out_ep, req, GFP_KERNEL); in f_hidg_read()
257 struct f_hidg *hidg = (struct f_hidg *)ep->driver_data; in f_hidg_req_complete() local
260 ERROR(hidg->func.config->cdev, in f_hidg_req_complete()
264 hidg->write_pending = 0; in f_hidg_req_complete()
265 wake_up(&hidg->write_queue); in f_hidg_req_complete()
271 struct f_hidg *hidg = file->private_data; in f_hidg_write() local
277 mutex_lock(&hidg->lock); in f_hidg_write()
279 #define WRITE_COND (!hidg->write_pending) in f_hidg_write()
283 mutex_unlock(&hidg->lock); in f_hidg_write()
288 hidg->write_queue, WRITE_COND)) in f_hidg_write()
291 mutex_lock(&hidg->lock); in f_hidg_write()
294 count = min_t(unsigned, count, hidg->report_length); in f_hidg_write()
295 status = copy_from_user(hidg->req->buf, buffer, count); in f_hidg_write()
298 ERROR(hidg->func.config->cdev, in f_hidg_write()
300 mutex_unlock(&hidg->lock); in f_hidg_write()
304 hidg->req->status = 0; in f_hidg_write()
305 hidg->req->zero = 0; in f_hidg_write()
306 hidg->req->length = count; in f_hidg_write()
307 hidg->req->complete = f_hidg_req_complete; in f_hidg_write()
308 hidg->req->context = hidg; in f_hidg_write()
309 hidg->write_pending = 1; in f_hidg_write()
311 status = usb_ep_queue(hidg->in_ep, hidg->req, GFP_ATOMIC); in f_hidg_write()
313 ERROR(hidg->func.config->cdev, in f_hidg_write()
315 hidg->write_pending = 0; in f_hidg_write()
316 wake_up(&hidg->write_queue); in f_hidg_write()
321 mutex_unlock(&hidg->lock); in f_hidg_write()
328 struct f_hidg *hidg = file->private_data; in f_hidg_poll() local
331 poll_wait(file, &hidg->read_queue, wait); in f_hidg_poll()
332 poll_wait(file, &hidg->write_queue, wait); in f_hidg_poll()
354 struct f_hidg *hidg = in f_hidg_open() local
357 fd->private_data = hidg; in f_hidg_open()
373 struct f_hidg *hidg = (struct f_hidg *) req->context; in hidg_set_report_complete() local
383 spin_lock_irqsave(&hidg->spinlock, flags); in hidg_set_report_complete()
384 list_add_tail(&req_list->list, &hidg->completed_out_req); in hidg_set_report_complete()
385 spin_unlock_irqrestore(&hidg->spinlock, flags); in hidg_set_report_complete()
387 wake_up(&hidg->read_queue); in hidg_set_report_complete()
393 struct f_hidg *hidg = func_to_hidg(f); in hidg_setup() local
412 length = min_t(unsigned, length, hidg->report_length); in hidg_setup()
446 cpu_to_le16(hidg->report_desc_length); in hidg_setup()
457 hidg->report_desc_length); in hidg_setup()
458 memcpy(req->buf, hidg->report_desc, length); in hidg_setup()
491 struct f_hidg *hidg = func_to_hidg(f); in hidg_disable() local
494 usb_ep_disable(hidg->in_ep); in hidg_disable()
495 usb_ep_disable(hidg->out_ep); in hidg_disable()
497 list_for_each_entry_safe(list, next, &hidg->completed_out_req, list) { in hidg_disable()
506 struct f_hidg *hidg = func_to_hidg(f); in hidg_set_alt() local
511 if (hidg->in_ep != NULL) { in hidg_set_alt()
513 usb_ep_disable(hidg->in_ep); in hidg_set_alt()
516 hidg->in_ep); in hidg_set_alt()
521 status = usb_ep_enable(hidg->in_ep); in hidg_set_alt()
526 hidg->in_ep->driver_data = hidg; in hidg_set_alt()
530 if (hidg->out_ep != NULL) { in hidg_set_alt()
532 usb_ep_disable(hidg->out_ep); in hidg_set_alt()
535 hidg->out_ep); in hidg_set_alt()
540 status = usb_ep_enable(hidg->out_ep); in hidg_set_alt()
545 hidg->out_ep->driver_data = hidg; in hidg_set_alt()
550 for (i = 0; i < hidg->qlen && status == 0; i++) { in hidg_set_alt()
552 hidg_alloc_ep_req(hidg->out_ep, in hidg_set_alt()
553 hidg->report_length); in hidg_set_alt()
556 req->context = hidg; in hidg_set_alt()
557 status = usb_ep_queue(hidg->out_ep, req, in hidg_set_alt()
561 hidg->out_ep->name, status); in hidg_set_alt()
563 usb_ep_disable(hidg->out_ep); in hidg_set_alt()
587 struct f_hidg *hidg = func_to_hidg(f); in hidg_bind() local
611 hidg->in_ep = ep; in hidg_bind()
616 hidg->out_ep = ep; in hidg_bind()
620 hidg->req = usb_ep_alloc_request(hidg->in_ep, GFP_KERNEL); in hidg_bind()
621 if (!hidg->req) in hidg_bind()
624 hidg->req->buf = kmalloc(hidg->report_length, GFP_KERNEL); in hidg_bind()
625 if (!hidg->req->buf) in hidg_bind()
629 hidg_interface_desc.bInterfaceSubClass = hidg->bInterfaceSubClass; in hidg_bind()
630 hidg_interface_desc.bInterfaceProtocol = hidg->bInterfaceProtocol; in hidg_bind()
631 hidg_hs_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
632 hidg_fs_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
633 hidg_hs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
634 hidg_fs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); in hidg_bind()
641 cpu_to_le16(hidg->report_desc_length); in hidg_bind()
653 mutex_init(&hidg->lock); in hidg_bind()
654 spin_lock_init(&hidg->spinlock); in hidg_bind()
655 init_waitqueue_head(&hidg->write_queue); in hidg_bind()
656 init_waitqueue_head(&hidg->read_queue); in hidg_bind()
657 INIT_LIST_HEAD(&hidg->completed_out_req); in hidg_bind()
660 cdev_init(&hidg->cdev, &f_hidg_fops); in hidg_bind()
661 dev = MKDEV(major, hidg->minor); in hidg_bind()
662 status = cdev_add(&hidg->cdev, dev, 1); in hidg_bind()
667 "%s%d", "hidg", hidg->minor); in hidg_bind()
675 cdev_del(&hidg->cdev); in hidg_bind()
680 if (hidg->req != NULL) { in hidg_bind()
681 kfree(hidg->req->buf); in hidg_bind()
682 if (hidg->in_ep != NULL) in hidg_bind()
683 usb_ep_free_request(hidg->in_ep, hidg->req); in hidg_bind()
892 struct f_hidg *hidg; in hidg_free() local
895 hidg = func_to_hidg(f); in hidg_free()
897 kfree(hidg->report_desc); in hidg_free()
898 kfree(hidg); in hidg_free()
906 struct f_hidg *hidg = func_to_hidg(f); in hidg_unbind() local
908 device_destroy(hidg_class, MKDEV(major, hidg->minor)); in hidg_unbind()
909 cdev_del(&hidg->cdev); in hidg_unbind()
912 usb_ep_disable(hidg->in_ep); in hidg_unbind()
913 kfree(hidg->req->buf); in hidg_unbind()
914 usb_ep_free_request(hidg->in_ep, hidg->req); in hidg_unbind()
921 struct f_hidg *hidg; in hidg_alloc() local
925 hidg = kzalloc(sizeof(*hidg), GFP_KERNEL); in hidg_alloc()
926 if (!hidg) in hidg_alloc()
934 hidg->minor = opts->minor; in hidg_alloc()
935 hidg->bInterfaceSubClass = opts->subclass; in hidg_alloc()
936 hidg->bInterfaceProtocol = opts->protocol; in hidg_alloc()
937 hidg->report_length = opts->report_length; in hidg_alloc()
938 hidg->report_desc_length = opts->report_desc_length; in hidg_alloc()
940 hidg->report_desc = kmemdup(opts->report_desc, in hidg_alloc()
943 if (!hidg->report_desc) { in hidg_alloc()
944 kfree(hidg); in hidg_alloc()
952 hidg->func.name = "hid"; in hidg_alloc()
953 hidg->func.bind = hidg_bind; in hidg_alloc()
954 hidg->func.unbind = hidg_unbind; in hidg_alloc()
955 hidg->func.set_alt = hidg_set_alt; in hidg_alloc()
956 hidg->func.disable = hidg_disable; in hidg_alloc()
957 hidg->func.setup = hidg_setup; in hidg_alloc()
958 hidg->func.free_func = hidg_free; in hidg_alloc()
961 hidg->qlen = 4; in hidg_alloc()
963 return &hidg->func; in hidg_alloc()