[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 17/26] scsi esp: use realize for scsi esp
From: |
Hu Tao |
Subject: |
[Qemu-devel] [PATCH 17/26] scsi esp: use realize for scsi esp |
Date: |
Sat, 22 Jun 2013 16:50:29 +0800 |
Cc: Paolo Bonzini <address@hidden>
Signed-off-by: Hu Tao <address@hidden>
---
hw/scsi/esp.c | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 0c81a50..0207dba 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -666,23 +666,33 @@ static void sysbus_esp_gpio_demux(void *opaque, int irq,
int level)
}
}
-static int sysbus_esp_init(SysBusDevice *dev)
+static void sysbus_esp_init(Object *obj)
{
- SysBusESPState *sysbus = FROM_SYSBUS(SysBusESPState, dev);
+ SysBusESPState *sysbus = DO_UPCAST(SysBusESPState, busdev.qdev.parent_obj,
obj);
+
+ memory_region_init_io(&sysbus->iomem, &sysbus_esp_mem_ops, sysbus,
+ "esp", ESP_REGS << sysbus->it_shift);
+}
+
+static void sysbus_esp_realize(DeviceState *dev, Error **errp)
+{
+ SysBusESPState *sysbus = DO_UPCAST(SysBusESPState, busdev.qdev, dev);
+ SysBusDevice *sb = SYS_BUS_DEVICE(dev);
ESPState *s = &sysbus->esp;
- sysbus_init_irq(dev, &s->irq);
+ sysbus_init_irq(sb, &s->irq);
assert(sysbus->it_shift != -1);
s->chip_id = TCHI_FAS100A;
- memory_region_init_io(&sysbus->iomem, &sysbus_esp_mem_ops, sysbus,
- "esp", ESP_REGS << sysbus->it_shift);
- sysbus_init_mmio(dev, &sysbus->iomem);
+ sysbus_init_mmio(sb, &sysbus->iomem);
- qdev_init_gpio_in(&dev->qdev, sysbus_esp_gpio_demux, 2);
+ qdev_init_gpio_in(dev, sysbus_esp_gpio_demux, 2);
- scsi_bus_new(&s->bus, &dev->qdev, &esp_scsi_info, NULL);
- return scsi_bus_legacy_handle_cmdline(&s->bus);
+ scsi_bus_new(&s->bus, dev, &esp_scsi_info, NULL);
+ if (scsi_bus_legacy_handle_cmdline(&s->bus) < 0) {
+ error_setg(errp, "handling scsi bus failed");
+ return;
+ }
}
static void sysbus_esp_hard_reset(DeviceState *dev)
@@ -705,9 +715,8 @@ static const VMStateDescription vmstate_sysbus_esp_scsi = {
static void sysbus_esp_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = sysbus_esp_init;
+ dc->realize = sysbus_esp_realize;
dc->reset = sysbus_esp_hard_reset;
dc->vmsd = &vmstate_sysbus_esp_scsi;
}
@@ -716,6 +725,7 @@ static const TypeInfo sysbus_esp_info = {
.name = "esp",
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(SysBusESPState),
+ .instance_init = sysbus_esp_init,
.class_init = sysbus_esp_class_init,
};
--
1.8.3.1
- [Qemu-devel] [PATCH 07/26] fdc: use realize for fdc., (continued)
- [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, 2013/06/22
- [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 <=
- [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
[Qemu-devel] [PATCH 19/26] hpet: use realize for hpet, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 18/26] scsi esp: QOM'ify some more, Hu Tao, 2013/06/22