summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/gadget/composite.c18
-rw-r--r--include/linux/usb/composite.h1
2 files changed, 17 insertions, 2 deletions
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index f917efb4926c..cb35adc59f89 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -781,7 +781,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);
if (result >= 0 && cdev->delayed_status)
result = USB_GADGET_DELAYED_STATUS;
@@ -1430,7 +1430,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);
}
/*-------------------------------------------------------------------------*/
@@ -1511,6 +1511,19 @@ static u8 override_id(struct usb_composite_dev *cdev, u8 *desc)
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;
@@ -1564,6 +1577,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;
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index f9ca73feb9ea..9405ea22f566 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -376,6 +376,7 @@ struct usb_composite_dev {
spinlock_t lock;
struct switch_dev sdev;
+ struct work_struct switch_work;
};
extern int usb_string_id(struct usb_composite_dev *c);