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

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

drivers/usb/gadget/tegra_udc.c

index aaffe84..ddf9c60 100644 (file)
@@ -2364,11 +2364,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);