Patchwork [v3,042/197] isa: move methods from isadeviceinfo to isadeviceclass

login
register
mail settings
Submitter Anthony Liguori
Date Dec. 12, 2011, 8:18 p.m.
Message ID <1323721273-32404-43-git-send-email-aliguori@us.ibm.com>
Download mbox | patch
Permalink /patch/130843/
State New
Headers show

Comments

Anthony Liguori - Dec. 12, 2011, 8:18 p.m.
---
 hw/applesmc.c    |    8 +++++++-
 hw/cs4231a.c     |    8 +++++++-
 hw/debugcon.c    |    8 +++++++-
 hw/fdc.c         |    8 +++++++-
 hw/gus.c         |    8 +++++++-
 hw/i8254.c       |    8 +++++++-
 hw/i8259.c       |    8 +++++++-
 hw/ide/isa.c     |    8 +++++++-
 hw/isa-bus.c     |    8 ++++++--
 hw/isa.h         |    3 +--
 hw/m48t59.c      |    8 +++++++-
 hw/mc146818rtc.c |    8 +++++++-
 hw/ne2000-isa.c  |    8 +++++++-
 hw/parallel.c    |    8 +++++++-
 hw/pc.c          |    8 +++++++-
 hw/pckbd.c       |    8 +++++++-
 hw/sb16.c        |    8 +++++++-
 hw/serial.c      |    8 +++++++-
 hw/sga.c         |    8 +++++++-
 hw/vga-isa.c     |    8 +++++++-
 hw/vmmouse.c     |    8 +++++++-
 hw/vmport.c      |    8 +++++++-
 hw/wdt_ib700.c   |    8 +++++++-
 23 files changed, 154 insertions(+), 25 deletions(-)

Patch

diff --git a/hw/applesmc.c b/hw/applesmc.c
index c47b592..279c4d3 100644
--- a/hw/applesmc.c
+++ b/hw/applesmc.c
@@ -220,11 +220,17 @@  static int applesmc_isa_init(ISADevice *dev)
     return 0;
 }
 
