From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkwFR-0000xf-Ov for qemu-devel@nongnu.org; Fri, 07 Jun 2013 08:58:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkwFP-00084j-Pg for qemu-devel@nongnu.org; Fri, 07 Jun 2013 08:58:29 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53782 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkwFP-00084G-Fe for qemu-devel@nongnu.org; Fri, 07 Jun 2013 08:58:27 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Fri, 7 Jun 2013 14:58:13 +0200 Message-Id: <1370609900-21998-6-git-send-email-afaerber@suse.de> In-Reply-To: <1370609900-21998-1-git-send-email-afaerber@suse.de> References: <1370609900-21998-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v2 05/12] kvm/i8254: QOM'ify some more List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , anthony@codemonkey.ws Introduce type constant and cast macro to obsolete DO_UPCAST(). Prepares for PIT realizefn. Signed-off-by: Andreas F=C3=A4rber --- hw/i386/kvm/i8254.c | 19 +++++++++++-------- include/hw/timer/i8254.h | 13 ++++++++----- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c index da90711..4ac5551 100644 --- a/hw/i386/kvm/i8254.c +++ b/hw/i386/kvm/i8254.c @@ -32,8 +32,11 @@ =20 #define CALIBRATION_ROUNDS 3 =20 +#define KVM_PIT(obj) OBJECT_CHECK(KVMPITState, (obj), TYPE_KVM_I8254) + typedef struct KVMPITState { - PITCommonState pit; + PITCommonState parent_obj; + LostTickPolicy lost_tick_policy; bool vm_stopped; int64_t kernel_clock_offset; @@ -70,7 +73,7 @@ static void kvm_pit_update_clock_offset(KVMPITState *s) =20 static void kvm_pit_get(PITCommonState *pit) { - KVMPITState *s =3D DO_UPCAST(KVMPITState, pit, pit); + KVMPITState *s =3D KVM_PIT(pit); struct kvm_pit_state2 kpit; struct kvm_pit_channel_state *kchan; struct PITChannelState *sc; @@ -124,7 +127,7 @@ static void kvm_pit_get(PITCommonState *pit) =20 static void kvm_pit_put(PITCommonState *pit) { - KVMPITState *s =3D DO_UPCAST(KVMPITState, pit, pit); + KVMPITState *s =3D KVM_PIT(pit); struct kvm_pit_state2 kpit; struct kvm_pit_channel_state *kchan; struct PITChannelState *sc; @@ -200,7 +203,7 @@ static void kvm_pit_get_channel_info(PITCommonState *= s, PITChannelState *sc, =20 static void kvm_pit_reset(DeviceState *dev) { - PITCommonState *s =3D DO_UPCAST(PITCommonState, dev.qdev, dev); + PITCommonState *s =3D PIT_COMMON(dev); =20 pit_reset_common(s); =20 @@ -229,14 +232,14 @@ static void kvm_pit_vm_state_change(void *opaque, i= nt running, s->vm_stopped =3D false; } else { kvm_pit_update_clock_offset(s); - kvm_pit_get(&s->pit); + kvm_pit_get(PIT_COMMON(s)); s->vm_stopped =3D true; } } =20 static int kvm_pit_initfn(PITCommonState *pit) { - KVMPITState *s =3D DO_UPCAST(KVMPITState, pit, pit); + KVMPITState *s =3D KVM_PIT(pit); struct kvm_pit_config config =3D { .flags =3D 0, }; @@ -282,7 +285,7 @@ static int kvm_pit_initfn(PITCommonState *pit) } =20 static Property kvm_pit_properties[] =3D { - DEFINE_PROP_HEX32("iobase", KVMPITState, pit.iobase, -1), + DEFINE_PROP_HEX32("iobase", PITCommonState, iobase, -1), DEFINE_PROP_LOSTTICKPOLICY("lost_tick_policy", KVMPITState, lost_tick_policy, LOST_TICK_DELAY), DEFINE_PROP_END_OF_LIST(), @@ -303,7 +306,7 @@ static void kvm_pit_class_init(ObjectClass *klass, vo= id *data) } =20 static const TypeInfo kvm_pit_info =3D { - .name =3D "kvm-pit", + .name =3D TYPE_KVM_I8254, .parent =3D TYPE_PIT_COMMON, .instance_size =3D sizeof(KVMPITState), .class_init =3D kvm_pit_class_init, diff --git a/include/hw/timer/i8254.h b/include/hw/timer/i8254.h index 016f990..4349033 100644 --- a/include/hw/timer/i8254.h +++ b/include/hw/timer/i8254.h @@ -38,6 +38,7 @@ typedef struct PITChannelInfo { } PITChannelInfo; =20 #define TYPE_I8254 "isa-pit" +#define TYPE_KVM_I8254 "kvm-pit" =20 static inline ISADevice *pit_init(ISABus *bus, int base, int isa_irq, qemu_irq alt_irq) @@ -57,13 +58,15 @@ static inline ISADevice *pit_init(ISABus *bus, int ba= se, int isa_irq, =20 static inline ISADevice *kvm_pit_init(ISABus *bus, int base) { - ISADevice *dev; + DeviceState *dev; + ISADevice *d; =20 - dev =3D isa_create(bus, "kvm-pit"); - qdev_prop_set_uint32(&dev->qdev, "iobase", base); - qdev_init_nofail(&dev->qdev); + d =3D isa_create(bus, TYPE_KVM_I8254); + dev =3D DEVICE(d); + qdev_prop_set_uint32(dev, "iobase", base); + qdev_init_nofail(dev); =20 - return dev; + return d; } =20 void pit_set_gate(ISADevice *dev, int channel, int val); --=20 1.8.1.4