From 56299135f5c32a8b606e4b62af9200a3cee65985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Thu, 25 Jul 2013 00:48:23 +0200 Subject: milkymist-tmu2: QOM cast cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce a type constant, use QOM casts and rename the parent field. Signed-off-by: Andreas Färber --- hw/display/milkymist-tmu2.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'hw/display') diff --git a/hw/display/milkymist-tmu2.c b/hw/display/milkymist-tmu2.c index efda0824fe..b2a5fba0ff 100644 --- a/hw/display/milkymist-tmu2.c +++ b/hw/display/milkymist-tmu2.c @@ -75,8 +75,13 @@ struct vertex { int y; } QEMU_PACKED; +#define TYPE_MILKYMIST_TMU2 "milkymist-tmu2" +#define MILKYMIST_TMU2(obj) \ + OBJECT_CHECK(MilkymistTMU2State, (obj), TYPE_MILKYMIST_TMU2) + struct MilkymistTMU2State { - SysBusDevice busdev; + SysBusDevice parent_obj; + MemoryRegion regs_region; CharDriverState *chr; qemu_irq irq; @@ -429,7 +434,7 @@ static const MemoryRegionOps tmu2_mmio_ops = { static void milkymist_tmu2_reset(DeviceState *d) { - MilkymistTMU2State *s = container_of(d, MilkymistTMU2State, busdev.qdev); + MilkymistTMU2State *s = MILKYMIST_TMU2(d); int i; for (i = 0; i < R_MAX; i++) { @@ -439,7 +444,7 @@ static void milkymist_tmu2_reset(DeviceState *d) static int milkymist_tmu2_init(SysBusDevice *dev) { - MilkymistTMU2State *s = FROM_SYSBUS(typeof(*s), dev); + MilkymistTMU2State *s = MILKYMIST_TMU2(dev); if (tmu2_glx_init(s)) { return 1; @@ -476,7 +481,7 @@ static void milkymist_tmu2_class_init(ObjectClass *klass, void *data) } static const TypeInfo milkymist_tmu2_info = { - .name = "milkymist-tmu2", + .name = TYPE_MILKYMIST_TMU2, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(MilkymistTMU2State), .class_init = milkymist_tmu2_class_init, -- cgit v1.2.3