Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb Use howmany. NFC.



details:   https://anonhg.NetBSD.org/src/rev/4064ba5d4cea
branches:  trunk
changeset: 1007944:4064ba5d4cea
user:      skrll <skrll%NetBSD.org@localhost>
date:      Thu Mar 05 08:30:58 2020 +0000

description:
Use howmany.  NFC.

diffstat:

 sys/dev/usb/ehci.c |  12 ++++++------
 sys/dev/usb/ohci.c |   9 ++++-----
 2 files changed, 10 insertions(+), 11 deletions(-)

diffs (91 lines):

diff -r 8ba3b2b7ba86 -r 4064ba5d4cea sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c        Thu Mar 05 08:12:30 2020 +0000
+++ b/sys/dev/usb/ehci.c        Thu Mar 05 08:30:58 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ehci.c,v 1.274 2020/02/21 12:41:29 skrll Exp $ */
+/*     $NetBSD: ehci.c,v 1.275 2020/03/05 08:35:16 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.274 2020/02/21 12:41:29 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.275 2020/03/05 08:35:16 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -2913,7 +2913,7 @@
        KASSERT(alen != 0 || (!rd && (flags & USBD_FORCE_SHORT_XFER)));
 
        size_t nsqtd = (!rd && (flags & USBD_FORCE_SHORT_XFER)) ? 1 : 0;
-       nsqtd += ((alen + EHCI_PAGE_SIZE - 1) / EHCI_PAGE_SIZE);
+       nsqtd += howmany(alen, EHCI_PAGE_SIZE);
        exfer->ex_sqtds = kmem_zalloc(sizeof(ehci_soft_qtd_t *) * nsqtd,
            KM_SLEEP);
        exfer->ex_nsqtd = nsqtd;
@@ -3061,7 +3061,7 @@
 
                ehci_append_sqtd(sqtd, prev);
 
-               if (((curlen + mps - 1) / mps) & 1) {
+               if (howmany(curlen, mps) & 1) {
                        tog ^= 1;
                }
 
@@ -4582,7 +4582,7 @@
        }
 
        ufrperframe = uimax(1, USB_UFRAMES_PER_FRAME / (1 << (i - 1)));
-       frames = (xfer->ux_nframes + (ufrperframe - 1)) / ufrperframe;
+       frames = howmany(xfer->ux_nframes, ufrperframe);
 
        for (i = 0, prev = NULL; i < frames; i++, prev = itd) {
                itd = ehci_alloc_itd(sc);
@@ -4717,7 +4717,7 @@
        }
 
        ufrperframe = uimax(1, USB_UFRAMES_PER_FRAME / (1 << (i - 1)));
-       frames = (xfer->ux_nframes + (ufrperframe - 1)) / ufrperframe;
+       frames = howmany(xfer->ux_nframes, ufrperframe);
        uframes = USB_UFRAMES_PER_FRAME / ufrperframe;
 
        if (frames == 0) {
diff -r 8ba3b2b7ba86 -r 4064ba5d4cea sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c        Thu Mar 05 08:12:30 2020 +0000
+++ b/sys/dev/usb/ohci.c        Thu Mar 05 08:30:58 2020 +0000
@@ -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;
 



Home | Main Index | Thread Index | Old Index