[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V4 1/5] pci/shpc: Move function to generic header fi
From: |
Marcel Apfelbaum |
Subject: |
[Qemu-devel] [PATCH V4 1/5] pci/shpc: Move function to generic header file |
Date: |
Thu, 4 Jan 2018 18:36:48 +0200 |
From: Yuval Shaia <address@hidden>
This function should be declared in generic header file so we can
utilize it.
Signed-off-by: Yuval Shaia <address@hidden>
Signed-off-by: Marcel Apfelbaum <address@hidden>
---
hw/pci/shpc.c | 13 ++-----------
include/qemu/host-utils.h | 10 ++++++++++
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c
index 69fc14b218..a8462d48bb 100644
--- a/hw/pci/shpc.c
+++ b/hw/pci/shpc.c
@@ -1,6 +1,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu-common.h"
+#include "qemu/host-utils.h"
#include "qemu/range.h"
#include "qemu/error-report.h"
#include "hw/pci/shpc.h"
@@ -122,16 +123,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);
@@ -656,7 +647,7 @@ int shpc_init(PCIDevice *d, PCIBus *sec_bus, MemoryRegion
*bar,
int shpc_bar_size(PCIDevice *d)
{
- return roundup_pow_of_two(SHPC_SLOT_REG(SHPC_MAX_SLOTS));
+ return pow2roundup32(SHPC_SLOT_REG(SHPC_MAX_SLOTS));
}
void shpc_cleanup(PCIDevice *d, MemoryRegion *bar)
diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h
index 5ac621cf1f..9fadb3f1ba 100644
--- a/include/qemu/host-utils.h
+++ b/include/qemu/host-utils.h
@@ -400,6 +400,16 @@ static inline uint64_t pow2ceil(uint64_t value)
return 0x8000000000000000ull >> (n - 1);
}
+static inline int pow2roundup32(int x)
+{
+ x |= (x >> 1);
+ x |= (x >> 2);
+ x |= (x >> 4);
+ x |= (x >> 8);
+ x |= (x >> 16);
+ return x + 1;
+}
+
/**
* urshift - 128-bit Unsigned Right Shift.
* @plow: in/out - lower 64-bit integer.
--
2.13.5
- [Qemu-devel] [PATCH V4 0/5] hw/pvrdma: PVRDMA device implementation, Marcel Apfelbaum, 2018/01/04
- [Qemu-devel] [PATCH V4 1/5] pci/shpc: Move function to generic header file,
Marcel Apfelbaum <=
- [Qemu-devel] [PATCH V4 3/5] docs: add pvrdma device documentation., Marcel Apfelbaum, 2018/01/04
- [Qemu-devel] [PATCH V4 2/5] mem: add share parameter to memory-backend-ram, Marcel Apfelbaum, 2018/01/04
- [Qemu-devel] [PATCH V4 5/5] MAINTAINERS: add entry for hw/rdma, Marcel Apfelbaum, 2018/01/04
- [Qemu-devel] [PATCH V4 4/5] pvrdma: initial implementation, Marcel Apfelbaum, 2018/01/04
- Re: [Qemu-devel] [PATCH V4 0/5] hw/pvrdma: PVRDMA device implementation, no-reply, 2018/01/04
- Re: [Qemu-devel] [PATCH V4 0/5] hw/pvrdma: PVRDMA device implementation, no-reply, 2018/01/04