USB: use usb_endpoint_maxp() instead of le16_to_cpu()
Kuninori Morimoto [Tue, 23 Aug 2011 10:12:03 +0000 (03:12 -0700)]
Now ${LINUX}/drivers/usb/* can use usb_endpoint_maxp(desc) to get maximum packet size
instead of le16_to_cpu(desc->wMaxPacketSize).
This patch fix it up

Cc: Armin Fuerst <fuerst@in.tum.de>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Johannes Erdfelt <johannes@erdfelt.com>
Cc: Vojtech Pavlik <vojtech@suse.cz>
Cc: Oliver Neukum <oliver@neukum.name>
Cc: David Kubicek <dave@awk.cz>
Cc: Johan Hovold <jhovold@gmail.com>
Cc: Brad Hards <bhards@bigpond.net.au>
Acked-by: Felipe Balbi <balbi@ti.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Thomas Dahlmann <dahlmann.thomas@arcor.de>
Cc: David Brownell <david-b@pacbell.net>
Cc: David Lopo <dlopo@chipidea.mips.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Michal Nazarewicz <m.nazarewicz@samsung.com>
Cc: Xie Xiaobo <X.Xie@freescale.com>
Cc: Li Yang <leoli@freescale.com>
Cc: Jiang Bo <tanya.jiang@freescale.com>
Cc: Yuan-hsin Chen <yhchen@faraday-tech.com>
Cc: Darius Augulis <augulis.darius@gmail.com>
Cc: Xiaochen Shen <xiaochen.shen@intel.com>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: OKI SEMICONDUCTOR, <toshiharu-linux@dsn.okisemi.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Ben Dooks <ben@simtec.co.uk>
Cc: Thomas Abraham <thomas.ab@samsung.com>
Cc: Herbert Pƶtzl <herbert@13thfloor.at>
Cc: Arnaud Patard <arnaud.patard@rtp-net.org>
Cc: Roman Weissgaerber <weissg@vienna.at>
Acked-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: Tony Olech <tony.olech@elandigitalsystems.com>
Cc: Florian Floe Echtler <echtler@fs.tum.de>
Cc: Christian Lucht <lucht@codemercs.com>
Cc: Juergen Stuber <starblue@sourceforge.net>
Cc: Georges Toth <g.toth@e-biz.lu>
Cc: Bill Ryder <bryder@sgi.com>
Cc: Kuba Ober <kuba@mareimbrium.org>
Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

59 files changed:
drivers/usb/class/cdc-acm.c
drivers/usb/class/cdc-wdm.c
drivers/usb/class/usbtmc.c
drivers/usb/core/config.c
drivers/usb/core/devices.c
drivers/usb/core/endpoint.c
drivers/usb/core/hub.c
drivers/usb/core/urb.c
drivers/usb/dwc3/gadget.c
drivers/usb/gadget/amd5536udc.c
drivers/usb/gadget/at91_udc.c
drivers/usb/gadget/atmel_usba_udc.c
drivers/usb/gadget/ci13xxx_udc.c
drivers/usb/gadget/composite.c
drivers/usb/gadget/dummy_hcd.c
drivers/usb/gadget/epautoconf.c
drivers/usb/gadget/f_mass_storage.c
drivers/usb/gadget/file_storage.c
drivers/usb/gadget/fsl_qe_udc.c
drivers/usb/gadget/fsl_udc_core.c
drivers/usb/gadget/fusb300_udc.c
drivers/usb/gadget/imx_udc.c
drivers/usb/gadget/langwell_udc.c
drivers/usb/gadget/m66592-udc.c
drivers/usb/gadget/mv_udc_core.c
drivers/usb/gadget/net2272.c
drivers/usb/gadget/net2280.c
drivers/usb/gadget/omap_udc.c
drivers/usb/gadget/pch_udc.c
drivers/usb/gadget/pxa25x_udc.c
drivers/usb/gadget/pxa27x_udc.c
drivers/usb/gadget/r8a66597-udc.c
drivers/usb/gadget/s3c-hsotg.c
drivers/usb/gadget/s3c-hsudc.c
drivers/usb/gadget/s3c2410_udc.c
drivers/usb/host/ohci-q.c
drivers/usb/host/r8a66597-hcd.c
drivers/usb/host/uhci-q.c
drivers/usb/host/xhci-mem.c
drivers/usb/host/xhci-ring.c
drivers/usb/host/xhci.c
drivers/usb/misc/adutux.c
drivers/usb/misc/ftdi-elan.c
drivers/usb/misc/idmouse.c
drivers/usb/misc/iowarrior.c
drivers/usb/misc/ldusb.c
drivers/usb/misc/legousbtower.c
drivers/usb/misc/usblcd.c
drivers/usb/misc/usbtest.c
drivers/usb/musb/musb_gadget.c
drivers/usb/musb/musb_host.c
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/io_edgeport.c
drivers/usb/serial/opticon.c
drivers/usb/serial/symbolserial.c
drivers/usb/serial/usb-serial.c
drivers/usb/usb-skeleton.c
drivers/usb/wusbcore/wa-hc.c
include/linux/usb.h

index dac7676..f69a185 100644 (file)
@@ -1058,11 +1058,11 @@ made_compressed_probe:
                goto alloc_fail;
        }
 
-       ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize);
-       readsize = le16_to_cpu(epread->wMaxPacketSize) *
+       ctrlsize = usb_endpoint_maxp(epctrl);
+       readsize = usb_endpoint_maxp(epread) *
                                (quirks == SINGLE_RX_URB ? 1 : 2);
        acm->combined_interfaces = combined_interfaces;
-       acm->writesize = le16_to_cpu(epwrite->wMaxPacketSize) * 20;
+       acm->writesize = usb_endpoint_maxp(epwrite) * 20;
        acm->control = control_interface;
        acm->data = data_interface;
        acm->minor = minor;
index 2b9ff51..1d26a71 100644 (file)
@@ -682,7 +682,7 @@ next_desc:
        if (!ep || !usb_endpoint_is_int_in(ep))
                goto err;
 
-       desc->wMaxPacketSize = le16_to_cpu(ep->wMaxPacketSize);
+       desc->wMaxPacketSize = usb_endpoint_maxp(ep);
        desc->bMaxPacketSize0 = udev->descriptor.bMaxPacketSize0;
 
        desc->orq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
index 3f94ac3..12cf5e7 100644 (file)
@@ -186,8 +186,7 @@ static int usbtmc_ioctl_abort_bulk_in(struct usbtmc_device_data *data)
        for (n = 0; n < current_setting->desc.bNumEndpoints; n++)
                if (current_setting->endpoint[n].desc.bEndpointAddress ==
                        data->bulk_in)
-                       max_size = le16_to_cpu(current_setting->endpoint[n].
-                                               desc.wMaxPacketSize);
+                       max_size = usb_endpoint_maxp(&current_setting->endpoint[n].desc);
 
        if (max_size == 0) {
                dev_err(dev, "Couldn't get wMaxPacketSize\n");
@@ -636,7 +635,7 @@ static int usbtmc_ioctl_clear(struct usbtmc_device_data *data)
        for (n = 0; n < current_setting->desc.bNumEndpoints; n++) {
                desc = &current_setting->endpoint[n].desc;
                if (desc->bEndpointAddress == data->bulk_in)
-                       max_size = le16_to_cpu(desc->wMaxPacketSize);
+                       max_size = usb_endpoint_maxp(desc);
        }
 
        if (max_size == 0) {
index 26678ca..9d5e07a 100644 (file)
@@ -124,9 +124,9 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
 
        if (usb_endpoint_xfer_isoc(&ep->desc))
                max_tx = (desc->bMaxBurst + 1) * (desc->bmAttributes + 1) *
-                       le16_to_cpu(ep->desc.wMaxPacketSize);
+                       usb_endpoint_maxp(&ep->desc);
        else if (usb_endpoint_xfer_int(&ep->desc))
-               max_tx = le16_to_cpu(ep->desc.wMaxPacketSize) *
+               max_tx = usb_endpoint_maxp(&ep->desc) *
                        (desc->bMaxBurst + 1);
        else
                max_tx = 999999;
@@ -241,7 +241,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
                    cfgno, inum, asnum, d->bEndpointAddress);
                endpoint->desc.bmAttributes = USB_ENDPOINT_XFER_INT;
                endpoint->desc.bInterval = 1;
-               if (le16_to_cpu(endpoint->desc.wMaxPacketSize) > 8)
+               if (usb_endpoint_maxp(&endpoint->desc) > 8)
                        endpoint->desc.wMaxPacketSize = cpu_to_le16(8);
        }
 
@@ -254,7 +254,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
                        && usb_endpoint_xfer_bulk(d)) {
                unsigned maxp;
 
-               maxp = le16_to_cpu(endpoint->desc.wMaxPacketSize) & 0x07ff;
+               maxp = usb_endpoint_maxp(&endpoint->desc) & 0x07ff;
                if (maxp != 512)
                        dev_warn(ddev, "config %d interface %d altsetting %d "
                                "bulk endpoint 0x%X has invalid maxpacket %d\n",
index 0149c09..d956965 100644 (file)
@@ -190,7 +190,7 @@ static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end,
        dir = usb_endpoint_dir_in(desc) ? 'I' : 'O';
 
        if (speed == USB_SPEED_HIGH) {
-               switch (le16_to_cpu(desc->wMaxPacketSize) & (0x03 << 11)) {
+               switch (usb_endpoint_maxp(desc) & (0x03 << 11)) {
                case 1 << 11:
                        bandwidth = 2; break;
                case 2 << 11:
@@ -240,7 +240,7 @@ static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end,
 
        start += sprintf(start, format_endpt, desc->bEndpointAddress, dir,
                         desc->bmAttributes, type,
-                        (le16_to_cpu(desc->wMaxPacketSize) & 0x07ff) *
+                        (usb_endpoint_maxp(desc) & 0x07ff) *
                         bandwidth,
                         interval, unit);
        return start;
index df502a9..db7fe50 100644 (file)
@@ -56,7 +56,7 @@ static ssize_t show_ep_wMaxPacketSize(struct device *dev,
 {
        struct ep_device *ep = to_ep_device(dev);
        return sprintf(buf, "%04x\n",
-                       le16_to_cpu(ep->desc->wMaxPacketSize) & 0x07ff);
+                       usb_endpoint_maxp(ep->desc) & 0x07ff);
 }
 static DEVICE_ATTR(wMaxPacketSize, S_IRUGO, show_ep_wMaxPacketSize, NULL);
 
index 99fff6b..338f91f 100644 (file)
@@ -3018,7 +3018,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
                i = 512;
        else
                i = udev->descriptor.bMaxPacketSize0;
-       if (le16_to_cpu(udev->ep0.desc.wMaxPacketSize) != i) {
+       if (usb_endpoint_maxp(&udev->ep0.desc) != i) {
                if (udev->speed == USB_SPEED_LOW ||
                                !(i == 8 || i == 16 || i == 32 || i == 64)) {
                        dev_err(&udev->dev, "Invalid ep0 maxpacket: %d\n", i);
index ae334b0..909625b 100644 (file)
@@ -350,7 +350,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
                        dev->state < USB_STATE_CONFIGURED)
                return -ENODEV;
 
-       max = le16_to_cpu(ep->desc.wMaxPacketSize);
+       max = usb_endpoint_maxp(&ep->desc);
        if (max <= 0) {
                dev_dbg(&dev->dev,
                        "bogus endpoint ep%d%s in %s (bad maxpacket %d)\n",
index de5f0af..cebaef7 100644 (file)
@@ -254,8 +254,7 @@ static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep,
        memset(&params, 0x00, sizeof(params));
 
        params.param0.depcfg.ep_type = usb_endpoint_type(desc);
-       params.param0.depcfg.max_packet_size =
-               le16_to_cpu(desc->wMaxPacketSize);
+       params.param0.depcfg.max_packet_size = usb_endpoint_maxp(desc);
 
        params.param1.depcfg.xfer_complete_enable = true;
        params.param1.depcfg.xfer_not_ready_enable = true;
index 70f2b37..d65d839 100644 (file)
@@ -354,7 +354,7 @@ udc_ep_enable(struct usb_ep *usbep, const struct usb_endpoint_descriptor *desc)
        writel(tmp, &dev->ep[ep->num].regs->ctl);
 
        /* set max packet size */
