Commit 498f78e6 authored by Dan Streetman's avatar Dan Streetman Committed by Linus Torvalds

[PATCH] USB: fix in usb_calc_bus_time

This patch does the same swap, i.e. use the ISO macro if (isoc).
Additionally, it fixes the return value - the usb_calc_bus_time function
returns the time in nanoseconds (I didn't notice that before) while the
HS_USECS and HS_USECS_ISO are microseconds.  This fixes the function to
return nanoseconds always, and adjusts ehci-q.c (the only high-speed
caller of the function) to wrap the call in NS_TO_US().
Signed-off-by: default avatarDan Streetman <ddstreet@ieee.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 6b216df8
...@@ -939,9 +939,9 @@ long usb_calc_bus_time (int speed, int is_input, int isoc, int bytecount) ...@@ -939,9 +939,9 @@ long usb_calc_bus_time (int speed, int is_input, int isoc, int bytecount)
case USB_SPEED_HIGH: /* ISOC or INTR */ case USB_SPEED_HIGH: /* ISOC or INTR */
// FIXME adjust for input vs output // FIXME adjust for input vs output
if (isoc) if (isoc)
tmp = HS_USECS (bytecount); tmp = HS_NSECS_ISO (bytecount);
else else
tmp = HS_USECS_ISO (bytecount); tmp = HS_NSECS (bytecount);
return tmp; return tmp;
default: default:
pr_debug ("%s: bogus device speed!\n", usbcore_name); pr_debug ("%s: bogus device speed!\n", usbcore_name);
......
...@@ -334,17 +334,19 @@ extern void usb_release_bandwidth (struct usb_device *dev, struct urb *urb, ...@@ -334,17 +334,19 @@ extern void usb_release_bandwidth (struct usb_device *dev, struct urb *urb,
extern int usb_check_bandwidth (struct usb_device *dev, struct urb *urb); extern int usb_check_bandwidth (struct usb_device *dev, struct urb *urb);
/* /*
* Ceiling microseconds (typical) for that many bytes at high speed * Ceiling [nano/micro]seconds (typical) for that many bytes at high speed
* ISO is a bit less, no ACK ... from USB 2.0 spec, 5.11.3 (and needed * ISO is a bit less, no ACK ... from USB 2.0 spec, 5.11.3 (and needed
* to preallocate bandwidth) * to preallocate bandwidth)
*/ */
#define USB2_HOST_DELAY 5 /* nsec, guess */ #define USB2_HOST_DELAY 5 /* nsec, guess */
#define HS_USECS(bytes) NS_TO_US ( ((55 * 8 * 2083)/1000) \ #define HS_NSECS(bytes) ( ((55 * 8 * 2083)/1000) \
+ ((2083UL * (3167 + BitTime (bytes)))/1000) \ + ((2083UL * (3167 + BitTime (bytes)))/1000) \
+ USB2_HOST_DELAY) + USB2_HOST_DELAY)
#define HS_USECS_ISO(bytes) NS_TO_US ( ((38 * 8 * 2083)/1000) \ #define HS_NSECS_ISO(bytes) ( ((38 * 8 * 2083)/1000) \
+ ((2083UL * (3167 + BitTime (bytes)))/1000) \ + ((2083UL * (3167 + BitTime (bytes)))/1000) \
+ USB2_HOST_DELAY) + USB2_HOST_DELAY)
#define HS_USECS(bytes) NS_TO_US (HS_NSECS(bytes))
#define HS_USECS_ISO(bytes) NS_TO_US (HS_NSECS_ISO(bytes))
extern long usb_calc_bus_time (int speed, int is_input, extern long usb_calc_bus_time (int speed, int is_input,
int isoc, int bytecount); int isoc, int bytecount);
......
...@@ -657,8 +657,8 @@ qh_make ( ...@@ -657,8 +657,8 @@ qh_make (
* For control/bulk requests, the HC or TT handles these. * For control/bulk requests, the HC or TT handles these.
*/ */
if (type == PIPE_INTERRUPT) { if (type == PIPE_INTERRUPT) {
qh->usecs = usb_calc_bus_time (USB_SPEED_HIGH, is_input, 0, qh->usecs = NS_TO_US (usb_calc_bus_time (USB_SPEED_HIGH, is_input, 0,
hb_mult (maxp) * max_packet (maxp)); hb_mult (maxp) * max_packet (maxp)));
qh->start = NO_FRAME; qh->start = NO_FRAME;
if (urb->dev->speed == USB_SPEED_HIGH) { if (urb->dev->speed == USB_SPEED_HIGH) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment