Lines Matching full:gadget

3  * USB Raw Gadget driver.
4 * See Documentation/usb/raw-gadget.rst for more details.
27 #include <linux/usb/gadget.h>
32 #define DRIVER_DESC "USB Raw Gadget"
33 #define DRIVER_NAME "raw-gadget"
175 struct usb_gadget *gadget; member
216 usb_ep_dequeue(dev->gadget->ep0, dev->req); in dev_free()
217 usb_ep_free_request(dev->gadget->ep0, dev->req); in dev_free()
280 static int gadget_bind(struct usb_gadget *gadget, in gadget_bind() argument
289 if (strcmp(gadget->name, dev->udc_name) != 0) in gadget_bind()
292 set_gadget_data(gadget, dev); in gadget_bind()
293 req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL); in gadget_bind()
295 dev_err(&gadget->dev, "usb_ep_alloc_request failed\n"); in gadget_bind()
296 set_gadget_data(gadget, NULL); in gadget_bind()
304 dev->gadget = gadget; in gadget_bind()
305 gadget_for_each_ep(ep, dev->gadget) { in gadget_bind()
314 dev_dbg(&gadget->dev, "gadget connected\n"); in gadget_bind()
317 dev_err(&gadget->dev, "failed to queue connect event\n"); in gadget_bind()
318 set_gadget_data(gadget, NULL); in gadget_bind()
327 static void gadget_unbind(struct usb_gadget *gadget) in gadget_unbind() argument
329 struct raw_dev *dev = get_gadget_data(gadget); in gadget_unbind()
331 set_gadget_data(gadget, NULL); in gadget_unbind()
336 static int gadget_setup(struct usb_gadget *gadget, in gadget_setup() argument
340 struct raw_dev *dev = get_gadget_data(gadget); in gadget_setup()
345 dev_err(&gadget->dev, "ignoring, device is not running\n"); in gadget_setup()
350 dev_dbg(&gadget->dev, "stalling, request already pending\n"); in gadget_setup()
362 dev_err(&gadget->dev, "failed to queue control event\n"); in gadget_setup()
381 static void gadget_disconnect(struct usb_gadget *gadget) in gadget_disconnect() argument
383 struct raw_dev *dev = get_gadget_data(gadget); in gadget_disconnect()
386 dev_dbg(&gadget->dev, "gadget disconnected\n"); in gadget_disconnect()
389 dev_err(&gadget->dev, "failed to queue disconnect event\n"); in gadget_disconnect()
391 static void gadget_suspend(struct usb_gadget *gadget) in gadget_suspend() argument
393 struct raw_dev *dev = get_gadget_data(gadget); in gadget_suspend()
396 dev_dbg(&gadget->dev, "gadget suspended\n"); in gadget_suspend()
399 dev_err(&gadget->dev, "failed to queue suspend event\n"); in gadget_suspend()
401 static void gadget_resume(struct usb_gadget *gadget) in gadget_resume() argument
403 struct raw_dev *dev = get_gadget_data(gadget); in gadget_resume()
406 dev_dbg(&gadget->dev, "gadget resumed\n"); in gadget_resume()
409 dev_err(&gadget->dev, "failed to queue resume event\n"); in gadget_resume()
411 static void gadget_reset(struct usb_gadget *gadget) in gadget_reset() argument
413 struct raw_dev *dev = get_gadget_data(gadget); in gadget_reset()
416 dev_dbg(&gadget->dev, "gadget reset\n"); in gadget_reset()
419 dev_err(&gadget->dev, "failed to queue reset event\n"); in gadget_reset()
452 if (!dev->gadget) { in raw_release()
630 if (!dev->gadget) { in raw_ioctl_event_fetch()
631 dev_dbg(dev->dev, "fail, gadget is not bound\n"); in raw_ioctl_event_fetch()
639 dev_dbg(&dev->gadget->dev, "event fetching interrupted\n"); in raw_ioctl_event_fetch()
643 dev_err(&dev->gadget->dev, "failed to fetch event\n"); in raw_ioctl_event_fetch()
694 if (!dev->gadget) { in raw_process_ep0_io()
695 dev_dbg(dev->dev, "fail, gadget is not bound\n"); in raw_process_ep0_io()
700 dev_dbg(&dev->gadget->dev, "fail, urb already queued\n"); in raw_process_ep0_io()
706 dev_dbg(&dev->gadget->dev, "fail, wrong direction\n"); in raw_process_ep0_io()
727 ret = usb_ep_queue(dev->gadget->ep0, dev->req, GFP_KERNEL); in raw_process_ep0_io()
729 dev_err(&dev->gadget->dev, in raw_process_ep0_io()
737 dev_dbg(&dev->gadget->dev, "wait interrupted\n"); in raw_process_ep0_io()
738 usb_ep_dequeue(dev->gadget->ep0, dev->req); in raw_process_ep0_io()
808 if (!dev->gadget) { in raw_ioctl_ep0_stall()
809 dev_dbg(dev->dev, "fail, gadget is not bound\n"); in raw_ioctl_ep0_stall()
814 dev_dbg(&dev->gadget->dev, "fail, urb already queued\n"); in raw_ioctl_ep0_stall()
819 dev_dbg(&dev->gadget->dev, "fail, no request pending\n"); in raw_ioctl_ep0_stall()
824 ret = usb_ep_set_halt(dev->gadget->ep0); in raw_ioctl_ep0_stall()
826 dev_err(&dev->gadget->dev, in raw_ioctl_ep0_stall()
867 if (!dev->gadget) { in raw_ioctl_ep_enable()
868 dev_dbg(dev->dev, "fail, gadget is not bound\n"); in raw_ioctl_ep_enable()
878 if (!usb_gadget_ep_match_desc(dev->gadget, ep->ep, desc, NULL)) in raw_ioctl_ep_enable()
886 dev_err(&dev->gadget->dev, in raw_ioctl_ep_enable()
892 dev_err(&dev->gadget->dev, in raw_ioctl_ep_enable()
905 dev_dbg(&dev->gadget->dev, "fail, bad endpoint descriptor\n"); in raw_ioctl_ep_enable()
908 dev_dbg(&dev->gadget->dev, "fail, no endpoints available\n"); in raw_ioctl_ep_enable()
930 if (!dev->gadget) { in raw_ioctl_ep_disable()
931 dev_dbg(dev->dev, "fail, gadget is not bound\n"); in raw_ioctl_ep_disable()
941 dev_dbg(&dev->gadget->dev, "fail, endpoint is not enabled\n"); in raw_ioctl_ep_disable()
946 dev_dbg(&dev->gadget->dev, in raw_ioctl_ep_disable()
952 dev_dbg(&dev->gadget->dev, in raw_ioctl_ep_disable()
985 if (!dev->gadget) { in raw_ioctl_ep_set_clear_halt_wedge()
986 dev_dbg(dev->dev, "fail, gadget is not bound\n"); in raw_ioctl_ep_set_clear_halt_wedge()
996 dev_dbg(&dev->gadget->dev, "fail, endpoint is not enabled\n"); in raw_ioctl_ep_set_clear_halt_wedge()
1001 dev_dbg(&dev->gadget->dev, in raw_ioctl_ep_set_clear_halt_wedge()
1007 dev_dbg(&dev->gadget->dev, in raw_ioctl_ep_set_clear_halt_wedge()
1013 dev_dbg(&dev->gadget->dev, in raw_ioctl_ep_set_clear_halt_wedge()
1022 dev_err(&dev->gadget->dev, in raw_ioctl_ep_set_clear_halt_wedge()
1027 dev_err(&dev->gadget->dev, in raw_ioctl_ep_set_clear_halt_wedge()
1032 dev_err(&dev->gadget->dev, in raw_ioctl_ep_set_clear_halt_wedge()
1071 if (!dev->gadget) { in raw_process_ep_io()
1072 dev_dbg(dev->dev, "fail, gadget is not bound\n"); in raw_process_ep_io()
1077 dev_dbg(&dev->gadget->dev, "fail, invalid endpoint\n"); in raw_process_ep_io()
1083 dev_dbg(&dev->gadget->dev, "fail, endpoint is not enabled\n"); in raw_process_ep_io()
1088 dev_dbg(&dev->gadget->dev, in raw_process_ep_io()
1094 dev_dbg(&dev->gadget->dev, "fail, urb already queued\n"); in raw_process_ep_io()
1099 dev_dbg(&dev->gadget->dev, "fail, wrong direction\n"); in raw_process_ep_io()
1115 dev_err(&dev->gadget->dev, in raw_process_ep_io()
1123 dev_dbg(&dev->gadget->dev, "wait interrupted\n"); in raw_process_ep_io()
1194 if (!dev->gadget) { in raw_ioctl_configure()
1195 dev_dbg(dev->dev, "fail, gadget is not bound\n"); in raw_ioctl_configure()
1199 usb_gadget_set_state(dev->gadget, USB_STATE_CONFIGURED); in raw_ioctl_configure()
1217 if (!dev->gadget) { in raw_ioctl_vbus_draw()
1218 dev_dbg(dev->dev, "fail, gadget is not bound\n"); in raw_ioctl_vbus_draw()
1222 usb_gadget_vbus_draw(dev->gadget, 2 * value); in raw_ioctl_vbus_draw()
1266 if (!dev->gadget) { in raw_ioctl_eps_info()
1267 dev_dbg(dev->dev, "fail, gadget is not bound\n"); in raw_ioctl_eps_info()