Received: from eggs.gnu.org ([208.118.235.92]:33682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TcmKa-0007b5-Ts for qemu-devel@nongnu.org; Sun, 25 Nov 2012 19:13:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TcmKU-0000KD-D0 for qemu-devel@nongnu.org; Sun, 25 Nov 2012 19:13:48 -0500 Received: from cantor2.suse.de ([195.135.220.15]:46241 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TcmKT-0000IW-Q2 for qemu-devel@nongnu.org; Sun, 25 Nov 2012 19:13:42 -0500 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 26 Nov 2012 01:12:42 +0100 Message-Id: <1353888766-6951-31-git-send-email-afaerber@suse.de> In-Reply-To: <1353888766-6951-1-git-send-email-afaerber@suse.de> References: <1353888766-6951-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] [RFC 30/34] 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/i8254.h | 3 ++- hw/kvm/i8254.c | 21 ++++++++++++--------- 2 Dateien ge=C3=A4ndert, 14 Zeilen hinzugef=C3=BCgt(+), 10 Zeilen entfer= nt(-) diff --git a/hw/i8254.h b/hw/i8254.h index 2566bac..cfa8dc9 100644 --- a/hw/i8254.h +++ b/hw/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,7 +58,7 @@ static inline ISADevice *kvm_pit_init(ISABus *bus, int = base) { ISADevice *dev; =20 - dev =3D isa_create(bus, "kvm-pit"); + dev =3D isa_create(bus, TYPE_KVM_I8254); qdev_prop_set_uint32(&dev->qdev, "iobase", base); qdev_init_nofail(&dev->qdev); =20 diff --git a/hw/kvm/i8254.c b/hw/kvm/i8254.c index 53d13e3..420d5ad 100644 --- a/hw/kvm/i8254.c +++ b/hw/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(), @@ -302,8 +305,8 @@ static void kvm_pit_class_init(ObjectClass *klass, vo= id *data) dc->props =3D kvm_pit_properties; } =20 -static TypeInfo kvm_pit_info =3D { - .name =3D "kvm-pit", +static const TypeInfo kvm_pit_info =3D { + .name =3D TYPE_KVM_I8254, .parent =3D TYPE_PIT_COMMON, .instance_size =3D sizeof(KVMPITState), .class_init =3D kvm_pit_class_init, --=20 1.7.10.4