Patchwork [v2,22/26] kvmclock: QOM'ify some more

login
register
mail settings
Submitter Hu Tao
Date July 1, 2013, 10:18 a.m.
Message ID <7ad17b06154e798942989a622136468ae7d726f1.1372673778.git.hutao@cn.fujitsu.com>
Download mbox | patch
Permalink /patch/256076/
State New
Headers show

Comments

Hu Tao - July 1, 2013, 10:18 a.m.
Introduce type constant and avoid FROM_SYSBUS().

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
---
 hw/i386/kvm/clock.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
Andreas Färber - July 16, 2013, 2 p.m.
Am 01.07.2013 12:18, schrieb Hu Tao:
> Introduce type constant and avoid FROM_SYSBUS().
> 
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
>  hw/i386/kvm/clock.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

Thanks, by now I've picked up all remaining QOM cast patches (and
renamed and marked up their parent field):
https://github.com/afaerber/qemu-cpu/commits/qom-next

The remaining realizefn patches still need some calm review time.

Andreas

Patch

diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c
index 87d4d0f..fcdcbca 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,7 +92,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;
@@ -119,7 +122,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,
@@ -131,7 +134,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);
     }
 }