diff options
author | David Hildenbrand <david@redhat.com> | 2018-10-05 11:20:19 +0200 |
---|---|---|
committer | Eduardo Habkost <ehabkost@redhat.com> | 2018-10-24 06:44:59 -0300 |
commit | af390027475a0ada7a9da71108d5aee6fcc18151 (patch) | |
tree | cfa20288525dbbd2398dcec7ef98efda40d0fa40 /hw/mem | |
parent | 3a0a2b0a2ba87ed00b732f061e59f890aaa27c17 (diff) |
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 <david@gibson.dropbear.id.au>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20181005092024.14344-12-david@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'hw/mem')
-rw-r--r-- | hw/mem/memory-device.c | 11 | ||||
-rw-r--r-- | hw/mem/pc-dimm.c | 18 |
2 files changed, 10 insertions, 19 deletions
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; } |