summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/controller
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-04-26 15:03:15 +0000
committerpfg <pfg@FreeBSD.org>2016-04-26 15:03:15 +0000
commit96555d383362c30d444593333d60a4588416db62 (patch)
treedf1bb710ebf946f1a7c1b38464ef836fddfee71c /sys/dev/usb/controller
parent8f98488963488a3a64220dd06361d0286c15cdb4 (diff)
downloadFreeBSD-src-96555d383362c30d444593333d60a4588416db62.zip
FreeBSD-src-96555d383362c30d444593333d60a4588416db62.tar.gz
sys/dev: extend use of the howmany() macro when available.
We have a howmany() macro in the <sys/param.h> header that is convenient to re-use as it makes things easier to read.
Diffstat (limited to 'sys/dev/usb/controller')
-rw-r--r--sys/dev/usb/controller/ehci.c3
-rw-r--r--sys/dev/usb/controller/ohci.c2
-rw-r--r--sys/dev/usb/controller/xhci.c9
3 files changed, 6 insertions, 8 deletions
diff --git a/sys/dev/usb/controller/ehci.c b/sys/dev/usb/controller/ehci.c
index eb4ccb9..7f9547c 100644
--- a/sys/dev/usb/controller/ehci.c
+++ b/sys/dev/usb/controller/ehci.c
@@ -1659,8 +1659,7 @@ restart:
/* update data toggle */
- if (((average + temp->max_frame_size - 1) /
- temp->max_frame_size) & 1) {
+ if (howmany(average, temp->max_frame_size) & 1) {
temp->qtd_status ^=
htohc32(temp->sc, EHCI_QTD_TOGGLE_MASK);
}
diff --git a/sys/dev/usb/controller/ohci.c b/sys/dev/usb/controller/ohci.c
index 206c753..93785c0 100644
--- a/sys/dev/usb/controller/ohci.c
+++ b/sys/dev/usb/controller/ohci.c
@@ -2437,7 +2437,7 @@ ohci_xfer_setup(struct usb_setup_params *parm)
usbd_transfer_setup_sub(parm);
nitd = ((xfer->max_data_length / OHCI_PAGE_SIZE) +
- ((xfer->nframes + OHCI_ITD_NOFFSET - 1) / OHCI_ITD_NOFFSET) +
+ howmany(xfer->nframes, OHCI_ITD_NOFFSET) +
1 /* EXTRA */ );
ntd = 0;
nqh = 1;
diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c
index 0739e28..6c58e6d 100644
--- a/sys/dev/usb/controller/xhci.c
+++ b/sys/dev/usb/controller/xhci.c
@@ -1830,8 +1830,8 @@ restart:
}
/* set up npkt */
- npkt = (len_old - npkt_off + temp->max_packet_size - 1) /
- temp->max_packet_size;
+ npkt = howmany(len_old - npkt_off,
+ temp->max_packet_size);
if (npkt == 0)
npkt = 1;
@@ -2185,10 +2185,9 @@ xhci_setup_generic_chain(struct usb_xfer *xfer)
temp.len = xfer->max_frame_size;
/* compute TD packet count */
- tdpc = (temp.len + xfer->max_packet_size - 1) /
- xfer->max_packet_size;
+ tdpc = howmany(temp.len, xfer->max_packet_size);
- temp.tbc = ((tdpc + mult - 1) / mult) - 1;
+ temp.tbc = howmany(tdpc, mult) - 1;
temp.tlbpc = (tdpc % mult);
if (temp.tlbpc == 0)
OpenPOWER on IntegriCloud