From 98bdc0d7ff93f2ab39c0634c744cc7f4a8ac7399 Mon Sep 17 00:00:00 2001 From: Hu Tao Date: Mon, 1 Jul 2013 18:18:38 +0800 Subject: kvm/clock: QOM'ify some more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce type constant and avoid FROM_SYSBUS(). Signed-off-by: Hu Tao [AF: Renamed parent field] Signed-off-by: Andreas Färber --- hw/i386/kvm/clock.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'hw/i386/kvm/clock.c') diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c index 1022d67178..62654584d6 100644 --- a/hw/i386/kvm/clock.c +++ b/hw/i386/kvm/clock.c @@ -22,8 +22,14 @@ #include #include +#define TYPE_KVM_CLOCK "kvmclock" +#define KVM_CLOCK(obj) OBJECT_CHECK(KVMClockState, (obj), TYPE_KVM_CLOCK) + typedef struct KVMClockState { + /*< private >*/ SysBusDevice busdev; + /*< public >*/ + uint64_t clock; bool clock_valid; } KVMClockState; @@ -87,7 +93,7 @@ static void kvmclock_vm_state_change(void *opaque, int running, static int kvmclock_init(SysBusDevice *dev) { - KVMClockState *s = FROM_SYSBUS(KVMClockState, dev); + KVMClockState *s = KVM_CLOCK(dev); qemu_add_vm_change_state_handler(kvmclock_vm_state_change, s); return 0; @@ -115,7 +121,7 @@ static void kvmclock_class_init(ObjectClass *klass, void *data) } static const TypeInfo kvmclock_info = { - .name = "kvmclock", + .name = TYPE_KVM_CLOCK, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(KVMClockState), .class_init = kvmclock_class_init, @@ -129,7 +135,7 @@ void kvmclock_create(void) if (kvm_enabled() && cpu->env.features[FEAT_KVM] & ((1ULL << KVM_FEATURE_CLOCKSOURCE) | (1ULL << KVM_FEATURE_CLOCKSOURCE2))) { - sysbus_create_simple("kvmclock", -1, NULL); + sysbus_create_simple(TYPE_KVM_CLOCK, -1, NULL); } } -- cgit v1.2.3