usb: gadget: fsl_udc: Unlock the spinlock before calling clk_enable
authorBenoit Goby <benoit@android.com>
Wed, 29 Sep 2010 23:04:25 +0000 (16:04 -0700)
committerColin Cross <ccross@android.com>
Wed, 6 Oct 2010 23:28:57 +0000 (16:28 -0700)
On suspend, dr_controller_stop disable interrupts and on resume, interrupts
are disabled until dr_controller_run is called, so it is safe to call
fsl_udc_clk_suspend/resume with interrupts and the spinlock unlocked.

Change-Id: I33618295ea096a4bfd796d1a07dfc9722e7786b0
Signed-off-by: Benoit Goby <benoit@android.com>
drivers/usb/gadget/fsl_udc_core.c

index fa37f529ae53e44e53f0ab122a320666c063ab39..1242c1a57e43032711e54161c73780d199b141ae 100644 (file)
@@ -1162,24 +1162,25 @@ static int fsl_vbus_session(struct usb_gadget *gadget, int is_active)
                        /* stop the controller and turn off the clocks */
                        dr_controller_stop(udc);
                        dr_controller_reset(udc);
+                       spin_unlock_irqrestore(&udc->lock, flags);
                        fsl_udc_clk_suspend();
                        udc->vbus_active = 0;
                        udc->usb_state = USB_STATE_DEFAULT;
                } else if (!udc->vbus_active && is_active) {
+                       spin_unlock_irqrestore(&udc->lock, flags);
                        fsl_udc_clk_resume();
                        /* setup the controller in the device mode */
                        dr_controller_setup(udc);
                        /* setup EP0 for setup packet */
                        ep0_setup(udc);
-                       /* start the controller */
-                       dr_controller_run(udc);
                        /* initialize the USB and EP states */
                        udc->usb_state = USB_STATE_ATTACHED;
                        udc->ep0_state = WAIT_FOR_SETUP;
                        udc->ep0_dir = 0;
                        udc->vbus_active = 1;
+                       /* start the controller */
+                       dr_controller_run(udc);
                }
-               spin_unlock_irqrestore(&udc->lock, flags);
                return 0;
        }