+static void qdev_applesmc_class_init(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = applesmc_isa_init;
+}
+
 static ISADeviceInfo applesmc_isa_info = {
     .qdev.name  = "isa-applesmc",
     .qdev.size  = sizeof(struct AppleSMCStatus),
     .qdev.reset = qdev_applesmc_isa_reset,
-    .init       = applesmc_isa_init,
+    .qdev.class_init = qdev_applesmc_class_init,
     .qdev.props = (Property[]) {
         DEFINE_PROP_HEX32("iobase", struct AppleSMCStatus, iobase,
                           APPLESMC_DEFAULT_IOBASE),
diff --git a/hw/cs4231a.c b/hw/cs4231a.c
index a7e03a3..25af773 100644
--- a/hw/cs4231a.c
+++ b/hw/cs4231a.c
@@ -665,12 +665,18 @@  int cs4231a_init (qemu_irq *pic)
     return 0;
 }
 
+static void cs4231a_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = cs4231a_initfn;
+}
+
 static ISADeviceInfo cs4231a_info = {
     .qdev.name     = "cs4231a",
     .qdev.desc     = "Crystal Semiconductor CS4231A",
     .qdev.size     = sizeof (CSState),
     .qdev.vmsd     = &vmstate_cs4231a,
-    .init          = cs4231a_initfn,
+    .qdev.class_init = cs4231a_class_initfn,
     .qdev.props    = (Property[]) {
         DEFINE_PROP_HEX32  ("iobase",  CSState, port, 0x534),
         DEFINE_PROP_UINT32 ("irq",     CSState, irq,  9),
diff --git a/hw/debugcon.c b/hw/debugcon.c
index c9ee6d9..1490bfa 100644
--- a/hw/debugcon.c
+++ b/hw/debugcon.c
@@ -87,10 +87,16 @@  static int debugcon_isa_initfn(ISADevice *dev)
     return 0;
 }
 
+static void debugcon_isa_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = debugcon_isa_initfn;
+}
+
 static ISADeviceInfo debugcon_isa_info = {
     .qdev.name  = "isa-debugcon",
     .qdev.size  = sizeof(ISADebugconState),
-    .init       = debugcon_isa_initfn,
+    .qdev.class_init = debugcon_isa_class_initfn,
     .qdev.props = (Property[]) {
         DEFINE_PROP_HEX32("iobase", ISADebugconState, iobase, 0xe9),
         DEFINE_PROP_CHR("chardev",  ISADebugconState, state.chr),
diff --git a/hw/fdc.c b/hw/fdc.c
index ecaad09..dfeb138 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1969,8 +1969,14 @@  static const VMStateDescription vmstate_isa_fdc ={
     }
 };
 
+static void isabus_fdc_class_init1(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = isabus_fdc_init1;
+}
+
 static ISADeviceInfo isa_fdc_info = {
-    .init = isabus_fdc_init1,
+    .qdev.class_init = isabus_fdc_class_init1,
     .qdev.name  = "isa-fdc",
     .qdev.fw_name  = "fdc",
     .qdev.size  = sizeof(FDCtrlISABus),
diff --git a/hw/gus.c b/hw/gus.c
index b5eb548..49e0d16 100644
--- a/hw/gus.c
+++ b/hw/gus.c
@@ -299,12 +299,18 @@  int GUS_init (qemu_irq *pic)
     return 0;
 }
 
+static void gus_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = gus_initfn;
+}
+
 static ISADeviceInfo gus_info = {
     .qdev.name     = "gus",
     .qdev.desc     = "Gravis Ultrasound GF1",
     .qdev.size     = sizeof (GUSState),
     .qdev.vmsd     = &vmstate_gus,
-    .init          = gus_initfn,
+    .qdev.class_init          = gus_class_initfn,
     .qdev.props    = (Property[]) {
         DEFINE_PROP_UINT32 ("freq",    GUSState, freq,        44100),
         DEFINE_PROP_HEX32  ("iobase",  GUSState, port,        0x240),
diff --git a/hw/i8254.c b/hw/i8254.c
index 12571ef..5d10206 100644
--- a/hw/i8254.c
+++ b/hw/i8254.c
@@ -535,13 +535,19 @@  static int pit_initfn(ISADevice *dev)
     return 0;
 }
 
+static void pit_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = pit_initfn;
+}
+
 static ISADeviceInfo pit_info = {
     .qdev.name     = "isa-pit",
     .qdev.size     = sizeof(PITState),
     .qdev.vmsd     = &vmstate_pit,
     .qdev.reset    = pit_reset,
     .qdev.no_user  = 1,
-    .init          = pit_initfn,
+    .qdev.class_init          = pit_class_initfn,
     .qdev.props = (Property[]) {
         DEFINE_PROP_UINT32("irq", PITState, irq,  -1),
         DEFINE_PROP_HEX32("iobase", PITState, iobase,  -1),
diff --git a/hw/i8259.c b/hw/i8259.c
index ab519de..da34f2b 100644
--- a/hw/i8259.c
+++ b/hw/i8259.c
@@ -556,13 +556,19 @@  qemu_irq *i8259_init(qemu_irq parent_irq)
     return irq_set;
 }
 
+static void pic_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = pic_initfn;
+}
+
 static ISADeviceInfo i8259_info = {
     .qdev.name     = "isa-i8259",
     .qdev.size     = sizeof(PicState),
     .qdev.vmsd     = &vmstate_pic,
     .qdev.reset    = pic_reset,
     .qdev.no_user  = 1,
-    .init          = pic_initfn,
+    .qdev.class_init          = pic_class_initfn,
     .qdev.props = (Property[]) {
         DEFINE_PROP_HEX32("iobase", PicState, iobase,  -1),
         DEFINE_PROP_HEX32("elcr_addr", PicState, elcr_addr,  -1),
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index 01a9e59..aeca96d 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -94,11 +94,17 @@  ISADevice *isa_ide_init(int iobase, int iobase2, int isairq,
     return dev;
 }
 
+static void isa_ide_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = isa_ide_initfn;
+}
+
 static ISADeviceInfo isa_ide_info = {
     .qdev.name  = "isa-ide",
     .qdev.fw_name  = "ide",
     .qdev.size  = sizeof(ISAIDEState),
-    .init       = isa_ide_initfn,
+    .qdev.class_init       = isa_ide_class_initfn,
     .qdev.reset = isa_ide_reset,
     .qdev.props = (Property[]) {
         DEFINE_PROP_HEX32("iobase",  ISAIDEState, iobase,  0x1f0),
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 50131f7..9d02919 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -114,12 +114,16 @@  void isa_register_portio_list(ISADevice *dev, uint16_t start,
 static int isa_qdev_init(DeviceState *qdev, DeviceInfo *base)
 {
     ISADevice *dev = ISA_DEVICE(qdev);
-    ISADeviceInfo *info = DO_UPCAST(ISADeviceInfo, qdev, base);
+    ISADeviceClass *klass = ISA_DEVICE_GET_CLASS(dev);
 
     dev->isairq[0] = -1;
     dev->isairq[1] = -1;
 
-    return info->init(dev);
+    if (klass->init) {
+        return klass->init(dev);
+    }
+
+    return 0;
 }
 
 void isa_qdev_register(ISADeviceInfo *info)
diff --git a/hw/isa.h b/hw/isa.h
index d5fd7d7..a1afc7b 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -23,6 +23,7 @@  typedef struct ISADeviceInfo ISADeviceInfo;
 
 typedef struct ISADeviceClass {
     DeviceClass parent_class;
+    int (*init)(ISADevice *dev);
 } ISADeviceClass;
 
 struct ISADevice {
@@ -32,10 +33,8 @@  struct ISADevice {
     int ioport_id;
 };
 
-typedef int (*isa_qdev_initfn)(ISADevice *dev);
 struct ISADeviceInfo {
     DeviceInfo qdev;
-    isa_qdev_initfn init;
 };
 
 ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io);
diff --git a/hw/m48t59.c b/hw/m48t59.c
index a77937e..e58b48f 100644
--- a/hw/m48t59.c
+++ b/hw/m48t59.c
@@ -724,8 +724,14 @@  static int m48t59_init1(SysBusDevice *dev)
     return 0;
 }
 
+static void m48t59_init_class_isa1(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = m48t59_init_isa1;
+}
+
 static ISADeviceInfo m48t59_isa_info = {
-    .init = m48t59_init_isa1,
+    .qdev.class_init = m48t59_init_class_isa1,
     .qdev.name = "m48t59_isa",
     .qdev.size = sizeof(M48t59ISAState),
     .qdev.reset = m48t59_reset_isa,
diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index d5b737a..e2acf12 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -694,12 +694,18 @@  ISADevice *rtc_init(int base_year, qemu_irq intercept_irq)
     return dev;
 }
 
+static void rtc_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = rtc_initfn;
+}
+
 static ISADeviceInfo mc146818rtc_info = {
     .qdev.name     = "mc146818rtc",
     .qdev.size     = sizeof(RTCState),
     .qdev.no_user  = 1,
     .qdev.vmsd     = &vmstate_rtc,
-    .init          = rtc_initfn,
+    .qdev.class_init          = rtc_class_initfn,
     .qdev.props    = (Property[]) {
         DEFINE_PROP_INT32("base_year", RTCState, base_year, 1980),
         DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/ne2000-isa.c b/hw/ne2000-isa.c
index 9e89256..da86a61 100644
--- a/hw/ne2000-isa.c
+++ b/hw/ne2000-isa.c
@@ -82,10 +82,16 @@  static int isa_ne2000_initfn(ISADevice *dev)
     return 0;
 }
 
+static void isa_ne2000_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = isa_ne2000_initfn;
+}
+
 static ISADeviceInfo ne2000_isa_info = {
     .qdev.name  = "ne2k_isa",
     .qdev.size  = sizeof(ISANE2000State),
-    .init       = isa_ne2000_initfn,
+    .qdev.class_init       = isa_ne2000_class_initfn,
     .qdev.props = (Property[]) {
         DEFINE_PROP_HEX32("iobase", ISANE2000State, iobase, 0x300),
         DEFINE_PROP_UINT32("irq",   ISANE2000State, isairq, 9),
diff --git a/hw/parallel.c b/hw/parallel.c
index 8494d94..ac7dc46 100644
--- a/hw/parallel.c
+++ b/hw/parallel.c
@@ -586,10 +586,16 @@  bool parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq,
     return true;
 }
 
+static void parallel_isa_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = parallel_isa_initfn;
+}
+
 static ISADeviceInfo parallel_isa_info = {
     .qdev.name  = "isa-parallel",
     .qdev.size  = sizeof(ISAParallelState),
-    .init       = parallel_isa_initfn,
+    .qdev.class_init       = parallel_isa_class_initfn,
     .qdev.props = (Property[]) {
         DEFINE_PROP_UINT32("index", ISAParallelState, index,   -1),
         DEFINE_PROP_HEX32("iobase", ISAParallelState, iobase,  -1),
diff --git a/hw/pc.c b/hw/pc.c
index 47e6fb9..4e4dc6d 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -496,13 +496,19 @@  static int port92_initfn(ISADevice *dev)
     return 0;
 }
 
+static void port92_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = port92_initfn;
+}
+
 static ISADeviceInfo port92_info = {
     .qdev.name     = "port92",
     .qdev.size     = sizeof(Port92State),
     .qdev.vmsd     = &vmstate_port92_isa,
     .qdev.no_user  = 1,
     .qdev.reset    = port92_reset,
-    .init          = port92_initfn,
+    .qdev.class_init          = port92_class_initfn,
 };
 
 static void port92_register(void)
diff --git a/hw/pckbd.c b/hw/pckbd.c
index 06b40c5..fe5cc6e 100644
--- a/hw/pckbd.c
+++ b/hw/pckbd.c
@@ -497,12 +497,18 @@  static int i8042_initfn(ISADevice *dev)
     return 0;
 }
 
+static void i8042_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = i8042_initfn;
+}
+
 static ISADeviceInfo i8042_info = {
     .qdev.name     = "i8042",
     .qdev.size     = sizeof(ISAKBDState),
     .qdev.vmsd     = &vmstate_kbd_isa,
     .qdev.no_user  = 1,
-    .init          = i8042_initfn,
+    .qdev.class_init          = i8042_class_initfn,
 };
 
 static void i8042_register(void)
