diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/gadget/composite.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index d3250ea7f444..79f4ff1870a3 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -532,7 +532,7 @@ static int set_config(struct usb_composite_dev *cdev, done: usb_gadget_vbus_draw(gadget, power); - switch_set_state(&cdev->sdev, number); + schedule_work(&cdev->switch_work); return result; } @@ -1067,7 +1067,7 @@ static void composite_disconnect(struct usb_gadget *gadget) composite->disconnect(cdev); spin_unlock_irqrestore(&cdev->lock, flags); - switch_set_state(&cdev->sdev, 0); + schedule_work(&cdev->switch_work); } /*-------------------------------------------------------------------------*/ @@ -1158,6 +1158,19 @@ string_override(struct usb_gadget_strings **tab, u8 id, const char *s) } } +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; @@ -1213,6 +1226,7 @@ static int composite_bind(struct usb_gadget *gadget) 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; |