Introduce type constant and cast macro to obsolete DO_UPCAST(). Prepares for ISA realizefn.
Signed-off-by: Andreas Färber <afaer...@suse.de> --- hw/pc.c | 16 ++++++++++------ 1 Datei geändert, 10 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-) diff --git a/hw/pc.c b/hw/pc.c index 5fc2076..e878106 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -413,9 +413,13 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, qemu_register_reset(pc_cmos_init_late, &arg); } +#define TYPE_PORT92 "port92" +#define PORT92(obj) OBJECT_CHECK(Port92State, (obj), TYPE_PORT92) + /* port 92 stuff: could be split off */ typedef struct Port92State { - ISADevice dev; + ISADevice parent_obj; + MemoryRegion io; uint8_t outport; qemu_irq *a20_out; @@ -447,7 +451,7 @@ static uint64_t port92_read(void *opaque, hwaddr addr, static void port92_init(ISADevice *dev, qemu_irq *a20_out) { - Port92State *s = DO_UPCAST(Port92State, dev, dev); + Port92State *s = PORT92(dev); s->a20_out = a20_out; } @@ -465,7 +469,7 @@ static const VMStateDescription vmstate_port92_isa = { static void port92_reset(DeviceState *d) { - Port92State *s = container_of(d, Port92State, dev.qdev); + Port92State *s = PORT92(d); s->outport &= ~1; } @@ -482,7 +486,7 @@ static const MemoryRegionOps port92_ops = { static int port92_initfn(ISADevice *dev) { - Port92State *s = DO_UPCAST(Port92State, dev, dev); + Port92State *s = PORT92(dev); memory_region_init_io(&s->io, &port92_ops, s, "port92", 1); isa_register_ioport(dev, &s->io, 0x92); @@ -501,8 +505,8 @@ static void port92_class_initfn(ObjectClass *klass, void *data) dc->vmsd = &vmstate_port92_isa; } -static TypeInfo port92_info = { - .name = "port92", +static const TypeInfo port92_info = { + .name = TYPE_PORT92, .parent = TYPE_ISA_DEVICE, .instance_size = sizeof(Port92State), .class_init = port92_class_initfn, -- 1.7.10.4