]> git.karo-electronics.de Git - linux-beck.git/commitdiff
usb: gadget: udc-core: stop UDC on device-initiated disconnect
authorFelipe Balbi <balbi@ti.com>
Thu, 15 Mar 2012 14:37:18 +0000 (16:37 +0200)
committerFelipe Balbi <balbi@ti.com>
Tue, 10 Apr 2012 09:21:32 +0000 (12:21 +0300)
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.

Cc: stable@vger.kernel.org
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/udc-core.c

index 56da49f31d6c35a0f61611c1bb651b51e59732ab..c261887e05aeaa9369839b176ff78fc64e6394f4 100644 (file)
@@ -411,8 +411,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);