Patchwork [RFC,22/34] serial: QOM'ify ISA serial

login
register
mail settings
Submitter Andreas Färber
Date Nov. 26, 2012, 12:12 a.m.
Message ID <1353888766-6951-23-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/201607/
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/serial-isa.c |   13 ++++++++-----
 hw/serial.h     |    1 +
 2 Dateien geändert, 9 Zeilen hinzugefügt(+), 5 Zeilen entfernt(-)

Patch

diff --git a/hw/serial-isa.c b/hw/serial-isa.c
index 96c78f7..904cc41 100644
--- a/hw/serial-isa.c
+++ b/hw/serial-isa.c
@@ -26,8 +26,11 @@ 
 #include "serial.h"
 #include "isa.h"
 
+#define ISA_SERIAL(obj) OBJECT_CHECK(ISASerialState, (obj), TYPE_ISA_SERIAL)
+
 typedef struct ISASerialState {
-    ISADevice dev;
+    ISADevice parent_obj;
+
     uint32_t index;
     uint32_t iobase;
     uint32_t isairq;
@@ -44,7 +47,7 @@  static const int isa_serial_irq[MAX_SERIAL_PORTS] = {
 static int serial_isa_initfn(ISADevice *dev)
 {
     static int index;
-    ISASerialState *isa = DO_UPCAST(ISASerialState, dev, dev);
+    ISASerialState *isa = ISA_SERIAL(dev);
     SerialState *s = &isa->state;
 
     if (isa->index == -1) {
@@ -99,8 +102,8 @@  static void serial_isa_class_initfn(ObjectClass *klass, void *data)
     dc->props = serial_isa_properties;
 }
 
-static TypeInfo serial_isa_info = {
-    .name          = "isa-serial",
+static const TypeInfo serial_isa_info = {
+    .name          = TYPE_ISA_SERIAL,
     .parent        = TYPE_ISA_DEVICE,
     .instance_size = sizeof(ISASerialState),
     .class_init    = serial_isa_class_initfn,
@@ -117,7 +120,7 @@  bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr)
 {
     ISADevice *dev;
 
-    dev = isa_try_create(bus, "isa-serial");
+    dev = isa_try_create(bus, TYPE_ISA_SERIAL);
     if (!dev) {
         return false;
     }
diff --git a/hw/serial.h b/hw/serial.h
index ed1a5cd..bb06366 100644
--- a/hw/serial.h
+++ b/hw/serial.h
@@ -96,4 +96,5 @@  SerialState *serial_mm_init(MemoryRegion *address_space,
                             CharDriverState *chr, enum device_endian end);
 
 /* serial-isa.c */
+#define TYPE_ISA_SERIAL "isa-serial"
 bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr);