Lines Matching refs:udc
73 static void nuke(struct vudc *udc, struct vep *ep) in nuke() argument
83 spin_unlock(&udc->lock); in nuke()
85 spin_lock(&udc->lock); in nuke()
90 static void stop_activity(struct vudc *udc) in stop_activity() argument
95 udc->address = 0; in stop_activity()
98 nuke(udc, &udc->ep[i]); in stop_activity()
100 list_for_each_entry_safe(urb_p, tmp, &udc->urb_queue, urb_entry) { in stop_activity()
106 struct vep *vudc_find_endpoint(struct vudc *udc, u8 address) in vudc_find_endpoint() argument
111 return &udc->ep[0]; in vudc_find_endpoint()
114 struct vep *ep = &udc->ep[i]; in vudc_find_endpoint()
129 struct vudc *udc = usb_gadget_to_vudc(_gadget); in vgadget_get_frame() local
132 return ((now.tv_sec - udc->start_time.tv_sec) * 1000 + in vgadget_get_frame()
133 (now.tv_nsec - udc->start_time.tv_nsec) / NSEC_PER_MSEC) in vgadget_get_frame()
139 struct vudc *udc = usb_gadget_to_vudc(_gadget); in vgadget_set_selfpowered() local
142 udc->devstatus |= (1 << USB_DEVICE_SELF_POWERED); in vgadget_set_selfpowered()
144 udc->devstatus &= ~(1 << USB_DEVICE_SELF_POWERED); in vgadget_set_selfpowered()
150 struct vudc *udc = usb_gadget_to_vudc(_gadget); in vgadget_pullup() local
155 spin_lock_irqsave(&udc->lock, flags); in vgadget_pullup()
157 if (value == udc->pullup) in vgadget_pullup()
160 udc->pullup = value; in vgadget_pullup()
162 udc->gadget.speed = min_t(u8, USB_SPEED_HIGH, in vgadget_pullup()
163 udc->driver->max_speed); in vgadget_pullup()
164 udc->ep[0].ep.maxpacket = 64; in vgadget_pullup()
169 ret = get_gadget_descs(udc); in vgadget_pullup()
171 dev_err(&udc->gadget.dev, "Unable go get desc: %d", ret); in vgadget_pullup()
175 spin_unlock_irqrestore(&udc->lock, flags); in vgadget_pullup()
176 usbip_start_eh(&udc->ud); in vgadget_pullup()
179 udc->desc_cached = 0; in vgadget_pullup()
181 spin_unlock_irqrestore(&udc->lock, flags); in vgadget_pullup()
182 usbip_event_add(&udc->ud, VUDC_EVENT_REMOVED); in vgadget_pullup()
183 usbip_stop_eh(&udc->ud); /* Wait for eh completion */ in vgadget_pullup()
189 spin_unlock_irqrestore(&udc->lock, flags); in vgadget_pullup()
196 struct vudc *udc = usb_gadget_to_vudc(g); in vgadget_udc_start() local
199 spin_lock_irqsave(&udc->lock, flags); in vgadget_udc_start()
200 udc->driver = driver; in vgadget_udc_start()
201 udc->pullup = udc->connected = udc->desc_cached = 0; in vgadget_udc_start()
202 spin_unlock_irqrestore(&udc->lock, flags); in vgadget_udc_start()
209 struct vudc *udc = usb_gadget_to_vudc(g); in vgadget_udc_stop() local
212 spin_lock_irqsave(&udc->lock, flags); in vgadget_udc_stop()
213 udc->driver = NULL; in vgadget_udc_stop()
214 spin_unlock_irqrestore(&udc->lock, flags); in vgadget_udc_stop()
233 struct vudc *udc; in vep_enable() local
238 udc = ep_to_vudc(ep); in vep_enable()
244 if (!udc->driver) in vep_enable()
247 spin_lock_irqsave(&udc->lock, flags); in vep_enable()
255 spin_unlock_irqrestore(&udc->lock, flags); in vep_enable()
263 struct vudc *udc; in vep_disable() local
267 udc = ep_to_vudc(ep); in vep_disable()
271 spin_lock_irqsave(&udc->lock, flags); in vep_disable()
273 nuke(udc, ep); in vep_disable()
274 spin_unlock_irqrestore(&udc->lock, flags); in vep_disable()
313 struct vudc *udc; in vep_queue() local
321 udc = ep_to_vudc(ep); in vep_queue()
323 spin_lock_irqsave(&udc->lock, flags); in vep_queue()
328 spin_unlock_irqrestore(&udc->lock, flags); in vep_queue()
337 struct vudc *udc; in vep_dequeue() local
347 udc = req->udc; in vep_dequeue()
349 if (!udc->driver) in vep_dequeue()
352 spin_lock_irqsave(&udc->lock, flags); in vep_dequeue()
361 spin_unlock_irqrestore(&udc->lock, flags); in vep_dequeue()
373 struct vudc *udc; in vep_set_halt_and_wedge() local
381 udc = ep_to_vudc(ep); in vep_set_halt_and_wedge()
382 if (!udc->driver) in vep_set_halt_and_wedge()
385 spin_lock_irqsave(&udc->lock, flags); in vep_set_halt_and_wedge()
397 spin_unlock_irqrestore(&udc->lock, flags); in vep_set_halt_and_wedge()
431 struct vudc *udc = container_of(ud, struct vudc, ud); in vudc_shutdown() local
435 dev_dbg(&udc->pdev->dev, "device shutdown"); in vudc_shutdown()
453 spin_lock_irqsave(&udc->lock, flags); in vudc_shutdown()
454 stop_activity(udc); in vudc_shutdown()
455 if (udc->connected && udc->driver->disconnect) in vudc_shutdown()
457 udc->connected = 0; in vudc_shutdown()
458 spin_unlock_irqrestore(&udc->lock, flags); in vudc_shutdown()
460 udc->driver->disconnect(&udc->gadget); in vudc_shutdown()
465 struct vudc *udc = container_of(ud, struct vudc, ud); in vudc_device_reset() local
468 dev_dbg(&udc->pdev->dev, "device reset"); in vudc_device_reset()
469 spin_lock_irqsave(&udc->lock, flags); in vudc_device_reset()
470 stop_activity(udc); in vudc_device_reset()
471 spin_unlock_irqrestore(&udc->lock, flags); in vudc_device_reset()
472 if (udc->driver) in vudc_device_reset()
473 usb_gadget_udc_reset(&udc->gadget, udc->driver); in vudc_device_reset()
516 static int init_vudc_hw(struct vudc *udc) in init_vudc_hw() argument
519 struct usbip_device *ud = &udc->ud; in init_vudc_hw()
522 udc->ep = kcalloc(VIRTUAL_ENDPOINTS, sizeof(*udc->ep), GFP_KERNEL); in init_vudc_hw()
523 if (!udc->ep) in init_vudc_hw()
526 INIT_LIST_HEAD(&udc->gadget.ep_list); in init_vudc_hw()
533 ep = &udc->ep[i]; in init_vudc_hw()
543 ep->gadget = &udc->gadget; in init_vudc_hw()
552 udc->gadget.ep0 = &ep->ep; in init_vudc_hw()
564 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); in init_vudc_hw()
568 spin_lock_init(&udc->lock); in init_vudc_hw()
569 spin_lock_init(&udc->lock_tx); in init_vudc_hw()
570 INIT_LIST_HEAD(&udc->urb_queue); in init_vudc_hw()
571 INIT_LIST_HEAD(&udc->tx_queue); in init_vudc_hw()
572 init_waitqueue_head(&udc->tx_waitq); in init_vudc_hw()
583 v_init_timer(udc); in init_vudc_hw()
590 static void cleanup_vudc_hw(struct vudc *udc) in cleanup_vudc_hw() argument
592 kfree(udc->ep); in cleanup_vudc_hw()
599 struct vudc *udc; in vudc_probe() local
602 udc = kzalloc(sizeof(*udc), GFP_KERNEL); in vudc_probe()
603 if (!udc) in vudc_probe()
606 udc->gadget.name = GADGET_NAME; in vudc_probe()
607 udc->gadget.ops = &vgadget_ops; in vudc_probe()
608 udc->gadget.max_speed = USB_SPEED_HIGH; in vudc_probe()
609 udc->gadget.dev.parent = &pdev->dev; in vudc_probe()
610 udc->pdev = pdev; in vudc_probe()
612 ret = init_vudc_hw(udc); in vudc_probe()
616 ret = usb_add_gadget_udc(&pdev->dev, &udc->gadget); in vudc_probe()
620 platform_set_drvdata(pdev, udc); in vudc_probe()
625 cleanup_vudc_hw(udc); in vudc_probe()
627 kfree(udc); in vudc_probe()
634 struct vudc *udc = platform_get_drvdata(pdev); in vudc_remove() local
636 usb_del_gadget_udc(&udc->gadget); in vudc_remove()
637 cleanup_vudc_hw(udc); in vudc_remove()
638 kfree(udc); in vudc_remove()