Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci virtio(4): Use howmany from sys/param.h instead ...



details:   https://anonhg.NetBSD.org/src/rev/33299f0a138f
branches:  trunk
changeset: 371888:33299f0a138f
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Oct 15 19:55:37 2022 +0000

description:
virtio(4): Use howmany from sys/param.h instead of open-coding it.

howmany will divide by VIRTIO_PAGE_SIZE instead of doing &
~(VIRTIO_PAGE_SIZE - 1), but it's a constant 4096 so this should make
no difference in the compiled output except possibly at -O0.

No functional change intended.

diffstat:

 sys/dev/pci/virtio.c |  7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diffs (28 lines):

diff -r 817e96e8fe56 -r 33299f0a138f sys/dev/pci/virtio.c
--- a/sys/dev/pci/virtio.c      Sat Oct 15 19:53:27 2022 +0000
+++ b/sys/dev/pci/virtio.c      Sat Oct 15 19:55:37 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: virtio.c,v 1.59 2022/10/15 19:53:27 riastradh Exp $    */
+/*     $NetBSD: virtio.c,v 1.60 2022/10/15 19:55:37 riastradh Exp $    */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.59 2022/10/15 19:53:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.60 2022/10/15 19:55:37 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -760,8 +760,7 @@
 {
        int vq_size, allocsize1, allocsize2, allocsize3, allocsize = 0;
        int rsegs, r, hdrlen;
-#define VIRTQUEUE_ALIGN(n)     (((n) + (VIRTIO_PAGE_SIZE - 1)) &       \
-                                   ~(VIRTIO_PAGE_SIZE - 1))
+#define VIRTQUEUE_ALIGN(n)     howmany(n, VIRTIO_PAGE_SIZE)
 
        /* Make sure callers allocate vqs in order */
        KASSERT(sc->sc_nvqs == index);



Home | Main Index | Thread Index | Old Index