diff options
author | Kamil Debski <k.debski@samsung.com> | 2014-06-09 14:12:41 +0200 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-11-18 11:59:53 +0900 |
commit | e6d791b365467674e3ebb9647919e58d12f985fa (patch) | |
tree | cec002d087ecdcd9c0f2571be8cd0e1ccf49bc00 /drivers | |
parent | b8e91f4ad89b5f68ec852f004b71ae1b366430e0 (diff) | |
download | linux-3.10-e6d791b365467674e3ebb9647919e58d12f985fa.tar.gz linux-3.10-e6d791b365467674e3ebb9647919e58d12f985fa.tar.bz2 linux-3.10-e6d791b365467674e3ebb9647919e58d12f985fa.zip |
usb: gadget: udc: Fix initialization sequence with extcon present
Prior to this patch during initialization the udc would switch off regardless
of the current state of the cable. Then it would be enabled if the cable is
present. After applying this patch the udc would be disabled only if the cable
is not present during initialization.
Change-Id: Icfd7e42f9890798afb92428f4041dcffefaa2a08
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/gadget/udc-core.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c index 1db6f187674..1011c2141f2 100644 --- a/drivers/usb/gadget/udc-core.c +++ b/drivers/usb/gadget/udc-core.c @@ -376,6 +376,8 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri udc->gadget->dev.driver = &driver->driver; node = udc->gadget->dev.of_node; + + edev = 0; /* Check if we have an extcon associated with the UDC driver */ if (node && of_property_read_bool(node, "extcon")) { edev = extcon_get_edev_by_phandle(&udc->gadget->dev, 0); @@ -402,20 +404,25 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri ret = driver->bind(udc->gadget, driver); if (ret) goto err2; - ret = usb_gadget_udc_start(udc->gadget, driver); - if (ret) { - driver->unbind(udc->gadget); - goto err2; - } - - usb_gadget_connect(udc->gadget); if (udc->extcon_usb_dev.edev) { - udc->enabled = 1; + udc->enabled = 0; udc->cable_state = extcon_get_cable_state_( udc->extcon_usb_dev.edev, udc->extcon_usb_dev.cable_index); - queue_work(udc->pwr_workqueue, &udc->pwr_work); + } else { + udc->cable_state = 1; + } + + if (udc->cable_state) { + ret = usb_gadget_udc_start(udc->gadget, driver); + if (ret) { + driver->unbind(udc->gadget); + goto err2; + } + + usb_gadget_connect(udc->gadget); + udc->enabled = 1; } kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); |