summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShaoqin Huang <shaoqin.huang@intel.com>2022-10-21 08:27:34 +0200
committerMichael S. Tsirkin <mst@redhat.com>2022-12-28 11:28:09 +0100
commitb9d978a89296c57fbbbd8ea647c303ce4d37028f (patch)
tree8c65295579a9c92e5d5e816b4c9a56ef468aed69
parentvirtio_pci: use helper function is_power_of_2() (diff)
downloadlinux-b9d978a89296c57fbbbd8ea647c303ce4d37028f.tar.xz
linux-b9d978a89296c57fbbbd8ea647c303ce4d37028f.zip
virtio_ring: use helper function is_power_of_2()
Use helper function is_power_of_2() to check if num is power of two. Minor readability improvement. Signed-off-by: Shaoqin Huang <shaoqin.huang@intel.com> Message-Id: <20221021062734.228881-3-shaoqin.huang@intel.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
-rw-r--r--drivers/virtio/virtio_ring.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 2e7689bb933b..723c4e29e1d3 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -1052,7 +1052,7 @@ static int vring_alloc_queue_split(struct vring_virtqueue_split *vring_split,
dma_addr_t dma_addr;
/* We assume num is a power of 2. */
- if (num & (num - 1)) {
+ if (!is_power_of_2(num)) {
dev_warn(&vdev->dev, "Bad virtqueue length %u\n", num);
return -EINVAL;
}