From 3b609d41c065e2248d2886586c7845d2ca3c73c6 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Mon, 18 Mar 2024 11:53:45 -0500 Subject: [PATCH] lib: Add and use IS_ENABLED() macro Checks if this symbol is defined and set to equal 1. Used to make it more clear that a preprocessor level check is intended. Signed-off-by: Andrew Davis --- lib/include/openamp/virtio.h | 2 ++ lib/remoteproc/remoteproc.c | 4 +-- lib/remoteproc/remoteproc_virtio.c | 14 ++++---- lib/rpmsg/rpmsg_virtio.c | 52 +++++++++++++++--------------- lib/virtio/virtio.c | 2 +- lib/virtio/virtqueue.c | 30 ++++++++--------- 6 files changed, 53 insertions(+), 51 deletions(-) diff --git a/lib/include/openamp/virtio.h b/lib/include/openamp/virtio.h index 980b89f03..f3122df14 100644 --- a/lib/include/openamp/virtio.h +++ b/lib/include/openamp/virtio.h @@ -101,6 +101,8 @@ __deprecated static inline int deprecated_virtio_dev_slave(void) #warning "VIRTIO_DEVICE_ONLY is deprecated, please use VIRTIO_DRIVER_SUPPORT=0" #endif +#define IS_ENABLED(option) (option == 1) + /** @brief Virtio device identifier. */ struct virtio_device_id { /** Virtio subsystem device ID. */ diff --git a/lib/remoteproc/remoteproc.c b/lib/remoteproc/remoteproc.c index 2a4273ef6..d0bd7ed0e 100644 --- a/lib/remoteproc/remoteproc.c +++ b/lib/remoteproc/remoteproc.c @@ -916,12 +916,12 @@ remoteproc_create_virtio(struct remoteproc *rproc, unsigned int num_vrings, i; struct metal_list *node; -#if !VIRTIO_DRIVER_SUPPORT +#if !IS_ENABLED(VIRTIO_DRIVER_SUPPORT) if (role == VIRTIO_DEV_DRIVER) return NULL; #endif -#if !VIRTIO_DEVICE_SUPPORT +#if !IS_ENABLED(VIRTIO_DEVICE_SUPPORT) if (role == VIRTIO_DEV_DEVICE) return NULL; #endif diff --git a/lib/remoteproc/remoteproc_virtio.c b/lib/remoteproc/remoteproc_virtio.c index 7d529d5ca..b81056811 100644 --- a/lib/remoteproc/remoteproc_virtio.c +++ b/lib/remoteproc/remoteproc_virtio.c @@ -55,7 +55,7 @@ static int rproc_virtio_create_virtqueue(struct virtio_device *vdev, if (!vring_info->vq) return ERROR_NO_MEM; - if (VIRTIO_DRIVER_SUPPORT && vdev->role == VIRTIO_DEV_DRIVER) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && vdev->role == VIRTIO_DEV_DRIVER) { size_t offset = metal_io_virt_to_offset(vring_info->io, vring_alloc->vaddr); size_t size = vring_size(vring_alloc->num_descs, vring_alloc->align); @@ -128,7 +128,7 @@ static unsigned char rproc_virtio_get_status(struct virtio_device *vdev) return status; } -#if VIRTIO_DRIVER_SUPPORT +#if IS_ENABLED(VIRTIO_DRIVER_SUPPORT) static void rproc_virtio_set_status(struct virtio_device *vdev, unsigned char status) { @@ -183,7 +183,7 @@ static uint32_t rproc_virtio_get_features(struct virtio_device *vdev) return dfeatures & gfeatures; } -#if VIRTIO_DRIVER_SUPPORT +#if IS_ENABLED(VIRTIO_DRIVER_SUPPORT) static void rproc_virtio_set_features(struct virtio_device *vdev, uint32_t features) { @@ -233,7 +233,7 @@ static void rproc_virtio_read_config(struct virtio_device *vdev, } } -#if VIRTIO_DRIVER_SUPPORT +#if IS_ENABLED(VIRTIO_DRIVER_SUPPORT) static void rproc_virtio_write_config(struct virtio_device *vdev, uint32_t offset, void *src, int length) { @@ -271,7 +271,7 @@ static const struct virtio_dispatch remoteproc_virtio_dispatch_funcs = { .get_features = rproc_virtio_get_features, .read_config = rproc_virtio_read_config, .notify = rproc_virtio_virtqueue_notify, -#if VIRTIO_DRIVER_SUPPORT +#if IS_ENABLED(VIRTIO_DRIVER_SUPPORT) /* * We suppose here that the vdev is in a shared memory so that can * be access only by one core: the host. In this case salve core has @@ -326,7 +326,7 @@ rproc_virtio_create_vdev(unsigned int role, unsigned int notifyid, vdev->vrings_num = num_vrings; vdev->func = &remoteproc_virtio_dispatch_funcs; -#if VIRTIO_DRIVER_SUPPORT +#if IS_ENABLED(VIRTIO_DRIVER_SUPPORT) if (role == VIRTIO_DEV_DRIVER) { uint32_t dfeatures = rproc_virtio_get_dfeatures(vdev); /* Assume the virtio driver support all remote features */ @@ -405,7 +405,7 @@ void rproc_virtio_wait_remote_ready(struct virtio_device *vdev) * remote action, we can return. Behavior should be updated * in future if a remote status is added. */ - if (VIRTIO_DRIVER_SUPPORT && vdev->role == VIRTIO_DEV_DRIVER) + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && vdev->role == VIRTIO_DEV_DRIVER) return; while (1) { diff --git a/lib/rpmsg/rpmsg_virtio.c b/lib/rpmsg/rpmsg_virtio.c index b3993c580..8f3d2399a 100644 --- a/lib/rpmsg/rpmsg_virtio.c +++ b/lib/rpmsg/rpmsg_virtio.c @@ -58,7 +58,7 @@ struct vbuff_reclaimer_t { }; /* Default configuration */ -#if VIRTIO_DRIVER_SUPPORT +#if IS_ENABLED(VIRTIO_DRIVER_SUPPORT) #define RPMSG_VIRTIO_DEFAULT_CONFIG \ (&(const struct rpmsg_virtio_config) { \ .h2r_buf_size = RPMSG_BUFFER_SIZE, \ @@ -69,7 +69,7 @@ struct vbuff_reclaimer_t { #define RPMSG_VIRTIO_DEFAULT_CONFIG NULL #endif -#if VIRTIO_DRIVER_SUPPORT +#if IS_ENABLED(VIRTIO_DRIVER_SUPPORT) metal_weak void * rpmsg_virtio_shm_pool_get_buffer(struct rpmsg_virtio_shm_pool *shpool, size_t size) @@ -83,7 +83,7 @@ rpmsg_virtio_shm_pool_get_buffer(struct rpmsg_virtio_shm_pool *shpool, return buffer; } -#endif /*VIRTIO_DRIVER_SUPPORT*/ +#endif void rpmsg_virtio_init_shm_pool(struct rpmsg_virtio_shm_pool *shpool, void *shb, size_t size) @@ -114,7 +114,7 @@ static void rpmsg_virtio_return_buffer(struct rpmsg_virtio_device *rvdev, BUFFER_INVALIDATE(buffer, len); - if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { struct virtqueue_buf vqbuf; (void)idx; @@ -125,7 +125,7 @@ static void rpmsg_virtio_return_buffer(struct rpmsg_virtio_device *rvdev, RPMSG_ASSERT(ret == VQUEUE_SUCCESS, "add buffer failed\r\n"); } - if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) { + if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { (void)buffer; ret = virtqueue_add_consumed_buffer(rvdev->rvq, idx, len); RPMSG_ASSERT(ret == VQUEUE_SUCCESS, "add consumed buffer failed\r\n"); @@ -152,7 +152,7 @@ static int rpmsg_virtio_enqueue_buffer(struct rpmsg_virtio_device *rvdev, BUFFER_FLUSH(buffer, len); - if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { struct virtqueue_buf vqbuf; (void)idx; @@ -162,7 +162,7 @@ static int rpmsg_virtio_enqueue_buffer(struct rpmsg_virtio_device *rvdev, return virtqueue_add_buffer(rvdev->svq, &vqbuf, 1, 0, buffer); } - if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) { + if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { (void)buffer; return virtqueue_add_consumed_buffer(rvdev->svq, idx, len); } @@ -197,11 +197,11 @@ static void *rpmsg_virtio_get_tx_buffer(struct rpmsg_virtio_device *rvdev, data = r_desc; *idx = r_desc->idx; - if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) *len = rvdev->config.h2r_buf_size; - if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) + if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) *len = virtqueue_get_buffer_length(rvdev->svq, *idx); - } else if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) { + } else if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { data = virtqueue_get_buffer(rvdev->svq, len, idx); if (!data && rvdev->svq->vq_free_cnt) { data = rpmsg_virtio_shm_pool_get_buffer(rvdev->shpool, @@ -209,7 +209,7 @@ static void *rpmsg_virtio_get_tx_buffer(struct rpmsg_virtio_device *rvdev, *len = rvdev->config.h2r_buf_size; *idx = 0; } - } else if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) { + } else if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { data = virtqueue_get_available_buffer(rvdev->svq, idx, len); } @@ -233,11 +233,11 @@ static void *rpmsg_virtio_get_rx_buffer(struct rpmsg_virtio_device *rvdev, unsigned int role = rpmsg_virtio_get_role(rvdev); void *data = NULL; - if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { data = virtqueue_get_buffer(rvdev->rvq, len, idx); } - if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) { + if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { data = virtqueue_get_available_buffer(rvdev->rvq, idx, len); } @@ -452,7 +452,7 @@ static int rpmsg_virtio_send_offchannel_nocopy(struct rpmsg_device *rdev, metal_mutex_acquire(&rdev->lock); - if (VIRTIO_DRIVER_SUPPORT && rpmsg_virtio_get_role(rvdev) == RPMSG_HOST) + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && rpmsg_virtio_get_role(rvdev) == RPMSG_HOST) buff_len = rvdev->config.h2r_buf_size; else buff_len = virtqueue_get_buffer_length(rvdev->svq, idx); @@ -712,7 +712,7 @@ int rpmsg_virtio_get_tx_buffer_size(struct rpmsg_device *rdev) rvdev = (struct rpmsg_virtio_device *)rdev; role = rpmsg_virtio_get_role(rvdev); - if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { /* * If device role is host then buffers are provided by us, * so just provide the macro. @@ -720,7 +720,7 @@ int rpmsg_virtio_get_tx_buffer_size(struct rpmsg_device *rdev) size = rvdev->config.h2r_buf_size - sizeof(struct rpmsg_hdr); } - if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) { + if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { /* * If other core is host then buffers are provided by it, * so get the buffer size from the virtqueue. @@ -750,7 +750,7 @@ int rpmsg_virtio_get_rx_buffer_size(struct rpmsg_device *rdev) rvdev = (struct rpmsg_virtio_device *)rdev; role = rpmsg_virtio_get_role(rvdev); - if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { /* * If device role is host then buffers are provided by us, * so just provide the macro. @@ -758,7 +758,7 @@ int rpmsg_virtio_get_rx_buffer_size(struct rpmsg_device *rdev) size = rvdev->config.r2h_buf_size - sizeof(struct rpmsg_hdr); } - if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) { + if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { /* * If other core is host then buffers are provided by it, * so get the buffer size from the virtqueue. @@ -816,7 +816,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, rdev->ops.release_tx_buffer = rpmsg_virtio_release_tx_buffer; role = rpmsg_virtio_get_role(rvdev); - if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { /* * The virtio configuration contains only options applicable to * a virtio driver, implying rpmsg host role. @@ -827,7 +827,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, rvdev->config = *config; } - if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) { + if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { /* wait synchro with the host */ status = rpmsg_virtio_wait_remote_ready(rvdev); if (status) @@ -839,7 +839,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, return status; rdev->support_ns = !!(features & (1 << VIRTIO_RPMSG_F_NS)); - if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { /* * Since device is RPMSG Remote so we need to manage the * shared buffers. Create shared memory pool to handle buffers. @@ -856,7 +856,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, callback[1] = rpmsg_virtio_tx_callback; } - if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) { + if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { vq_names[0] = "tx_vq"; vq_names[1] = "rx_vq"; callback[0] = rpmsg_virtio_tx_callback; @@ -873,12 +873,12 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, return status; /* Create virtqueue success, assign back the virtqueue */ - if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { rvdev->rvq = vdev->vrings_info[0].vq; rvdev->svq = vdev->vrings_info[1].vq; } - if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) { + if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { rvdev->rvq = vdev->vrings_info[1].vq; rvdev->svq = vdev->vrings_info[0].vq; } @@ -897,7 +897,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, vq->shm_io = shm_io; } - if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { struct virtqueue_buf vqbuf; unsigned int idx; void *buffer; @@ -942,7 +942,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, rpmsg_virtio_ns_callback, NULL); } - if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { status = virtio_set_status(rvdev->vdev, VIRTIO_CONFIG_STATUS_DRIVER_OK); if (status) goto err; diff --git a/lib/virtio/virtio.c b/lib/virtio/virtio.c index aa90bb272..5689d1d08 100644 --- a/lib/virtio/virtio.c +++ b/lib/virtio/virtio.c @@ -120,7 +120,7 @@ int virtio_create_virtqueues(struct virtio_device *vdev, unsigned int flags, vring_info = &vdev->vrings_info[i]; vring_alloc = &vring_info->info; - if (VIRTIO_DRIVER_SUPPORT && vdev->role == VIRTIO_DEV_DRIVER) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && vdev->role == VIRTIO_DEV_DRIVER) { size_t offset; struct metal_io_region *io = vring_info->io; diff --git a/lib/virtio/virtqueue.c b/lib/virtio/virtqueue.c index b43418d73..5c7ab72ba 100644 --- a/lib/virtio/virtqueue.c +++ b/lib/virtio/virtqueue.c @@ -279,25 +279,25 @@ void virtqueue_disable_cb(struct virtqueue *vq) VQUEUE_BUSY(vq); if (vq->vq_dev->features & VIRTIO_RING_F_EVENT_IDX) { - if (VIRTIO_DRIVER_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DRIVER) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DRIVER) { vring_used_event(&vq->vq_ring) = vq->vq_used_cons_idx - vq->vq_nentries - 1; VRING_FLUSH(&vring_used_event(&vq->vq_ring), sizeof(vring_used_event(&vq->vq_ring))); } - if (VIRTIO_DEVICE_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DEVICE) { + if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DEVICE) { vring_avail_event(&vq->vq_ring) = vq->vq_available_idx - vq->vq_nentries - 1; VRING_FLUSH(&vring_avail_event(&vq->vq_ring), sizeof(vring_avail_event(&vq->vq_ring))); } } else { - if (VIRTIO_DRIVER_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DRIVER) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DRIVER) { vq->vq_ring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT; VRING_FLUSH(&vq->vq_ring.avail->flags, sizeof(vq->vq_ring.avail->flags)); } - if (VIRTIO_DEVICE_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DEVICE) { + if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DEVICE) { vq->vq_ring.used->flags |= VRING_USED_F_NO_NOTIFY; VRING_FLUSH(&vq->vq_ring.used->flags, sizeof(vq->vq_ring.used->flags)); @@ -486,7 +486,7 @@ static void vq_ring_init(struct virtqueue *vq, void *ring_mem, int alignment) vring_init(vr, size, ring_mem, alignment); - if (VIRTIO_DRIVER_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DRIVER) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DRIVER) { int i; for (i = 0; i < size - 1; i++) @@ -543,25 +543,25 @@ static int vq_ring_enable_interrupt(struct virtqueue *vq, uint16_t ndesc) * what's already been consumed. */ if (vq->vq_dev->features & VIRTIO_RING_F_EVENT_IDX) { - if (VIRTIO_DRIVER_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DRIVER) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DRIVER) { vring_used_event(&vq->vq_ring) = vq->vq_used_cons_idx + ndesc; VRING_FLUSH(&vring_used_event(&vq->vq_ring), sizeof(vring_used_event(&vq->vq_ring))); } - if (VIRTIO_DEVICE_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DEVICE) { + if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DEVICE) { vring_avail_event(&vq->vq_ring) = vq->vq_available_idx + ndesc; VRING_FLUSH(&vring_avail_event(&vq->vq_ring), sizeof(vring_avail_event(&vq->vq_ring))); } } else { - if (VIRTIO_DRIVER_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DRIVER) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DRIVER) { vq->vq_ring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT; VRING_FLUSH(&vq->vq_ring.avail->flags, sizeof(vq->vq_ring.avail->flags)); } - if (VIRTIO_DEVICE_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DEVICE) { + if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DEVICE) { vq->vq_ring.used->flags &= ~VRING_USED_F_NO_NOTIFY; VRING_FLUSH(&vq->vq_ring.used->flags, sizeof(vq->vq_ring.used->flags)); @@ -575,12 +575,12 @@ static int vq_ring_enable_interrupt(struct virtqueue *vq, uint16_t ndesc) * since we last checked. Let our caller know so it processes the new * entries. */ - if (VIRTIO_DRIVER_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DRIVER) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DRIVER) { if (virtqueue_nused(vq) > ndesc) { return 1; } } - if (VIRTIO_DEVICE_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DEVICE) { + if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DEVICE) { if (virtqueue_navail(vq) > ndesc) { return 1; } @@ -611,7 +611,7 @@ static int vq_ring_must_notify(struct virtqueue *vq) uint16_t new_idx, prev_idx, event_idx; if (vq->vq_dev->features & VIRTIO_RING_F_EVENT_IDX) { - if (VIRTIO_DRIVER_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DRIVER) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DRIVER) { /* CACHE: no need to invalidate avail */ new_idx = vq->vq_ring.avail->idx; prev_idx = new_idx - vq->vq_queued_cnt; @@ -621,7 +621,7 @@ static int vq_ring_must_notify(struct virtqueue *vq) return vring_need_event(event_idx, new_idx, prev_idx) != 0; } - if (VIRTIO_DEVICE_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DEVICE) { + if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DEVICE) { /* CACHE: no need to invalidate used */ new_idx = vq->vq_ring.used->idx; prev_idx = new_idx - vq->vq_queued_cnt; @@ -632,13 +632,13 @@ static int vq_ring_must_notify(struct virtqueue *vq) prev_idx) != 0; } } else { - if (VIRTIO_DRIVER_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DRIVER) { + if (IS_ENABLED(VIRTIO_DRIVER_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DRIVER) { VRING_INVALIDATE(&vq->vq_ring.used->flags, sizeof(vq->vq_ring.used->flags)); return (vq->vq_ring.used->flags & VRING_USED_F_NO_NOTIFY) == 0; } - if (VIRTIO_DEVICE_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DEVICE) { + if (IS_ENABLED(VIRTIO_DEVICE_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DEVICE) { VRING_INVALIDATE(&vq->vq_ring.avail->flags, sizeof(vq->vq_ring.avail->flags)); return (vq->vq_ring.avail->flags &