-       maxpacket = le16_to_cpu(desc->wMaxPacketSize);
+       maxpacket = usb_endpoint_maxp(desc);
        tmp = readl(&dev->ep[ep->num].regs->bufout_maxpkt);
        tmp = AMD_ADDBITS(tmp, maxpacket, UDC_EP_MAX_PKT_SIZE);
        ep->ep.maxpacket = maxpacket;
index ddb118a..d01fa5b 100644 (file)
@@ -487,7 +487,7 @@ static int at91_ep_enable(struct usb_ep *_ep,
                        || !desc || ep->desc
                        || _ep->name == ep0name
                        || desc->bDescriptorType != USB_DT_ENDPOINT
-                       || (maxpacket = le16_to_cpu(desc->wMaxPacketSize)) == 0
+                       || (maxpacket = usb_endpoint_maxp(desc)) == 0
                        || maxpacket > ep->maxpacket) {
                DBG("bad ep or descriptor\n");
                return -EINVAL;
index 5b1665e..722c468 100644 (file)
@@ -527,7 +527,7 @@ usba_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
 
        DBG(DBG_GADGET, "%s: ep_enable: desc=%p\n", ep->ep.name, desc);
 
-       maxpacket = le16_to_cpu(desc->wMaxPacketSize) & 0x7ff;
+       maxpacket = usb_endpoint_maxp(desc) & 0x7ff;
 
        if (((desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK) != ep->index)
                        || ep->index == 0
@@ -571,7 +571,7 @@ usba_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
                 * Bits 11:12 specify number of _additional_
                 * transactions per microframe.
                 */
-               nr_trans = ((le16_to_cpu(desc->wMaxPacketSize) >> 11) & 3) + 1;
+               nr_trans = ((usb_endpoint_maxp(desc) >> 11) & 3) + 1;
                if (nr_trans > 3)
                        return -EINVAL;
 
index 1265a85..83428f5 100644 (file)
@@ -2101,7 +2101,7 @@ static int ep_enable(struct usb_ep *ep,
        mEp->num  = usb_endpoint_num(desc);
        mEp->type = usb_endpoint_type(desc);
 
-       mEp->ep.maxpacket = __constant_le16_to_cpu(desc->wMaxPacketSize);
+       mEp->ep.maxpacket = usb_endpoint_maxp(desc);
 
        dbg_event(_usb_addr(mEp), "ENABLE", 0);
 
index aef4741..8065464 100644 (file)
@@ -164,7 +164,7 @@ int config_ep_by_speed(struct usb_gadget *g,
 
 ep_found:
        /* commit results */
-       _ep->maxpacket = le16_to_cpu(chosen_desc->wMaxPacketSize);
+       _ep->maxpacket = usb_endpoint_maxp(chosen_desc);
        _ep->desc = chosen_desc;
        _ep->comp_desc = NULL;
        _ep->maxburst = 0;
index e755a9d..7b06d39 100644 (file)
@@ -439,7 +439,7 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
         * maximum packet size.
         * For SS devices the wMaxPacketSize is limited by 1024.
         */
-       max = le16_to_cpu(desc->wMaxPacketSize) & 0x7ff;
+       max = usb_endpoint_maxp(desc) & 0x7ff;
 
        /* drivers must not request bad settings, since lower levels
         * (hardware or its drivers) may not check.  some endpoints
@@ -1277,7 +1277,7 @@ static int periodic_bytes (struct dummy *dum, struct dummy_ep *ep)
                int     tmp;
 
                /* high bandwidth mode */
-               tmp = le16_to_cpu(ep->desc->wMaxPacketSize);
+               tmp = usb_endpoint_maxp(ep->desc);
                tmp = (tmp >> 11) & 0x03;
                tmp *= 8 /* applies to entire frame */;
                limit += limit * tmp;
index 7a7e6b7..cdca7eb 100644 (file)
@@ -158,7 +158,7 @@ ep_matches (
         * where it's an output parameter representing the full speed limit.
         * the usb spec fixes high speed bulk maxpacket at 512 bytes.
         */
-       max = 0x7ff & le16_to_cpu(desc->wMaxPacketSize);
+       max = 0x7ff & usb_endpoint_maxp(desc);
        switch (type) {
        case USB_ENDPOINT_XFER_INT:
                /* INT:  limit 64 bytes full speed, 1024 high/super speed */
index 5b93395..4ce3dec 100644 (file)
@@ -2401,8 +2401,7 @@ reset:
                goto reset;
        fsg->bulk_out->driver_data = common;
        fsg->bulk_out_enabled = 1;
-       common->bulk_out_maxpacket =
-               le16_to_cpu(fsg->bulk_out->desc->wMaxPacketSize);
+       common->bulk_out_maxpacket = usb_endpoint_maxp(fsg->bulk_out->desc);
        clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags);
 
        /* Allocate the requests */
index 639e14a..39ece40 100644 (file)
@@ -2801,7 +2801,7 @@ reset:
        if ((rc = enable_endpoint(fsg, fsg->bulk_out, d)) != 0)
                goto reset;
        fsg->bulk_out_enabled = 1;
-       fsg->bulk_out_maxpacket = le16_to_cpu(d->wMaxPacketSize);
+       fsg->bulk_out_maxpacket = usb_endpoint_maxp(d);
        clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags);
 
        if (transport_is_cbi()) {
index 3bf872e..2a03e4d 100644 (file)
@@ -540,7 +540,7 @@ static int qe_ep_init(struct qe_udc *udc,
        int reval = 0;
        u16 max = 0;
 
-       max = le16_to_cpu(desc->wMaxPacketSize);
+       max = usb_endpoint_maxp(desc);
 
        /* check the max package size validate for this endpoint */
        /* Refer to USB2.0 spec table 9-13,
index de24a42..d699350 100644 (file)
@@ -559,7 +559,7 @@ static int fsl_ep_enable(struct usb_ep *_ep,
        if (!udc->driver || (udc->gadget.speed == USB_SPEED_UNKNOWN))
                return -ESHUTDOWN;
 
-       max = le16_to_cpu(desc->wMaxPacketSize);
+       max = usb_endpoint_maxp(desc);
 
        /* Disable automatic zlp generation.  Driver is responsible to indicate
         * explicitly through req->req.zero.  This is needed to enable multi-td
index 4ec888f..d9ee6c3 100644 (file)
@@ -220,7 +220,7 @@ static int config_ep(struct fusb300_ep *ep,
 
        info.type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
        info.dir_in = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? 1 : 0;
-       info.maxpacket = le16_to_cpu(desc->wMaxPacketSize);
+       info.maxpacket = usb_endpoint_maxp(desc);
        info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
 
        if ((info.type == USB_ENDPOINT_XFER_INT) ||
index 692fd9b..bf08bfc 100644 (file)
@@ -689,7 +689,7 @@ static int imx_ep_enable(struct usb_ep *usb_ep,
                return -EINVAL;
        }
 
-       if (imx_ep->fifosize < le16_to_cpu(desc->wMaxPacketSize)) {
+       if (imx_ep->fifosize < usb_endpoint_maxp(desc)) {
                D_ERR(imx_usb->dev,
                        "<%s> bad %s maxpacket\n", __func__, usb_ep->name);
                return -ERANGE;
index a06e2c2..5bf9942 100644 (file)
@@ -283,7 +283,7 @@ static int langwell_ep_enable(struct usb_ep *_ep,
        if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)
                return -ESHUTDOWN;
 
-       max = le16_to_cpu(desc->wMaxPacketSize);
+       max = usb_endpoint_maxp(desc);
 
        /*
         * disable HW zero length termination select
index 491f825..5e597c3 100644 (file)
@@ -370,7 +370,7 @@ static void m66592_ep_setting(struct m66592 *m66592, struct m66592_ep *ep,
 
        ep->pipectr = get_pipectr_addr(pipenum);
        ep->pipenum = pipenum;
-       ep->ep.maxpacket = le16_to_cpu(desc->wMaxPacketSize);
+       ep->ep.maxpacket = usb_endpoint_maxp(desc);
        m66592->pipenum2ep[pipenum] = ep;
        m66592->epaddr2ep[desc->bEndpointAddress&USB_ENDPOINT_NUMBER_MASK] = ep;
        INIT_LIST_HEAD(&ep->queue);
@@ -447,7 +447,7 @@ static int alloc_pipe_config(struct m66592_ep *ep,
        ep->type = info.type;
 
        info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
-       info.maxpacket = le16_to_cpu(desc->wMaxPacketSize);
+       info.maxpacket = usb_endpoint_maxp(desc);
        info.interval = desc->bInterval;
        if (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
                info.dir_in = 1;
index ce1ac2b..263dec4 100644 (file)
@@ -493,7 +493,7 @@ static int mv_ep_enable(struct usb_ep *_ep,
                return -ESHUTDOWN;
 
        direction = ep_dir(ep);
-       max = le16_to_cpu(desc->wMaxPacketSize);
+       max = usb_endpoint_maxp(desc);
 
        /*
         * disable HW zero length termination select
index ab98ea9..6fef1c0 100644 (file)
@@ -204,7 +204,7 @@ net2272_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
        if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)
                return -ESHUTDOWN;
 
-       max = le16_to_cpu(desc->wMaxPacketSize) & 0x1fff;
+       max = usb_endpoint_maxp(desc) & 0x1fff;
 
        spin_lock_irqsave(&dev->lock, flags);
        _ep->maxpacket = max & 0x7fff;
index 3dd40b4..8d3673f 100644 (file)
@@ -169,7 +169,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
                return -EDOM;
 
        /* sanity check ep-e/ep-f since their fifos are small */
-       max = le16_to_cpu (desc->wMaxPacketSize) & 0x1fff;
+       max = usb_endpoint_maxp (desc) & 0x1fff;
        if (ep->num > 4 && max > 64)
                return -ERANGE;
 
@@ -1640,7 +1640,7 @@ show_queues (struct device *_dev, struct device_attribute *attr, char *buf)
                                 default:
                                        val = "iso"; break;
                                 }; val; }),
-                               le16_to_cpu (d->wMaxPacketSize) & 0x1fff,
+                               usb_endpoint_maxp (d) & 0x1fff,
                                ep->dma ? "dma" : "pio", ep->fifo_size
                                );
                } else /* ep0 should only have one transfer queued */
index 740c7da..b7a7799 100644 (file)
@@ -166,15 +166,14 @@ static int omap_ep_enable(struct usb_ep *_ep,
        if (!_ep || !desc || ep->desc
                        || desc->bDescriptorType != USB_DT_ENDPOINT
                        || ep->bEndpointAddress != desc->bEndpointAddress
-                       || ep->maxpacket < le16_to_cpu
-                                               (desc->wMaxPacketSize)) {
+                       || ep->maxpacket < usb_endpoint_maxp(desc)) {
                DBG("%s, bad ep or descriptor\n", __func__);
                return -EINVAL;
        }
-       maxp = le16_to_cpu (desc->wMaxPacketSize);
+       maxp = usb_endpoint_maxp(desc);
        if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK
                                && maxp != ep->maxpacket)
-                       || le16_to_cpu(desc->wMaxPacketSize) > ep->maxpacket
+                       || usb_endpoint_maxp(desc) > ep->maxpacket
                        || !desc->wMaxPacketSize) {
                DBG("%s, bad %s maxpacket\n", __func__, _ep->name);
                return -ERANGE;
index f96615a..b69ae3e 100644 (file)
@@ -947,7 +947,7 @@ static void pch_udc_ep_enable(struct pch_udc_ep *ep,
        else
                buff_size = UDC_EPOUT_BUFF_SIZE;
        pch_udc_ep_set_bufsz(ep, buff_size, ep->in);
-       pch_udc_ep_set_maxpkt(ep, le16_to_cpu(desc->wMaxPacketSize));
+       pch_udc_ep_set_maxpkt(ep, usb_endpoint_maxp(desc));
        pch_udc_ep_set_nak(ep);
        pch_udc_ep_fifo_flush(ep, ep->in);
        /* Configure the endpoint */
@@ -957,7 +957,7 @@ static void pch_udc_ep_enable(struct pch_udc_ep *ep,
              (cfg->cur_cfg << UDC_CSR_NE_CFG_SHIFT) |
              (cfg->cur_intf << UDC_CSR_NE_INTF_SHIFT) |
              (cfg->cur_alt << UDC_CSR_NE_ALT_SHIFT) |
-             le16_to_cpu(desc->wMaxPacketSize) << UDC_CSR_NE_MAX_PKT_SHIFT;
+             usb_endpoint_maxp(desc) << UDC_CSR_NE_MAX_PKT_SHIFT;
 
        if (ep->in)
                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,
        ep->desc = desc;
        ep->halted = 0;
        pch_udc_ep_enable(ep, &ep->dev->cfg_data, desc);
-       ep->ep.maxpacket = le16_to_cpu(desc->wMaxPacketSize);
+       ep->ep.maxpacket = usb_endpoint_maxp(desc);
        pch_udc_enable_ep_interrupts(ep->dev, PCH_UDC_EPINT(ep->in, ep->num));
        spin_unlock_irqrestore(&dev->lock, iflags);
        return 0;
index e4e59b4..7862465 100644 (file)
@@ -232,8 +232,7 @@ static int pxa25x_ep_enable (struct usb_ep *_ep,
        if (!_ep || !desc || ep->desc || _ep->name == ep0name
                        || desc->bDescriptorType != USB_DT_ENDPOINT
                        || ep->bEndpointAddress != desc->bEndpointAddress
-                       || ep->fifo_size < le16_to_cpu
-                                               (desc->wMaxPacketSize)) {
+                       || ep->fifo_size < usb_endpoint_maxp (desc)) {
                DMSG("%s, bad ep or descriptor\n", __func__);
                return -EINVAL;
        }
@@ -248,7 +247,7 @@ static int pxa25x_ep_enable (struct usb_ep *_ep,
 
        /* hardware _could_ do smaller, but driver doesn't */
        if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK
-                               && le16_to_cpu (desc->wMaxPacketSize)
+                               && usb_endpoint_maxp (desc)
                                                != BULK_FIFO_SIZE)
                        || !desc->wMaxPacketSize) {
                DMSG("%s, bad %s maxpacket\n", __func__, _ep->name);
@@ -264,7 +263,7 @@ static int pxa25x_ep_enable (struct usb_ep *_ep,
        ep->desc = desc;
        ep->stopped = 0;
        ep->pio_irqs = 0;
-       ep->ep.maxpacket = le16_to_cpu (desc->wMaxPacketSize);
+       ep->ep.maxpacket = usb_endpoint_maxp (desc);
 
        /* flush fifo (mostly for OUT buffers) */
        pxa25x_ep_fifo_flush (_ep);
@@ -401,7 +400,7 @@ write_fifo (struct pxa25x_ep *ep, struct pxa25x_request *req)
 {
        unsigned                max;
 
-       max = le16_to_cpu(ep->desc->wMaxPacketSize);
+       max = usb_endpoint_maxp(ep->desc);
        do {
                unsigned        count;
                int             is_last, is_short;
@@ -671,8 +670,7 @@ pxa25x_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
         * we can report per-packet status.  that also helps with dma.
         */
        if (unlikely (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC
-                       && req->req.length > le16_to_cpu
-                                               (ep->desc->wMaxPacketSize)))
+                       && req->req.length > usb_endpoint_maxp (ep->desc)))
                return -EMSGSIZE;
 
        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)
                        tmp = *dev->ep [i].reg_udccs;
                        seq_printf(m,
                                "%s max %d %s udccs %02x irqs %lu\n",
-                               ep->ep.name, le16_to_cpu(desc->wMaxPacketSize),
+                               ep->ep.name, usb_endpoint_maxp(desc),
                                "pio", tmp, ep->pio_irqs);
                        /* TODO translate all five groups of udccs bits! */
 
index 85b68c7..d21455f 100644 (file)
@@ -1439,7 +1439,7 @@ static int pxa_ep_enable(struct usb_ep *_ep,
                return -EINVAL;
        }
 
-       if (ep->fifo_size < le16_to_cpu(desc->wMaxPacketSize)) {
+       if (ep->fifo_size < usb_endpoint_maxp(desc)) {
                ep_err(ep, "bad maxpacket\n");
                return -ERANGE;
        }
index 50991e5..61d0c65 100644 (file)
@@ -341,7 +341,7 @@ static void r8a66597_ep_setting(struct r8a66597 *r8a66597,
 
        ep->pipectr = get_pipectr_addr(pipenum);
        ep->pipenum = pipenum;
-       ep->ep.maxpacket = le16_to_cpu(desc->wMaxPacketSize);
+       ep->ep.maxpacket = usb_endpoint_maxp(desc);
        r8a66597->pipenum2ep[pipenum] = ep;
        r8a66597->epaddr2ep[desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK]
                = ep;
@@ -420,7 +420,7 @@ static int alloc_pipe_config(struct r8a66597_ep *ep,
        ep->type = info.type;
 
        info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
-       info.maxpacket = le16_to_cpu(desc->wMaxPacketSize);
+       info.maxpacket = usb_endpoint_maxp(desc);
        info.interval = desc->bInterval;
        if (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
                info.dir_in = 1;
index 8bdee67..39b134d 100644 (file)
@@ -2297,7 +2297,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
                return -EINVAL;
        }
 
-       mps = le16_to_cpu(desc->wMaxPacketSize);
+       mps = usb_endpoint_maxp(desc);
 
        /* note, we handle this here instead of s3c_hsotg_set_ep_maxpacket */
 
index 3e96cc5..25829b4 100644 (file)
@@ -761,11 +761,11 @@ static int s3c_hsudc_ep_enable(struct usb_ep *_ep,
        if (!_ep || !desc || hsep->desc || _ep->name == ep0name
                || desc->bDescriptorType != USB_DT_ENDPOINT
                || hsep->bEndpointAddress != desc->bEndpointAddress
-               || ep_maxpacket(hsep) < le16_to_cpu(desc->wMaxPacketSize))
+               || ep_maxpacket(hsep) < usb_endpoint_maxp(desc))
                return -EINVAL;
 
        if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK
-               && le16_to_cpu(desc->wMaxPacketSize) != ep_maxpacket(hsep))
+               && usb_endpoint_maxp(desc) != ep_maxpacket(hsep))
                || !desc->wMaxPacketSize)
                return -ERANGE;
 
@@ -781,7 +781,7 @@ static int s3c_hsudc_ep_enable(struct usb_ep *_ep,
 
        hsep->stopped = hsep->wedge = 0;
        hsep->desc = desc;
-       hsep->ep.maxpacket = le16_to_cpu(desc->wMaxPacketSize);
+       hsep->ep.maxpacket = usb_endpoint_maxp(desc);
 
        s3c_hsudc_set_halt(_ep, 0);
        __set_bit(ep_index(hsep), hsudc->regs + S3C_EIER);
index 8d31848..2572854 100644 (file)
@@ -1082,7 +1082,7 @@ static int s3c2410_udc_ep_enable(struct usb_ep *_ep,
        if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)
                return -ESHUTDOWN;
 
-       max = le16_to_cpu(desc->wMaxPacketSize) & 0x1fff;
+       max = usb_endpoint_maxp(desc) & 0x1fff;
 
        local_irq_save (flags);
        _ep->maxpacket = max & 0x7ff;
index dd24fc1..15dc51d 100644 (file)
@@ -428,7 +428,7 @@ static struct ed *ed_get (
                ed->type = usb_pipetype(pipe);
 
                info |= (ep->desc.bEndpointAddress & ~USB_DIR_IN) << 7;
-               info |= le16_to_cpu(ep->desc.wMaxPacketSize) << 16;
+               info |= usb_endpoint_maxp(&ep->desc) << 16;
                if (udev->speed == USB_SPEED_LOW)
                        info |= ED_LOWSPEED;
                /* only control transfers store pids in tds */
@@ -444,7 +444,7 @@ static struct ed *ed_get (
                                ed->load = usb_calc_bus_time (
                                        udev->speed, !is_out,
                                        ed->type == PIPE_ISOCHRONOUS,
-                                       le16_to_cpu(ep->desc.wMaxPacketSize))
+                                       usb_endpoint_maxp(&ep->desc))
                                                / 1000;
                        }
                }
index 40a0d8b..a6f2564 100644 (file)
@@ -959,7 +959,7 @@ static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb,
        info.pipenum = get_empty_pipenum(r8a66597, ep);
        info.address = get_urb_to_r8a66597_addr(r8a66597, urb);
        info.epnum = usb_endpoint_num(ep);
-       info.maxpacket = le16_to_cpu(ep->wMaxPacketSize);
+       info.maxpacket = usb_endpoint_maxp(ep);
        info.type = get_r8a66597_type(usb_endpoint_type(ep));
        info.bufnum = get_bufnum(info.pipenum);
        info.buf_bsize = get_buf_bsize(info.pipenum);
index 84ed28b..f6ca80e 100644 (file)
@@ -280,7 +280,7 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci,
                        qh->load = usb_calc_bus_time(udev->speed,
                                        usb_endpoint_dir_in(&hep->desc),
                                        qh->type == USB_ENDPOINT_XFER_ISOC,
-                                       le16_to_cpu(hep->desc.wMaxPacketSize))
+                                       usb_endpoint_maxp(&hep->desc))
                                / 1000 + 1;
 
        } else {                /* Skeleton QH */
@@ -792,7 +792,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb,
 {
        struct uhci_td *td;
        unsigned long destination, status;
-       int maxsze = le16_to_cpu(qh->hep->desc.wMaxPacketSize);
+       int maxsze = usb_endpoint_maxp(&qh->hep->desc);
        int len = urb->transfer_buffer_length;
        dma_addr_t data = urb->transfer_dma;
        __hc32 *plink;
@@ -918,7 +918,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb,
 {
        struct uhci_td *td;
        unsigned long destination, status;
-       int maxsze = le16_to_cpu(qh->hep->desc.wMaxPacketSize);
+       int maxsze = usb_endpoint_maxp(&qh->hep->desc);
        int len = urb->transfer_buffer_length;
        int this_sg_len;
        dma_addr_t data;
index d446886..d873a03 100644 (file)
@@ -1141,8 +1141,8 @@ static u32 xhci_get_max_esit_payload(struct xhci_hcd *xhci,
        if (udev->speed == USB_SPEED_SUPER)
                return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval);
 
-       max_packet = GET_MAX_PACKET(le16_to_cpu(ep->desc.wMaxPacketSize));
-       max_burst = (le16_to_cpu(ep->desc.wMaxPacketSize) & 0x1800) >> 11;
+       max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc));
+       max_burst = (usb_endpoint_maxp(&ep->desc) & 0x1800) >> 11;
        /* A 0 in max burst means 1 transfer per ESIT */
        return max_packet * (max_burst + 1);
 }
@@ -1211,7 +1211,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
        /* Set the max packet size and max burst */
        switch (udev->speed) {
        case USB_SPEED_SUPER:
-               max_packet = le16_to_cpu(ep->desc.wMaxPacketSize);
+               max_packet = usb_endpoint_maxp(&ep->desc);
                ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet));
                /* dig out max burst from ep companion desc */
                max_packet = ep->ss_ep_comp.bMaxBurst;
@@ -1223,14 +1223,14 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
                 */
                if (usb_endpoint_xfer_isoc(&ep->desc) ||
                                usb_endpoint_xfer_int(&ep->desc)) {
-                       max_burst = (le16_to_cpu(ep->desc.wMaxPacketSize)
+                       max_burst = (usb_endpoint_maxp(&ep->desc)
                                     & 0x1800) >> 11;
                        ep_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(max_burst));
                }
                /* Fall through */
        case USB_SPEED_FULL:
        case USB_SPEED_LOW:
-               max_packet = GET_MAX_PACKET(le16_to_cpu(ep->desc.wMaxPacketSize));
+               max_packet = GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc));
                ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet));
                break;
        default:
