[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 15/26] fwcfg: use realize for fwcfg
From: |
Hu Tao |
Subject: |
[Qemu-devel] [PATCH 15/26] fwcfg: use realize for fwcfg |
Date: |
Sat, 22 Jun 2013 16:50:27 +0800 |
Cc: Markus Armbruster <address@hidden>
Cc: Paolo Bonzini <address@hidden>
Cc: Blue Swirl <address@hidden>
Cc: Anthony Liguori <address@hidden>
Cc: "Andreas Färber" <address@hidden>
Signed-off-by: Hu Tao <address@hidden>
---
hw/nvram/fw_cfg.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 3c255ce..f5c85ec 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -522,31 +522,37 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t
data_port,
return s;
}
-static int fw_cfg_init1(SysBusDevice *dev)
+static void fw_cfg_initfn(Object *obj)
{
- FWCfgState *s = FROM_SYSBUS(FWCfgState, dev);
+ FWCfgState *s = DO_UPCAST(FWCfgState, busdev.qdev.parent_obj, obj);
memory_region_init_io(&s->ctl_iomem, &fw_cfg_ctl_mem_ops, s,
"fwcfg.ctl", FW_CFG_SIZE);
- sysbus_init_mmio(dev, &s->ctl_iomem);
memory_region_init_io(&s->data_iomem, &fw_cfg_data_mem_ops, s,
"fwcfg.data", FW_CFG_DATA_SIZE);
- sysbus_init_mmio(dev, &s->data_iomem);
/* In case ctl and data overlap: */
memory_region_init_io(&s->comb_iomem, &fw_cfg_comb_mem_ops, s,
"fwcfg", FW_CFG_SIZE);
+}
+
+static void fw_cfg_realize(DeviceState *dev, Error **errp)
+{
+ FWCfgState *s = DO_UPCAST(FWCfgState, busdev.qdev, dev);
+ SysBusDevice *b = SYS_BUS_DEVICE(dev);
+
+ sysbus_init_mmio(b, &s->ctl_iomem);
+ sysbus_init_mmio(b, &s->data_iomem);
if (s->ctl_iobase + 1 == s->data_iobase) {
- sysbus_add_io(dev, s->ctl_iobase, &s->comb_iomem);
+ sysbus_add_io(b, s->ctl_iobase, &s->comb_iomem);
} else {
if (s->ctl_iobase) {
- sysbus_add_io(dev, s->ctl_iobase, &s->ctl_iomem);
+ sysbus_add_io(b, s->ctl_iobase, &s->ctl_iomem);
}
if (s->data_iobase) {
- sysbus_add_io(dev, s->data_iobase, &s->data_iomem);
+ sysbus_add_io(b, s->data_iobase, &s->data_iomem);
}
}
- return 0;
}
static Property fw_cfg_properties[] = {
@@ -564,9 +570,8 @@ FWCfgState *fw_cfg_find(void)
static void fw_cfg_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = fw_cfg_init1;
+ dc->realize = fw_cfg_realize;
dc->no_user = 1;
dc->reset = fw_cfg_reset;
dc->vmsd = &vmstate_fw_cfg;
@@ -577,6 +582,7 @@ static const TypeInfo fw_cfg_info = {
.name = TYPE_FW_CFG,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(FWCfgState),
+ .instance_init = fw_cfg_initfn,
.class_init = fw_cfg_class_init,
};
--
1.8.3.1
- [Qemu-devel] [PATCH 04/26] i440fx: use type-safe cast instead of directly access of parent dev, (continued)
- [Qemu-devel] [PATCH 04/26] i440fx: use type-safe cast instead of directly access of parent dev, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 09/26] pflash_cfi01: use realize for pflash_cfi01, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 07/26] fdc: use realize for fdc., Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 05/26] q35: use realize for q35 host, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 10/26] pflash-cfi01: QOM'ify some more, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 12/26] pflash-cfi02: QOM'ify some more, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 11/26] pflash_cfi02: use realize for pflash_cfi02, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 08/26] fdc: QOM'ify some more, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 14/26] ahci: QOM'ify some more, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 06/26] q35: use type-safe cast instead of directly access of parent dev, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 15/26] fwcfg: use realize for fwcfg,
Hu Tao <=
- [Qemu-devel] [PATCH 16/26] fwcfg: QOM'ify some more, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 17/26] scsi esp: use realize for scsi esp, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 13/26] ahci: use realize for ahci, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 21/26] kvmclock: use realize for kvmclock, Hu Tao, 2013/06/22