Patchwork [RFC,17/34] parallel: QOM'ify

login
register
mail settings
Submitter Andreas Färber
Date Nov. 26, 2012, 12:12 a.m.
Message ID <1353888766-6951-18-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/201606/
State New
Headers show

Comments

Andreas Färber - Nov. 26, 2012, 12:12 a.m.
Introduce type constant and cast macro to obsolete DO_UPCAST().

Prepares for ISA realizefn.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/parallel.c |   13 +++++++++----
 1 Datei geändert, 9 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)

Patch

diff --git a/hw/parallel.c b/hw/parallel.c
index c4705bc..65447d3 100644
--- a/hw/parallel.c
+++ b/hw/parallel.c
@@ -80,8 +80,13 @@  typedef struct ParallelState {
     int it_shift;
 } ParallelState;
 
+#define TYPE_ISA_PARALLEL "isa-parallel"
+#define ISA_PARALLEL(obj) \
+    OBJECT_CHECK(ISAParallelState, (obj), TYPE_ISA_PARALLEL)
+
 typedef struct ISAParallelState {
-    ISADevice dev;
+    ISADevice parent_obj;
+
     uint32_t index;
     uint32_t iobase;
     uint32_t isairq;
@@ -475,7 +480,7 @@  static const MemoryRegionPortio isa_parallel_portio_sw_list[] = {
 static int parallel_isa_initfn(ISADevice *dev)
 {
     static int index;
-    ISAParallelState *isa = DO_UPCAST(ISAParallelState, dev, dev);
+    ISAParallelState *isa = ISA_PARALLEL(dev);
     ParallelState *s = &isa->state;
     int base;
     uint8_t dummy;
@@ -599,8 +604,8 @@  static void parallel_isa_class_initfn(ObjectClass *klass, void *data)
     dc->props = parallel_isa_properties;
 }
 
-static TypeInfo parallel_isa_info = {
-    .name          = "isa-parallel",
+static const TypeInfo parallel_isa_info = {
+    .name          = TYPE_ISA_PARALLEL,
     .parent        = TYPE_ISA_DEVICE,
     .instance_size = sizeof(ISAParallelState),
     .class_init    = parallel_isa_class_initfn,