index 7113d16..bf0b52c 100644 (file)
@@ -2676,7 +2676,7 @@ static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len,
         * running_total.
         */
        packets_transferred = (running_total + trb_buff_len) /
-               le16_to_cpu(urb->ep->desc.wMaxPacketSize);
+               usb_endpoint_maxp(&urb->ep->desc);
 
        return xhci_td_remainder(total_packet_count - packets_transferred);
 }
@@ -2706,7 +2706,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
        num_trbs = count_sg_trbs_needed(xhci, urb);
        num_sgs = urb->num_sgs;
        total_packet_count = roundup(urb->transfer_buffer_length,
-                       le16_to_cpu(urb->ep->desc.wMaxPacketSize));
+                       usb_endpoint_maxp(&urb->ep->desc));
 
        trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id],
                        ep_index, urb->stream_id,
@@ -2913,7 +2913,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
 
        running_total = 0;
        total_packet_count = roundup(urb->transfer_buffer_length,
-                       le16_to_cpu(urb->ep->desc.wMaxPacketSize));
+                       usb_endpoint_maxp(&urb->ep->desc));
        /* How much data is in the first TRB? */
        addr = (u64) urb->transfer_dma;
        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,
                td_remain_len = td_len;
                /* FIXME: Ignoring zero-length packets, can those happen? */
                total_packet_count = roundup(td_len,
-                               le16_to_cpu(urb->ep->desc.wMaxPacketSize));
+                               usb_endpoint_maxp(&urb->ep->desc));
                burst_count = xhci_get_burst_count(xhci, urb->dev, urb,
                                total_packet_count);
                residue = xhci_get_last_burst_packet_count(xhci,
index 1c4432d..f53596b 100644 (file)
@@ -987,7 +987,7 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id,
        out_ctx = xhci->devs[slot_id]->out_ctx;
        ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index);
        hw_max_packet_size = MAX_PACKET_DECODED(le32_to_cpu(ep_ctx->ep_info2));
