usb: dwc2: gadget: Only initialize device if in device mode
authorJohn Youn <johnyoun@synopsys.com>
Thu, 8 Sep 2016 02:39:37 +0000 (19:39 -0700)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 8 Sep 2016 11:02:50 +0000 (14:02 +0300)
In dwc2_hsotg_udc_start(), don't initialize the controller for device
mode unless we are actually in device mode.

Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc2/gadget.c

index 94bd19a..4cd6403 100644 (file)
@@ -3466,8 +3466,11 @@ static int dwc2_hsotg_udc_start(struct usb_gadget *gadget,
                otg_set_peripheral(hsotg->uphy->otg, &hsotg->gadget);
 
        spin_lock_irqsave(&hsotg->lock, flags);
-       dwc2_hsotg_init(hsotg);
-       dwc2_hsotg_core_init_disconnected(hsotg, false);
+       if (dwc2_hw_is_device(hsotg)) {
+               dwc2_hsotg_init(hsotg);
+               dwc2_hsotg_core_init_disconnected(hsotg, false);
+       }
+
        hsotg->enabled = 0;
        spin_unlock_irqrestore(&hsotg->lock, flags);