From: Felipe Balbi Date: Thu, 15 Mar 2012 14:37:18 +0000 (+0200) Subject: usb: gadget: udc-core: stop UDC on device-initiated disconnect X-Git-Tag: v3.2.17~137 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=cae3fe8f1d95bf654378f9dc8b3404348ac7225c;p=karo-tx-linux.git usb: gadget: udc-core: stop UDC on device-initiated disconnect commit 6d258a4c42089229b855fd706622029decf316d6 upstream. When we want to do device-initiated disconnect, let's make sure we stop the UDC in order to e.g. allow lower power states to be achieved by turning off unnecessary clocks and/or stoping PHYs. When reconnecting, call ->udc_start() again to make sure UDC is reinitialized. Signed-off-by: Felipe Balbi Signed-off-by: Ben Hutchings --- diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c index 6939e17f4580..93b03738c1b1 100644 --- a/drivers/usb/gadget/udc-core.c +++ b/drivers/usb/gadget/udc-core.c @@ -359,8 +359,12 @@ static ssize_t usb_udc_softconn_store(struct device *dev, struct usb_udc *udc = container_of(dev, struct usb_udc, dev); if (sysfs_streq(buf, "connect")) { + if (udc_is_newstyle(udc)) + usb_gadget_udc_start(udc->gadget, udc->driver); usb_gadget_connect(udc->gadget); } else if (sysfs_streq(buf, "disconnect")) { + if (udc_is_newstyle(udc)) + usb_gadget_udc_stop(udc->gadget, udc->driver); usb_gadget_disconnect(udc->gadget); } else { dev_err(dev, "unsupported command '%s'\n", buf);