From af390027475a0ada7a9da71108d5aee6fcc18151 Mon Sep 17 00:00:00 2001 From: David Hildenbrand Date: Fri, 5 Oct 2018 11:20:19 +0200 Subject: memory-device: drop get_region_size() 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 Reviewed-by: Igor Mammedov Signed-off-by: David Hildenbrand Message-Id: <20181005092024.14344-12-david@redhat.com> Signed-off-by: Eduardo Habkost --- hw/mem/memory-device.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'hw/mem/memory-device.c') 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 = { -- cgit v1.2.3