diff options
author | Hu Tao <hutao@cn.fujitsu.com> | 2013-07-01 18:18:38 +0800 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2013-07-23 00:37:35 +0200 |
commit | 98bdc0d7ff93f2ab39c0634c744cc7f4a8ac7399 (patch) | |
tree | 8949dfde10d57c35c1971c82efd811a947f9b07c /hw/i386 | |
parent | 02f9a6f5da74251e1e5685ae57643d45c3fb6c30 (diff) | |
download | qemu-98bdc0d7ff93f2ab39c0634c744cc7f4a8ac7399.zip qemu-98bdc0d7ff93f2ab39c0634c744cc7f4a8ac7399.tar.gz qemu-98bdc0d7ff93f2ab39c0634c744cc7f4a8ac7399.tar.bz2 |
kvm/clock: QOM'ify some more
Introduce type constant and avoid FROM_SYSBUS().
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
[AF: Renamed parent field]
Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/i386')
-rw-r--r-- | hw/i386/kvm/clock.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c index 1022d67..6265458 100644 --- a/hw/i386/kvm/clock.c +++ b/hw/i386/kvm/clock.c @@ -22,8 +22,14 @@ #include <linux/kvm.h> #include <linux/kvm_para.h> +#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); } } |