diff options
author | David Hildenbrand <david@redhat.com> | 2018-10-05 11:20:17 +0200 |
---|---|---|
committer | Eduardo Habkost <ehabkost@redhat.com> | 2018-10-24 06:44:59 -0300 |
commit | 946d6154aba9aaa4d19433a6a8bcd3de3b119240 (patch) | |
tree | 4c6d9491b3eafb8873887220d319b71ebb0d666c /hw/mem/memory-device.c | |
parent | 5cca020c8835921c5de634a3ff31c3e1cfe5b245 (diff) |
memory-device: add and use memory_device_get_region_size()
We will factor out get_memory_region() from pc-dimm to memory device code
soon. Once that is done, get_region_size() can be implemented
generically and essentially be replaced by
memory_device_get_region_size (and work only on get_memory_region()).
We have some users of get_memory_region() (spapr and pc-dimm code) that are
only interested in the size. So let's rework them to use
memory_device_get_region_size() first, then we can factor out
get_memory_region() and eventually remove get_region_size() without
touching the same code multiple times.
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-10-david@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'hw/mem/memory-device.c')
-rw-r--r-- | hw/mem/memory-device.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c index c1e1b81cf2..425830c65c 100644 --- a/hw/mem/memory-device.c +++ b/hw/mem/memory-device.c @@ -57,10 +57,9 @@ static int memory_device_used_region_size(Object *obj, void *opaque) if (object_dynamic_cast(obj, TYPE_MEMORY_DEVICE)) { const DeviceState *dev = DEVICE(obj); const MemoryDeviceState *md = MEMORY_DEVICE(obj); - const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(obj); if (dev->realized) { - *size += mdc->get_region_size(md, &error_abort); + *size += memory_device_get_region_size(md, &error_abort); } } @@ -167,7 +166,7 @@ uint64_t memory_device_get_free_addr(MachineState *ms, const uint64_t *hint, uint64_t md_size, md_addr; md_addr = mdc->get_addr(md); - md_size = mdc->get_region_size(md, &error_abort); + md_size = memory_device_get_region_size(md, &error_abort); if (ranges_overlap(md_addr, md_size, new_addr, size)) { if (hint) { @@ -266,6 +265,14 @@ void memory_device_unplug_region(MachineState *ms, MemoryRegion *mr) memory_region_del_subregion(&ms->device_memory->mr, mr); } +uint64_t memory_device_get_region_size(const MemoryDeviceState *md, + Error **errp) +{ + MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(md); + + return mdc->get_region_size(md, errp); +} + static const TypeInfo memory_device_info = { .name = TYPE_MEMORY_DEVICE, .parent = TYPE_INTERFACE, |