Patchwork [RFC,21/34] sb16: QOM'ify

login
register
mail settings
Submitter Andreas Färber
Date Nov. 26, 2012, 12:12 a.m.
Message ID <1353888766-6951-22-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/201590/
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/sb16.c |   16 +++++++++-------
 1 Datei geändert, 9 Zeilen hinzugefügt(+), 7 Zeilen entfernt(-)

Patch

diff --git a/hw/sb16.c b/hw/sb16.c
index 523ab0d..b7e93a4 100644
--- a/hw/sb16.c
+++ b/hw/sb16.c
@@ -47,8 +47,12 @@ 
 
 static const char e3[] = "COPYRIGHT (C) CREATIVE TECHNOLOGY LTD, 1992.";
 
+#define TYPE_SB16 "sb16"
+#define SB16(obj) OBJECT_CHECK (SB16State, (obj), TYPE_SB16)
+
 typedef struct SB16State {
-    ISADevice dev;
+    ISADevice parent_obj;
+
     QEMUSoundCard card;
     qemu_irq pic;
     uint32_t irq;
@@ -1354,9 +1358,7 @@  static const MemoryRegionPortio sb16_ioport_list[] = {
 
 static int sb16_initfn (ISADevice *dev)
 {
-    SB16State *s;
-
-    s = DO_UPCAST (SB16State, dev, dev);
+    SB16State *s = SB16 (dev);
 
     s->cmd = -1;
     isa_init_irq (dev, &s->pic, s->irq);
@@ -1386,7 +1388,7 @@  static int sb16_initfn (ISADevice *dev)
 
 int SB16_init (ISABus *bus)
 {
-    isa_create_simple (bus, "sb16");
+    isa_create_simple (bus, TYPE_SB16);
     return 0;
 }
 
@@ -1409,8 +1411,8 @@  static void sb16_class_initfn (ObjectClass *klass, void *data)
     dc->props = sb16_properties;
 }
 
-static TypeInfo sb16_info = {
-    .name          = "sb16",
+static const TypeInfo sb16_info = {
+    .name          = TYPE_SB16,
     .parent        = TYPE_ISA_DEVICE,
     .instance_size = sizeof (SB16State),
     .class_init    = sb16_class_initfn,