-       max_packet_size = le16_to_cpu(urb->dev->ep0.desc.wMaxPacketSize);
+       max_packet_size = usb_endpoint_maxp(&urb->dev->ep0.desc);
        if (hw_max_packet_size != max_packet_size) {
                xhci_dbg(xhci, "Max Packet Size for ep 0 changed.\n");
                xhci_dbg(xhci, "Max packet size in usb_device = %d\n",
index a6afd15..fe85871 100644 (file)
@@ -213,7 +213,7 @@ static void adu_interrupt_in_callback(struct urb *urb)
 
        if (urb->actual_length > 0 && dev->interrupt_in_buffer[0] != 0x00) {
                if (dev->read_buffer_length <
-                   (4 * le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize)) -
+                   (4 * usb_endpoint_maxp(dev->interrupt_in_endpoint)) -
                     (urb->actual_length)) {
                        memcpy (dev->read_buffer_primary +
                                dev->read_buffer_length,
@@ -315,7 +315,7 @@ static int adu_open(struct inode *inode, struct file *file)
                         usb_rcvintpipe(dev->udev,
                                        dev->interrupt_in_endpoint->bEndpointAddress),
                         dev->interrupt_in_buffer,
-                        le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
+                        usb_endpoint_maxp(dev->interrupt_in_endpoint),
                         adu_interrupt_in_callback, dev,
                         dev->interrupt_in_endpoint->bInterval);
        dev->read_urb_finished = 0;
@@ -483,7 +483,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
                                                         usb_rcvintpipe(dev->udev,
                                                                        dev->interrupt_in_endpoint->bEndpointAddress),
                                                         dev->interrupt_in_buffer,
-                                                        le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
+                                                        usb_endpoint_maxp(dev->interrupt_in_endpoint),
                                                         adu_interrupt_in_callback,
                                                         dev,
                                                         dev->interrupt_in_endpoint->bInterval);
@@ -536,7 +536,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
                                 usb_rcvintpipe(dev->udev,
                                                dev->interrupt_in_endpoint->bEndpointAddress),
                                dev->interrupt_in_buffer,
-                               le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
+                               usb_endpoint_maxp(dev->interrupt_in_endpoint),
                                adu_interrupt_in_callback,
                                dev,
                                dev->interrupt_in_endpoint->bInterval);
@@ -622,7 +622,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
                        dbg(4," %s : sending, count = %Zd", __func__, count);
 
                        /* write the data into interrupt_out_buffer from userspace */
-                       buffer_size = le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize);
+                       buffer_size = usb_endpoint_maxp(dev->interrupt_out_endpoint);
                        bytes_to_write = count > buffer_size ? buffer_size : count;
                        dbg(4," %s : buffer_size = %Zd, count = %Zd, bytes_to_write = %Zd",
                            __func__, buffer_size, count, bytes_to_write);
