done:
usb_gadget_vbus_draw(gadget, power);
- switch_set_state(&cdev->sdev, number);
+ schedule_work(&cdev->switch_work);
if (result >= 0 && cdev->delayed_status)
result = USB_GADGET_DELAYED_STATUS;
composite->disconnect(cdev);
spin_unlock_irqrestore(&cdev->lock, flags);
- switch_set_state(&cdev->sdev, 0);
+ schedule_work(&cdev->switch_work);
}
/*-------------------------------------------------------------------------*/
return *desc;
}
+static void
+composite_switch_work(struct work_struct *data)
+{
+ struct usb_composite_dev *cdev =
+ container_of(data, struct usb_composite_dev, switch_work);
+ struct usb_configuration *config = cdev->config;
+
+ if (config)
+ switch_set_state(&cdev->sdev, config->bConfigurationValue);
+ else
+ switch_set_state(&cdev->sdev, 0);
+}
+
static int composite_bind(struct usb_gadget *gadget)
{
struct usb_composite_dev *cdev;
status = switch_dev_register(&cdev->sdev);
if (status < 0)
goto fail;
+ INIT_WORK(&cdev->switch_work, composite_switch_work);
cdev->desc = *composite->dev;
cdev->desc.bMaxPacketSize0 = gadget->ep0->maxpacket;