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

virtio_pci: 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-2-shaoqin.huang@intel.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>

authored by

Shaoqin Huang and committed by
Michael S. Tsirkin
34468613 38fc462f

+1 -1
+1 -1
drivers/virtio/virtio_pci_modern.c
··· 310 310 if (!num || vp_modern_get_queue_enable(mdev, index)) 311 311 return ERR_PTR(-ENOENT); 312 312 313 - if (num & (num - 1)) { 313 + if (!is_power_of_2(num)) { 314 314 dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u", num); 315 315 return ERR_PTR(-EINVAL); 316 316 }