Skip to content

Commit

Permalink
USB: NS_TO_US should round up
Browse files Browse the repository at this point in the history
Host controller drivers use the NS_TO_US macro to convert transaction
times, which are computed in nanoseconds, to microseconds for
scheduling.  Periodic scheduling requires worst-case estimates, but
the macro does its conversion using round-to-nearest.  This patch
changes it to use round-up, giving a correct worst-case value.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Oct 11, 2013
1 parent 6ec4147 commit 63fb3a2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions include/linux/usb/hcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,8 @@ extern void usb_ep0_reinit(struct usb_device *);
* of (7/6 * 8 * bytecount) = 9.33 * bytecount */
/* bytecount = data payload byte count */

#define NS_TO_US(ns) ((ns + 500L) / 1000L)
/* convert & round nanoseconds to microseconds */

#define NS_TO_US(ns) DIV_ROUND_UP(ns, 1000L)
/* convert nanoseconds to microseconds, rounding up */

/*
* Full/low speed bandwidth allocation constants/support.
Expand Down

0 comments on commit 63fb3a2

Please sign in to comment.