diff --git a/hw/sb16.c b/hw/sb16.c
index f0658ac..f7a6b7e 100644
--- a/hw/sb16.c
+++ b/hw/sb16.c
@@ -1391,12 +1391,18 @@  int SB16_init (qemu_irq *pic)
     return 0;
 }
 
+static void sb16_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = sb16_initfn;
+}
+
 static ISADeviceInfo sb16_info = {
     .qdev.name     = "sb16",
     .qdev.desc     = "Creative Sound Blaster 16",
     .qdev.size     = sizeof (SB16State),
     .qdev.vmsd     = &vmstate_sb16,
-    .init          = sb16_initfn,
+    .qdev.class_init          = sb16_class_initfn,
     .qdev.props    = (Property[]) {
         DEFINE_PROP_HEX32  ("version", SB16State, ver,  0x0405), /* 4.5 */
         DEFINE_PROP_HEX32  ("iobase",  SB16State, port, 0x220),
diff --git a/hw/serial.c b/hw/serial.c
index d35c7a9..74ed5fe 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -879,11 +879,17 @@  SerialState *serial_mm_init(MemoryRegion *address_space,
     return s;
 }
 
+static void serial_isa_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = serial_isa_initfn;
+}
+
 static ISADeviceInfo serial_isa_info = {
     .qdev.name  = "isa-serial",
     .qdev.size  = sizeof(ISASerialState),
     .qdev.vmsd  = &vmstate_isa_serial,
-    .init       = serial_isa_initfn,
+    .qdev.class_init       = serial_isa_class_initfn,
     .qdev.props = (Property[]) {
         DEFINE_PROP_UINT32("index", ISASerialState, index,   -1),
         DEFINE_PROP_HEX32("iobase", ISASerialState, iobase,  -1),
diff --git a/hw/sga.c b/hw/sga.c
index 7ef750a..6801995 100644
--- a/hw/sga.c
+++ b/hw/sga.c
@@ -41,11 +41,17 @@  static int isa_cirrus_vga_initfn(ISADevice *dev)
     return 0;
 }
 
+static void isa_cirrus_vga_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = isa_cirrus_vga_initfn;
+}
+
 static ISADeviceInfo sga_info = {
     .qdev.name    = "sga",
     .qdev.desc    = "Serial Graphics Adapter",
     .qdev.size    = sizeof(ISASGAState),
-    .init         = isa_cirrus_vga_initfn,
+    .qdev.class_init         = isa_cirrus_vga_class_initfn,
 };
 
 static void sga_register(void)
diff --git a/hw/vga-isa.c b/hw/vga-isa.c
index 4825313..ba7f9bf 100644
--- a/hw/vga-isa.c
+++ b/hw/vga-isa.c
@@ -69,12 +69,18 @@  static int vga_initfn(ISADevice *dev)
     return 0;
 }
 
