Lines Matching refs:usb9pfs

80 	struct f_usb9pfs *usb9pfs;  member
91 static int usb9pfs_queue_tx(struct f_usb9pfs *usb9pfs, struct p9_req_t *p9_tx_req, in usb9pfs_queue_tx() argument
94 struct usb_composite_dev *cdev = usb9pfs->function.config->cdev; in usb9pfs_queue_tx()
95 struct usb_request *req = usb9pfs->in_req; in usb9pfs_queue_tx()
98 if (!(p9_tx_req->tc.size % usb9pfs->in_ep->maxpacket)) in usb9pfs_queue_tx()
106 usb9pfs->in_ep->name, req->actual, req->length, req->zero); in usb9pfs_queue_tx()
108 ret = usb_ep_queue(usb9pfs->in_ep, req, gfp_flags); in usb9pfs_queue_tx()
117 static int usb9pfs_queue_rx(struct f_usb9pfs *usb9pfs, struct usb_request *req, in usb9pfs_queue_rx() argument
120 struct usb_composite_dev *cdev = usb9pfs->function.config->cdev; in usb9pfs_queue_rx()
123 ret = usb_ep_queue(usb9pfs->out_ep, req, gfp_flags); in usb9pfs_queue_rx()
130 static int usb9pfs_transmit(struct f_usb9pfs *usb9pfs, struct p9_req_t *p9_req) in usb9pfs_transmit() argument
134 guard(spinlock_irqsave)(&usb9pfs->lock); in usb9pfs_transmit()
136 ret = usb9pfs_queue_tx(usb9pfs, p9_req, GFP_ATOMIC); in usb9pfs_transmit()
149 struct f_usb9pfs *usb9pfs = ep->driver_data; in usb9pfs_tx_complete() local
150 struct usb_composite_dev *cdev = usb9pfs->function.config->cdev; in usb9pfs_tx_complete()
166 spin_lock_irqsave(&usb9pfs->lock, flags); in usb9pfs_tx_complete()
169 p9_req_put(usb9pfs->client, p9_tx_req); in usb9pfs_tx_complete()
173 spin_unlock_irqrestore(&usb9pfs->lock, flags); in usb9pfs_tx_complete()
175 complete(&usb9pfs->send); in usb9pfs_tx_complete()
178 static struct p9_req_t *usb9pfs_rx_header(struct f_usb9pfs *usb9pfs, void *buf) in usb9pfs_rx_header() argument
190 p9_debug(P9_DEBUG_TRANS, "mux %p got %zu bytes\n", usb9pfs, in usb9pfs_rx_header()
202 usb9pfs, rc.size, rc.tag); in usb9pfs_rx_header()
204 p9_rx_req = p9_tag_lookup(usb9pfs->client, rc.tag); in usb9pfs_rx_header()
214 p9_req_put(usb9pfs->client, p9_rx_req); in usb9pfs_rx_header()
222 p9_req_put(usb9pfs->client, p9_rx_req); in usb9pfs_rx_header()
231 struct f_usb9pfs *usb9pfs = ep->driver_data; in usb9pfs_rx_complete() local
232 struct usb_composite_dev *cdev = usb9pfs->function.config->cdev; in usb9pfs_rx_complete()
241 p9_rx_req = usb9pfs_rx_header(usb9pfs, req->buf); in usb9pfs_rx_complete()
249 p9_client_cb(usb9pfs->client, p9_rx_req, REQ_STATUS_RCVD); in usb9pfs_rx_complete()
250 p9_req_put(usb9pfs->client, p9_rx_req); in usb9pfs_rx_complete()
252 complete(&usb9pfs->received); in usb9pfs_rx_complete()
265 static void disable_usb9pfs(struct f_usb9pfs *usb9pfs) in disable_usb9pfs() argument
268 usb9pfs->function.config->cdev; in disable_usb9pfs()
270 if (usb9pfs->in_req) { in disable_usb9pfs()
271 usb_ep_free_request(usb9pfs->in_ep, usb9pfs->in_req); in disable_usb9pfs()
272 usb9pfs->in_req = NULL; in disable_usb9pfs()
275 if (usb9pfs->out_req) { in disable_usb9pfs()
276 usb_ep_free_request(usb9pfs->out_ep, usb9pfs->out_req); in disable_usb9pfs()
277 usb9pfs->out_req = NULL; in disable_usb9pfs()
280 disable_ep(cdev, usb9pfs->in_ep); in disable_usb9pfs()
281 disable_ep(cdev, usb9pfs->out_ep); in disable_usb9pfs()
283 usb9pfs->function.name); in disable_usb9pfs()
287 struct f_usb9pfs *usb9pfs) in alloc_requests() argument
291 usb9pfs->in_req = usb_ep_alloc_request(usb9pfs->in_ep, GFP_ATOMIC); in alloc_requests()
292 if (!usb9pfs->in_req) { in alloc_requests()
297 usb9pfs->out_req = alloc_ep_req(usb9pfs->out_ep, usb9pfs->buflen); in alloc_requests()
298 if (!usb9pfs->out_req) { in alloc_requests()
303 usb9pfs->in_req->complete = usb9pfs_tx_complete; in alloc_requests()
304 usb9pfs->out_req->complete = usb9pfs_rx_complete; in alloc_requests()
307 usb9pfs->in_req->context = usb9pfs; in alloc_requests()
308 usb9pfs->out_req->context = usb9pfs; in alloc_requests()
313 usb_ep_free_request(usb9pfs->in_ep, usb9pfs->in_req); in alloc_requests()
319 struct f_usb9pfs *usb9pfs, struct usb_ep *ep) in enable_endpoint() argument
323 ret = config_ep_by_speed(cdev->gadget, &usb9pfs->function, ep); in enable_endpoint()
331 ep->driver_data = usb9pfs; in enable_endpoint()
337 enable_usb9pfs(struct usb_composite_dev *cdev, struct f_usb9pfs *usb9pfs) in enable_usb9pfs() argument
342 ret = enable_endpoint(cdev, usb9pfs, usb9pfs->in_ep); in enable_usb9pfs()
346 ret = enable_endpoint(cdev, usb9pfs, usb9pfs->out_ep); in enable_usb9pfs()
350 ret = alloc_requests(cdev, usb9pfs); in enable_usb9pfs()
354 client = usb9pfs->client; in enable_usb9pfs()
358 dev_dbg(&cdev->gadget->dev, "%s enabled\n", usb9pfs->function.name); in enable_usb9pfs()
362 usb_ep_disable(usb9pfs->out_ep); in enable_usb9pfs()
364 usb_ep_disable(usb9pfs->in_ep); in enable_usb9pfs()
372 struct f_usb9pfs *usb9pfs; in p9_usbg_create() local
398 usb9pfs = dev->usb9pfs; in p9_usbg_create()
399 if (!usb9pfs) in p9_usbg_create()
402 client->trans = (void *)usb9pfs; in p9_usbg_create()
403 if (!usb9pfs->in_req) in p9_usbg_create()
407 usb9pfs->client = client; in p9_usbg_create()
409 client->trans_mod->maxsize = usb9pfs->buflen; in p9_usbg_create()
411 complete(&usb9pfs->received); in p9_usbg_create()
416 static void usb9pfs_clear_tx(struct f_usb9pfs *usb9pfs) in usb9pfs_clear_tx() argument
420 guard(spinlock_irqsave)(&usb9pfs->lock); in usb9pfs_clear_tx()
422 req = usb9pfs->in_req->context; in usb9pfs_clear_tx()
429 p9_client_cb(usb9pfs->client, req, REQ_STATUS_ERROR); in usb9pfs_clear_tx()
434 struct f_usb9pfs *usb9pfs; in p9_usbg_close() local
441 usb9pfs = client->trans; in p9_usbg_close()
442 if (!usb9pfs) in p9_usbg_close()
447 usb9pfs_clear_tx(usb9pfs); in p9_usbg_close()
449 opts = container_of(usb9pfs->function.fi, in p9_usbg_close()
461 struct f_usb9pfs *usb9pfs = client->trans; in p9_usbg_request() local
467 ret = wait_for_completion_killable(&usb9pfs->received); in p9_usbg_request()
471 ret = usb9pfs_transmit(usb9pfs, p9_req); in p9_usbg_request()
475 ret = wait_for_completion_killable(&usb9pfs->send); in p9_usbg_request()
479 return usb9pfs_queue_rx(usb9pfs, usb9pfs->out_req, GFP_ATOMIC); in p9_usbg_request()
484 struct f_usb9pfs *usb9pfs = client->trans; in p9_usbg_cancel() local
489 guard(spinlock_irqsave)(&usb9pfs->lock); in p9_usbg_cancel()
640 struct f_usb9pfs *usb9pfs = func_to_usb9pfs(f); in usb9pfs_func_bind() local
659 usb9pfs->in_ep = usb_ep_autoconfig(cdev->gadget, in usb9pfs_func_bind()
661 if (!usb9pfs->in_ep) in usb9pfs_func_bind()
664 usb9pfs->out_ep = usb_ep_autoconfig(cdev->gadget, in usb9pfs_func_bind()
666 if (!usb9pfs->out_ep) in usb9pfs_func_bind()
687 opts->dev->usb9pfs = usb9pfs; in usb9pfs_func_bind()
692 f->name, usb9pfs->in_ep->name, usb9pfs->out_ep->name); in usb9pfs_func_bind()
705 struct f_usb9pfs *usb9pfs = func_to_usb9pfs(f); in usb9pfs_func_unbind() local
707 disable_usb9pfs(usb9pfs); in usb9pfs_func_unbind()
712 struct f_usb9pfs *usb9pfs = func_to_usb9pfs(f); in usb9pfs_free_func() local
715 kfree(usb9pfs); in usb9pfs_free_func()
729 struct f_usb9pfs *usb9pfs = func_to_usb9pfs(f); in usb9pfs_set_alt() local
732 return enable_usb9pfs(cdev, usb9pfs); in usb9pfs_set_alt()
737 struct f_usb9pfs *usb9pfs = func_to_usb9pfs(f); in usb9pfs_disable() local
739 usb9pfs_clear_tx(usb9pfs); in usb9pfs_disable()
745 struct f_usb9pfs *usb9pfs; in usb9pfs_alloc() local
747 usb9pfs = kzalloc(sizeof(*usb9pfs), GFP_KERNEL); in usb9pfs_alloc()
748 if (!usb9pfs) in usb9pfs_alloc()
751 spin_lock_init(&usb9pfs->lock); in usb9pfs_alloc()
753 init_completion(&usb9pfs->send); in usb9pfs_alloc()
754 init_completion(&usb9pfs->received); in usb9pfs_alloc()
762 usb9pfs->buflen = usb9pfs_opts->buflen; in usb9pfs_alloc()
764 usb9pfs->function.name = "usb9pfs"; in usb9pfs_alloc()
765 usb9pfs->function.bind = usb9pfs_func_bind; in usb9pfs_alloc()
766 usb9pfs->function.unbind = usb9pfs_func_unbind; in usb9pfs_alloc()
767 usb9pfs->function.set_alt = usb9pfs_set_alt; in usb9pfs_alloc()
768 usb9pfs->function.disable = usb9pfs_disable; in usb9pfs_alloc()
769 usb9pfs->function.strings = usb9pfs_strings; in usb9pfs_alloc()
771 usb9pfs->function.free_func = usb9pfs_free_func; in usb9pfs_alloc()
773 return &usb9pfs->function; in usb9pfs_alloc()
929 DECLARE_USB_FUNCTION(usb9pfs, usb9pfs_alloc_instance, usb9pfs_alloc);