15 #ifndef __LINUX_USB_GADGET_H
16 #define __LINUX_USB_GADGET_H
18 #include <linux/device.h>
19 #include <linux/errno.h>
21 #include <linux/list.h>
22 #include <linux/slab.h>
24 #include <linux/types.h>
25 #include <linux/usb/ch9.h>
203 static inline int usb_ep_enable(
struct usb_ep *ep)
205 return ep->
ops->enable(ep, ep->
desc);
220 static inline int usb_ep_disable(
struct usb_ep *ep)
222 return ep->
ops->disable(ep);
242 return ep->
ops->alloc_request(ep, gfp_flags);
254 static inline void usb_ep_free_request(
struct usb_ep *ep,
257 ep->
ops->free_request(ep, req);
317 static inline int usb_ep_queue(
struct usb_ep *ep,
320 return ep->
ops->queue(ep, req, gfp_flags);
339 return ep->
ops->dequeue(ep, req);
363 static inline int usb_ep_set_halt(
struct usb_ep *ep)
365 return ep->
ops->set_halt(ep, 1);
381 static inline int usb_ep_clear_halt(
struct usb_ep *ep)
383 return ep->
ops->set_halt(ep, 0);
397 usb_ep_set_wedge(
struct usb_ep *ep)
399 if (ep->
ops->set_wedge)
400 return ep->
ops->set_wedge(ep);
402 return ep->
ops->set_halt(ep, 1);
420 static inline int usb_ep_fifo_status(
struct usb_ep *ep)
422 if (ep->
ops->fifo_status)
423 return ep->
ops->fifo_status(ep);
437 static inline void usb_ep_fifo_flush(
struct usb_ep *ep)
439 if (ep->
ops->fifo_flush)
440 ep->
ops->fifo_flush(ep);
448 #define USB_DEFAULT_U1_DEV_EXIT_LAT 0x01
450 #define USB_DEFAULT_U2_DEV_EXIT_LAT 0x1F4
546 static inline void set_gadget_data(
struct usb_gadget *gadget,
void *
data)
548 static inline void *get_gadget_data(
struct usb_gadget *gadget)
556 #define gadget_for_each_ep(tmp, gadget) \
557 list_for_each_entry(tmp, &(gadget)->ep_list, ep_list)
564 static inline int gadget_is_dualspeed(
struct usb_gadget *g)
574 static inline int gadget_is_superspeed(
struct usb_gadget *g)
586 static inline int gadget_is_otg(
struct usb_gadget *g)
588 #ifdef CONFIG_USB_OTG
602 static inline int usb_gadget_frame_number(
struct usb_gadget *gadget)
604 return gadget->
ops->get_frame(gadget);
620 static inline int usb_gadget_wakeup(
struct usb_gadget *gadget)
622 if (!gadget->
ops->wakeup)
624 return gadget->
ops->wakeup(gadget);
636 static inline int usb_gadget_set_selfpowered(
struct usb_gadget *gadget)
638 if (!gadget->
ops->set_selfpowered)
640 return gadget->
ops->set_selfpowered(gadget, 1);
653 static inline int usb_gadget_clear_selfpowered(
struct usb_gadget *gadget)
655 if (!gadget->
ops->set_selfpowered)
657 return gadget->
ops->set_selfpowered(gadget, 0);
673 static inline int usb_gadget_vbus_connect(
struct usb_gadget *gadget)
675 if (!gadget->
ops->vbus_session)
677 return gadget->
ops->vbus_session(gadget, 1);
692 static inline int usb_gadget_vbus_draw(
struct usb_gadget *gadget,
unsigned mA)
694 if (!gadget->
ops->vbus_draw)
696 return gadget->
ops->vbus_draw(gadget, mA);
710 static inline int usb_gadget_vbus_disconnect(
struct usb_gadget *gadget)
712 if (!gadget->
ops->vbus_session)
714 return gadget->
ops->vbus_session(gadget, 0);
728 static inline int usb_gadget_connect(
struct usb_gadget *gadget)
730 if (!gadget->
ops->pullup)
732 return gadget->
ops->pullup(gadget, 1);
750 static inline int usb_gadget_disconnect(
struct usb_gadget *gadget)
752 if (!gadget->
ops->pullup)
754 return gadget->
ops->pullup(gadget, 0);