mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-21 18:27:22 +00:00
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
This commit is contained in:
parent
40b9b2995f
commit
ccb576a83c
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue