aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/composite.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/composite.c')
-rw-r--r--drivers/usb/gadget/composite.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 7b5cc16e4a0b..f6ff8456d52d 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1047,9 +1047,9 @@ composite_unbind(struct usb_gadget *gadget)
1047 kfree(cdev->req->buf); 1047 kfree(cdev->req->buf);
1048 usb_ep_free_request(gadget->ep0, cdev->req); 1048 usb_ep_free_request(gadget->ep0, cdev->req);
1049 } 1049 }
1050 device_remove_file(&gadget->dev, &dev_attr_suspended);
1050 kfree(cdev); 1051 kfree(cdev);
1051 set_gadget_data(gadget, NULL); 1052 set_gadget_data(gadget, NULL);
1052 device_remove_file(&gadget->dev, &dev_attr_suspended);
1053 composite = NULL; 1053 composite = NULL;
1054} 1054}
1055 1055
@@ -1107,14 +1107,6 @@ static int composite_bind(struct usb_gadget *gadget)
1107 */ 1107 */
1108 usb_ep_autoconfig_reset(cdev->gadget); 1108 usb_ep_autoconfig_reset(cdev->gadget);
1109 1109
1110 /* standardized runtime overrides for device ID data */
1111 if (idVendor)
1112 cdev->desc.idVendor = cpu_to_le16(idVendor);
1113 if (idProduct)
1114 cdev->desc.idProduct = cpu_to_le16(idProduct);
1115 if (bcdDevice)
1116 cdev->desc.bcdDevice = cpu_to_le16(bcdDevice);
1117
1118 /* composite gadget needs to assign strings for whole device (like 1110 /* composite gadget needs to assign strings for whole device (like
1119 * serial number), register function drivers, potentially update 1111 * serial number), register function drivers, potentially update
1120 * power state and consumption, etc 1112 * power state and consumption, etc
@@ -1126,7 +1118,15 @@ static int composite_bind(struct usb_gadget *gadget)
1126 cdev->desc = *composite->dev; 1118 cdev->desc = *composite->dev;
1127 cdev->desc.bMaxPacketSize0 = gadget->ep0->maxpacket; 1119 cdev->desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
1128 1120
1129 /* stirng overrides */ 1121 /* standardized runtime overrides for device ID data */
1122 if (idVendor)
1123 cdev->desc.idVendor = cpu_to_le16(idVendor);
1124 if (idProduct)
1125 cdev->desc.idProduct = cpu_to_le16(idProduct);
1126 if (bcdDevice)
1127 cdev->desc.bcdDevice = cpu_to_le16(bcdDevice);
1128
1129 /* string overrides */
1130 if (iManufacturer || !cdev->desc.iManufacturer) { 1130 if (iManufacturer || !cdev->desc.iManufacturer) {
1131 if (!iManufacturer && !composite->iManufacturer && 1131 if (!iManufacturer && !composite->iManufacturer &&
1132 !*composite_manufacturer) 1132 !*composite_manufacturer)
@@ -1188,6 +1188,8 @@ composite_suspend(struct usb_gadget *gadget)
1188 composite->suspend(cdev); 1188 composite->suspend(cdev);
1189 1189
1190 cdev->suspended = 1; 1190 cdev->suspended = 1;
1191
1192 usb_gadget_vbus_draw(gadget, 2);
1191} 1193}
1192 1194
1193static void 1195static void
@@ -1195,6 +1197,7 @@ composite_resume(struct usb_gadget *gadget)
1195{ 1197{
1196 struct usb_composite_dev *cdev = get_gadget_data(gadget); 1198 struct usb_composite_dev *cdev = get_gadget_data(gadget);
1197 struct usb_function *f; 1199 struct usb_function *f;
1200 u8 maxpower;
1198 1201
1199 /* REVISIT: should we have config level 1202 /* REVISIT: should we have config level
1200 * suspend/resume callbacks? 1203 * suspend/resume callbacks?
@@ -1207,6 +1210,11 @@ composite_resume(struct usb_gadget *gadget)
1207 if (f->resume) 1210 if (f->resume)
1208 f->resume(f); 1211 f->resume(f);
1209 } 1212 }
1213
1214 maxpower = cdev->config->bMaxPower;
1215
1216 usb_gadget_vbus_draw(gadget, maxpower ?
1217 (2 * maxpower) : CONFIG_USB_GADGET_VBUS_DRAW);
1210 } 1218 }
1211 1219
1212 cdev->suspended = 0; 1220 cdev->suspended = 0;