shaoqin.huang at intel.com
2022-Oct-21 06:27 UTC
[PATCH 0/2] virtio: use helper function is_power_of_2()
From: Shaoqin Huang <shaoqin.huang at intel.com> Use helper function is_power_of_2() to check if num is power of two. Minor readability improvement. Shaoqin Huang (2): virtio_pci: use helper function is_power_of_2() virtio_ring: use helper function is_power_of_2() drivers/virtio/virtio_pci_modern.c | 2 +- drivers/virtio/virtio_ring.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.34.1
shaoqin.huang at intel.com
2022-Oct-21 06:27 UTC
[PATCH 1/2] virtio_pci: use helper function is_power_of_2()
From: Shaoqin Huang <shaoqin.huang at intel.com> 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 at intel.com> --- drivers/virtio/virtio_pci_modern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index c3b9f2761849..207294bd7b9d 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c @@ -310,7 +310,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, if (!num || vp_modern_get_queue_enable(mdev, index)) return ERR_PTR(-ENOENT); - if (num & (num - 1)) { + if (!is_power_of_2(num)) { dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u", num); return ERR_PTR(-EINVAL); } -- 2.34.1
shaoqin.huang at intel.com
2022-Oct-21 06:27 UTC
[PATCH 2/2] virtio_ring: use helper function is_power_of_2()
From: Shaoqin Huang <shaoqin.huang at intel.com> 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 at intel.com> --- drivers/virtio/virtio_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } -- 2.34.1