+static void vga_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = vga_initfn;
+}
+
 static ISADeviceInfo vga_info = {
     .qdev.name     = "isa-vga",
     .qdev.size     = sizeof(ISAVGAState),
     .qdev.vmsd     = &vmstate_vga_common,
     .qdev.reset     = vga_reset_isa,
-    .init          = vga_initfn,
+    .qdev.class_init          = vga_class_initfn,
 };
 
 static void vga_register(void)
diff --git a/hw/vmmouse.c b/hw/vmmouse.c
index 1113f33..f936089 100644
--- a/hw/vmmouse.c
+++ b/hw/vmmouse.c
@@ -269,8 +269,14 @@  static int vmmouse_initfn(ISADevice *dev)
     return 0;
 }
 
+static void vmmouse_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = vmmouse_initfn;
+}
+
 static ISADeviceInfo vmmouse_info = {
-    .init          = vmmouse_initfn,
+    .qdev.class_init          = vmmouse_class_initfn,
     .qdev.name     = "vmmouse",
     .qdev.size     = sizeof(VMMouseState),
     .qdev.vmsd     = &vmstate_vmmouse,
diff --git a/hw/vmport.c b/hw/vmport.c
index b5c6fa1..7468812 100644
--- a/hw/vmport.c
+++ b/hw/vmport.c
@@ -144,11 +144,17 @@  static int vmport_initfn(ISADevice *dev)
     return 0;
 }
 
