[RFC,0/7] usb: gadget: add reset API at usb_gadget_driver

Message ID 20140902155051.GI16872@saruman.home
State New
Headers show

Commit Message

Felipe Balbi Sept. 2, 2014, 3:50 p.m.
On Tue, Sep 02, 2014 at 10:43:37AM -0500, Felipe Balbi wrote:
> On Tue, Sep 02, 2014 at 11:32:52AM -0400, Alan Stern wrote:
> > On Fri, 29 Aug 2014, Felipe Balbi wrote:
> > 
> > > > I still have some old patch files lying around, adding reset callback
> > > > support to dummy-hcd, net2280, and net2272.  Would you like me to post
> > > > them?
> > > 
> > > Please do :-) let's get all of that sorted out soon.
> > 
> > Patches coming up.  These were written about two years ago, and
> > although they have been forward-ported, I haven't tested them since
> > they were written.  They are based on a patch you posted on August 16, 
> > 2012 (usb: gadget: add reset method to struct usb_gadget_driver).
> alright, I still have my branch with that patch together with musb and
> dwc3 implementation. The problem I see, though, is that all three of
> your patches and my dwc3 and musb implementation conditionally calls
> ->disconnect() if the gadget driver doesn't driver doesn't implement
> ->reset(). If we're talking about usb_gadget_disconnect() from
> ->disconnect(), than all 5 patches will cause regressions.

and in fact, the way we discussed way back, ->reset() was supposed to be

commit e95e07648e892bfe811ce2e68ba6e0dc64ae458d
Author: Felipe Balbi <balbi@ti.com>
Date:   Wed Aug 15 20:41:40 2012 +0300

    usb: gadget: add reset method to struct usb_gadget_driver
    Some gadget drivers might benefit from having
    separate ->disconnect and ->reset notifications.
    For those gadget drivers which don't care, they
    can implement only ->disconnect and UDC driver
    is required to call ->disconnect case ->reset
    isn't valid.
    Signed-off-by: Felipe Balbi <balbi@ti.com>

are we changing that too ?


diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index c3a6185..7b0661a 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -810,6 +810,10 @@  static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
  *	when the host is disconnected.  May be called in_interrupt; this
  *	may not sleep.  Some devices can't detect disconnect, so this might
  *	not be called except as part of controller shutdown.
+ * @reset: Invoked from reset interrupt handler. This call may not sleep.
+ *	Some gadget drivers might benefit from having a different @reset
+ *	and @disconnect methods. For those which don't provide @reset,
+ *	UDC driver is expected to call @disconnect.
  * @bind: the driver's bind callback
  * @unbind: Invoked when the driver is unbound from a gadget,
  *	usually from rmmod (after a disconnect is reported).
@@ -871,6 +875,7 @@  struct usb_gadget_driver {
 	int			(*setup)(struct usb_gadget *,
 					const struct usb_ctrlrequest *);
 	void			(*disconnect)(struct usb_gadget *);
+	void			(*reset)(struct usb_gadget *);
 	void			(*suspend)(struct usb_gadget *);
 	void			(*resume)(struct usb_gadget *);