Directly access the MemoryRegion array, removing the need for the embedded structure.
Signed-off-by: Philippe Mathieu-Daudé <[email protected]> --- include/hw/sysbus.h | 4 +--- hw/core/sysbus.c | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h index b2a2ea507ea..2cee5bcd44f 100644 --- a/include/hw/sysbus.h +++ b/include/hw/sysbus.h @@ -59,9 +59,7 @@ struct SysBusDevice { /*< public >*/ int num_mmio; - struct { - MemoryRegion *memory; - } mmio[QDEV_MAX_MMIO]; + MemoryRegion *mmio[QDEV_MAX_MMIO]; int num_pio; uint32_t pio[QDEV_MAX_PIO]; }; diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index b3060e02484..188a6ab055e 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -125,7 +125,7 @@ static void sysbus_mmio_map_common(SysBusDevice *dev, int n, hwaddr addr, MemoryRegion *mr; assert(n >= 0 && n < dev->num_mmio); - mr = dev->mmio[n].memory; + mr = dev->mmio[n]; if (memory_region_is_mapped(mr)) { /* Unregister previous mapping. */ @@ -143,7 +143,7 @@ void sysbus_mmio_map(SysBusDevice *dev, int n, hwaddr addr) int sysbus_mmio_map_name(SysBusDevice *dev, const char *name, hwaddr addr) { for (int i = 0; i < dev->num_mmio; i++) { - if (!strcmp(memory_region_name(dev->mmio[i].memory), name)) { + if (!strcmp(memory_region_name(dev->mmio[i]), name)) { sysbus_mmio_map(dev, i, addr); return i; } @@ -175,13 +175,13 @@ void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory) assert(dev->num_mmio < QDEV_MAX_MMIO); n = dev->num_mmio++; - dev->mmio[n].memory = memory; + dev->mmio[n] = memory; } MemoryRegion *sysbus_mmio_get_region(const SysBusDevice *dev, int n) { assert(n >= 0 && n < QDEV_MAX_MMIO); - return dev->mmio[n].memory; + return dev->mmio[n]; } void sysbus_init_ioports(SysBusDevice *dev, uint32_t ioport, uint32_t size) -- 2.51.0
