Patchwork [v2,04/26] i440fx-pcihost: use realize for i440fx-pcihost

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

Comments

Hu Tao - July 1, 2013, 10:18 a.m.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
---
 hw/pci-host/piix.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)
Andreas Färber - July 7, 2013, 9:24 p.m.
Am 01.07.2013 12:18, schrieb Hu Tao:
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
>  hw/pci-host/piix.c | 25 +++++++++++++++----------
>  1 file changed, 15 insertions(+), 10 deletions(-)

Thanks, rebased and applied to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next

Andreas

Patch

diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index f9e68c3..801341a 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -197,21 +197,26 @@  static const VMStateDescription vmstate_i440fx = {
     }
 };
 
-static int i440fx_pcihost_initfn(SysBusDevice *dev)
+static void i440fx_pcihost_initfn(Object *obj)
 {
-    PCIHostState *s = PCI_HOST_BRIDGE(dev);
+    PCIHostState *s = PCI_HOST_BRIDGE(obj);
 
     memory_region_init_io(&s->conf_mem, &pci_host_conf_le_ops, s,
                           "pci-conf-idx", 4);
-    sysbus_add_io(dev, 0xcf8, &s->conf_mem);
-    sysbus_init_ioports(&s->busdev, 0xcf8, 4);
-
     memory_region_init_io(&s->data_mem, &pci_host_data_le_ops, s,
                           "pci-conf-data", 4);
-    sysbus_add_io(dev, 0xcfc, &s->data_mem);
-    sysbus_init_ioports(&s->busdev, 0xcfc, 4);
+}
 
-    return 0;
+static void i440fx_pcihost_realize(DeviceState *dev, Error **errp)
+{
+    PCIHostState *s = PCI_HOST_BRIDGE(dev);
+    SysBusDevice *b = SYS_BUS_DEVICE(dev);
+
+    sysbus_add_io(b, 0xcf8, &s->conf_mem);
+    sysbus_init_ioports(b, 0xcf8, 4);
+
+    sysbus_add_io(b, 0xcfc, &s->data_mem);
+    sysbus_init_ioports(b, 0xcfc, 4);
 }
 
 static int i440fx_initfn(PCIDevice *dev)
@@ -632,9 +637,8 @@  static const TypeInfo i440fx_info = {
 static void i440fx_pcihost_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-    k->init = i440fx_pcihost_initfn;
+    dc->realize = i440fx_pcihost_realize;
     dc->fw_name = "pci";
     dc->no_user = 1;
 }
@@ -643,6 +647,7 @@  static const TypeInfo i440fx_pcihost_info = {
     .name          = "i440FX-pcihost",
     .parent        = TYPE_PCI_HOST_BRIDGE,
     .instance_size = sizeof(I440FXState),
+    .instance_init = i440fx_pcihost_initfn,
     .class_init    = i440fx_pcihost_class_init,
 };