git: ccb576a83cc9 - main - virtio: use bool for boolean functions
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 18 Sep 2023 20:04:43 UTC
The branch main has been updated by cognet: URL: https://cgit.FreeBSD.org/src/commit/?id=ccb576a83cc959070de59454d4dcd6395f7ae91a commit ccb576a83cc959070de59454d4dcd6395f7ae91a Author: Mina Galić <freebsd@igalic.co> AuthorDate: 2023-09-18 20:02:37 +0000 Commit: Olivier Houchard <cognet@FreeBSD.org> CommitDate: 2023-09-18 20:03:26 +0000 virtio: use bool for boolean functions Summary: these static functions: - vq_ring_use_indirect and these public functions: - virtio_bus_is_modern - virtio_with_feature - virtqueue_empty - virtqueue_full exclusively return a boolean value. Change their return values to bool. Sponsored by: The FreeBSD Foundation Reviewers: bryanv Reviewed By: bryanv Subscribers: cognet, imp Differential Revision: https://reviews.freebsd.org/D41848 --- sys/dev/virtio/mmio/virtio_mmio.c | 4 ++-- sys/dev/virtio/pci/virtio_pci.c | 2 +- sys/dev/virtio/pci/virtio_pci.h | 2 +- sys/dev/virtio/pci/virtio_pci_legacy.c | 4 ++-- sys/dev/virtio/pci/virtio_pci_modern.c | 4 ++-- sys/dev/virtio/virtio.c | 4 ++-- sys/dev/virtio/virtio.h | 4 ++-- sys/dev/virtio/virtio_bus_if.m | 2 +- sys/dev/virtio/virtqueue.c | 16 ++++++++-------- sys/dev/virtio/virtqueue.h | 4 ++-- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/sys/dev/virtio/mmio/virtio_mmio.c b/sys/dev/virtio/mmio/virtio_mmio.c index 36c6a255c385..6059ef76eceb 100644 --- a/sys/dev/virtio/mmio/virtio_mmio.c +++ b/sys/dev/virtio/mmio/virtio_mmio.c @@ -73,7 +73,7 @@ static int vtmmio_read_ivar(device_t, device_t, int, uintptr_t *); static int vtmmio_write_ivar(device_t, device_t, int, uintptr_t); static uint64_t vtmmio_negotiate_features(device_t, uint64_t); static int vtmmio_finalize_features(device_t); -static int vtmmio_with_feature(device_t, uint64_t); +static bool vtmmio_with_feature(device_t, uint64_t); static void vtmmio_set_virtqueue(struct vtmmio_softc *sc, struct virtqueue *vq, uint32_t size); static int vtmmio_alloc_virtqueues(device_t, int, int, @@ -489,7 +489,7 @@ vtmmio_finalize_features(device_t dev) return (0); } -static int +static bool vtmmio_with_feature(device_t dev, uint64_t feature) { struct vtmmio_softc *sc; diff --git a/sys/dev/virtio/pci/virtio_pci.c b/sys/dev/virtio/pci/virtio_pci.c index 4849affae58c..1470dc83949c 100644 --- a/sys/dev/virtio/pci/virtio_pci.c +++ b/sys/dev/virtio/pci/virtio_pci.c @@ -267,7 +267,7 @@ vtpci_negotiate_features(struct vtpci_common *cn, return (features); } -int +bool vtpci_with_feature(struct vtpci_common *cn, uint64_t feature) { return ((cn->vtpci_features & feature) != 0); diff --git a/sys/dev/virtio/pci/virtio_pci.h b/sys/dev/virtio/pci/virtio_pci.h index 2d123ebdbb53..401cba25bbf4 100644 --- a/sys/dev/virtio/pci/virtio_pci.h +++ b/sys/dev/virtio/pci/virtio_pci.h @@ -117,7 +117,7 @@ int vtpci_reinit(struct vtpci_common *cn); uint64_t vtpci_negotiate_features(struct vtpci_common *cn, uint64_t child_features, uint64_t host_features); -int vtpci_with_feature(struct vtpci_common *cn, uint64_t feature); +bool vtpci_with_feature(struct vtpci_common *cn, uint64_t feature); int vtpci_read_ivar(struct vtpci_common *cn, int index, uintptr_t *result); int vtpci_write_ivar(struct vtpci_common *cn, int index, uintptr_t value); diff --git a/sys/dev/virtio/pci/virtio_pci_legacy.c b/sys/dev/virtio/pci/virtio_pci_legacy.c index 88a8323bdd6f..72d637fb0f55 100644 --- a/sys/dev/virtio/pci/virtio_pci_legacy.c +++ b/sys/dev/virtio/pci/virtio_pci_legacy.c @@ -86,7 +86,7 @@ static int vtpci_legacy_register_vq_msix(device_t, int idx, struct vtpci_interrupt *); static uint64_t vtpci_legacy_negotiate_features(device_t, uint64_t); -static int vtpci_legacy_with_feature(device_t, uint64_t); +static bool vtpci_legacy_with_feature(device_t, uint64_t); static int vtpci_legacy_alloc_virtqueues(device_t, int, int, struct vq_alloc_info *); static int vtpci_legacy_setup_interrupts(device_t, enum intr_type); @@ -379,7 +379,7 @@ vtpci_legacy_negotiate_features(device_t dev, uint64_t child_features) return (features); } -static int +static bool vtpci_legacy_with_feature(device_t dev, uint64_t feature) { struct vtpci_legacy_softc *sc; diff --git a/sys/dev/virtio/pci/virtio_pci_modern.c b/sys/dev/virtio/pci/virtio_pci_modern.c index 2fa921dd9141..84d9511798e0 100644 --- a/sys/dev/virtio/pci/virtio_pci_modern.c +++ b/sys/dev/virtio/pci/virtio_pci_modern.c @@ -111,7 +111,7 @@ static int vtpci_modern_register_vq_msix(device_t, int idx, static uint64_t vtpci_modern_negotiate_features(device_t, uint64_t); static int vtpci_modern_finalize_features(device_t); -static int vtpci_modern_with_feature(device_t, uint64_t); +static bool vtpci_modern_with_feature(device_t, uint64_t); static int vtpci_modern_alloc_virtqueues(device_t, int, int, struct vq_alloc_info *); static int vtpci_modern_setup_interrupts(device_t, enum intr_type); @@ -469,7 +469,7 @@ vtpci_modern_finalize_features(device_t dev) return (0); } -static int +static bool vtpci_modern_with_feature(device_t dev, uint64_t feature) { struct vtpci_modern_softc *sc; diff --git a/sys/dev/virtio/virtio.c b/sys/dev/virtio/virtio.c index 0637e0299333..45a657542e28 100644 --- a/sys/dev/virtio/virtio.c +++ b/sys/dev/virtio/virtio.c @@ -200,7 +200,7 @@ virtio_filter_transport_features(uint64_t features) return (features & mask); } -int +bool virtio_bus_is_modern(device_t dev) { uintptr_t modern; @@ -275,7 +275,7 @@ virtio_setup_intr(device_t dev, enum intr_type type) return (VIRTIO_BUS_SETUP_INTR(device_get_parent(dev), type)); } -int +bool virtio_with_feature(device_t dev, uint64_t feature) { diff --git a/sys/dev/virtio/virtio.h b/sys/dev/virtio/virtio.h index b3ef98cbd167..96ebaf653428 100644 --- a/sys/dev/virtio/virtio.h +++ b/sys/dev/virtio/virtio.h @@ -92,7 +92,7 @@ void virtio_describe(device_t dev, const char *msg, int virtio_describe_sbuf(struct sbuf *sb, uint64_t features, struct virtio_feature_desc *desc); uint64_t virtio_filter_transport_features(uint64_t features); -int virtio_bus_is_modern(device_t dev); +bool virtio_bus_is_modern(device_t dev); void virtio_read_device_config_array(device_t dev, bus_size_t offset, void *dst, int size, int count); @@ -106,7 +106,7 @@ int virtio_finalize_features(device_t dev); int virtio_alloc_virtqueues(device_t dev, int flags, int nvqs, struct vq_alloc_info *info); int virtio_setup_intr(device_t dev, enum intr_type type); -int virtio_with_feature(device_t dev, uint64_t feature); +bool virtio_with_feature(device_t dev, uint64_t feature); void virtio_stop(device_t dev); int virtio_config_generation(device_t dev); int virtio_reinit(device_t dev, uint64_t features); diff --git a/sys/dev/virtio/virtio_bus_if.m b/sys/dev/virtio/virtio_bus_if.m index 8d7b6db7d488..848c6ac05b62 100644 --- a/sys/dev/virtio/virtio_bus_if.m +++ b/sys/dev/virtio/virtio_bus_if.m @@ -56,7 +56,7 @@ METHOD int finalize_features { device_t dev; } DEFAULT virtio_bus_default_finalize_features; -METHOD int with_feature { +METHOD bool with_feature { device_t dev; uint64_t feature; }; diff --git a/sys/dev/virtio/virtqueue.c b/sys/dev/virtio/virtqueue.c index cc7b0a8ed064..53e7de587195 100644 --- a/sys/dev/virtio/virtqueue.c +++ b/sys/dev/virtio/virtqueue.c @@ -128,7 +128,7 @@ static void vq_ring_init(struct virtqueue *); static void vq_ring_update_avail(struct virtqueue *, uint16_t); static uint16_t vq_ring_enqueue_segments(struct virtqueue *, struct vring_desc *, uint16_t, struct sglist *, int, int); -static int vq_ring_use_indirect(struct virtqueue *, int); +static bool vq_ring_use_indirect(struct virtqueue *, int); static void vq_ring_enqueue_indirect(struct virtqueue *, void *, struct sglist *, int, int); static int vq_ring_enable_interrupt(struct virtqueue *, uint16_t); @@ -418,14 +418,14 @@ virtqueue_nfree(struct virtqueue *vq) return (vq->vq_free_cnt); } -int +bool virtqueue_empty(struct virtqueue *vq) { return (vq->vq_nentries == vq->vq_free_cnt); } -int +bool virtqueue_full(struct virtqueue *vq) { @@ -733,20 +733,20 @@ vq_ring_enqueue_segments(struct virtqueue *vq, struct vring_desc *desc, return (idx); } -static int +static bool vq_ring_use_indirect(struct virtqueue *vq, int needed) { if ((vq->vq_flags & VIRTQUEUE_FLAG_INDIRECT) == 0) - return (0); + return (false); if (vq->vq_max_indirect_size < needed) - return (0); + return (false); if (needed < 2) - return (0); + return (false); - return (1); + return (true); } static void diff --git a/sys/dev/virtio/virtqueue.h b/sys/dev/virtio/virtqueue.h index a98dc4728259..b5c60b0ce951 100644 --- a/sys/dev/virtio/virtqueue.h +++ b/sys/dev/virtio/virtqueue.h @@ -85,8 +85,8 @@ vm_paddr_t virtqueue_avail_paddr(struct virtqueue *vq); vm_paddr_t virtqueue_used_paddr(struct virtqueue *vq); uint16_t virtqueue_index(struct virtqueue *vq); -int virtqueue_full(struct virtqueue *vq); -int virtqueue_empty(struct virtqueue *vq); +bool virtqueue_full(struct virtqueue *vq); +bool virtqueue_empty(struct virtqueue *vq); int virtqueue_size(struct virtqueue *vq); int virtqueue_nfree(struct virtqueue *vq); int virtqueue_nused(struct virtqueue *vq);