usb: gadget: tegra: check vbus before run bit set
Rohith Seelaboyina [Wed, 12 Sep 2012 08:52:15 +0000 (13:52 +0530)]
Adding the check for vbus before setting the
run bit.

Bug 1046443

Reviewed-on: http://git-master/r/131733
(cherry picked from commit e2dcc0fff0bde89eced1482f3df763bfc7afd3a2)

Change-Id: Ie88ad2ab60b0e8c7691d5b66e52f9ee6c19d34fa
Signed-off-by: Rohith Seelaboyina <rseelaboyina@nvidia.com>
Reviewed-on: http://git-master/r/132210
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Venkata Jagadish <vjagadish@nvidia.com>
Reviewed-by: Rakesh Bodla <rbodla@nvidia.com>
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>

drivers/usb/gadget/tegra_udc.c

index 160a8f5..ae5efc0 100644 (file)
@@ -2386,11 +2386,13 @@ static int tegra_udc_start(struct usb_gadget_driver *driver,
 
 
        /* Enable DR IRQ reg and Set usbcmd reg  Run bit */
-       dr_controller_run(udc);
-       udc->usb_state = USB_STATE_ATTACHED;
-       udc->ep0_state = WAIT_FOR_SETUP;
-       udc->ep0_dir = 0;
-       udc->vbus_active = vbus_enabled(udc);
+       if (vbus_enabled(udc)) {
+               dr_controller_run(udc);
+               udc->usb_state = USB_STATE_ATTACHED;
+               udc->ep0_state = WAIT_FOR_SETUP;
+               udc->ep0_dir = 0;
+               udc->vbus_active = vbus_enabled(udc);
+       }
 
        printk(KERN_INFO "%s: bind to driver %s\n",
                        udc->gadget.name, driver->driver.name);