Skip to content

Commit b9d978a

Browse files
huangshaoqinmstsirkin
authored andcommitted
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 <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Xuan Zhuo <[email protected]>
1 parent 3446861 commit b9d978a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/virtio/virtio_ring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ static int vring_alloc_queue_split(struct vring_virtqueue_split *vring_split,
10521052
dma_addr_t dma_addr;
10531053

10541054
/* We assume num is a power of 2. */
1055-
if (num & (num - 1)) {
1055+
if (!is_power_of_2(num)) {
10561056
dev_warn(&vdev->dev, "Bad virtqueue length %u\n", num);
10571057
return -EINVAL;
10581058
}

0 commit comments

Comments
 (0)