@@ -752,8 +752,8 @@ static int adu_probe(struct usb_interface *interface,
                goto error;
        }
 
-       in_end_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize);
-       out_end_size = le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize);
+       in_end_size = usb_endpoint_maxp(dev->interrupt_in_endpoint);
+       out_end_size = usb_endpoint_maxp(dev->interrupt_out_endpoint);
 
        dev->read_buffer_primary = kmalloc((4 * in_end_size), GFP_KERNEL);
        if (!dev->read_buffer_primary) {
index 2f41089..2dbe600 100644 (file)
@@ -2777,7 +2777,7 @@ static int ftdi_elan_probe(struct usb_interface *interface,
                 endpoint = &iface_desc->endpoint[i].desc;
                 if (!ftdi->bulk_in_endpointAddr &&
                    usb_endpoint_is_bulk_in(endpoint)) {
-                        buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
+                        buffer_size = usb_endpoint_maxp(endpoint);
                         ftdi->bulk_in_size = buffer_size;
                         ftdi->bulk_in_endpointAddr = endpoint->bEndpointAddress;
                         ftdi->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
index c6184b4..515b67f 100644 (file)
@@ -359,7 +359,7 @@ static int idmouse_probe(struct usb_interface *interface,
        endpoint = &iface_desc->endpoint[0].desc;
        if (!dev->bulk_in_endpointAddr && usb_endpoint_is_bulk_in(endpoint)) {
                /* we found a bulk in endpoint */
-               dev->orig_bi_size = le16_to_cpu(endpoint->wMaxPacketSize);
+               dev->orig_bi_size = usb_endpoint_maxp(endpoint);
                dev->bulk_in_size = 0x200; /* works _much_ faster */
                dev->bulk_in_endpointAddr = endpoint->bEndpointAddress;
                dev->bulk_in_buffer =
index a2190b9..8145790 100644 (file)
@@ -803,7 +803,7 @@ static int iowarrior_probe(struct usb_interface *interface,
                        dev->int_out_endpoint = endpoint;
        }
        /* we have to check the report_size often, so remember it in the endianess suitable for our machine */
-       dev->report_size = le16_to_cpu(dev->int_in_endpoint->wMaxPacketSize);
+       dev->report_size = usb_endpoint_maxp(dev->int_in_endpoint);
        if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) &&
            (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56))
                /* IOWarrior56 has wMaxPacketSize different from report size */
index cb40962..48c166f 100644 (file)
@@ -721,7 +721,7 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *
        if (dev->interrupt_out_endpoint == NULL)
                dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)\n");
 
-       dev->interrupt_in_endpoint_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize);
+       dev->interrupt_in_endpoint_size = usb_endpoint_maxp(dev->interrupt_in_endpoint);
        dev->ring_buffer = kmalloc(ring_buffer_size*(sizeof(size_t)+dev->interrupt_in_endpoint_size), GFP_KERNEL);
        if (!dev->ring_buffer) {
                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 *
                dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n");
                goto error;
        }
-       dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize) :
+       dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? usb_endpoint_maxp(dev->interrupt_out_endpoint) :
                                                                         udev->descriptor.bMaxPacketSize0;
        dev->interrupt_out_buffer = kmalloc(write_buffer_size*dev->interrupt_out_endpoint_size, GFP_KERNEL);
        if (!dev->interrupt_out_buffer) {
index 6482c6e..a989356 100644 (file)
@@ -409,7 +409,7 @@ static int tower_open (struct inode *inode, struct file *file)
                          dev->udev,
                          usb_rcvintpipe(dev->udev, dev->interrupt_in_endpoint->bEndpointAddress),
                          dev->interrupt_in_buffer,
-                         le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
+                         usb_endpoint_maxp(dev->interrupt_in_endpoint),
                          tower_interrupt_in_callback,
                          dev,
                          dev->interrupt_in_interval);
