qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Yuval Shaia <yuval.shaia@oracle.com>
To: mst@redhat.com, marcel@redhat.com
Cc: qemu-devel@nongnu.org, yuval.shaia@oracle.com
Subject: [Qemu-devel] [PATCH] include: Add roundup_pow_of_two helper function
Date: Mon, 28 Nov 2016 09:18:42 +0200	[thread overview]
Message-ID: <1480317522-5950-1-git-send-email-yuval.shaia@oracle.com> (raw)

Move private implementation of rthe function to osdep.h

Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
---
 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
-- 
1.8.3.1

             reply	other threads:[~2016-11-28  7:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28  7:18 Yuval Shaia [this message]
2016-11-28 12:08 ` [Qemu-devel] [PATCH] include: Add roundup_pow_of_two helper function Marcel Apfelbaum
2016-11-29 13:28 ` no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1480317522-5950-1-git-send-email-yuval.shaia@oracle.com \
    --to=yuval.shaia@oracle.com \
    --cc=marcel@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).