diff options
author | hselasky <hselasky@FreeBSD.org> | 2011-11-19 11:17:27 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2011-11-19 11:17:27 +0000 |
commit | 1b8ad7ed8ef38e1a06f631089cb1b7ab758fc406 (patch) | |
tree | 857ccda22917502e79fea61b91da7a1a2f54d359 /sys/dev/usb/usb_util.c | |
parent | 3bcdb8772aed66918259718d05cb24d56914ab89 (diff) | |
download | FreeBSD-src-1b8ad7ed8ef38e1a06f631089cb1b7ab758fc406.zip FreeBSD-src-1b8ad7ed8ef38e1a06f631089cb1b7ab758fc406.tar.gz |
Simplify the usb_pause_mtx() function by factoring out the generic parts
to the kernel's pause() function. The pause() function can now be used
when cold != 0. Also assert that the timeout in system ticks must be
positive.
Suggested by: Bruce Evans
MFC after: 1 week
Diffstat (limited to 'sys/dev/usb/usb_util.c')
-rw-r--r-- | sys/dev/usb/usb_util.c | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/sys/dev/usb/usb_util.c b/sys/dev/usb/usb_util.c index a9b1d6f..4fe79c5 100644 --- a/sys/dev/usb/usb_util.c +++ b/sys/dev/usb/usb_util.c @@ -115,33 +115,21 @@ device_set_usb_desc(device_t dev) * * This function will delay the code by the passed number of system * ticks. The passed mutex "mtx" will be dropped while waiting, if - * "mtx" is not NULL. + * "mtx" is different from NULL. *------------------------------------------------------------------------*/ void -usb_pause_mtx(struct mtx *mtx, int _ticks) +usb_pause_mtx(struct mtx *mtx, int timo) { if (mtx != NULL) mtx_unlock(mtx); - if (cold) { - /* convert to milliseconds */ - _ticks = (_ticks * 1000) / hz; - /* convert to microseconds, rounded up */ - _ticks = (_ticks + 1) * 1000; - DELAY(_ticks); + /* + * Add one tick to the timeout so that we don't return too + * early! Note that pause() will assert that the passed + * timeout is positive and non-zero! + */ + pause("USBWAIT", timo + 1); - } else { - - /* - * Add one to the number of ticks so that we don't return - * too early! - */ - _ticks++; - - if (pause("USBWAIT", _ticks)) { - /* ignore */ - } - } if (mtx != NULL) mtx_lock(mtx); } |