Introduce type constant and avoid DO_UPCAST(). Cc: qemu-devel@nongnu.org Cc: "Andreas Färber" <afaer...@suse.de> Cc: Paolo Bonzini <pbonz...@redhat.com> Cc: Eduardo Habkost <ehabk...@redhat.com> Cc: Igor Mammedov <imamm...@redhat.com> Cc: Anthony Liguori <aligu...@us.ibm.com> Signed-off-by: Hu Tao <hu...@cn.fujitsu.com> --- hw/i386/kvm/clock.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c index 74aa240..eaad880 100644 --- a/hw/i386/kvm/clock.c +++ b/hw/i386/kvm/clock.c @@ -22,6 +22,9 @@ #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 { SysBusDevice busdev; uint64_t clock; @@ -89,13 +92,13 @@ static void kvmclock_vm_state_change(void *opaque, int running, static void kvmclock_realize(DeviceState *dev, Error **errp) { - KVMClockState *s = DO_UPCAST(KVMClockState, busdev.qdev, dev); + KVMClockState *s = KVM_CLOCK(dev); qemu_add_vm_change_state_handler(kvmclock_vm_state_change, s); } static const VMStateDescription kvmclock_vmsd = { - .name = "kvmclock", + .name = TYPE_KVM_CLOCK, .version_id = 1, .minimum_version_id = 1, .minimum_version_id_old = 1, @@ -117,7 +120,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 +132,7 @@ void kvmclock_create(void) if (kvm_enabled() && first_cpu->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); } } -- 1.8.3.1