From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40290) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPQaF-00053L-AA for qemu-devel@nongnu.org; Wed, 12 Aug 2015 03:36:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZPQaE-0001dL-Br for qemu-devel@nongnu.org; Wed, 12 Aug 2015 03:36:23 -0400 Date: Wed, 12 Aug 2015 10:36:13 +0300 From: "Michael S. Tsirkin" Message-ID: <20150812103608-mutt-send-email-mst@redhat.com> References: <1437741192-20955-1-git-send-email-peter.maydell@linaro.org> <1437741192-20955-3-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437741192-20955-3-git-send-email-peter.maydell@linaro.org> Subject: Re: [Qemu-devel] [PATCH v2 2/6] hw/virtio/virtio-pci: Use pow2ceil() rather than hand-calculation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Kevin Wolf , qemu-block@nongnu.org, patches@linaro.org, qemu-devel@nongnu.org, Keith Busch , Paolo Bonzini On Fri, Jul 24, 2015 at 01:33:08PM +0100, Peter Maydell wrote: > Use the utility function pow2ceil() for rounding up to the next > largest power of 2, rather than inline calculation. > > Signed-off-by: Peter Maydell Reviewed-by: Michael S. Tsirkin > --- > hw/virtio/virtio-pci.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c > index 283401a..845f52f 100644 > --- a/hw/virtio/virtio-pci.c > +++ b/hw/virtio/virtio-pci.c > @@ -1497,9 +1497,7 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) > if (legacy) { > size = VIRTIO_PCI_REGION_SIZE(&proxy->pci_dev) > + virtio_bus_get_vdev_config_len(bus); > - if (size & (size - 1)) { > - size = 1 << qemu_fls(size); > - } > + size = pow2ceil(size); > > memory_region_init_io(&proxy->bar, OBJECT(proxy), > &virtio_pci_config_ops, > -- > 1.9.1