From patchwork Fri Jul 24 12:33:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 51441 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 0691322D94 for ; Fri, 24 Jul 2015 12:33:32 +0000 (UTC) Received: by laef2 with SMTP id f2sf7150789lae.0 for ; Fri, 24 Jul 2015 05:33:31 -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=YN4uEqWrQqOWolUnFO5PdE483nyRkYreMA0ASQiVbnaeAmt1ZBVv+QQ/uWDLLmb1Ry ZHgpSMNZ1jbHwH22wLJL4X+oQBlrjo63fEl58lYgZ/6DQkXuRZHRJeA/ivzyjJJ458Ha +JKx24Iv1RFEsVU91XzAKndi3OIZaSbSNu1DPT53g6yFgdXiafyZtKnafmmBFQuvm7bd P/Pn15GbWgKpM6wZC+Mi0bkePXK/RGge027+HM57/mQz83t9ofD66YLjn8/I4HE62Zki FhC63TbeyXn8Eov2LayB0zG1JHVQKuGFc71ff82YuyxsduRmByMs3Uy7ko6CKYbksRlM rhNg== X-Gm-Message-State: ALoCoQlxSdSmSqGwSKg8+FFtN7TuU+ax26bSTDHw6ncMtrnVh4rbafOKY2ZoK+gQ6rRM6GDiaL8s X-Received: by 10.112.14.101 with SMTP id o5mr6100125lbc.3.1437741210579; Fri, 24 Jul 2015 05:33:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.207.38 with SMTP id lt6ls388056lac.50.gmail; Fri, 24 Jul 2015 05:33:30 -0700 (PDT) X-Received: by 10.112.202.234 with SMTP id kl10mr13441702lbc.51.1437741210435; Fri, 24 Jul 2015 05:33:30 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id jg8si6657028lbc.29.2015.07.24.05.33.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Jul 2015 05:33:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbbyj8 with SMTP id yj8so14289669lbb.0 for ; Fri, 24 Jul 2015 05:33:30 -0700 (PDT) X-Received: by 10.112.166.2 with SMTP id zc2mr13376217lbb.29.1437741210339; Fri, 24 Jul 2015 05:33:30 -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 l6csp1150400lba; Fri, 24 Jul 2015 05:33:29 -0700 (PDT) X-Received: by 10.66.222.103 with SMTP id ql7mr30391387pac.144.1437741200922; Fri, 24 Jul 2015 05:33:20 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id u9si20346244pdp.186.2015.07.24.05.33.19 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 24 Jul 2015 05:33:20 -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 1ZIcA4-0005Sa-RS; Fri, 24 Jul 2015 13:33:12 +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 v2 2/6] hw/virtio/virtio-pci: Use pow2ceil() rather than hand-calculation Date: Fri, 24 Jul 2015 13:33:08 +0100 Message-Id: <1437741192-20955-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1437741192-20955-1-git-send-email-peter.maydell@linaro.org> References: <1437741192-20955-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.178 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,