aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb/gadget.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/usb/gadget.h')
-rw-r--r--include/linux/usb/gadget.h29
1 files changed, 27 insertions, 2 deletions
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index c14a69b36d27..3d583a10b926 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -215,6 +215,7 @@ struct usb_ep {
215 struct list_head ep_list; 215 struct list_head ep_list;
216 struct usb_ep_caps caps; 216 struct usb_ep_caps caps;
217 bool claimed; 217 bool claimed;
218 bool enabled;
218 unsigned maxpacket:16; 219 unsigned maxpacket:16;
219 unsigned maxpacket_limit:16; 220 unsigned maxpacket_limit:16;
220 unsigned max_streams:16; 221 unsigned max_streams:16;
@@ -264,7 +265,18 @@ static inline void usb_ep_set_maxpacket_limit(struct usb_ep *ep,
264 */ 265 */
265static inline int usb_ep_enable(struct usb_ep *ep) 266static inline int usb_ep_enable(struct usb_ep *ep)
266{ 267{
267 return ep->ops->enable(ep, ep->desc); 268 int ret;
269
270 if (ep->enabled)
271 return 0;
272
273 ret = ep->ops->enable(ep, ep->desc);
274 if (ret)
275 return ret;
276
277 ep->enabled = true;
278
279 return 0;
268} 280}
269 281
270/** 282/**
@@ -281,7 +293,18 @@ static inline int usb_ep_enable(struct usb_ep *ep)
281 */ 293 */
282static inline int usb_ep_disable(struct usb_ep *ep) 294static inline int usb_ep_disable(struct usb_ep *ep)
283{ 295{
284 return ep->ops->disable(ep); 296 int ret;
297
298 if (!ep->enabled)
299 return 0;
300
301 ret = ep->ops->disable(ep);
302 if (ret)
303 return ret;
304
305 ep->enabled = false;
306
307 return 0;
285} 308}
286 309
287/** 310/**
@@ -1233,6 +1256,8 @@ extern struct usb_ep *usb_ep_autoconfig_ss(struct usb_gadget *,
1233 struct usb_endpoint_descriptor *, 1256 struct usb_endpoint_descriptor *,
1234 struct usb_ss_ep_comp_descriptor *); 1257 struct usb_ss_ep_comp_descriptor *);
1235 1258
1259extern void usb_ep_autoconfig_release(struct usb_ep *);
1260
1236extern void usb_ep_autoconfig_reset(struct usb_gadget *); 1261extern void usb_ep_autoconfig_reset(struct usb_gadget *);
1237 1262
1238#endif /* __LINUX_USB_GADGET_H */ 1263#endif /* __LINUX_USB_GADGET_H */