From patchwork Thu Jul 23 11:08:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 51393 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id 2259320323 for ; Thu, 23 Jul 2015 11:21:56 +0000 (UTC) Received: by lafd3 with SMTP id d3sf67468245laf.1 for ; Thu, 23 Jul 2015 04:21:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=eauhg9HrVkyTYBX7V8y+w8Z0ZNrFJRPSRRv+yeAzsYs=; b=Ny0owWZMhRlmgEeFkwcuuLtgryt8jHo7jxYzOikM3bnqjQQhrh7ENZX988Xqr1ihQo Fg3EugHqXjziB5JeFoEYc5uvYDst1FKQ+mvf4DwcsdIG5Ru/gsJE4qGqOxCVZkNDvcx4 lXGwuEgumCbC3oyD9n6pVHYKm3yszbW8TgUNEDJrck9MFUKqE15IGYZ4J9883JRL/HB8 PuiWqJlxPdlqxYZG2mvZj996XJYrEWSJRS0XN7x5UAPOO/WObNrIT+lh6YlIZrfH3LCB wZesv3rOvPaPJsVZQpIRIL0mWGsIhr7s5RgU6FqAlRW30sQ3On0oxYSUZVsnDN83CvSb UOOQ== X-Gm-Message-State: ALoCoQkQlbLOWkRnzN4MQPUPt0UjRwuh6jKv9O0YiSM0VjUWIx+TvobJK0x4BwMMD/7y9BBjVv3p X-Received: by 10.112.13.200 with SMTP id j8mr3484076lbc.14.1437650514878; Thu, 23 Jul 2015 04:21:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.179.39 with SMTP id dd7ls223754lac.60.gmail; Thu, 23 Jul 2015 04:21:54 -0700 (PDT) X-Received: by 10.112.198.74 with SMTP id ja10mr7296693lbc.19.1437650514738; Thu, 23 Jul 2015 04:21:54 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id b10si3947771laf.38.2015.07.23.04.21.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jul 2015 04:21:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lbbqi7 with SMTP id qi7so75028151lbb.3 for ; Thu, 23 Jul 2015 04:21:54 -0700 (PDT) X-Received: by 10.152.36.161 with SMTP id r1mr7296655laj.88.1437650514482; Thu, 23 Jul 2015 04:21:54 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.7.198 with SMTP id l6csp493437lba; Thu, 23 Jul 2015 04:21:53 -0700 (PDT) X-Received: by 10.180.14.200 with SMTP id r8mr16403313wic.53.1437650513750; Thu, 23 Jul 2015 04:21:53 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id z7si1158981wjz.12.2015.07.23.04.21.52 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 23 Jul 2015 04:21:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1ZIEN0-0003cY-Hy; Thu, 23 Jul 2015 12:08:58 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Paolo Bonzini , Keith Busch , Kevin Wolf , "Michael S. Tsirkin" , qemu-block@nongnu.org Subject: [PATCH 2/5] hw/virtio/virtio-pci: Use pow2ceil() rather than hand-calculation Date: Thu, 23 Jul 2015 12:08:55 +0100 Message-Id: <1437649738-13885-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1437649738-13885-1-git-send-email-peter.maydell@linaro.org> References: <1437649738-13885-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Use the utility function pow2ceil() for rounding up to the next largest power of 2, rather than inline calculation. Signed-off-by: Peter Maydell --- 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,