Received: from eggs.gnu.org ([2001:4830:134:3::10]:47976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBKjv-0001f6-0h for qemu-devel@nongnu.org; Mon, 28 Nov 2016 07:08:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBKjq-0000VP-DV for qemu-devel@nongnu.org; Mon, 28 Nov 2016 07:08:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44756) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cBKjq-0000VB-7U for qemu-devel@nongnu.org; Mon, 28 Nov 2016 07:08:50 -0500 References: <1480317522-5950-1-git-send-email-yuval.shaia@oracle.com> From: Marcel Apfelbaum Message-ID: <94a6b3e9-e122-0886-bc98-8172dccd0b2f@redhat.com> Date: Mon, 28 Nov 2016 14:08:41 +0200 MIME-Version: 1.0 In-Reply-To: <1480317522-5950-1-git-send-email-yuval.shaia@oracle.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] include: Add roundup_pow_of_two helper function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Yuval Shaia , mst@redhat.com Cc: qemu-devel@nongnu.org On 11/28/2016 09:18 AM, Yuval Shaia wrote: > Move private implementation of rthe function to osdep.h Hi Yuval, In my opinion we need to use the function in at least two places in order to promote it to a global utility. You are welcome to try to find another place needing it. Thanks, Marcel > > 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 >