usb: dwc2: gadget: don't modify pullup state in host mode
authorGregory Herrero <[email protected]>
Tue, 29 Sep 2015 10:08:19 +0000 (12:08 +0200)
committerFelipe Balbi <[email protected]>
Thu, 1 Oct 2015 17:40:24 +0000 (12:40 -0500)
Modifying the pullup state during host mode trig a new enumeration
of attached device. Thus, avoid modifying pullup in host mode.

Signed-off-by: Gregory Herrero <[email protected]>
Signed-off-by: Mian Yousaf Kaukab <[email protected]>
Tested-by: Robert Baldyga <[email protected]>
Tested-by: Dinh Nguyen <[email protected]>
Tested-by: John Youn <[email protected]>
Acked-by: John Youn <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>
drivers/usb/dwc2/gadget.c

index 36345ab05f7e0d1e5a9f27289282ca5dfa65a4e2..61d102185bf1b3f88e5130174e873b903a97fe3c 100644 (file)
@@ -3170,7 +3170,14 @@ static int dwc2_hsotg_pullup(struct usb_gadget *gadget, int is_on)
        struct dwc2_hsotg *hsotg = to_hsotg(gadget);
        unsigned long flags = 0;
 
-       dev_dbg(hsotg->dev, "%s: is_on: %d\n", __func__, is_on);
+       dev_dbg(hsotg->dev, "%s: is_on: %d op_state: %d\n", __func__, is_on,
+                       hsotg->op_state);
+
+       /* Don't modify pullup state while in host mode */
+       if (hsotg->op_state != OTG_STATE_B_PERIPHERAL) {
+               hsotg->enabled = is_on;
+               return 0;
+       }
 
        mutex_lock(&hsotg->init_mutex);
        spin_lock_irqsave(&hsotg->lock, flags);