@@ -501,13 +501,16 @@ static irqreturn_t max3420_vbus_handler(int irq, void *dev_id)
unsigned long flags;
spin_lock_irqsave(&udc->lock, flags);
+
/* its a vbus change interrupt */
udc->vbus_active = !udc->vbus_active;
udc->todo |= UDC_START;
+
+ spin_unlock_irqrestore(&udc->lock, flags);
+
usb_udc_vbus_handler(&udc->gadget, udc->vbus_active);
usb_gadget_set_state(&udc->gadget, udc->vbus_active
? USB_STATE_POWERED : USB_STATE_NOTATTACHED);
- spin_unlock_irqrestore(&udc->lock, flags);
if (udc->thread_task)
wake_up_process(udc->thread_task);
@@ -1298,15 +1301,14 @@ static int max3420_probe(struct spi_device *spi)
static void max3420_remove(struct spi_device *spi)
{
struct max3420_udc *udc = spi_get_drvdata(spi);
- unsigned long flags;
usb_del_gadget_udc(&udc->gadget);
- spin_lock_irqsave(&udc->lock, flags);
+ mutex_lock(&udc->spi_bus_mutex);
kthread_stop(udc->thread_task);
- spin_unlock_irqrestore(&udc->lock, flags);
+ mutex_unlock(&udc->spi_bus_mutex);
}
static const struct of_device_id max3420_udc_of_match[] = {