From patchwork Mon Nov 28 07:18:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 9449141 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ACEE66071E for ; Mon, 28 Nov 2016 07:20:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AD69204BD for ; Mon, 28 Nov 2016 07:20:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E17320649; Mon, 28 Nov 2016 07:20:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E396A204BD for ; Mon, 28 Nov 2016 07:20:45 +0000 (UTC) Received: from localhost ([::1]:57067 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBGF2-0004bx-Id for patchwork-qemu-devel@patchwork.kernel.org; Mon, 28 Nov 2016 02:20:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBGDH-0003c7-8B for qemu-devel@nongnu.org; Mon, 28 Nov 2016 02:18:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBGDE-0004iq-3X for qemu-devel@nongnu.org; Mon, 28 Nov 2016 02:18:55 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:47854) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cBGDD-0004ie-T4 for qemu-devel@nongnu.org; Mon, 28 Nov 2016 02:18:52 -0500 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uAS7InS5020805 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Nov 2016 07:18:50 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id uAS7ImYY026634 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 28 Nov 2016 07:18:49 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id uAS7IlNE005913; Mon, 28 Nov 2016 07:18:48 GMT Received: from yuval-lap.localdomain (/77.138.186.148) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 27 Nov 2016 23:18:46 -0800 From: Yuval Shaia To: mst@redhat.com, marcel@redhat.com Date: Mon, 28 Nov 2016 09:18:42 +0200 Message-Id: <1480317522-5950-1-git-send-email-yuval.shaia@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Source-IP: userv0022.oracle.com [156.151.31.74] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 141.146.126.69 Subject: [Qemu-devel] [PATCH] include: Add roundup_pow_of_two helper function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, yuval.shaia@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Move private implementation of rthe function to osdep.h Signed-off-by: Yuval Shaia --- hw/pci/shpc.c | 12 +----------- include/qemu/osdep.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c index 3dcd472..4b8982d 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -122,16 +122,6 @@ #define SHPC_PCI_TO_IDX(pci_slot) ((pci_slot) - 1) #define SHPC_IDX_TO_PHYSICAL(slot) ((slot) + 1) -static int roundup_pow_of_two(int x) -{ - x |= (x >> 1); - x |= (x >> 2); - x |= (x >> 4); - x |= (x >> 8); - x |= (x >> 16); - return x + 1; -} - static uint16_t shpc_get_status(SHPCDevice *shpc, int slot, uint16_t msk) { uint8_t *status = shpc->config + SHPC_SLOT_STATUS(slot); @@ -654,7 +644,7 @@ int shpc_init(PCIDevice *d, PCIBus *sec_bus, MemoryRegion *bar, unsigned offset) int shpc_bar_size(PCIDevice *d) { - return roundup_pow_of_two(SHPC_SLOT_REG(SHPC_MAX_SLOTS)); + return round_up_pow_of_two(SHPC_SLOT_REG(SHPC_MAX_SLOTS)); } void shpc_cleanup(PCIDevice *d, MemoryRegion *bar) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 689f253..74d5c30 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -194,6 +194,16 @@ extern int daemon(int, int); #define ROUND_UP(n,d) (((n) + (d) - 1) & -(d)) #endif +static inline int round_up_pow_of_two(int x) +{ + x |= (x >> 1); + x |= (x >> 2); + x |= (x >> 4); + x |= (x >> 8); + x |= (x >> 16); + return x + 1; +} + #ifndef DIV_ROUND_UP #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) #endif