diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2011-08-23 06:12:03 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-08-23 12:47:40 -0400 |
commit | 29cc88979a8818cd8c5019426e945aed118b400e (patch) | |
tree | 849401ad869d09ce45dd7a3fadd7eb71b1e9fcbd /drivers/usb/misc | |
parent | 46a57283e86c68351377ac3349f1465aee938fbd (diff) |
USB: use usb_endpoint_maxp() instead of le16_to_cpu()
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>
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r-- | drivers/usb/misc/adutux.c | 14 | ||||
-rw-r--r-- | drivers/usb/misc/ftdi-elan.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/idmouse.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/iowarrior.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/ldusb.c | 4 | ||||
-rw-r--r-- | drivers/usb/misc/legousbtower.c | 4 | ||||
-rw-r--r-- | drivers/usb/misc/usblcd.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/usbtest.c | 6 |
8 files changed, 18 insertions, 18 deletions
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, |