Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Shaoqin Huang and committed by
Michael S. Tsirkin
b9d978a8 34468613

+1 -1
+1 -1
drivers/virtio/virtio_ring.c
··· 1052 1052 dma_addr_t dma_addr; 1053 1053 1054 1054 /* We assume num is a power of 2. */ 1055 - if (num & (num - 1)) { 1055 + if (!is_power_of_2(num)) { 1056 1056 dev_warn(&vdev->dev, "Bad virtqueue length %u\n", num); 1057 1057 return -EINVAL; 1058 1058 }