aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@redhat.com>2020-02-22 18:11:33 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2020-03-17 15:18:49 +0100
commit41e82da57dbb6cad8ef1c9a281a9aac2265a0586 (patch)
tree6081f7fb22c4f47275112038d31bed11613fa63c /hw
parent414c47d234d6b12756d987bd93b9c8a04d009675 (diff)
downloadqemu-41e82da57dbb6cad8ef1c9a281a9aac2265a0586.zip
qemu-41e82da57dbb6cad8ef1c9a281a9aac2265a0586.tar.gz
qemu-41e82da57dbb6cad8ef1c9a281a9aac2265a0586.tar.bz2
hw/char: Let devices own the MemoryRegion they create
Avoid orphan memory regions being added in the /unattached QOM container. This commit was produced with the Coccinelle script scripts/coccinelle/memory-region-housekeeping.cocci. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/char/serial.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/hw/char/serial.c b/hw/char/serial.c
index 9298881..2ab8b69 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -997,7 +997,7 @@ static void serial_io_realize(DeviceState *dev, Error **errp)
return;
}
- memory_region_init_io(&s->io, NULL, &serial_io_ops, s, "serial", 8);
+ memory_region_init_io(&s->io, OBJECT(dev), &serial_io_ops, s, "serial", 8);
sysbus_init_mmio(SYS_BUS_DEVICE(sio), &s->io);
sysbus_init_irq(SYS_BUS_DEVICE(sio), &s->irq);
}
@@ -1106,8 +1106,9 @@ static void serial_mm_realize(DeviceState *dev, Error **errp)
return;
}
- memory_region_init_io(&s->io, NULL, &serial_mm_ops[smm->endianness], smm,
- "serial", 8 << smm->regshift);
+ memory_region_init_io(&s->io, OBJECT(dev),
+ &serial_mm_ops[smm->endianness], smm, "serial",
+ 8 << smm->regshift);
sysbus_init_mmio(SYS_BUS_DEVICE(smm), &s->io);
sysbus_init_irq(SYS_BUS_DEVICE(smm), &smm->serial.irq);
}