Thu Mar 5 08:30:59 2020 UTC ()
Use howmany.  NFC.


(skrll)
diff -r1.297 -r1.298 src/sys/dev/usb/ohci.c

cvs diff -r1.297 -r1.298 src/sys/dev/usb/ohci.c (expand / switch to context diff)
--- src/sys/dev/usb/ohci.c 2020/03/05 08:12:30 1.297
+++ src/sys/dev/usb/ohci.c 2020/03/05 08:30:58 1.298
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.297 2020/03/05 08:12:30 skrll Exp $	*/
+/*	$NetBSD: ohci.c,v 1.298 2020/03/05 08:30:58 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.297 2020/03/05 08:12:30 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.298 2020/03/05 08:30:58 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -531,7 +531,7 @@
 	KASSERT(length != 0 || (!rd && (flags & USBD_FORCE_SHORT_XFER)));
 
 	size_t nstd = (!rd && (flags & USBD_FORCE_SHORT_XFER)) ? 1 : 0;
-	nstd += ((length + OHCI_PAGE_SIZE - 1) / OHCI_PAGE_SIZE);
+	nstd += howmany(length, OHCI_PAGE_SIZE);
 	ox->ox_stds = kmem_zalloc(sizeof(ohci_soft_td_t *) * nstd,
 	    KM_SLEEP);
 	ox->ox_nstd = nstd;
@@ -3358,8 +3358,7 @@
 	DPRINTFN(1, "xfer %#jx len %jd flags %jd", (uintptr_t)xfer,
 	    xfer->ux_length, xfer->ux_flags, 0);
 
-	const size_t nfsitd =
-	    (xfer->ux_nframes + OHCI_ITD_NOFFSET - 1) / OHCI_ITD_NOFFSET;
+	const size_t nfsitd = howmany(xfer->ux_nframes, OHCI_ITD_NOFFSET);
 	const size_t nbsitd = xfer->ux_bufsize / OHCI_PAGE_SIZE;
 	const size_t nsitd = MAX(nfsitd, nbsitd) + 1;