aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2011-06-23 08:26:11 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-07-01 17:31:12 -0400
commit765f5b830e547229bb752e7b232ee83e2b3d49d5 (patch)
treeffa37920a165fd3a964b7e0f333f6509d3e59de3 /drivers/usb
parent193ab2a6070039e7ee2b9b9bebea754a7c52fd1b (diff)
usb: gadget: defer setting maxpacket till ->setup()
maxpacket is set by the udc driver for ep0 very early. This value is copied by the function gadget used later for the USB_DT_DEVICE and USB_DT_DEVICE_QUALIFIER query. This seems to work fine so far. For USB3 we need set a different value here. In SS speed it is 2^x with x=9 and in HS we set something <= 64. If the UDC starts in SS and continues in HS after the cable has been plugged it will report a too small value. There setting of this value is defered and taken automaticly from the ep0 pointer where the UDC driver can update it according to the speed it detected _after_ a cable has been plugged. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/composite.c3
-rw-r--r--drivers/usb/gadget/dbgp.c2
-rw-r--r--drivers/usb/gadget/file_storage.c10
-rw-r--r--drivers/usb/gadget/gmidi.c3
-rw-r--r--drivers/usb/gadget/inode.c5
-rw-r--r--drivers/usb/gadget/printer.c14
6 files changed, 20 insertions, 17 deletions
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index c5abe270970a..5ef87794fd32 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -573,7 +573,7 @@ static void device_qual(struct usb_composite_dev *cdev)
573 qual->bDeviceSubClass = cdev->desc.bDeviceSubClass; 573 qual->bDeviceSubClass = cdev->desc.bDeviceSubClass;
574 qual->bDeviceProtocol = cdev->desc.bDeviceProtocol; 574 qual->bDeviceProtocol = cdev->desc.bDeviceProtocol;
575 /* ASSUME same EP0 fifo size at both speeds */ 575 /* ASSUME same EP0 fifo size at both speeds */
576 qual->bMaxPacketSize0 = cdev->desc.bMaxPacketSize0; 576 qual->bMaxPacketSize0 = cdev->gadget->ep0->maxpacket;
577 qual->bNumConfigurations = count_configs(cdev, USB_DT_DEVICE_QUALIFIER); 577 qual->bNumConfigurations = count_configs(cdev, USB_DT_DEVICE_QUALIFIER);
578 qual->bRESERVED = 0; 578 qual->bRESERVED = 0;
579} 579}
@@ -1450,7 +1450,6 @@ static int composite_bind(struct usb_gadget *gadget)
1450 goto fail; 1450 goto fail;
1451 1451
1452 cdev->desc = *composite->dev; 1452 cdev->desc = *composite->dev;
1453 cdev->desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
1454 1453
1455 /* standardized runtime overrides for device ID data */ 1454 /* standardized runtime overrides for device ID data */
1456 if (idVendor) 1455 if (idVendor)
diff --git a/drivers/usb/gadget/dbgp.c b/drivers/usb/gadget/dbgp.c
index 052209e89271..8beefdd36787 100644
--- a/drivers/usb/gadget/dbgp.c
+++ b/drivers/usb/gadget/dbgp.c
@@ -314,7 +314,6 @@ static int __init dbgp_bind(struct usb_gadget *gadget)
314 314
315 dbgp.req->length = DBGP_REQ_EP0_LEN; 315 dbgp.req->length = DBGP_REQ_EP0_LEN;
316 gadget->ep0->driver_data = gadget; 316 gadget->ep0->driver_data = gadget;
317 device_desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
318 317
319#ifdef CONFIG_USB_G_DBGP_SERIAL 318#ifdef CONFIG_USB_G_DBGP_SERIAL
320 dbgp.serial = kzalloc(sizeof(struct gserial), GFP_KERNEL); 319 dbgp.serial = kzalloc(sizeof(struct gserial), GFP_KERNEL);
@@ -365,6 +364,7 @@ static int dbgp_setup(struct usb_gadget *gadget,
365 dev_dbg(&dbgp.gadget->dev, "setup: desc device\n"); 364 dev_dbg(&dbgp.gadget->dev, "setup: desc device\n");
366 len = sizeof device_desc; 365 len = sizeof device_desc;
367 data = &device_desc; 366 data = &device_desc;
367 device_desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
368 break; 368 break;
369 case USB_DT_DEBUG: 369 case USB_DT_DEBUG:
370 dev_dbg(&dbgp.gadget->dev, "setup: desc debug\n"); 370 dev_dbg(&dbgp.gadget->dev, "setup: desc debug\n");
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 738591a64bb4..639e14a2fd15 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -929,6 +929,7 @@ static int standard_setup_req(struct fsg_dev *fsg,
929 929
930 case USB_DT_DEVICE: 930 case USB_DT_DEVICE:
931 VDBG(fsg, "get device descriptor\n"); 931 VDBG(fsg, "get device descriptor\n");
932 device_desc.bMaxPacketSize0 = fsg->ep0->maxpacket;
932 value = sizeof device_desc; 933 value = sizeof device_desc;
933 memcpy(req->buf, &device_desc, value); 934 memcpy(req->buf, &device_desc, value);
934 break; 935 break;
@@ -936,6 +937,11 @@ static int standard_setup_req(struct fsg_dev *fsg,
936 VDBG(fsg, "get device qualifier\n"); 937 VDBG(fsg, "get device qualifier\n");
937 if (!gadget_is_dualspeed(fsg->gadget)) 938 if (!gadget_is_dualspeed(fsg->gadget))
938 break; 939 break;
940 /*
941 * Assume ep0 uses the same maxpacket value for both
942 * speeds
943 */
944 dev_qualifier.bMaxPacketSize0 = fsg->ep0->maxpacket;
939 value = sizeof dev_qualifier; 945 value = sizeof dev_qualifier;
940 memcpy(req->buf, &dev_qualifier, value); 946 memcpy(req->buf, &dev_qualifier, value);
941 break; 947 break;
@@ -3417,7 +3423,6 @@ static int __init fsg_bind(struct usb_gadget *gadget)
3417 } 3423 }
3418 3424
3419 /* Fix up the descriptors */ 3425 /* Fix up the descriptors */
3420 device_desc.bMaxPacketSize0 = fsg->ep0->maxpacket;
3421 device_desc.idVendor = cpu_to_le16(mod_data.vendor); 3426 device_desc.idVendor = cpu_to_le16(mod_data.vendor);
3422 device_desc.idProduct = cpu_to_le16(mod_data.product); 3427 device_desc.idProduct = cpu_to_le16(mod_data.product);
3423 device_desc.bcdDevice = cpu_to_le16(mod_data.release); 3428 device_desc.bcdDevice = cpu_to_le16(mod_data.release);
@@ -3431,9 +3436,6 @@ static int __init fsg_bind(struct usb_gadget *gadget)
3431 if (gadget_is_dualspeed(gadget)) { 3436 if (gadget_is_dualspeed(gadget)) {
3432 fsg_hs_function[i + FSG_HS_FUNCTION_PRE_EP_ENTRIES] = NULL; 3437 fsg_hs_function[i + FSG_HS_FUNCTION_PRE_EP_ENTRIES] = NULL;
3433 3438
3434 /* Assume ep0 uses the same maxpacket value for both speeds */
3435 dev_qualifier.bMaxPacketSize0 = fsg->ep0->maxpacket;
3436
3437 /* Assume endpoint addresses are the same for both speeds */ 3439 /* Assume endpoint addresses are the same for both speeds */
3438 fsg_hs_bulk_in_desc.bEndpointAddress = 3440 fsg_hs_bulk_in_desc.bEndpointAddress =
3439 fsg_fs_bulk_in_desc.bEndpointAddress; 3441 fsg_fs_bulk_in_desc.bEndpointAddress;
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index 4f40f1467438..8b9220e128a7 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -695,6 +695,7 @@ static int gmidi_setup(struct usb_gadget *gadget,
695 switch (w_value >> 8) { 695 switch (w_value >> 8) {
696 696
697 case USB_DT_DEVICE: 697 case USB_DT_DEVICE:
698 device_desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
698 value = min(w_length, (u16) sizeof(device_desc)); 699 value = min(w_length, (u16) sizeof(device_desc));
699 memcpy(req->buf, &device_desc, value); 700 memcpy(req->buf, &device_desc, value);
700 break; 701 break;
@@ -1249,8 +1250,6 @@ autoconf_fail:
1249 1250
1250 dev->req->complete = gmidi_setup_complete; 1251 dev->req->complete = gmidi_setup_complete;
1251 1252
1252 device_desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
1253
1254 gadget->ep0->driver_data = dev; 1253 gadget->ep0->driver_data = dev;
1255 1254
1256 INFO(dev, "%s, version: " DRIVER_VERSION "\n", longname); 1255 INFO(dev, "%s, version: " DRIVER_VERSION "\n", longname);
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index a9a455692397..1b240990448f 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -1347,7 +1347,7 @@ static void make_qualifier (struct dev_data *dev)
1347 qual.bDeviceProtocol = desc->bDeviceProtocol; 1347 qual.bDeviceProtocol = desc->bDeviceProtocol;
1348 1348
1349 /* assumes ep0 uses the same value for both speeds ... */ 1349 /* assumes ep0 uses the same value for both speeds ... */
1350 qual.bMaxPacketSize0 = desc->bMaxPacketSize0; 1350 qual.bMaxPacketSize0 = dev->gadget->ep0->maxpacket;
1351 1351
1352 qual.bNumConfigurations = 1; 1352 qual.bNumConfigurations = 1;
1353 qual.bRESERVED = 0; 1353 qual.bRESERVED = 0;
@@ -1404,7 +1404,6 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1404 } 1404 }
1405 1405
1406 dev->state = STATE_DEV_CONNECTED; 1406 dev->state = STATE_DEV_CONNECTED;
1407 dev->dev->bMaxPacketSize0 = gadget->ep0->maxpacket;
1408 1407
1409 INFO (dev, "connected\n"); 1408 INFO (dev, "connected\n");
1410 event = next_event (dev, GADGETFS_CONNECT); 1409 event = next_event (dev, GADGETFS_CONNECT);
@@ -1432,6 +1431,7 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1432 1431
1433 case USB_DT_DEVICE: 1432 case USB_DT_DEVICE:
1434 value = min (w_length, (u16) sizeof *dev->dev); 1433 value = min (w_length, (u16) sizeof *dev->dev);
1434 dev->dev->bMaxPacketSize0 = dev->gadget->ep0->maxpacket;
1435 req->buf = dev->dev; 1435 req->buf = dev->dev;
1436 break; 1436 break;
1437#ifdef CONFIG_USB_GADGET_DUALSPEED 1437#ifdef CONFIG_USB_GADGET_DUALSPEED
@@ -1712,7 +1712,6 @@ gadgetfs_bind (struct usb_gadget *gadget)
1712 set_gadget_data (gadget, dev); 1712 set_gadget_data (gadget, dev);
1713 dev->gadget = gadget; 1713 dev->gadget = gadget;
1714 gadget->ep0->driver_data = dev; 1714 gadget->ep0->driver_data = dev;
1715 dev->dev->bMaxPacketSize0 = gadget->ep0->maxpacket;
1716 1715
1717 /* preallocate control response and buffer */ 1716 /* preallocate control response and buffer */
1718 dev->req = usb_ep_alloc_request (gadget->ep0, GFP_KERNEL); 1717 dev->req = usb_ep_alloc_request (gadget->ep0, GFP_KERNEL);
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index 00e5f19c75ba..d5df8dd9d58e 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -1148,6 +1148,8 @@ printer_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1148 switch (wValue >> 8) { 1148 switch (wValue >> 8) {
1149 1149
1150 case USB_DT_DEVICE: 1150 case USB_DT_DEVICE:
1151 device_desc.bMaxPacketSize0 =
1152 gadget->ep0->maxpacket;
1151 value = min(wLength, (u16) sizeof device_desc); 1153 value = min(wLength, (u16) sizeof device_desc);
1152 memcpy(req->buf, &device_desc, value); 1154 memcpy(req->buf, &device_desc, value);
1153 break; 1155 break;
@@ -1155,6 +1157,12 @@ printer_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1155 case USB_DT_DEVICE_QUALIFIER: 1157 case USB_DT_DEVICE_QUALIFIER:
1156 if (!gadget->is_dualspeed) 1158 if (!gadget->is_dualspeed)
1157 break; 1159 break;
1160 /*
1161 * assumes ep0 uses the same value for both
1162 * speeds
1163 */
1164 dev_qualifier.bMaxPacketSize0 =
1165 gadget->ep0->maxpacket;
1158 value = min(wLength, 1166 value = min(wLength,
1159 (u16) sizeof dev_qualifier); 1167 (u16) sizeof dev_qualifier);
1160 memcpy(req->buf, &dev_qualifier, value); 1168 memcpy(req->buf, &dev_qualifier, value);
@@ -1450,15 +1458,11 @@ autoconf_fail:
1450 out_ep->driver_data = out_ep; /* claim */ 1458 out_ep->driver_data = out_ep; /* claim */
1451 1459
1452#ifdef CONFIG_USB_GADGET_DUALSPEED 1460#ifdef CONFIG_USB_GADGET_DUALSPEED
1453 /* assumes ep0 uses the same value for both speeds ... */ 1461 /* assumes that all endpoints are dual-speed */
1454 dev_qualifier.bMaxPacketSize0 = device_desc.bMaxPacketSize0;
1455
1456 /* and that all endpoints are dual-speed */
1457 hs_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress; 1462 hs_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress;
1458 hs_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress; 1463 hs_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress;
1459#endif /* DUALSPEED */ 1464#endif /* DUALSPEED */
1460 1465
1461 device_desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
1462 usb_gadget_set_selfpowered(gadget); 1466 usb_gadget_set_selfpowered(gadget);
1463 1467
1464 if (gadget->is_otg) { 1468 if (gadget->is_otg) {