aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/class/cdc-acm.c6
-rw-r--r--drivers/usb/class/cdc-wdm.c2
-rw-r--r--drivers/usb/class/usbtmc.c5
-rw-r--r--drivers/usb/core/config.c8
-rw-r--r--drivers/usb/core/devices.c4
-rw-r--r--drivers/usb/core/endpoint.c2
-rw-r--r--drivers/usb/core/hub.c2
-rw-r--r--drivers/usb/core/urb.c2
-rw-r--r--drivers/usb/dwc3/gadget.c3
-rw-r--r--drivers/usb/gadget/amd5536udc.c2
-rw-r--r--drivers/usb/gadget/at91_udc.c2
-rw-r--r--drivers/usb/gadget/atmel_usba_udc.c4
-rw-r--r--drivers/usb/gadget/ci13xxx_udc.c2
-rw-r--r--drivers/usb/gadget/composite.c2
-rw-r--r--drivers/usb/gadget/dummy_hcd.c4
-rw-r--r--drivers/usb/gadget/epautoconf.c2
-rw-r--r--drivers/usb/gadget/f_mass_storage.c3
-rw-r--r--drivers/usb/gadget/file_storage.c2
-rw-r--r--drivers/usb/gadget/fsl_qe_udc.c2
-rw-r--r--drivers/usb/gadget/fsl_udc_core.c2
-rw-r--r--drivers/usb/gadget/fusb300_udc.c2
-rw-r--r--drivers/usb/gadget/imx_udc.c2
-rw-r--r--drivers/usb/gadget/langwell_udc.c2
-rw-r--r--drivers/usb/gadget/m66592-udc.c4
-rw-r--r--drivers/usb/gadget/mv_udc_core.c2
-rw-r--r--drivers/usb/gadget/net2272.c2
-rw-r--r--drivers/usb/gadget/net2280.c4
-rw-r--r--drivers/usb/gadget/omap_udc.c7
-rw-r--r--drivers/usb/gadget/pch_udc.c6
-rw-r--r--drivers/usb/gadget/pxa25x_udc.c14
-rw-r--r--drivers/usb/gadget/pxa27x_udc.c2
-rw-r--r--drivers/usb/gadget/r8a66597-udc.c4
-rw-r--r--drivers/usb/gadget/s3c-hsotg.c2
-rw-r--r--drivers/usb/gadget/s3c-hsudc.c6
-rw-r--r--drivers/usb/gadget/s3c2410_udc.c2
-rw-r--r--drivers/usb/host/ohci-q.c4
-rw-r--r--drivers/usb/host/r8a66597-hcd.c2
-rw-r--r--drivers/usb/host/uhci-q.c6
-rw-r--r--drivers/usb/host/xhci-mem.c10
-rw-r--r--drivers/usb/host/xhci-ring.c8
-rw-r--r--drivers/usb/host/xhci.c2
-rw-r--r--drivers/usb/misc/adutux.c14
-rw-r--r--drivers/usb/misc/ftdi-elan.c2
-rw-r--r--drivers/usb/misc/idmouse.c2
-rw-r--r--drivers/usb/misc/iowarrior.c2
-rw-r--r--drivers/usb/misc/ldusb.c4
-rw-r--r--drivers/usb/misc/legousbtower.c4
-rw-r--r--drivers/usb/misc/usblcd.c2
-rw-r--r--drivers/usb/misc/usbtest.c6
-rw-r--r--drivers/usb/musb/musb_gadget.c2
-rw-r--r--drivers/usb/musb/musb_host.c2
-rw-r--r--drivers/usb/serial/ftdi_sio.c2
-rw-r--r--drivers/usb/serial/io_edgeport.c4
-rw-r--r--drivers/usb/serial/opticon.c2
-rw-r--r--drivers/usb/serial/symbolserial.c2
-rw-r--r--drivers/usb/serial/usb-serial.c8
-rw-r--r--drivers/usb/usb-skeleton.c2
-rw-r--r--drivers/usb/wusbcore/wa-hc.c2
-rw-r--r--include/linux/usb.h2
59 files changed, 106 insertions, 112 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index dac7676ce21b..f69a1854a59c 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1058,11 +1058,11 @@ made_compressed_probe:
1058 goto alloc_fail; 1058 goto alloc_fail;
1059 } 1059 }
1060 1060
1061 ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize); 1061 ctrlsize = usb_endpoint_maxp(epctrl);
1062 readsize = le16_to_cpu(epread->wMaxPacketSize) * 1062 readsize = usb_endpoint_maxp(epread) *
1063 (quirks == SINGLE_RX_URB ? 1 : 2); 1063 (quirks == SINGLE_RX_URB ? 1 : 2);
1064 acm->combined_interfaces = combined_interfaces; 1064 acm->combined_interfaces = combined_interfaces;
1065 acm->writesize = le16_to_cpu(epwrite->wMaxPacketSize) * 20; 1065 acm->writesize = usb_endpoint_maxp(epwrite) * 20;
1066 acm->control = control_interface; 1066 acm->control = control_interface;
1067 acm->data = data_interface; 1067 acm->data = data_interface;
1068 acm->minor = minor; 1068 acm->minor = minor;
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 2b9ff518b509..1d26a7135dd9 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -682,7 +682,7 @@ next_desc:
682 if (!ep || !usb_endpoint_is_int_in(ep)) 682 if (!ep || !usb_endpoint_is_int_in(ep))
683 goto err; 683 goto err;
684 684
685 desc->wMaxPacketSize = le16_to_cpu(ep->wMaxPacketSize); 685 desc->wMaxPacketSize = usb_endpoint_maxp(ep);
686 desc->bMaxPacketSize0 = udev->descriptor.bMaxPacketSize0; 686 desc->bMaxPacketSize0 = udev->descriptor.bMaxPacketSize0;
687 687
688 desc->orq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); 688 desc->orq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 3f94ac34dce3..12cf5e7395a8 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -186,8 +186,7 @@ static int usbtmc_ioctl_abort_bulk_in(struct usbtmc_device_data *data)
186 for (n = 0; n < current_setting->desc.bNumEndpoints; n++) 186 for (n = 0; n < current_setting->desc.bNumEndpoints; n++)
187 if (current_setting->endpoint[n].desc.bEndpointAddress == 187 if (current_setting->endpoint[n].desc.bEndpointAddress ==
188 data->bulk_in) 188 data->bulk_in)
189 max_size = le16_to_cpu(current_setting->endpoint[n]. 189 max_size = usb_endpoint_maxp(&current_setting->endpoint[n].desc);
190 desc.wMaxPacketSize);
191 190
192 if (max_size == 0) { 191 if (max_size == 0) {
193 dev_err(dev, "Couldn't get wMaxPacketSize\n"); 192 dev_err(dev, "Couldn't get wMaxPacketSize\n");
@@ -636,7 +635,7 @@ static int usbtmc_ioctl_clear(struct usbtmc_device_data *data)
636 for (n = 0; n < current_setting->desc.bNumEndpoints; n++) { 635 for (n = 0; n < current_setting->desc.bNumEndpoints; n++) {
637 desc = &current_setting->endpoint[n].desc; 636 desc = &current_setting->endpoint[n].desc;
638 if (desc->bEndpointAddress == data->bulk_in) 637 if (desc->bEndpointAddress == data->bulk_in)
639 max_size = le16_to_cpu(desc->wMaxPacketSize); 638 max_size = usb_endpoint_maxp(desc);
640 } 639 }
641 640
642 if (max_size == 0) { 641 if (max_size == 0) {
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 26678cadfb21..9d5e07af55be 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -124,9 +124,9 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
124 124
125 if (usb_endpoint_xfer_isoc(&ep->desc)) 125 if (usb_endpoint_xfer_isoc(&ep->desc))
126 max_tx = (desc->bMaxBurst + 1) * (desc->bmAttributes + 1) * 126 max_tx = (desc->bMaxBurst + 1) * (desc->bmAttributes + 1) *
127 le16_to_cpu(ep->desc.wMaxPacketSize); 127 usb_endpoint_maxp(&ep->desc);
128 else if (usb_endpoint_xfer_int(&ep->desc)) 128 else if (usb_endpoint_xfer_int(&ep->desc))
129 max_tx = le16_to_cpu(ep->desc.wMaxPacketSize) * 129 max_tx = usb_endpoint_maxp(&ep->desc) *
130 (desc->bMaxBurst + 1); 130 (desc->bMaxBurst + 1);
131 else 131 else
132 max_tx = 999999; 132 max_tx = 999999;
@@ -241,7 +241,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
241 cfgno, inum, asnum, d->bEndpointAddress); 241 cfgno, inum, asnum, d->bEndpointAddress);
242 endpoint->desc.bmAttributes = USB_ENDPOINT_XFER_INT; 242 endpoint->desc.bmAttributes = USB_ENDPOINT_XFER_INT;
243 endpoint->desc.bInterval = 1; 243 endpoint->desc.bInterval = 1;
244 if (le16_to_cpu(endpoint->desc.wMaxPacketSize) > 8) 244 if (usb_endpoint_maxp(&endpoint->desc) > 8)
245 endpoint->desc.wMaxPacketSize = cpu_to_le16(8); 245 endpoint->desc.wMaxPacketSize = cpu_to_le16(8);
246 } 246 }
247 247
@@ -254,7 +254,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
254 && usb_endpoint_xfer_bulk(d)) { 254 && usb_endpoint_xfer_bulk(d)) {
255 unsigned maxp; 255 unsigned maxp;
256 256
257 maxp = le16_to_cpu(endpoint->desc.wMaxPacketSize) & 0x07ff; 257 maxp = usb_endpoint_maxp(&endpoint->desc) & 0x07ff;
258 if (maxp != 512) 258 if (maxp != 512)
259 dev_warn(ddev, "config %d interface %d altsetting %d " 259 dev_warn(ddev, "config %d interface %d altsetting %d "
260 "bulk endpoint 0x%X has invalid maxpacket %d\n", 260 "bulk endpoint 0x%X has invalid maxpacket %d\n",
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index 0149c0976e9c..d95696584762 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -190,7 +190,7 @@ static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end,
190 dir = usb_endpoint_dir_in(desc) ? 'I' : 'O'; 190 dir = usb_endpoint_dir_in(desc) ? 'I' : 'O';
191 191
192 if (speed == USB_SPEED_HIGH) { 192 if (speed == USB_SPEED_HIGH) {
193 switch (le16_to_cpu(desc->wMaxPacketSize) & (0x03 << 11)) { 193 switch (usb_endpoint_maxp(desc) & (0x03 << 11)) {
194 case 1 << 11: 194 case 1 << 11:
195 bandwidth = 2; break; 195 bandwidth = 2; break;
196 case 2 << 11: 196 case 2 << 11:
@@ -240,7 +240,7 @@ static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end,
240 240
241 start += sprintf(start, format_endpt, desc->bEndpointAddress, dir, 241 start += sprintf(start, format_endpt, desc->bEndpointAddress, dir,
242 desc->bmAttributes, type, 242 desc->bmAttributes, type,
243 (le16_to_cpu(desc->wMaxPacketSize) & 0x07ff) * 243 (usb_endpoint_maxp(desc) & 0x07ff) *
244 bandwidth, 244 bandwidth,
245 interval, unit); 245 interval, unit);
246 return start; 246 return start;
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index df502a98d0df..db7fe50c23d4 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -56,7 +56,7 @@ static ssize_t show_ep_wMaxPacketSize(struct device *dev,
56{ 56{
57 struct ep_device *ep = to_ep_device(dev); 57 struct ep_device *ep = to_ep_device(dev);
58 return sprintf(buf, "%04x\n", 58 return sprintf(buf, "%04x\n",
59 le16_to_cpu(ep->desc->wMaxPacketSize) & 0x07ff); 59 usb_endpoint_maxp(ep->desc) & 0x07ff);
60} 60}
61static DEVICE_ATTR(wMaxPacketSize, S_IRUGO, show_ep_wMaxPacketSize, NULL); 61static DEVICE_ATTR(wMaxPacketSize, S_IRUGO, show_ep_wMaxPacketSize, NULL);
62 62
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 99fff6be3641..338f91ff54cb 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -3018,7 +3018,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
3018 i = 512; 3018 i = 512;
3019 else 3019 else
3020 i = udev->descriptor.bMaxPacketSize0; 3020 i = udev->descriptor.bMaxPacketSize0;
3021 if (le16_to_cpu(udev->ep0.desc.wMaxPacketSize) != i) { 3021 if (usb_endpoint_maxp(&udev->ep0.desc) != i) {
3022 if (udev->speed == USB_SPEED_LOW || 3022 if (udev->speed == USB_SPEED_LOW ||
3023 !(i == 8 || i == 16 || i == 32 || i == 64)) { 3023 !(i == 8 || i == 16 || i == 32 || i == 64)) {
3024 dev_err(&udev->dev, "Invalid ep0 maxpacket: %d\n", i); 3024 dev_err(&udev->dev, "Invalid ep0 maxpacket: %d\n", i);
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index ae334b067c13..909625b91eb3 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -350,7 +350,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
350 dev->state < USB_STATE_CONFIGURED) 350 dev->state < USB_STATE_CONFIGURED)
351 return -ENODEV; 351 return -ENODEV;
352 352
353 max = le16_to_cpu(ep->desc.wMaxPacketSize); 353 max = usb_endpoint_maxp(&ep->desc);
354 if (max <= 0) { 354 if (max <= 0) {
355 dev_dbg(&dev->dev, 355 dev_dbg(&dev->dev,
356 "bogus endpoint ep%d%s in %s (bad maxpacket %d)\n", 356 "bogus endpoint ep%d%s in %s (bad maxpacket %d)\n",
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index de5f0afa890a..cebaef720cd4 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -254,8 +254,7 @@ static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep,
254 memset(&params, 0x00, sizeof(params)); 254 memset(&params, 0x00, sizeof(params));
255 255
256 params.param0.depcfg.ep_type = usb_endpoint_type(desc); 256 params.param0.depcfg.ep_type = usb_endpoint_type(desc);
257 params.param0.depcfg.max_packet_size = 257 params.param0.depcfg.max_packet_size = usb_endpoint_maxp(desc);
258 le16_to_cpu(desc->wMaxPacketSize);
259 258
260 params.param1.depcfg.xfer_complete_enable = true; 259 params.param1.depcfg.xfer_complete_enable = true;
261 params.param1.depcfg.xfer_not_ready_enable = true; 260 params.param1.depcfg.xfer_not_ready_enable = true;
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index 70f2b376c86d..d65d8392be75 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -354,7 +354,7 @@ udc_ep_enable(struct usb_ep *usbep, const struct usb_endpoint_descriptor *desc)
354 writel(tmp, &dev->ep[ep->num].regs->ctl); 354 writel(tmp, &dev->ep[ep->num].regs->ctl);
355 355
356 /* set max packet size */ 356 /* set max packet size */
357 maxpacket = le16_to_cpu(desc->wMaxPacketSize); 357 maxpacket = usb_endpoint_maxp(desc);
358 tmp = readl(&dev->ep[ep->num].regs->bufout_maxpkt); 358 tmp = readl(&dev->ep[ep->num].regs->bufout_maxpkt);
359 tmp = AMD_ADDBITS(tmp, maxpacket, UDC_EP_MAX_PKT_SIZE); 359 tmp = AMD_ADDBITS(tmp, maxpacket, UDC_EP_MAX_PKT_SIZE);
360 ep->ep.maxpacket = maxpacket; 360 ep->ep.maxpacket = maxpacket;
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index ddb118a76807..d01fa5badd66 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -487,7 +487,7 @@ static int at91_ep_enable(struct usb_ep *_ep,
487 || !desc || ep->desc 487 || !desc || ep->desc
488 || _ep->name == ep0name 488 || _ep->name == ep0name
489 || desc->bDescriptorType != USB_DT_ENDPOINT 489 || desc->bDescriptorType != USB_DT_ENDPOINT
490 || (maxpacket = le16_to_cpu(desc->wMaxPacketSize)) == 0 490 || (maxpacket = usb_endpoint_maxp(desc)) == 0
491 || maxpacket > ep->maxpacket) { 491 || maxpacket > ep->maxpacket) {
492 DBG("bad ep or descriptor\n"); 492 DBG("bad ep or descriptor\n");
493 return -EINVAL; 493 return -EINVAL;
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index 5b1665eb1bef..722c468e9b3c 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -527,7 +527,7 @@ usba_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
527 527
528 DBG(DBG_GADGET, "%s: ep_enable: desc=%p\n", ep->ep.name, desc); 528 DBG(DBG_GADGET, "%s: ep_enable: desc=%p\n", ep->ep.name, desc);
529 529
530 maxpacket = le16_to_cpu(desc->wMaxPacketSize) & 0x7ff; 530 maxpacket = usb_endpoint_maxp(desc) & 0x7ff;
531 531
532 if (((desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK) != ep->index) 532 if (((desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK) != ep->index)
533 || ep->index == 0 533 || ep->index == 0
@@ -571,7 +571,7 @@ usba_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
571 * Bits 11:12 specify number of _additional_ 571 * Bits 11:12 specify number of _additional_
572 * transactions per microframe. 572 * transactions per microframe.
573 */ 573 */
574 nr_trans = ((le16_to_cpu(desc->wMaxPacketSize) >> 11) & 3) + 1; 574 nr_trans = ((usb_endpoint_maxp(desc) >> 11) & 3) + 1;
575 if (nr_trans > 3) 575 if (nr_trans > 3)
576 return -EINVAL; 576 return -EINVAL;
577 577
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c
index 1265a8502ea0..83428f56253b 100644
--- a/drivers/usb/gadget/ci13xxx_udc.c
+++ b/drivers/usb/gadget/ci13xxx_udc.c
@@ -2101,7 +2101,7 @@ static int ep_enable(struct usb_ep *ep,
2101 mEp->num = usb_endpoint_num(desc); 2101 mEp->num = usb_endpoint_num(desc);
2102 mEp->type = usb_endpoint_type(desc); 2102 mEp->type = usb_endpoint_type(desc);
2103 2103
2104 mEp->ep.maxpacket = __constant_le16_to_cpu(desc->wMaxPacketSize); 2104 mEp->ep.maxpacket = usb_endpoint_maxp(desc);
2105 2105
2106 dbg_event(_usb_addr(mEp), "ENABLE", 0); 2106 dbg_event(_usb_addr(mEp), "ENABLE", 0);
2107 2107
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index aef47414f5d5..8065464523b1 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -164,7 +164,7 @@ int config_ep_by_speed(struct usb_gadget *g,
164 164
165ep_found: 165ep_found:
166 /* commit results */ 166 /* commit results */
167 _ep->maxpacket = le16_to_cpu(chosen_desc->wMaxPacketSize); 167 _ep->maxpacket = usb_endpoint_maxp(chosen_desc);
168 _ep->desc = chosen_desc; 168 _ep->desc = chosen_desc;
169 _ep->comp_desc = NULL; 169 _ep->comp_desc = NULL;
170 _ep->maxburst = 0; 170 _ep->maxburst = 0;
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index e755a9d267fc..7b06d39d6203 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -439,7 +439,7 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
439 * maximum packet size. 439 * maximum packet size.
440 * For SS devices the wMaxPacketSize is limited by 1024. 440 * For SS devices the wMaxPacketSize is limited by 1024.
441 */ 441 */
442 max = le16_to_cpu(desc->wMaxPacketSize) & 0x7ff; 442 max = usb_endpoint_maxp(desc) & 0x7ff;
443 443
444 /* drivers must not request bad settings, since lower levels 444 /* drivers must not request bad settings, since lower levels
445 * (hardware or its drivers) may not check. some endpoints 445 * (hardware or its drivers) may not check. some endpoints
@@ -1277,7 +1277,7 @@ static int periodic_bytes (struct dummy *dum, struct dummy_ep *ep)
1277 int tmp; 1277 int tmp;
1278 1278
1279 /* high bandwidth mode */ 1279 /* high bandwidth mode */
1280 tmp = le16_to_cpu(ep->desc->wMaxPacketSize); 1280 tmp = usb_endpoint_maxp(ep->desc);
1281 tmp = (tmp >> 11) & 0x03; 1281 tmp = (tmp >> 11) & 0x03;
1282 tmp *= 8 /* applies to entire frame */; 1282 tmp *= 8 /* applies to entire frame */;
1283 limit += limit * tmp; 1283 limit += limit * tmp;
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 7a7e6b7e1fd6..cdca7ebb7b48 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -158,7 +158,7 @@ ep_matches (
158 * where it's an output parameter representing the full speed limit. 158 * where it's an output parameter representing the full speed limit.
159 * the usb spec fixes high speed bulk maxpacket at 512 bytes. 159 * the usb spec fixes high speed bulk maxpacket at 512 bytes.
160 */ 160 */
161 max = 0x7ff & le16_to_cpu(desc->wMaxPacketSize); 161 max = 0x7ff & usb_endpoint_maxp(desc);
162 switch (type) { 162 switch (type) {
163 case USB_ENDPOINT_XFER_INT: 163 case USB_ENDPOINT_XFER_INT:
164 /* INT: limit 64 bytes full speed, 1024 high/super speed */ 164 /* INT: limit 64 bytes full speed, 1024 high/super speed */
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 5b9339582007..4ce3decda1db 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -2401,8 +2401,7 @@ reset:
2401 goto reset; 2401 goto reset;
2402 fsg->bulk_out->driver_data = common; 2402 fsg->bulk_out->driver_data = common;
2403 fsg->bulk_out_enabled = 1; 2403 fsg->bulk_out_enabled = 1;
2404 common->bulk_out_maxpacket = 2404 common->bulk_out_maxpacket = usb_endpoint_maxp(fsg->bulk_out->desc);
2405 le16_to_cpu(fsg->bulk_out->desc->wMaxPacketSize);
2406 clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); 2405 clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags);
2407 2406
2408 /* Allocate the requests */ 2407 /* Allocate the requests */
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 639e14a2fd15..39ece40a045f 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -2801,7 +2801,7 @@ reset:
2801 if ((rc = enable_endpoint(fsg, fsg->bulk_out, d)) != 0) 2801 if ((rc = enable_endpoint(fsg, fsg->bulk_out, d)) != 0)
2802 goto reset; 2802 goto reset;
2803 fsg->bulk_out_enabled = 1; 2803 fsg->bulk_out_enabled = 1;
2804 fsg->bulk_out_maxpacket = le16_to_cpu(d->wMaxPacketSize); 2804 fsg->bulk_out_maxpacket = usb_endpoint_maxp(d);
2805 clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); 2805 clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags);
2806 2806
2807 if (transport_is_cbi()) { 2807 if (transport_is_cbi()) {
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c
index 3bf872e1ad39..2a03e4de11c1 100644
--- a/drivers/usb/gadget/fsl_qe_udc.c
+++ b/drivers/usb/gadget/fsl_qe_udc.c
@@ -540,7 +540,7 @@ static int qe_ep_init(struct qe_udc *udc,
540 int reval = 0; 540 int reval = 0;
541 u16 max = 0; 541 u16 max = 0;
542 542
543 max = le16_to_cpu(desc->wMaxPacketSize); 543 max = usb_endpoint_maxp(desc);
544 544
545 /* check the max package size validate for this endpoint */ 545 /* check the max package size validate for this endpoint */
546 /* Refer to USB2.0 spec table 9-13, 546 /* Refer to USB2.0 spec table 9-13,
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index de24a4233c25..d6993507165b 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -559,7 +559,7 @@ static int fsl_ep_enable(struct usb_ep *_ep,
559 if (!udc->driver || (udc->gadget.speed == USB_SPEED_UNKNOWN)) 559 if (!udc->driver || (udc->gadget.speed == USB_SPEED_UNKNOWN))
560 return -ESHUTDOWN; 560 return -ESHUTDOWN;
561 561
562 max = le16_to_cpu(desc->wMaxPacketSize); 562 max = usb_endpoint_maxp(desc);
563 563
564 /* Disable automatic zlp generation. Driver is responsible to indicate 564 /* Disable automatic zlp generation. Driver is responsible to indicate
565 * explicitly through req->req.zero. This is needed to enable multi-td 565 * explicitly through req->req.zero. This is needed to enable multi-td
diff --git a/drivers/usb/gadget/fusb300_udc.c b/drivers/usb/gadget/fusb300_udc.c
index 4ec888f90002..d9ee6c37a6c1 100644
--- a/drivers/usb/gadget/fusb300_udc.c
+++ b/drivers/usb/gadget/fusb300_udc.c
@@ -220,7 +220,7 @@ static int config_ep(struct fusb300_ep *ep,
220 220
221 info.type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; 221 info.type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
222 info.dir_in = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? 1 : 0; 222 info.dir_in = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? 1 : 0;
223 info.maxpacket = le16_to_cpu(desc->wMaxPacketSize); 223 info.maxpacket = usb_endpoint_maxp(desc);
224 info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 224 info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
225 225
226 if ((info.type == USB_ENDPOINT_XFER_INT) || 226 if ((info.type == USB_ENDPOINT_XFER_INT) ||
diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c
index 692fd9b2248b..bf08bfcd90b8 100644
--- a/drivers/usb/gadget/imx_udc.c
+++ b/drivers/usb/gadget/imx_udc.c
@@ -689,7 +689,7 @@ static int imx_ep_enable(struct usb_ep *usb_ep,
689 return -EINVAL; 689 return -EINVAL;
690 } 690 }
691 691
692 if (imx_ep->fifosize < le16_to_cpu(desc->wMaxPacketSize)) { 692 if (imx_ep->fifosize < usb_endpoint_maxp(desc)) {
693 D_ERR(imx_usb->dev, 693 D_ERR(imx_usb->dev,
694 "<%s> bad %s maxpacket\n", __func__, usb_ep->name); 694 "<%s> bad %s maxpacket\n", __func__, usb_ep->name);
695 return -ERANGE; 695 return -ERANGE;
diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c
index a06e2c27b435..5bf9942eb454 100644
--- a/drivers/usb/gadget/langwell_udc.c
+++ b/drivers/usb/gadget/langwell_udc.c
@@ -283,7 +283,7 @@ static int langwell_ep_enable(struct usb_ep *_ep,
283 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) 283 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)
284 return -ESHUTDOWN; 284 return -ESHUTDOWN;
285 285
286 max = le16_to_cpu(desc->wMaxPacketSize); 286 max = usb_endpoint_maxp(desc);
287 287
288 /* 288 /*
289 * disable HW zero length termination select 289 * disable HW zero length termination select
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c
index 491f825ed5c9..5e597c3c44f3 100644
--- a/drivers/usb/gadget/m66592-udc.c
+++ b/drivers/usb/gadget/m66592-udc.c
@@ -370,7 +370,7 @@ static void m66592_ep_setting(struct m66592 *m66592, struct m66592_ep *ep,
370 370
371 ep->pipectr = get_pipectr_addr(pipenum); 371 ep->pipectr = get_pipectr_addr(pipenum);
372 ep->pipenum = pipenum; 372 ep->pipenum = pipenum;
373 ep->ep.maxpacket = le16_to_cpu(desc->wMaxPacketSize); 373 ep->ep.maxpacket = usb_endpoint_maxp(desc);
374 m66592->pipenum2ep[pipenum] = ep; 374 m66592->pipenum2ep[pipenum] = ep;
375 m66592->epaddr2ep[desc->bEndpointAddress&USB_ENDPOINT_NUMBER_MASK] = ep; 375 m66592->epaddr2ep[desc->bEndpointAddress&USB_ENDPOINT_NUMBER_MASK] = ep;
376 INIT_LIST_HEAD(&ep->queue); 376 INIT_LIST_HEAD(&ep->queue);
@@ -447,7 +447,7 @@ static int alloc_pipe_config(struct m66592_ep *ep,
447 ep->type = info.type; 447 ep->type = info.type;
448 448
449 info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 449 info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
450 info.maxpacket = le16_to_cpu(desc->wMaxPacketSize); 450 info.maxpacket = usb_endpoint_maxp(desc);
451 info.interval = desc->bInterval; 451 info.interval = desc->bInterval;
452 if (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 452 if (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
453 info.dir_in = 1; 453 info.dir_in = 1;
diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c
index ce1ac2bcb314..263dec40af32 100644
--- a/drivers/usb/gadget/mv_udc_core.c
+++ b/drivers/usb/gadget/mv_udc_core.c
@@ -493,7 +493,7 @@ static int mv_ep_enable(struct usb_ep *_ep,
493 return -ESHUTDOWN; 493 return -ESHUTDOWN;
494 494
495 direction = ep_dir(ep); 495 direction = ep_dir(ep);
496 max = le16_to_cpu(desc->wMaxPacketSize); 496 max = usb_endpoint_maxp(desc);
497 497
498 /* 498 /*
499 * disable HW zero length termination select 499 * disable HW zero length termination select
diff --git a/drivers/usb/gadget/net2272.c b/drivers/usb/gadget/net2272.c
index ab98ea926a11..6fef1c02448e 100644
--- a/drivers/usb/gadget/net2272.c
+++ b/drivers/usb/gadget/net2272.c
@@ -204,7 +204,7 @@ net2272_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
204 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) 204 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)
205 return -ESHUTDOWN; 205 return -ESHUTDOWN;
206 206
207 max = le16_to_cpu(desc->wMaxPacketSize) & 0x1fff; 207 max = usb_endpoint_maxp(desc) & 0x1fff;
208 208
209 spin_lock_irqsave(&dev->lock, flags); 209 spin_lock_irqsave(&dev->lock, flags);
210 _ep->maxpacket = max & 0x7fff; 210 _ep->maxpacket = max & 0x7fff;
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 3dd40b4e675c..8d3673fadfe1 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -169,7 +169,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
169 return -EDOM; 169 return -EDOM;
170 170
171 /* sanity check ep-e/ep-f since their fifos are small */ 171 /* sanity check ep-e/ep-f since their fifos are small */
172 max = le16_to_cpu (desc->wMaxPacketSize) & 0x1fff; 172 max = usb_endpoint_maxp (desc) & 0x1fff;
173 if (ep->num > 4 && max > 64) 173 if (ep->num > 4 && max > 64)
174 return -ERANGE; 174 return -ERANGE;
175 175
@@ -1640,7 +1640,7 @@ show_queues (struct device *_dev, struct device_attribute *attr, char *buf)
1640 default: 1640 default:
1641 val = "iso"; break; 1641 val = "iso"; break;
1642 }; val; }), 1642 }; val; }),
1643 le16_to_cpu (d->wMaxPacketSize) & 0x1fff, 1643 usb_endpoint_maxp (d) & 0x1fff,
1644 ep->dma ? "dma" : "pio", ep->fifo_size 1644 ep->dma ? "dma" : "pio", ep->fifo_size
1645 ); 1645 );
1646 } else /* ep0 should only have one transfer queued */ 1646 } else /* ep0 should only have one transfer queued */
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 740c7daed279..b7a7799ddd4f 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -166,15 +166,14 @@ static int omap_ep_enable(struct usb_ep *_ep,
166 if (!_ep || !desc || ep->desc 166 if (!_ep || !desc || ep->desc
167 || desc->bDescriptorType != USB_DT_ENDPOINT 167 || desc->bDescriptorType != USB_DT_ENDPOINT
168 || ep->bEndpointAddress != desc->bEndpointAddress 168 || ep->bEndpointAddress != desc->bEndpointAddress
169 || ep->maxpacket < le16_to_cpu 169 || ep->maxpacket < usb_endpoint_maxp(desc)) {
170 (desc->wMaxPacketSize)) {
171 DBG("%s, bad ep or descriptor\n", __func__); 170 DBG("%s, bad ep or descriptor\n", __func__);
172 return -EINVAL; 171 return -EINVAL;
173 } 172 }
174 maxp = le16_to_cpu (desc->wMaxPacketSize); 173 maxp = usb_endpoint_maxp(desc);
175 if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK 174 if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK
176 && maxp != ep->maxpacket) 175 && maxp != ep->maxpacket)
177 || le16_to_cpu(desc->wMaxPacketSize) > ep->maxpacket 176 || usb_endpoint_maxp(desc) > ep->maxpacket
178 || !desc->wMaxPacketSize) { 177 || !desc->wMaxPacketSize) {
179 DBG("%s, bad %s maxpacket\n", __func__, _ep->name); 178 DBG("%s, bad %s maxpacket\n", __func__, _ep->name);
180 return -ERANGE; 179 return -ERANGE;
diff --git a/drivers/usb/gadget/pch_udc.c b/drivers/usb/gadget/pch_udc.c
index f96615ab6b77..b69ae3eec687 100644
--- a/drivers/usb/gadget/pch_udc.c
+++ b/drivers/usb/gadget/pch_udc.c
@@ -947,7 +947,7 @@ static void pch_udc_ep_enable(struct pch_udc_ep *ep,
947 else 947 else
948 buff_size = UDC_EPOUT_BUFF_SIZE; 948 buff_size = UDC_EPOUT_BUFF_SIZE;
949 pch_udc_ep_set_bufsz(ep, buff_size, ep->in); 949 pch_udc_ep_set_bufsz(ep, buff_size, ep->in);
950 pch_udc_ep_set_maxpkt(ep, le16_to_cpu(desc->wMaxPacketSize)); 950 pch_udc_ep_set_maxpkt(ep, usb_endpoint_maxp(desc));
951 pch_udc_ep_set_nak(ep); 951 pch_udc_ep_set_nak(ep);
952 pch_udc_ep_fifo_flush(ep, ep->in); 952 pch_udc_ep_fifo_flush(ep, ep->in);
953 /* Configure the endpoint */ 953 /* Configure the endpoint */
@@ -957,7 +957,7 @@ static void pch_udc_ep_enable(struct pch_udc_ep *ep,
957 (cfg->cur_cfg << UDC_CSR_NE_CFG_SHIFT) | 957 (cfg->cur_cfg << UDC_CSR_NE_CFG_SHIFT) |
958 (cfg->cur_intf << UDC_CSR_NE_INTF_SHIFT) | 958 (cfg->cur_intf << UDC_CSR_NE_INTF_SHIFT) |
959 (cfg->cur_alt << UDC_CSR_NE_ALT_SHIFT) | 959 (cfg->cur_alt << UDC_CSR_NE_ALT_SHIFT) |
960 le16_to_cpu(desc->wMaxPacketSize) << UDC_CSR_NE_MAX_PKT_SHIFT; 960 usb_endpoint_maxp(desc) << UDC_CSR_NE_MAX_PKT_SHIFT;
961 961
962 if (ep->in) 962 if (ep->in)
963 pch_udc_write_csr(ep->dev, val, UDC_EPIN_IDX(ep->num)); 963 pch_udc_write_csr(ep->dev, val, UDC_EPIN_IDX(ep->num));
@@ -1466,7 +1466,7 @@ static int pch_udc_pcd_ep_enable(struct usb_ep *usbep,
1466 ep->desc = desc; 1466 ep->desc = desc;
1467 ep->halted = 0; 1467 ep->halted = 0;
1468 pch_udc_ep_enable(ep, &ep->dev->cfg_data, desc); 1468 pch_udc_ep_enable(ep, &ep->dev->cfg_data, desc);
1469 ep->ep.maxpacket = le16_to_cpu(desc->wMaxPacketSize); 1469 ep->ep.maxpacket = usb_endpoint_maxp(desc);
1470 pch_udc_enable_ep_interrupts(ep->dev, PCH_UDC_EPINT(ep->in, ep->num)); 1470 pch_udc_enable_ep_interrupts(ep->dev, PCH_UDC_EPINT(ep->in, ep->num));
1471 spin_unlock_irqrestore(&dev->lock, iflags); 1471 spin_unlock_irqrestore(&dev->lock, iflags);
1472 return 0; 1472 return 0;
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c
index e4e59b4de25d..7862465291d1 100644
--- a/drivers/usb/gadget/pxa25x_udc.c
+++ b/drivers/usb/gadget/pxa25x_udc.c
@@ -232,8 +232,7 @@ static int pxa25x_ep_enable (struct usb_ep *_ep,
232 if (!_ep || !desc || ep->desc || _ep->name == ep0name 232 if (!_ep || !desc || ep->desc || _ep->name == ep0name
233 || desc->bDescriptorType != USB_DT_ENDPOINT 233 || desc->bDescriptorType != USB_DT_ENDPOINT
234 || ep->bEndpointAddress != desc->bEndpointAddress 234 || ep->bEndpointAddress != desc->bEndpointAddress
235 || ep->fifo_size < le16_to_cpu 235 || ep->fifo_size < usb_endpoint_maxp (desc)) {
236 (desc->wMaxPacketSize)) {
237 DMSG("%s, bad ep or descriptor\n", __func__); 236 DMSG("%s, bad ep or descriptor\n", __func__);
238 return -EINVAL; 237 return -EINVAL;
239 } 238 }
@@ -248,7 +247,7 @@ static int pxa25x_ep_enable (struct usb_ep *_ep,
248 247
249 /* hardware _could_ do smaller, but driver doesn't */ 248 /* hardware _could_ do smaller, but driver doesn't */
250 if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK 249 if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK
251 && le16_to_cpu (desc->wMaxPacketSize) 250 && usb_endpoint_maxp (desc)
252 != BULK_FIFO_SIZE) 251 != BULK_FIFO_SIZE)
253 || !desc->wMaxPacketSize) { 252 || !desc->wMaxPacketSize) {
254 DMSG("%s, bad %s maxpacket\n", __func__, _ep->name); 253 DMSG("%s, bad %s maxpacket\n", __func__, _ep->name);
@@ -264,7 +263,7 @@ static int pxa25x_ep_enable (struct usb_ep *_ep,
264 ep->desc = desc; 263 ep->desc = desc;
265 ep->stopped = 0; 264 ep->stopped = 0;
266 ep->pio_irqs = 0; 265 ep->pio_irqs = 0;
267 ep->ep.maxpacket = le16_to_cpu (desc->wMaxPacketSize); 266 ep->ep.maxpacket = usb_endpoint_maxp (desc);
268 267
269 /* flush fifo (mostly for OUT buffers) */ 268 /* flush fifo (mostly for OUT buffers) */
270 pxa25x_ep_fifo_flush (_ep); 269 pxa25x_ep_fifo_flush (_ep);
@@ -401,7 +400,7 @@ write_fifo (struct pxa25x_ep *ep, struct pxa25x_request *req)
401{ 400{
402 unsigned max; 401 unsigned max;
403 402
404 max = le16_to_cpu(ep->desc->wMaxPacketSize); 403 max = usb_endpoint_maxp(ep->desc);
405 do { 404 do {
406 unsigned count; 405 unsigned count;
407 int is_last, is_short; 406 int is_last, is_short;
@@ -671,8 +670,7 @@ pxa25x_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
671 * we can report per-packet status. that also helps with dma. 670 * we can report per-packet status. that also helps with dma.
672 */ 671 */
673 if (unlikely (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC 672 if (unlikely (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC
674 && req->req.length > le16_to_cpu 673 && req->req.length > usb_endpoint_maxp (ep->desc)))
675 (ep->desc->wMaxPacketSize)))
676 return -EMSGSIZE; 674 return -EMSGSIZE;
677 675
678 DBG(DBG_NOISY, "%s queue req %p, len %d buf %p\n", 676 DBG(DBG_NOISY, "%s queue req %p, len %d buf %p\n",
@@ -1105,7 +1103,7 @@ udc_seq_show(struct seq_file *m, void *_d)
1105 tmp = *dev->ep [i].reg_udccs; 1103 tmp = *dev->ep [i].reg_udccs;
1106 seq_printf(m, 1104 seq_printf(m,
1107 "%s max %d %s udccs %02x irqs %lu\n", 1105 "%s max %d %s udccs %02x irqs %lu\n",
1108 ep->ep.name, le16_to_cpu(desc->wMaxPacketSize), 1106 ep->ep.name, usb_endpoint_maxp(desc),
1109 "pio", tmp, ep->pio_irqs); 1107 "pio", tmp, ep->pio_irqs);
1110 /* TODO translate all five groups of udccs bits! */ 1108 /* TODO translate all five groups of udccs bits! */
1111 1109
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 85b68c75dc9d..d21455f457e2 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -1439,7 +1439,7 @@ static int pxa_ep_enable(struct usb_ep *_ep,
1439 return -EINVAL; 1439 return -EINVAL;
1440 } 1440 }
1441 1441
1442 if (ep->fifo_size < le16_to_cpu(desc->wMaxPacketSize)) { 1442 if (ep->fifo_size < usb_endpoint_maxp(desc)) {
1443 ep_err(ep, "bad maxpacket\n"); 1443 ep_err(ep, "bad maxpacket\n");
1444 return -ERANGE; 1444 return -ERANGE;
1445 } 1445 }
diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c
index 50991e5bd5e8..61d0c65802e8 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -341,7 +341,7 @@ static void r8a66597_ep_setting(struct r8a66597 *r8a66597,
341 341
342 ep->pipectr = get_pipectr_addr(pipenum); 342 ep->pipectr = get_pipectr_addr(pipenum);
343 ep->pipenum = pipenum; 343 ep->pipenum = pipenum;
344 ep->ep.maxpacket = le16_to_cpu(desc->wMaxPacketSize); 344 ep->ep.maxpacket = usb_endpoint_maxp(desc);
345 r8a66597->pipenum2ep[pipenum] = ep; 345 r8a66597->pipenum2ep[pipenum] = ep;
346 r8a66597->epaddr2ep[desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK] 346 r8a66597->epaddr2ep[desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK]
347 = ep; 347 = ep;
@@ -420,7 +420,7 @@ static int alloc_pipe_config(struct r8a66597_ep *ep,
420 ep->type = info.type; 420 ep->type = info.type;
421 421
422 info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 422 info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
423 info.maxpacket = le16_to_cpu(desc->wMaxPacketSize); 423 info.maxpacket = usb_endpoint_maxp(desc);
424 info.interval = desc->bInterval; 424 info.interval = desc->bInterval;
425 if (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 425 if (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
426 info.dir_in = 1; 426 info.dir_in = 1;
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 8bdee67ce09a..39b134dec94c 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -2297,7 +2297,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
2297 return -EINVAL; 2297 return -EINVAL;
2298 } 2298 }
2299 2299
2300 mps = le16_to_cpu(desc->wMaxPacketSize); 2300 mps = usb_endpoint_maxp(desc);
2301 2301
2302 /* note, we handle this here instead of s3c_hsotg_set_ep_maxpacket */ 2302 /* note, we handle this here instead of s3c_hsotg_set_ep_maxpacket */
2303 2303
diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c
index 3e96cc5bb77f..25829b4398da 100644
--- a/drivers/usb/gadget/s3c-hsudc.c
+++ b/drivers/usb/gadget/s3c-hsudc.c
@@ -761,11 +761,11 @@ static int s3c_hsudc_ep_enable(struct usb_ep *_ep,
761 if (!_ep || !desc || hsep->desc || _ep->name == ep0name 761 if (!_ep || !desc || hsep->desc || _ep->name == ep0name
762 || desc->bDescriptorType != USB_DT_ENDPOINT 762 || desc->bDescriptorType != USB_DT_ENDPOINT
763 || hsep->bEndpointAddress != desc->bEndpointAddress 763 || hsep->bEndpointAddress != desc->bEndpointAddress
764 || ep_maxpacket(hsep) < le16_to_cpu(desc->wMaxPacketSize)) 764 || ep_maxpacket(hsep) < usb_endpoint_maxp(desc))
765 return -EINVAL; 765 return -EINVAL;
766 766
767 if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK 767 if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK
768 && le16_to_cpu(desc->wMaxPacketSize) != ep_maxpacket(hsep)) 768 && usb_endpoint_maxp(desc) != ep_maxpacket(hsep))
769 || !desc->wMaxPacketSize) 769 || !desc->wMaxPacketSize)
770 return -ERANGE; 770 return -ERANGE;
771 771
@@ -781,7 +781,7 @@ static int s3c_hsudc_ep_enable(struct usb_ep *_ep,
781 781
782 hsep->stopped = hsep->wedge = 0; 782 hsep->stopped = hsep->wedge = 0;
783 hsep->desc = desc; 783 hsep->desc = desc;
784 hsep->ep.maxpacket = le16_to_cpu(desc->wMaxPacketSize); 784 hsep->ep.maxpacket = usb_endpoint_maxp(desc);
785 785
786 s3c_hsudc_set_halt(_ep, 0); 786 s3c_hsudc_set_halt(_ep, 0);
787 __set_bit(ep_index(hsep), hsudc->regs + S3C_EIER); 787 __set_bit(ep_index(hsep), hsudc->regs + S3C_EIER);
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c
index 8d31848aab09..257285448678 100644
--- a/drivers/usb/gadget/s3c2410_udc.c
+++ b/drivers/usb/gadget/s3c2410_udc.c
@@ -1082,7 +1082,7 @@ static int s3c2410_udc_ep_enable(struct usb_ep *_ep,
1082 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) 1082 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)
1083 return -ESHUTDOWN; 1083 return -ESHUTDOWN;
1084 1084
1085 max = le16_to_cpu(desc->wMaxPacketSize) & 0x1fff; 1085 max = usb_endpoint_maxp(desc) & 0x1fff;
1086 1086
1087 local_irq_save (flags); 1087 local_irq_save (flags);
1088 _ep->maxpacket = max & 0x7ff; 1088 _ep->maxpacket = max & 0x7ff;
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index dd24fc115e48..15dc51ded61a 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -428,7 +428,7 @@ static struct ed *ed_get (
428 ed->type = usb_pipetype(pipe); 428 ed->type = usb_pipetype(pipe);
429 429
430 info |= (ep->desc.bEndpointAddress & ~USB_DIR_IN) << 7; 430 info |= (ep->desc.bEndpointAddress & ~USB_DIR_IN) << 7;
431 info |= le16_to_cpu(ep->desc.wMaxPacketSize) << 16; 431 info |= usb_endpoint_maxp(&ep->desc) << 16;
432 if (udev->speed == USB_SPEED_LOW) 432 if (udev->speed == USB_SPEED_LOW)
433 info |= ED_LOWSPEED; 433 info |= ED_LOWSPEED;
434 /* only control transfers store pids in tds */ 434 /* only control transfers store pids in tds */
@@ -444,7 +444,7 @@ static struct ed *ed_get (
444 ed->load = usb_calc_bus_time ( 444 ed->load = usb_calc_bus_time (
445 udev->speed, !is_out, 445 udev->speed, !is_out,
446 ed->type == PIPE_ISOCHRONOUS, 446 ed->type == PIPE_ISOCHRONOUS,
447 le16_to_cpu(ep->desc.wMaxPacketSize)) 447 usb_endpoint_maxp(&ep->desc))
448 / 1000; 448 / 1000;
449 } 449 }
450 } 450 }
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index 40a0d8b03ad7..a6f256436e77 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -959,7 +959,7 @@ static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb,
959 info.pipenum = get_empty_pipenum(r8a66597, ep); 959 info.pipenum = get_empty_pipenum(r8a66597, ep);
960 info.address = get_urb_to_r8a66597_addr(r8a66597, urb); 960 info.address = get_urb_to_r8a66597_addr(r8a66597, urb);
961 info.epnum = usb_endpoint_num(ep); 961 info.epnum = usb_endpoint_num(ep);
962 info.maxpacket = le16_to_cpu(ep->wMaxPacketSize); 962 info.maxpacket = usb_endpoint_maxp(ep);
963 info.type = get_r8a66597_type(usb_endpoint_type(ep)); 963 info.type = get_r8a66597_type(usb_endpoint_type(ep));
964 info.bufnum = get_bufnum(info.pipenum); 964 info.bufnum = get_bufnum(info.pipenum);
965 info.buf_bsize = get_buf_bsize(info.pipenum); 965 info.buf_bsize = get_buf_bsize(info.pipenum);
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 84ed28b34f93..f6ca80ee4cec 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -280,7 +280,7 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci,
280 qh->load = usb_calc_bus_time(udev->speed, 280 qh->load = usb_calc_bus_time(udev->speed,
281 usb_endpoint_dir_in(&hep->desc), 281 usb_endpoint_dir_in(&hep->desc),
282 qh->type == USB_ENDPOINT_XFER_ISOC, 282 qh->type == USB_ENDPOINT_XFER_ISOC,
283 le16_to_cpu(hep->desc.wMaxPacketSize)) 283 usb_endpoint_maxp(&hep->desc))
284 / 1000 + 1; 284 / 1000 + 1;
285 285
286 } else { /* Skeleton QH */ 286 } else { /* Skeleton QH */
@@ -792,7 +792,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb,
792{ 792{
793 struct uhci_td *td; 793 struct uhci_td *td;
794 unsigned long destination, status; 794 unsigned long destination, status;
795 int maxsze = le16_to_cpu(qh->hep->desc.wMaxPacketSize); 795 int maxsze = usb_endpoint_maxp(&qh->hep->desc);
796 int len = urb->transfer_buffer_length; 796 int len = urb->transfer_buffer_length;
797 dma_addr_t data = urb->transfer_dma; 797 dma_addr_t data = urb->transfer_dma;
798 __hc32 *plink; 798 __hc32 *plink;
@@ -918,7 +918,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb,
918{ 918{
919 struct uhci_td *td; 919 struct uhci_td *td;
920 unsigned long destination, status; 920 unsigned long destination, status;
921 int maxsze = le16_to_cpu(qh->hep->desc.wMaxPacketSize); 921 int maxsze = usb_endpoint_maxp(&qh->hep->desc);
922 int len = urb->transfer_buffer_length; 922 int len = urb->transfer_buffer_length;
923 int this_sg_len; 923 int this_sg_len;
924 dma_addr_t data; 924 dma_addr_t data;
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index d446886b22b0..d873a0330c9e 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1141,8 +1141,8 @@ static u32 xhci_get_max_esit_payload(struct xhci_hcd *xhci,
1141 if (udev->speed == USB_SPEED_SUPER) 1141 if (udev->speed == USB_SPEED_SUPER)
1142 return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval); 1142 return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval);
1143 1143
1144 max_packet = GET_MAX_PACKET(le16_to_cpu(ep->desc.wMaxPacketSize)); 1144 max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc));
1145 max_burst = (le16_to_cpu(ep->desc.wMaxPacketSize) & 0x1800) >> 11; 1145 max_burst = (usb_endpoint_maxp(&ep->desc) & 0x1800) >> 11;
1146 /* A 0 in max burst means 1 transfer per ESIT */ 1146 /* A 0 in max burst means 1 transfer per ESIT */
1147 return max_packet * (max_burst + 1); 1147 return max_packet * (max_burst + 1);
1148} 1148}
@@ -1211,7 +1211,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
1211 /* Set the max packet size and max burst */ 1211 /* Set the max packet size and max burst */
1212 switch (udev->speed) { 1212 switch (udev->speed) {
1213 case USB_SPEED_SUPER: 1213 case USB_SPEED_SUPER:
1214 max_packet = le16_to_cpu(ep->desc.wMaxPacketSize); 1214 max_packet = usb_endpoint_maxp(&ep->desc);
1215 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet)); 1215 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet));
1216 /* dig out max burst from ep companion desc */ 1216 /* dig out max burst from ep companion desc */
1217 max_packet = ep->ss_ep_comp.bMaxBurst; 1217 max_packet = ep->ss_ep_comp.bMaxBurst;
@@ -1223,14 +1223,14 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
1223 */ 1223 */
1224 if (usb_endpoint_xfer_isoc(&ep->desc) || 1224 if (usb_endpoint_xfer_isoc(&ep->desc) ||
1225 usb_endpoint_xfer_int(&ep->desc)) { 1225 usb_endpoint_xfer_int(&ep->desc)) {
1226 max_burst = (le16_to_cpu(ep->desc.wMaxPacketSize) 1226 max_burst = (usb_endpoint_maxp(&ep->desc)
1227 & 0x1800) >> 11; 1227 & 0x1800) >> 11;
1228 ep_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(max_burst)); 1228 ep_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(max_burst));
1229 } 1229 }
1230 /* Fall through */ 1230 /* Fall through */
1231 case USB_SPEED_FULL: 1231 case USB_SPEED_FULL:
1232 case USB_SPEED_LOW: 1232 case USB_SPEED_LOW:
1233 max_packet = GET_MAX_PACKET(le16_to_cpu(ep->desc.wMaxPacketSize)); 1233 max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc));
1234 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet)); 1234 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet));
1235 break; 1235 break;
1236 default: 1236 default:
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 7113d16e2d3a..bf0b52c6c960 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2676,7 +2676,7 @@ static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len,
2676 * running_total. 2676 * running_total.
2677 */ 2677 */
2678 packets_transferred = (running_total + trb_buff_len) / 2678 packets_transferred = (running_total + trb_buff_len) /
2679 le16_to_cpu(urb->ep->desc.wMaxPacketSize); 2679 usb_endpoint_maxp(&urb->ep->desc);
2680 2680
2681 return xhci_td_remainder(total_packet_count - packets_transferred); 2681 return xhci_td_remainder(total_packet_count - packets_transferred);
2682} 2682}
@@ -2706,7 +2706,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2706 num_trbs = count_sg_trbs_needed(xhci, urb); 2706 num_trbs = count_sg_trbs_needed(xhci, urb);
2707 num_sgs = urb->num_sgs; 2707 num_sgs = urb->num_sgs;
2708 total_packet_count = roundup(urb->transfer_buffer_length, 2708 total_packet_count = roundup(urb->transfer_buffer_length,
2709 le16_to_cpu(urb->ep->desc.wMaxPacketSize)); 2709 usb_endpoint_maxp(&urb->ep->desc));
2710 2710
2711 trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id], 2711 trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id],
2712 ep_index, urb->stream_id, 2712 ep_index, urb->stream_id,
@@ -2913,7 +2913,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2913 2913
2914 running_total = 0; 2914 running_total = 0;
2915 total_packet_count = roundup(urb->transfer_buffer_length, 2915 total_packet_count = roundup(urb->transfer_buffer_length,
2916 le16_to_cpu(urb->ep->desc.wMaxPacketSize)); 2916 usb_endpoint_maxp(&urb->ep->desc));
2917 /* How much data is in the first TRB? */ 2917 /* How much data is in the first TRB? */
2918 addr = (u64) urb->transfer_dma; 2918 addr = (u64) urb->transfer_dma;
2919 trb_buff_len = TRB_MAX_BUFF_SIZE - 2919 trb_buff_len = TRB_MAX_BUFF_SIZE -
@@ -3239,7 +3239,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3239 td_remain_len = td_len; 3239 td_remain_len = td_len;
3240 /* FIXME: Ignoring zero-length packets, can those happen? */ 3240 /* FIXME: Ignoring zero-length packets, can those happen? */
3241 total_packet_count = roundup(td_len, 3241 total_packet_count = roundup(td_len,
3242 le16_to_cpu(urb->ep->desc.wMaxPacketSize)); 3242 usb_endpoint_maxp(&urb->ep->desc));
3243 burst_count = xhci_get_burst_count(xhci, urb->dev, urb, 3243 burst_count = xhci_get_burst_count(xhci, urb->dev, urb,
3244 total_packet_count); 3244 total_packet_count);
3245 residue = xhci_get_last_burst_packet_count(xhci, 3245 residue = xhci_get_last_burst_packet_count(xhci,
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 1c4432d8fc10..f53596b16dec 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -987,7 +987,7 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id,
987 out_ctx = xhci->devs[slot_id]->out_ctx; 987 out_ctx = xhci->devs[slot_id]->out_ctx;
988 ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index); 988 ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index);
989 hw_max_packet_size = MAX_PACKET_DECODED(le32_to_cpu(ep_ctx->ep_info2)); 989 hw_max_packet_size = MAX_PACKET_DECODED(le32_to_cpu(ep_ctx->ep_info2));
990 max_packet_size = le16_to_cpu(urb->dev->ep0.desc.wMaxPacketSize); 990 max_packet_size = usb_endpoint_maxp(&urb->dev->ep0.desc);
991 if (hw_max_packet_size != max_packet_size) { 991 if (hw_max_packet_size != max_packet_size) {
992 xhci_dbg(xhci, "Max Packet Size for ep 0 changed.\n"); 992 xhci_dbg(xhci, "Max Packet Size for ep 0 changed.\n");
993 xhci_dbg(xhci, "Max packet size in usb_device = %d\n", 993 xhci_dbg(xhci, "Max packet size in usb_device = %d\n",
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index a6afd15f6a46..fe858711651c 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -213,7 +213,7 @@ static void adu_interrupt_in_callback(struct urb *urb)
213 213
214 if (urb->actual_length > 0 && dev->interrupt_in_buffer[0] != 0x00) { 214 if (urb->actual_length > 0 && dev->interrupt_in_buffer[0] != 0x00) {
215 if (dev->read_buffer_length < 215 if (dev->read_buffer_length <
216 (4 * le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize)) - 216 (4 * usb_endpoint_maxp(dev->interrupt_in_endpoint)) -
217 (urb->actual_length)) { 217 (urb->actual_length)) {
218 memcpy (dev->read_buffer_primary + 218 memcpy (dev->read_buffer_primary +
219 dev->read_buffer_length, 219 dev->read_buffer_length,
@@ -315,7 +315,7 @@ static int adu_open(struct inode *inode, struct file *file)
315 usb_rcvintpipe(dev->udev, 315 usb_rcvintpipe(dev->udev,
316 dev->interrupt_in_endpoint->bEndpointAddress), 316 dev->interrupt_in_endpoint->bEndpointAddress),
317 dev->interrupt_in_buffer, 317 dev->interrupt_in_buffer,
318 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), 318 usb_endpoint_maxp(dev->interrupt_in_endpoint),
319 adu_interrupt_in_callback, dev, 319 adu_interrupt_in_callback, dev,
320 dev->interrupt_in_endpoint->bInterval); 320 dev->interrupt_in_endpoint->bInterval);
321 dev->read_urb_finished = 0; 321 dev->read_urb_finished = 0;
@@ -483,7 +483,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
483 usb_rcvintpipe(dev->udev, 483 usb_rcvintpipe(dev->udev,
484 dev->interrupt_in_endpoint->bEndpointAddress), 484 dev->interrupt_in_endpoint->bEndpointAddress),
485 dev->interrupt_in_buffer, 485 dev->interrupt_in_buffer,
486 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), 486 usb_endpoint_maxp(dev->interrupt_in_endpoint),
487 adu_interrupt_in_callback, 487 adu_interrupt_in_callback,
488 dev, 488 dev,
489 dev->interrupt_in_endpoint->bInterval); 489 dev->interrupt_in_endpoint->bInterval);
@@ -536,7 +536,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
536 usb_rcvintpipe(dev->udev, 536 usb_rcvintpipe(dev->udev,
537 dev->interrupt_in_endpoint->bEndpointAddress), 537 dev->interrupt_in_endpoint->bEndpointAddress),
538 dev->interrupt_in_buffer, 538 dev->interrupt_in_buffer,
539 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), 539 usb_endpoint_maxp(dev->interrupt_in_endpoint),
540 adu_interrupt_in_callback, 540 adu_interrupt_in_callback,
541 dev, 541 dev,
542 dev->interrupt_in_endpoint->bInterval); 542 dev->interrupt_in_endpoint->bInterval);
@@ -622,7 +622,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
622 dbg(4," %s : sending, count = %Zd", __func__, count); 622 dbg(4," %s : sending, count = %Zd", __func__, count);
623 623
624 /* write the data into interrupt_out_buffer from userspace */ 624 /* write the data into interrupt_out_buffer from userspace */
625 buffer_size = le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize); 625 buffer_size = usb_endpoint_maxp(dev->interrupt_out_endpoint);
626 bytes_to_write = count > buffer_size ? buffer_size : count; 626 bytes_to_write = count > buffer_size ? buffer_size : count;
627 dbg(4," %s : buffer_size = %Zd, count = %Zd, bytes_to_write = %Zd", 627 dbg(4," %s : buffer_size = %Zd, count = %Zd, bytes_to_write = %Zd",
628 __func__, buffer_size, count, bytes_to_write); 628 __func__, buffer_size, count, bytes_to_write);
@@ -752,8 +752,8 @@ static int adu_probe(struct usb_interface *interface,
752 goto error; 752 goto error;
753 } 753 }
754 754
755 in_end_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize); 755 in_end_size = usb_endpoint_maxp(dev->interrupt_in_endpoint);
756 out_end_size = le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize); 756 out_end_size = usb_endpoint_maxp(dev->interrupt_out_endpoint);
757 757
758 dev->read_buffer_primary = kmalloc((4 * in_end_size), GFP_KERNEL); 758 dev->read_buffer_primary = kmalloc((4 * in_end_size), GFP_KERNEL);
759 if (!dev->read_buffer_primary) { 759 if (!dev->read_buffer_primary) {
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index 2f41089cd854..2dbe600fbc11 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -2777,7 +2777,7 @@ static int ftdi_elan_probe(struct usb_interface *interface,
2777 endpoint = &iface_desc->endpoint[i].desc; 2777 endpoint = &iface_desc->endpoint[i].desc;
2778 if (!ftdi->bulk_in_endpointAddr && 2778 if (!ftdi->bulk_in_endpointAddr &&
2779 usb_endpoint_is_bulk_in(endpoint)) { 2779 usb_endpoint_is_bulk_in(endpoint)) {
2780 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 2780 buffer_size = usb_endpoint_maxp(endpoint);
2781 ftdi->bulk_in_size = buffer_size; 2781 ftdi->bulk_in_size = buffer_size;
2782 ftdi->bulk_in_endpointAddr = endpoint->bEndpointAddress; 2782 ftdi->bulk_in_endpointAddr = endpoint->bEndpointAddress;
2783 ftdi->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); 2783 ftdi->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c
index c6184b4d1695..515b67fffab1 100644
--- a/drivers/usb/misc/idmouse.c
+++ b/drivers/usb/misc/idmouse.c
@@ -359,7 +359,7 @@ static int idmouse_probe(struct usb_interface *interface,
359 endpoint = &iface_desc->endpoint[0].desc; 359 endpoint = &iface_desc->endpoint[0].desc;
360 if (!dev->bulk_in_endpointAddr && usb_endpoint_is_bulk_in(endpoint)) { 360 if (!dev->bulk_in_endpointAddr && usb_endpoint_is_bulk_in(endpoint)) {
361 /* we found a bulk in endpoint */ 361 /* we found a bulk in endpoint */
362 dev->orig_bi_size = le16_to_cpu(endpoint->wMaxPacketSize); 362 dev->orig_bi_size = usb_endpoint_maxp(endpoint);
363 dev->bulk_in_size = 0x200; /* works _much_ faster */ 363 dev->bulk_in_size = 0x200; /* works _much_ faster */
364 dev->bulk_in_endpointAddr = endpoint->bEndpointAddress; 364 dev->bulk_in_endpointAddr = endpoint->bEndpointAddress;
365 dev->bulk_in_buffer = 365 dev->bulk_in_buffer =
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index a2190b983f52..81457904d6ba 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -803,7 +803,7 @@ static int iowarrior_probe(struct usb_interface *interface,
803 dev->int_out_endpoint = endpoint; 803 dev->int_out_endpoint = endpoint;
804 } 804 }
805 /* we have to check the report_size often, so remember it in the endianess suitable for our machine */ 805 /* we have to check the report_size often, so remember it in the endianess suitable for our machine */
806 dev->report_size = le16_to_cpu(dev->int_in_endpoint->wMaxPacketSize); 806 dev->report_size = usb_endpoint_maxp(dev->int_in_endpoint);
807 if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) && 807 if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) &&
808 (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56)) 808 (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56))
809 /* IOWarrior56 has wMaxPacketSize different from report size */ 809 /* IOWarrior56 has wMaxPacketSize different from report size */
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index cb4096201e29..48c166f0d764 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -721,7 +721,7 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *
721 if (dev->interrupt_out_endpoint == NULL) 721 if (dev->interrupt_out_endpoint == NULL)
722 dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)\n"); 722 dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)\n");
723 723
724 dev->interrupt_in_endpoint_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize); 724 dev->interrupt_in_endpoint_size = usb_endpoint_maxp(dev->interrupt_in_endpoint);
725 dev->ring_buffer = kmalloc(ring_buffer_size*(sizeof(size_t)+dev->interrupt_in_endpoint_size), GFP_KERNEL); 725 dev->ring_buffer = kmalloc(ring_buffer_size*(sizeof(size_t)+dev->interrupt_in_endpoint_size), GFP_KERNEL);
726 if (!dev->ring_buffer) { 726 if (!dev->ring_buffer) {
727 dev_err(&intf->dev, "Couldn't allocate ring_buffer\n"); 727 dev_err(&intf->dev, "Couldn't allocate ring_buffer\n");
@@ -737,7 +737,7 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *
737 dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n"); 737 dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n");
738 goto error; 738 goto error;
739 } 739 }
740 dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize) : 740 dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? usb_endpoint_maxp(dev->interrupt_out_endpoint) :
741 udev->descriptor.bMaxPacketSize0; 741 udev->descriptor.bMaxPacketSize0;
742 dev->interrupt_out_buffer = kmalloc(write_buffer_size*dev->interrupt_out_endpoint_size, GFP_KERNEL); 742 dev->interrupt_out_buffer = kmalloc(write_buffer_size*dev->interrupt_out_endpoint_size, GFP_KERNEL);
743 if (!dev->interrupt_out_buffer) { 743 if (!dev->interrupt_out_buffer) {
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index 6482c6e2e6bd..a989356f693e 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -409,7 +409,7 @@ static int tower_open (struct inode *inode, struct file *file)
409 dev->udev, 409 dev->udev,
410 usb_rcvintpipe(dev->udev, dev->interrupt_in_endpoint->bEndpointAddress), 410 usb_rcvintpipe(dev->udev, dev->interrupt_in_endpoint->bEndpointAddress),
411 dev->interrupt_in_buffer, 411 dev->interrupt_in_buffer,
412 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), 412 usb_endpoint_maxp(dev->interrupt_in_endpoint),
413 tower_interrupt_in_callback, 413 tower_interrupt_in_callback,
414 dev, 414 dev,
415 dev->interrupt_in_interval); 415 dev->interrupt_in_interval);
@@ -928,7 +928,7 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
928 err("Couldn't allocate read_buffer"); 928 err("Couldn't allocate read_buffer");
929 goto error; 929 goto error;
930 } 930 }
931 dev->interrupt_in_buffer = kmalloc (le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), GFP_KERNEL); 931 dev->interrupt_in_buffer = kmalloc (usb_endpoint_maxp(dev->interrupt_in_endpoint), GFP_KERNEL);
932 if (!dev->interrupt_in_buffer) { 932 if (!dev->interrupt_in_buffer) {
933 err("Couldn't allocate interrupt_in_buffer"); 933 err("Couldn't allocate interrupt_in_buffer");
934 goto error; 934 goto error;
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c
index 6ac106952e95..1871cdf10da3 100644
--- a/drivers/usb/misc/usblcd.c
+++ b/drivers/usb/misc/usblcd.c
@@ -347,7 +347,7 @@ static int lcd_probe(struct usb_interface *interface,
347 if (!dev->bulk_in_endpointAddr && 347 if (!dev->bulk_in_endpointAddr &&
348 usb_endpoint_is_bulk_in(endpoint)) { 348 usb_endpoint_is_bulk_in(endpoint)) {
349 /* we found a bulk in endpoint */ 349 /* we found a bulk in endpoint */
350 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 350 buffer_size = usb_endpoint_maxp(endpoint);
351 dev->bulk_in_size = buffer_size; 351 dev->bulk_in_size = buffer_size;
352 dev->bulk_in_endpointAddr = endpoint->bEndpointAddress; 352 dev->bulk_in_endpointAddr = endpoint->bEndpointAddress;
353 dev->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); 353 dev->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index bd715006b056..930962f49276 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -1585,8 +1585,8 @@ static struct urb *iso_alloc_urb(
1585 1585
1586 if (bytes < 0 || !desc) 1586 if (bytes < 0 || !desc)
1587 return NULL; 1587 return NULL;
1588 maxp = 0x7ff & le16_to_cpu(desc->wMaxPacketSize); 1588 maxp = 0x7ff & usb_endpoint_maxp(desc);
1589 maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11)); 1589 maxp *= 1 + (0x3 & (usb_endpoint_maxp(desc) >> 11));
1590 packets = DIV_ROUND_UP(bytes, maxp); 1590 packets = DIV_ROUND_UP(bytes, maxp);
1591 1591
1592 urb = usb_alloc_urb(packets, GFP_KERNEL); 1592 urb = usb_alloc_urb(packets, GFP_KERNEL);
@@ -1656,7 +1656,7 @@ test_iso_queue(struct usbtest_dev *dev, struct usbtest_param *param,
1656 "... iso period %d %sframes, wMaxPacket %04x\n", 1656 "... iso period %d %sframes, wMaxPacket %04x\n",
1657 1 << (desc->bInterval - 1), 1657 1 << (desc->bInterval - 1),
1658 (udev->speed == USB_SPEED_HIGH) ? "micro" : "", 1658 (udev->speed == USB_SPEED_HIGH) ? "micro" : "",
1659 le16_to_cpu(desc->wMaxPacketSize)); 1659 usb_endpoint_maxp(desc));
1660 1660
1661 for (i = 0; i < param->sglen; i++) { 1661 for (i = 0; i < param->sglen; i++) {
1662 urbs[i] = iso_alloc_urb(udev, pipe, desc, 1662 urbs[i] = iso_alloc_urb(udev, pipe, desc,
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 8c41a2e6ea77..44b331a74d58 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1020,7 +1020,7 @@ static int musb_gadget_enable(struct usb_ep *ep,
1020 goto fail; 1020 goto fail;
1021 1021
1022 /* REVISIT this rules out high bandwidth periodic transfers */ 1022 /* REVISIT this rules out high bandwidth periodic transfers */
1023 tmp = le16_to_cpu(desc->wMaxPacketSize); 1023 tmp = usb_endpoint_maxp(desc);
1024 if (tmp & ~0x07ff) { 1024 if (tmp & ~0x07ff) {
1025 int ok; 1025 int ok;
1026 1026
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 8b2473fa0f47..60ddba8066ea 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -1932,7 +1932,7 @@ static int musb_urb_enqueue(
1932 INIT_LIST_HEAD(&qh->ring); 1932 INIT_LIST_HEAD(&qh->ring);
1933 qh->is_ready = 1; 1933 qh->is_ready = 1;
1934 1934
1935 qh->maxpacket = le16_to_cpu(epd->wMaxPacketSize); 1935 qh->maxpacket = usb_endpoint_maxp(epd);
1936 qh->type = usb_endpoint_type(epd); 1936 qh->type = usb_endpoint_type(epd);
1937 1937
1938 /* Bits 11 & 12 of wMaxPacketSize encode high bandwidth multiplier. 1938 /* Bits 11 & 12 of wMaxPacketSize encode high bandwidth multiplier.
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 78a2cf9551cc..8aee28b89c36 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1480,7 +1480,7 @@ static void ftdi_set_max_packet_size(struct usb_serial_port *port)
1480 } 1480 }
1481 1481
1482 /* set max packet size based on descriptor */ 1482 /* set max packet size based on descriptor */
1483 priv->max_packet_size = le16_to_cpu(ep_desc->wMaxPacketSize); 1483 priv->max_packet_size = usb_endpoint_maxp(ep_desc);
1484 1484
1485 dev_info(&udev->dev, "Setting MaxPacketSize %d\n", priv->max_packet_size); 1485 dev_info(&udev->dev, "Setting MaxPacketSize %d\n", priv->max_packet_size);
1486} 1486}
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index abf095be5753..2ee807523f53 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -3042,7 +3042,7 @@ static int edge_startup(struct usb_serial *serial)
3042 3042
3043 endpoint = &serial->interface->altsetting[0]. 3043 endpoint = &serial->interface->altsetting[0].
3044 endpoint[i].desc; 3044 endpoint[i].desc;
3045 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 3045 buffer_size = usb_endpoint_maxp(endpoint);
3046 if (!interrupt_in_found && 3046 if (!interrupt_in_found &&
3047 (usb_endpoint_is_int_in(endpoint))) { 3047 (usb_endpoint_is_int_in(endpoint))) {
3048 /* we found a interrupt in endpoint */ 3048 /* we found a interrupt in endpoint */
@@ -3107,7 +3107,7 @@ static int edge_startup(struct usb_serial *serial)
3107 usb_rcvbulkpipe(dev, 3107 usb_rcvbulkpipe(dev,
3108 endpoint->bEndpointAddress), 3108 endpoint->bEndpointAddress),
3109 edge_serial->bulk_in_buffer, 3109 edge_serial->bulk_in_buffer,
3110 le16_to_cpu(endpoint->wMaxPacketSize), 3110 usb_endpoint_maxp(endpoint),
3111 edge_bulk_in_callback, 3111 edge_bulk_in_callback,
3112 edge_serial); 3112 edge_serial);
3113 bulk_in_found = true; 3113 bulk_in_found = true;
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index 96423f3c8ef3..c248a9147439 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -523,7 +523,7 @@ static int opticon_startup(struct usb_serial *serial)
523 goto error; 523 goto error;
524 } 524 }
525 525
526 priv->buffer_size = le16_to_cpu(endpoint->wMaxPacketSize) * 2; 526 priv->buffer_size = usb_endpoint_maxp(endpoint) * 2;
527 priv->bulk_in_buffer = kmalloc(priv->buffer_size, GFP_KERNEL); 527 priv->bulk_in_buffer = kmalloc(priv->buffer_size, GFP_KERNEL);
528 if (!priv->bulk_in_buffer) { 528 if (!priv->bulk_in_buffer) {
529 dev_err(&priv->udev->dev, "out of memory\n"); 529 dev_err(&priv->udev->dev, "out of memory\n");
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c
index d9457bd4fe10..7096f799b071 100644
--- a/drivers/usb/serial/symbolserial.c
+++ b/drivers/usb/serial/symbolserial.c
@@ -226,7 +226,7 @@ static int symbol_startup(struct usb_serial *serial)
226 goto error; 226 goto error;
227 } 227 }
228 228
229 priv->buffer_size = le16_to_cpu(endpoint->wMaxPacketSize) * 2; 229 priv->buffer_size = usb_endpoint_maxp(endpoint) * 2;
230 priv->int_buffer = kmalloc(priv->buffer_size, GFP_KERNEL); 230 priv->int_buffer = kmalloc(priv->buffer_size, GFP_KERNEL);
231 if (!priv->int_buffer) { 231 if (!priv->int_buffer) {
232 dev_err(&priv->udev->dev, "out of memory\n"); 232 dev_err(&priv->udev->dev, "out of memory\n");
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 1c031309ab25..cc274fdf2627 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -912,7 +912,7 @@ int usb_serial_probe(struct usb_interface *interface,
912 goto probe_error; 912 goto probe_error;
913 } 913 }
914 buffer_size = max_t(int, serial->type->bulk_in_size, 914 buffer_size = max_t(int, serial->type->bulk_in_size,
915 le16_to_cpu(endpoint->wMaxPacketSize)); 915 usb_endpoint_maxp(endpoint));
916 port->bulk_in_size = buffer_size; 916 port->bulk_in_size = buffer_size;
917 port->bulk_in_endpointAddress = endpoint->bEndpointAddress; 917 port->bulk_in_endpointAddress = endpoint->bEndpointAddress;
918 port->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); 918 port->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
@@ -942,7 +942,7 @@ int usb_serial_probe(struct usb_interface *interface,
942 goto probe_error; 942 goto probe_error;
943 buffer_size = serial->type->bulk_out_size; 943 buffer_size = serial->type->bulk_out_size;
944 if (!buffer_size) 944 if (!buffer_size)
945 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 945 buffer_size = usb_endpoint_maxp(endpoint);
946 port->bulk_out_size = buffer_size; 946 port->bulk_out_size = buffer_size;
947 port->bulk_out_endpointAddress = endpoint->bEndpointAddress; 947 port->bulk_out_endpointAddress = endpoint->bEndpointAddress;
948 port->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL); 948 port->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL);
@@ -990,7 +990,7 @@ int usb_serial_probe(struct usb_interface *interface,
990 "No free urbs available\n"); 990 "No free urbs available\n");
991 goto probe_error; 991 goto probe_error;
992 } 992 }
993 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 993 buffer_size = usb_endpoint_maxp(endpoint);
994 port->interrupt_in_endpointAddress = 994 port->interrupt_in_endpointAddress =
995 endpoint->bEndpointAddress; 995 endpoint->bEndpointAddress;
996 port->interrupt_in_buffer = kmalloc(buffer_size, 996 port->interrupt_in_buffer = kmalloc(buffer_size,
@@ -1021,7 +1021,7 @@ int usb_serial_probe(struct usb_interface *interface,
1021 "No free urbs available\n"); 1021 "No free urbs available\n");
1022 goto probe_error; 1022 goto probe_error;
1023 } 1023 }
1024 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 1024 buffer_size = usb_endpoint_maxp(endpoint);
1025 port->interrupt_out_size = buffer_size; 1025 port->interrupt_out_size = buffer_size;
1026 port->interrupt_out_endpointAddress = 1026 port->interrupt_out_endpointAddress =
1027 endpoint->bEndpointAddress; 1027 endpoint->bEndpointAddress;
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index e24ce3123071..32d6fc953904 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -555,7 +555,7 @@ static int skel_probe(struct usb_interface *interface,
555 if (!dev->bulk_in_endpointAddr && 555 if (!dev->bulk_in_endpointAddr &&
556 usb_endpoint_is_bulk_in(endpoint)) { 556 usb_endpoint_is_bulk_in(endpoint)) {
557 /* we found a bulk in endpoint */ 557 /* we found a bulk in endpoint */
558 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 558 buffer_size = usb_endpoint_maxp(endpoint);
559 dev->bulk_in_size = buffer_size; 559 dev->bulk_in_size = buffer_size;
560 dev->bulk_in_endpointAddr = endpoint->bEndpointAddress; 560 dev->bulk_in_endpointAddr = endpoint->bEndpointAddress;
561 dev->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); 561 dev->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
diff --git a/drivers/usb/wusbcore/wa-hc.c b/drivers/usb/wusbcore/wa-hc.c
index 59a748a0e5da..0d1863c9edde 100644
--- a/drivers/usb/wusbcore/wa-hc.c
+++ b/drivers/usb/wusbcore/wa-hc.c
@@ -43,7 +43,7 @@ int wa_create(struct wahc *wa, struct usb_interface *iface)
43 /* Fill up Data Transfer EP pointers */ 43 /* Fill up Data Transfer EP pointers */
44 wa->dti_epd = &iface->cur_altsetting->endpoint[1].desc; 44 wa->dti_epd = &iface->cur_altsetting->endpoint[1].desc;
45 wa->dto_epd = &iface->cur_altsetting->endpoint[2].desc; 45 wa->dto_epd = &iface->cur_altsetting->endpoint[2].desc;
46 wa->xfer_result_size = le16_to_cpu(wa->dti_epd->wMaxPacketSize); 46 wa->xfer_result_size = usb_endpoint_maxp(wa->dti_epd);
47 wa->xfer_result = kmalloc(wa->xfer_result_size, GFP_KERNEL); 47 wa->xfer_result = kmalloc(wa->xfer_result_size, GFP_KERNEL);
48 if (wa->xfer_result == NULL) 48 if (wa->xfer_result == NULL)
49 goto error_xfer_result_alloc; 49 goto error_xfer_result_alloc;
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 73c7df489607..c19f9100c307 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1574,7 +1574,7 @@ usb_maxpacket(struct usb_device *udev, int pipe, int is_out)
1574 return 0; 1574 return 0;
1575 1575
1576 /* NOTE: only 0x07ff bits are for packet size... */ 1576 /* NOTE: only 0x07ff bits are for packet size... */
1577 return le16_to_cpu(ep->desc.wMaxPacketSize); 1577 return usb_endpoint_maxp(&ep->desc);
1578} 1578}
1579 1579
1580/* ----------------------------------------------------------------------- */ 1580/* ----------------------------------------------------------------------- */