@@ -928,7 +928,7 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
                err("Couldn't allocate read_buffer");
                goto error;
        }
-       dev->interrupt_in_buffer = kmalloc (le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), GFP_KERNEL);
+       dev->interrupt_in_buffer = kmalloc (usb_endpoint_maxp(dev->interrupt_in_endpoint), GFP_KERNEL);
        if (!dev->interrupt_in_buffer) {
                err("Couldn't allocate interrupt_in_buffer");
                goto error;
index 6ac1069..1871cdf 100644 (file)
@@ -347,7 +347,7 @@ static int lcd_probe(struct usb_interface *interface,
                if (!dev->bulk_in_endpointAddr &&
                    usb_endpoint_is_bulk_in(endpoint)) {
                        /* we found a bulk in endpoint */
-                       buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
+                       buffer_size = usb_endpoint_maxp(endpoint);
                        dev->bulk_in_size = buffer_size;
                        dev->bulk_in_endpointAddr = endpoint->bEndpointAddress;
                        dev->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
index bd71500..930962f 100644 (file)
@@ -1585,8 +1585,8 @@ static struct urb *iso_alloc_urb(
 
        if (bytes < 0 || !desc)
                return NULL;
-       maxp = 0x7ff & le16_to_cpu(desc->wMaxPacketSize);
-       maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11));
+       maxp = 0x7ff & usb_endpoint_maxp(desc);
+       maxp *= 1 + (0x3 & (usb_endpoint_maxp(desc) >> 11));
        packets = DIV_ROUND_UP(bytes, maxp);
 
        urb = usb_alloc_urb(packets, GFP_KERNEL);
@@ -1656,7 +1656,7 @@ test_iso_queue(struct usbtest_dev *dev, struct usbtest_param *param,
                "... iso period %d %sframes, wMaxPacket %04x\n",
                1 << (desc->bInterval - 1),
                (udev->speed == USB_SPEED_HIGH) ? "micro" : "",
-               le16_to_cpu(desc->wMaxPacketSize));
+               usb_endpoint_maxp(desc));
 
        for (i = 0; i < param->sglen; i++) {
                urbs[i] = iso_alloc_urb(udev, pipe, desc,
index 8c41a2e..44b331a 100644 (file)
@@ -1020,7 +1020,7 @@ static int musb_gadget_enable(struct usb_ep *ep,
                goto fail;
 
        /* REVISIT this rules out high bandwidth periodic transfers */
-       tmp = le16_to_cpu(desc->wMaxPacketSize);
+       tmp = usb_endpoint_maxp(desc);
        if (tmp & ~0x07ff) {
                int ok;
 
index 8b2473f..60ddba8 100644 (file)
@@ -1932,7 +1932,7 @@ static int musb_urb_enqueue(
        INIT_LIST_HEAD(&qh->ring);
        qh->is_ready = 1;
 
-       qh->maxpacket = le16_to_cpu(epd->wMaxPacketSize);
+       qh->maxpacket = usb_endpoint_maxp(epd);
        qh->type = usb_endpoint_type(epd);
 
        /* Bits 11 & 12 of wMaxPacketSize encode high bandwidth multiplier.
index 78a2cf9..8aee28b 100644 (file)
@@ -1480,7 +1480,7 @@ static void ftdi_set_max_packet_size(struct usb_serial_port *port)
        }
 
        /* set max packet size based on descriptor */
-       priv->max_packet_size = le16_to_cpu(ep_desc->wMaxPacketSize);
+       priv->max_packet_size = usb_endpoint_maxp(ep_desc);
 
        dev_info(&udev->dev, "Setting MaxPacketSize %d\n", priv->max_packet_size);
 }
index abf095b..2ee8075 100644 (file)
@@ -3042,7 +3042,7 @@ static int edge_startup(struct usb_serial *serial)
 
                        endpoint = &serial->interface->altsetting[0].
                                                        endpoint[i].desc;
-                       buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
+                       buffer_size = usb_endpoint_maxp(endpoint);
                        if (!interrupt_in_found &&
                            (usb_endpoint_is_int_in(endpoint))) {
                                /* we found a interrupt in endpoint */
@@ -3107,7 +3107,7 @@ static int edge_startup(struct usb_serial *serial)
                                        usb_rcvbulkpipe(dev,
                                                endpoint->bEndpointAddress),
                                        edge_serial->bulk_in_buffer,
-                                       le16_to_cpu(endpoint->wMaxPacketSize),
+                                       usb_endpoint_maxp(endpoint),
                                        edge_bulk_in_callback,
                                        edge_serial);
                                bulk_in_found = true;
index 96423f3..c248a91 100644 (file)
@@ -523,7 +523,7 @@ static int opticon_startup(struct usb_serial *serial)
                        goto error;
                }
 
-               priv->buffer_size = le16_to_cpu(endpoint->wMaxPacketSize) * 2;
+               priv->buffer_size = usb_endpoint_maxp(endpoint) * 2;
                priv->bulk_in_buffer = kmalloc(priv->buffer_size, GFP_KERNEL);
                if (!priv->bulk_in_buffer) {
                        dev_err(&priv->udev->dev, "out of memory\n");
index d9457bd..7096f79 100644 (file)
@@ -226,7 +226,7 @@ static int symbol_startup(struct usb_serial *serial)
                        goto error;
                }
 
-               priv->buffer_size = le16_to_cpu(endpoint->wMaxPacketSize) * 2;
+               priv->buffer_size = usb_endpoint_maxp(endpoint) * 2;
                priv->int_buffer = kmalloc(priv->buffer_size, GFP_KERNEL);
                if (!priv->int_buffer) {
                        dev_err(&priv->udev->dev, "out of memory\n");
index 1c03130..cc274fd 100644 (file)
@@ -912,7 +912,7 @@ int usb_serial_probe(struct usb_interface *interface,
                        goto probe_error;
                }
                buffer_size = max_t(int, serial->type->bulk_in_size,
-                               le16_to_cpu(endpoint->wMaxPacketSize));
+                               usb_endpoint_maxp(endpoint));
                port->bulk_in_size = buffer_size;
                port->bulk_in_endpointAddress = endpoint->bEndpointAddress;
                port->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
@@ -942,7 +942,7 @@ int usb_serial_probe(struct usb_interface *interface,
                        goto probe_error;
                buffer_size = serial->type->bulk_out_size;
                if (!buffer_size)
-                       buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
+                       buffer_size = usb_endpoint_maxp(endpoint);
                port->bulk_out_size = buffer_size;
                port->bulk_out_endpointAddress = endpoint->bEndpointAddress;
                port->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL);
@@ -990,7 +990,7 @@ int usb_serial_probe(struct usb_interface *interface,
                                                "No free urbs available\n");
                                goto probe_error;
                        }
-                       buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
+                       buffer_size = usb_endpoint_maxp(endpoint);
                        port->interrupt_in_endpointAddress =
                                                endpoint->bEndpointAddress;
                        port->interrupt_in_buffer = kmalloc(buffer_size,
@@ -1021,7 +1021,7 @@ int usb_serial_probe(struct usb_interface *interface,
                                                "No free urbs available\n");
                                goto probe_error;
                        }
-                       buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
+                       buffer_size = usb_endpoint_maxp(endpoint);
                        port->interrupt_out_size = buffer_size;
                        port->interrupt_out_endpointAddress =
                                                endpoint->bEndpointAddress;
index e24ce31..32d6fc9 100644 (file)
@@ -555,7 +555,7 @@ static int skel_probe(struct usb_interface *interface,
                if (!dev->bulk_in_endpointAddr &&
                    usb_endpoint_is_bulk_in(endpoint)) {
                        /* we found a bulk in endpoint */
-                       buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
+                       buffer_size = usb_endpoint_maxp(endpoint);
                        dev->bulk_in_size = buffer_size;
                        dev->bulk_in_endpointAddr = endpoint->bEndpointAddress;
                        dev->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
index 59a748a..0d1863c 100644 (file)
@@ -43,7 +43,7 @@ int wa_create(struct wahc *wa, struct usb_interface *iface)
        /* Fill up Data Transfer EP pointers */
        wa->dti_epd = &iface->cur_altsetting->endpoint[1].desc;
        wa->dto_epd = &iface->cur_altsetting->endpoint[2].desc;
-       wa->xfer_result_size = le16_to_cpu(wa->dti_epd->wMaxPacketSize);
+       wa->xfer_result_size = usb_endpoint_maxp(wa->dti_epd);
        wa->xfer_result = kmalloc(wa->xfer_result_size, GFP_KERNEL);
        if (wa->xfer_result == NULL)
                goto error_xfer_result_alloc;
index 73c7df4..c19f910 100644 (file)
@@ -1574,7 +1574,7 @@ usb_maxpacket(struct usb_device *udev, int pipe, int is_out)
                return 0;
 
        /* NOTE:  only 0x07ff bits are for packet size... */
-       return le16_to_cpu(ep->desc.wMaxPacketSize);
+       return usb_endpoint_maxp(&ep->desc);
 }
 
 /* ----------------------------------------------------------------------- */