[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL v2 27/43] memory-device: drop get_region_size()
From: |
Eduardo Habkost |
Subject: |
[Qemu-ppc] [PULL v2 27/43] memory-device: drop get_region_size() |
Date: |
Thu, 25 Oct 2018 10:32:45 -0300 |
From: David Hildenbrand <address@hidden>
There are no remaining users of get_region_size() except
memory_device_get_region_size() itself. We can make
memory_device_get_region_size() work directly on get_memory_region()
instead and drop get_region_size().
In addition, we can now use memory_device_get_region_size() in pc-dimm
code to implement get_plugged_size()"
Reviewed-by: David Gibson <address@hidden>
Reviewed-by: Igor Mammedov <address@hidden>
Signed-off-by: David Hildenbrand <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
---
include/hw/mem/memory-device.h | 1 -
hw/mem/memory-device.c | 11 +++++++++--
hw/mem/pc-dimm.c | 18 +-----------------
3 files changed, 10 insertions(+), 20 deletions(-)
diff --git a/include/hw/mem/memory-device.h b/include/hw/mem/memory-device.h
index 659f38385c..9c3398bc4a 100644
--- a/include/hw/mem/memory-device.h
+++ b/include/hw/mem/memory-device.h
@@ -71,7 +71,6 @@ typedef struct MemoryDeviceClass {
* most devices, this corresponds to the size of the memory region.
*/
uint64_t (*get_plugged_size)(const MemoryDeviceState *md, Error **errp);
- uint64_t (*get_region_size)(const MemoryDeviceState *md, Error **errp);
/*
* Return the memory region of the memory device.
diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
index 425830c65c..07749bab69 100644
--- a/hw/mem/memory-device.c
+++ b/hw/mem/memory-device.c
@@ -268,9 +268,16 @@ void memory_device_unplug_region(MachineState *ms,
MemoryRegion *mr)
uint64_t memory_device_get_region_size(const MemoryDeviceState *md,
Error **errp)
{
- MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(md);
+ const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(md);
+ MemoryRegion *mr;
- return mdc->get_region_size(md, errp);
+ /* dropping const here is fine as we don't touch the memory region */
+ mr = mdc->get_memory_region((MemoryDeviceState *)md, errp);
+ if (!mr) {
+ return 0;
+ }
+
+ return memory_region_size(mr);
}
static const TypeInfo memory_device_info = {
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index c9f6ad589e..47b2e83389 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -236,21 +236,6 @@ static uint64_t pc_dimm_md_get_addr(const
MemoryDeviceState *md)
return dimm->addr;
}
-static uint64_t pc_dimm_md_get_region_size(const MemoryDeviceState *md,
- Error **errp)
-{
- MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(md);
- MemoryRegion *mr;
-
- /* dropping const here is fine as we don't touch the memory region */
- mr = mdc->get_memory_region((MemoryDeviceState *)md, errp);
- if (!mr) {
- return 0;
- }
-
- return memory_region_size(mr);
-}
-
static MemoryRegion *pc_dimm_md_get_memory_region(MemoryDeviceState *md,
Error **errp)
{
@@ -302,8 +287,7 @@ static void pc_dimm_class_init(ObjectClass *oc, void *data)
mdc->get_addr = pc_dimm_md_get_addr;
/* for a dimm plugged_size == region_size */
- mdc->get_plugged_size = pc_dimm_md_get_region_size;
- mdc->get_region_size = pc_dimm_md_get_region_size;
+ mdc->get_plugged_size = memory_device_get_region_size;
mdc->get_memory_region = pc_dimm_md_get_memory_region;
mdc->fill_device_info = pc_dimm_md_fill_device_info;
}
--
2.18.0.rc1.1.g3f1ff2140
- [Qemu-ppc] [PULL v2 15/43] hw/mips/malta: Remove unuseful code, (continued)
- [Qemu-ppc] [PULL v2 15/43] hw/mips/malta: Remove unuseful code, Eduardo Habkost, 2018/10/25
- [Qemu-ppc] [PULL v2 12/43] hw/sparc64/niagara: Model the I/O Bridge with the 'unimplemented_device', Eduardo Habkost, 2018/10/25
- [Qemu-ppc] [PULL v2 18/43] memory-device: fix error message when hinted address is too small, Eduardo Habkost, 2018/10/25
- [Qemu-ppc] [PULL v2 22/43] memory-device: introduce separate config option, Eduardo Habkost, 2018/10/25
- [Qemu-ppc] [PULL v2 21/43] memory-device: use memory device terminology in error messages, Eduardo Habkost, 2018/10/25
- [Qemu-ppc] [PULL v2 23/43] memory-device: forward errors in get_region_size()/get_plugged_size(), Eduardo Habkost, 2018/10/25
- [Qemu-ppc] [PULL v2 16/43] machine: fix a typo, Eduardo Habkost, 2018/10/25
- [Qemu-ppc] [PULL v2 24/43] memory-device: document MemoryDeviceClass, Eduardo Habkost, 2018/10/25
- [Qemu-ppc] [PULL v2 25/43] memory-device: add and use memory_device_get_region_size(), Eduardo Habkost, 2018/10/25
- [Qemu-ppc] [PULL v2 26/43] memory-device: factor out get_memory_region() from pc-dimm, Eduardo Habkost, 2018/10/25
- [Qemu-ppc] [PULL v2 27/43] memory-device: drop get_region_size(),
Eduardo Habkost <=
- [Qemu-ppc] [PULL v2 28/43] memory-device: add device class function set_addr(), Eduardo Habkost, 2018/10/25
- [Qemu-ppc] [PULL v2 29/43] memory-device: complete factoring out pre_plug handling, Eduardo Habkost, 2018/10/25
- [Qemu-ppc] [PULL v2 11/43] hw/mips/gt64xxx_pci: Mark as bridge device, Eduardo Habkost, 2018/10/25
- Re: [Qemu-ppc] [PULL v2 00/43] Machine queue, 2018-10-25, Peter Maydell, 2018/10/26