aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2007-02-26 14:56:14 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2007-03-09 22:52:23 -0500
commit97b9eb91dc131a10342da1f604e5bd8b1316abdb (patch)
treed960cf039c29b8c6c7603801db8c6966486bcca7
parent14360ab76ae81012ef09cce37a587e95ab2e1d86 (diff)
USB: set the correct interval for interrupt URBs
This patch (as862) fixes a couple of bugs in the way usbcore handles intervals for interrupt URBs. usb_interrupt_msg (and usb_bulk_msg for backward compatibility) don't set the interval correctly for high-speed devices. proc_do_submiturb() doesn't set it correctly when a bulk URB is submitted to an interrupt endpoint. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/core/devio.c13
-rw-r--r--drivers/usb/core/message.c9
2 files changed, 13 insertions, 9 deletions
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 274f14f1633e..36e7a843bf91 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -912,7 +912,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
912 struct async *as; 912 struct async *as;
913 struct usb_ctrlrequest *dr = NULL; 913 struct usb_ctrlrequest *dr = NULL;
914 unsigned int u, totlen, isofrmlen; 914 unsigned int u, totlen, isofrmlen;
915 int ret, interval = 0, ifnum = -1; 915 int ret, ifnum = -1;
916 916
917 if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP|USBDEVFS_URB_SHORT_NOT_OK| 917 if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP|USBDEVFS_URB_SHORT_NOT_OK|
918 URB_NO_FSBR|URB_ZERO_PACKET)) 918 URB_NO_FSBR|URB_ZERO_PACKET))
@@ -992,7 +992,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
992 if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 992 if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
993 != USB_ENDPOINT_XFER_ISOC) 993 != USB_ENDPOINT_XFER_ISOC)
994 return -EINVAL; 994 return -EINVAL;
995 interval = 1 << min (15, ep->desc.bInterval - 1);
996 isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) * uurb->number_of_packets; 995 isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) * uurb->number_of_packets;
997 if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL))) 996 if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL)))
998 return -ENOMEM; 997 return -ENOMEM;
@@ -1021,10 +1020,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1021 if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 1020 if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
1022 != USB_ENDPOINT_XFER_INT) 1021 != USB_ENDPOINT_XFER_INT)
1023 return -EINVAL; 1022 return -EINVAL;
1024 if (ps->dev->speed == USB_SPEED_HIGH)
1025 interval = 1 << min (15, ep->desc.bInterval - 1);
1026 else
1027 interval = ep->desc.bInterval;
1028 if (uurb->buffer_length > MAX_USBFS_BUFFER_SIZE) 1023 if (uurb->buffer_length > MAX_USBFS_BUFFER_SIZE)
1029 return -EINVAL; 1024 return -EINVAL;
1030 if (!access_ok((uurb->endpoint & USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb->buffer, uurb->buffer_length)) 1025 if (!access_ok((uurb->endpoint & USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb->buffer, uurb->buffer_length))
@@ -1053,7 +1048,11 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1053 as->urb->setup_packet = (unsigned char*)dr; 1048 as->urb->setup_packet = (unsigned char*)dr;
1054 as->urb->start_frame = uurb->start_frame; 1049 as->urb->start_frame = uurb->start_frame;
1055 as->urb->number_of_packets = uurb->number_of_packets; 1050 as->urb->number_of_packets = uurb->number_of_packets;
1056 as->urb->interval = interval; 1051 if (uurb->type == USBDEVFS_URB_TYPE_ISO ||
1052 ps->dev->speed == USB_SPEED_HIGH)
1053 as->urb->interval = 1 << min(15, ep->desc.bInterval - 1);
1054 else
1055 as->urb->interval = ep->desc.bInterval;
1057 as->urb->context = as; 1056 as->urb->context = as;
1058 as->urb->complete = async_completed; 1057 as->urb->complete = async_completed;
1059 for (totlen = u = 0; u < uurb->number_of_packets; u++) { 1058 for (totlen = u = 0; u < uurb->number_of_packets; u++) {
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 2f17468b5c1e..217a3d6d0a06 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -221,10 +221,15 @@ int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
221 221
222 if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 222 if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
223 USB_ENDPOINT_XFER_INT) { 223 USB_ENDPOINT_XFER_INT) {
224 int interval;
225
226 if (usb_dev->speed == USB_SPEED_HIGH)
227 interval = 1 << min(15, ep->desc.bInterval - 1);
228 else
229 interval = ep->desc.bInterval;
224 pipe = (pipe & ~(3 << 30)) | (PIPE_INTERRUPT << 30); 230 pipe = (pipe & ~(3 << 30)) | (PIPE_INTERRUPT << 30);
225 usb_fill_int_urb(urb, usb_dev, pipe, data, len, 231 usb_fill_int_urb(urb, usb_dev, pipe, data, len,
226 usb_api_blocking_completion, NULL, 232 usb_api_blocking_completion, NULL, interval);
227 ep->desc.bInterval);
228 } else 233 } else
229 usb_fill_bulk_urb(urb, usb_dev, pipe, data, len, 234 usb_fill_bulk_urb(urb, usb_dev, pipe, data, len,
230 usb_api_blocking_completion, NULL); 235 usb_api_blocking_completion, NULL);