Patchwork [v2,04/12] i8254: QOM'ify some more

login
register
mail settings
Submitter Andreas Färber
Date June 7, 2013, 12:58 p.m.
Message ID <1370609900-21998-5-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/249700/
State New
Headers show

Comments

Andreas Färber - June 7, 2013, 12:58 p.m.
Introduce type constant and avoid DO_UPCAST().

Prepares for PIT realizefn.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/timer/i8254.c         |  4 ++--
 include/hw/timer/i8254.h | 18 +++++++++++-------
 2 files changed, 13 insertions(+), 9 deletions(-)

Patch

diff --git a/hw/timer/i8254.c b/hw/timer/i8254.c
index 20c0c36..efbca19 100644
--- a/hw/timer/i8254.c
+++ b/hw/timer/i8254.c
@@ -265,7 +265,7 @@  static void pit_irq_timer(void *opaque)
 
 static void pit_reset(DeviceState *dev)
 {
-    PITCommonState *pit = DO_UPCAST(PITCommonState, dev.qdev, dev);
+    PITCommonState *pit = PIT_COMMON(dev);
     PITChannelState *s;
 
     pit_reset_common(pit);
@@ -348,7 +348,7 @@  static void pit_class_initfn(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo pit_info = {
-    .name          = "isa-pit",
+    .name          = TYPE_I8254,
     .parent        = TYPE_PIT_COMMON,
     .instance_size = sizeof(PITCommonState),
     .class_init    = pit_class_initfn,
diff --git a/include/hw/timer/i8254.h b/include/hw/timer/i8254.h
index 75bb530..016f990 100644
--- a/include/hw/timer/i8254.h
+++ b/include/hw/timer/i8254.h
@@ -37,18 +37,22 @@  typedef struct PITChannelInfo {
     int out;
 } PITChannelInfo;
 
+#define TYPE_I8254 "isa-pit"
+
 static inline ISADevice *pit_init(ISABus *bus, int base, int isa_irq,
                                   qemu_irq alt_irq)
 {
-    ISADevice *dev;
+    DeviceState *dev;
+    ISADevice *d;
 
-    dev = isa_create(bus, "isa-pit");
-    qdev_prop_set_uint32(&dev->qdev, "iobase", base);
-    qdev_init_nofail(&dev->qdev);
-    qdev_connect_gpio_out(&dev->qdev, 0,
-                          isa_irq >= 0 ? isa_get_irq(dev, isa_irq) : alt_irq);
+    d = isa_create(bus, TYPE_I8254);
+    dev = DEVICE(d);
+    qdev_prop_set_uint32(dev, "iobase", base);
+    qdev_init_nofail(dev);
+    qdev_connect_gpio_out(dev, 0,
+                          isa_irq >= 0 ? isa_get_irq(d, isa_irq) : alt_irq);
 
-    return dev;
+    return d;
 }
 
 static inline ISADevice *kvm_pit_init(ISABus *bus, int base)