[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v1 7/7] i8254: Remove [KVM]PITClass
From: |
peter . crosthwaite |
Subject: |
[Qemu-devel] [RFC PATCH v1 7/7] i8254: Remove [KVM]PITClass |
Date: |
Tue, 18 Jun 2013 19:48:42 +1000 |
From: Peter Crosthwaite <address@hidden>
[KVM]PITClass is only needed for super-class realize function access.
Just use Super classes for realize access and remove [KVM]PITClass
completely.
Signed-off-by: Peter Crosthwaite <address@hidden>
---
hw/i386/kvm/i8254.c | 17 ++---------------
hw/timer/i8254.c | 16 ++--------------
2 files changed, 4 insertions(+), 29 deletions(-)
diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c
index 93a3669..f344a23 100644
--- a/hw/i386/kvm/i8254.c
+++ b/hw/i386/kvm/i8254.c
@@ -33,10 +33,6 @@
#define CALIBRATION_ROUNDS 3
#define KVM_PIT(obj) OBJECT_CHECK(KVMPITState, (obj), TYPE_KVM_I8254)
-#define KVM_PIT_CLASS(class) \
- OBJECT_CLASS_CHECK(KVMPITClass, (class), TYPE_KVM_I8254)
-#define KVM_PIT_GET_CLASS(obj) \
- OBJECT_GET_CLASS(KVMPITClass, (obj), TYPE_KVM_I8254)
typedef struct KVMPITState {
PITCommonState parent_obj;
@@ -46,12 +42,6 @@ typedef struct KVMPITState {
int64_t kernel_clock_offset;
} KVMPITState;
-typedef struct KVMPITClass {
- PITCommonClass parent_class;
-
- DeviceRealize parent_realize;
-} KVMPITClass;
-
static int64_t abs64(int64_t v)
{
return v < 0 ? -v : v;
@@ -250,7 +240,7 @@ static void kvm_pit_vm_state_change(void *opaque, int
running,
static void kvm_pit_realizefn(DeviceState *dev, Error **errp)
{
PITCommonState *pit = PIT_COMMON(dev);
- KVMPITClass *kpc = KVM_PIT_GET_CLASS(dev);
+ DeviceClass *dc_super = DEVICE_GET_SUPER_CLASS(dev, TYPE_KVM_I8254);
KVMPITState *s = KVM_PIT(pit);
struct kvm_pit_config config = {
.flags = 0,
@@ -294,7 +284,7 @@ static void kvm_pit_realizefn(DeviceState *dev, Error
**errp)
qemu_add_vm_change_state_handler(kvm_pit_vm_state_change, s);
- kpc->parent_realize(dev, errp);
+ dc_super->realize(dev, errp);
}
static Property kvm_pit_properties[] = {
@@ -306,11 +296,9 @@ static Property kvm_pit_properties[] = {
static void kvm_pit_class_init(ObjectClass *klass, void *data)
{
- KVMPITClass *kpc = KVM_PIT_CLASS(klass);
PITCommonClass *k = PIT_COMMON_CLASS(klass);
DeviceClass *dc = DEVICE_CLASS(klass);
- kpc->parent_realize = dc->realize;
dc->realize = kvm_pit_realizefn;
k->set_channel_gate = kvm_pit_set_gate;
k->get_channel_info = kvm_pit_get_channel_info;
@@ -325,7 +313,6 @@ static const TypeInfo kvm_pit_info = {
.parent = TYPE_PIT_COMMON,
.instance_size = sizeof(KVMPITState),
.class_init = kvm_pit_class_init,
- .class_size = sizeof(KVMPITClass),
};
static void kvm_pit_register(void)
diff --git a/hw/timer/i8254.c b/hw/timer/i8254.c
index 16c8dd6..afccb28 100644
--- a/hw/timer/i8254.c
+++ b/hw/timer/i8254.c
@@ -35,15 +35,6 @@
#define RW_STATE_WORD0 3
#define RW_STATE_WORD1 4
-#define PIT_CLASS(class) OBJECT_CLASS_CHECK(PITClass, (class), TYPE_I8254)
-#define PIT_GET_CLASS(obj) OBJECT_GET_CLASS(PITClass, (obj), TYPE_I8254)
-
-typedef struct PITClass {
- PITCommonClass parent_class;
-
- DeviceRealize parent_realize;
-} PITClass;
-
static void pit_irq_timer_update(PITChannelState *s, int64_t current_time);
static int pit_get_count(PITChannelState *s)
@@ -325,7 +316,7 @@ static void pit_post_load(PITCommonState *s)
static void pit_realizefn(DeviceState *dev, Error **err)
{
PITCommonState *pit = PIT_COMMON(dev);
- PITClass *pc = PIT_GET_CLASS(dev);
+ DeviceClass *dc_super = DEVICE_GET_SUPER_CLASS(dev, TYPE_I8254);
PITChannelState *s;
s = &pit->channels[0];
@@ -337,7 +328,7 @@ static void pit_realizefn(DeviceState *dev, Error **err)
qdev_init_gpio_in(dev, pit_irq_control, 1);
- pc->parent_realize(dev, err);
+ dc_super->realize(dev, err);
}
static Property pit_properties[] = {
@@ -347,11 +338,9 @@ static Property pit_properties[] = {
static void pit_class_initfn(ObjectClass *klass, void *data)
{
- PITClass *pc = PIT_CLASS(klass);
PITCommonClass *k = PIT_COMMON_CLASS(klass);
DeviceClass *dc = DEVICE_CLASS(klass);
- pc->parent_realize = dc->realize;
dc->realize = pit_realizefn;
k->set_channel_gate = pit_set_channel_gate;
k->get_channel_info = pit_get_channel_info_common;
@@ -365,7 +354,6 @@ static const TypeInfo pit_info = {
.parent = TYPE_PIT_COMMON,
.instance_size = sizeof(PITCommonState),
.class_init = pit_class_initfn,
- .class_size = sizeof(PITClass),
};
static void pit_register_types(void)
--
1.8.3.rc1.44.gb387c77.dirty
- [Qemu-devel] [RFC PATCH v1 0/7] QOM Super class access, peter . crosthwaite, 2013/06/18
- [Qemu-devel] [RFC PATCH v1 1/7] target-arm/cpu.c: delete un-needed instance/class sizes, peter . crosthwaite, 2013/06/18
- [Qemu-devel] [RFC PATCH v1 2/7] qom: Add super class accessor, peter . crosthwaite, 2013/06/18
- [Qemu-devel] [RFC PATCH v1 3/7] qdev-core: Introduce DEVICE super class cast macros, peter . crosthwaite, 2013/06/18
- [Qemu-devel] [RFC PATCH v1 4/7] qom/cpu: Introduce CPU super class cast macros, peter . crosthwaite, 2013/06/18
- [Qemu-devel] [RFC PATCH v1 5/7] target-arm: Remove ARMCPUClass, peter . crosthwaite, 2013/06/18
- [Qemu-devel] [RFC PATCH v1 6/7] target-microblaze: Remove MicroblazeCPUClass, peter . crosthwaite, 2013/06/18
- [Qemu-devel] [RFC PATCH v1 7/7] i8254: Remove [KVM]PITClass,
peter . crosthwaite <=
- Re: [Qemu-devel] [RFC PATCH v1 0/7] QOM Super class access, Andreas Färber, 2013/06/18
- Re: [Qemu-devel] [RFC PATCH v1 0/7] QOM Super class access, Michael S. Tsirkin, 2013/06/18