+static void vmport_class_initfn(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = vmport_initfn;
+}
+
 static ISADeviceInfo vmport_info = {
     .qdev.name     = "vmport",
     .qdev.size     = sizeof(VMPortState),
     .qdev.no_user  = 1,
-    .init          = vmport_initfn,
+    .qdev.class_init          = vmport_class_initfn,
 };
 
 static void vmport_dev_register(void)
diff --git a/hw/wdt_ib700.c b/hw/wdt_ib700.c
index 81f22d0..3869e91 100644
--- a/hw/wdt_ib700.c
+++ b/hw/wdt_ib700.c
@@ -120,12 +120,18 @@  static WatchdogTimerModel model = {
     .wdt_description = "iBASE 700",
 };
 
+static void wdt_ib700_class_init(ObjectClass *klass, void *data)
+{
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = wdt_ib700_init;
+}
+
 static ISADeviceInfo wdt_ib700_info = {
     .qdev.name  = "ib700",
     .qdev.size  = sizeof(IB700State),
     .qdev.vmsd  = &vmstate_ib700,
     .qdev.reset = wdt_ib700_reset,
-    .init       = wdt_ib700_init,
+    .qdev.class_init       = wdt_ib700_class_init,
 };
 
 static void wdt_ib700_register_devices(void)