diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2018-08-10 21:32:25 +0200 |
---|---|---|
committer | Felipe Balbi <felipe.balbi@linux.intel.com> | 2018-10-02 09:44:11 +0200 |
commit | 0a55187a1ec8c03d0619e7ce41d10fdc39cff036 (patch) | |
tree | 64f9a84cb4712b6a6f949456f63767f7cbf411d9 /drivers/usb | |
parent | usb: dwc3: Fix spelling of 'optimizations' (diff) | |
download | linux-0a55187a1ec8c03d0619e7ce41d10fdc39cff036.tar.xz linux-0a55187a1ec8c03d0619e7ce41d10fdc39cff036.zip |
USB: gadget core: Issue ->disconnect() callback from usb_gadget_disconnect()
The gadget documentation doesn't state clearly whether a gadget
driver's ->disconnect() callback should be invoked when the D+ pullup
is turned off. Some UDC drivers do this and some don't. This patch
settles the issue by making the core function usb_gadget_disconnect()
issue the callback, so that UDC drivers don't need to worry about it.
A description of the new behavior is added to the function's
kerneldoc. Also, the patch removes a few superseded callbacks from
other core routines.
Future patches will remove the ->disconnect() calls from the UDC
drivers that make them, as they are now unnecessary. Until all those
patches are merged gadget drivers may receive extra ->disconnect()
callbacks, but this should be harmless.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/udc/core.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c index af88b48c1cea..87d6b12779f2 100644 --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c @@ -690,6 +690,9 @@ EXPORT_SYMBOL_GPL(usb_gadget_connect); * as a disconnect (when a VBUS session is active). Not all systems * support software pullup controls. * + * Following a successful disconnect, invoke the ->disconnect() callback + * for the current gadget driver so that UDC drivers don't need to. + * * Returns zero on success, else negative errno. */ int usb_gadget_disconnect(struct usb_gadget *gadget) @@ -711,8 +714,10 @@ int usb_gadget_disconnect(struct usb_gadget *gadget) } ret = gadget->ops->pullup(gadget, 0); - if (!ret) + if (!ret) { gadget->connected = 0; + gadget->udc->driver->disconnect(gadget); + } out: trace_usb_gadget_disconnect(gadget, ret); @@ -1281,7 +1286,6 @@ static void usb_gadget_remove_driver(struct usb_udc *udc) kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); usb_gadget_disconnect(udc->gadget); - udc->driver->disconnect(udc->gadget); udc->driver->unbind(udc->gadget); usb_gadget_udc_stop(udc); @@ -1471,7 +1475,6 @@ static ssize_t soft_connect_store(struct device *dev, usb_gadget_connect(udc->gadget); } else if (sysfs_streq(buf, "disconnect")) { usb_gadget_disconnect(udc->gadget); - udc->driver->disconnect(udc->gadget); usb_gadget_udc_stop(udc); } else { dev_err(dev, "unsupported command '%s'\n", buf); |