aboutsummaryrefslogtreecommitdiff
path: root/hw/block
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2012-11-25 02:37:14 +0100
committerAndreas Färber <afaerber@suse.de>2013-06-07 12:14:45 +0200
commitdb895a1e6a97e919f9b86d60c969377357b05066 (patch)
tree72f6786abe90f7fa77d2f10416df73cb9d62e35a /hw/block
parenta3dcca567a1d4a5c79fb9c8fe2d9a21a4a7cebd5 (diff)
isa: Use realizefn for ISADevice
Drop ISADeviceClass::init and the resulting no-op initfn and let children implement their own realizefn. Adapt error handling. Split off an instance_init where sensible. Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/block')
-rw-r--r--hw/block/fdc.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 0888652fe8..79ea625485 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -2117,24 +2117,28 @@ static const MemoryRegionPortio fdc_portio_list[] = {
PORTIO_END_OF_LIST(),
};
-static int isabus_fdc_init1(ISADevice *dev)
+static void isabus_fdc_realize(DeviceState *dev, Error **errp)
{
+ ISADevice *isadev = ISA_DEVICE(dev);
FDCtrlISABus *isa = ISA_FDC(dev);
FDCtrl *fdctrl = &isa->state;
int ret;
- isa_register_portio_list(dev, isa->iobase, fdc_portio_list, fdctrl, "fdc");
+ isa_register_portio_list(isadev, isa->iobase, fdc_portio_list, fdctrl,
+ "fdc");
- isa_init_irq(dev, &fdctrl->irq, isa->irq);
+ isa_init_irq(isadev, &fdctrl->irq, isa->irq);
fdctrl->dma_chann = isa->dma;
- qdev_set_legacy_instance_id(&dev->qdev, isa->iobase, 2);
+ qdev_set_legacy_instance_id(dev, isa->iobase, 2);
ret = fdctrl_init_common(fdctrl);
+ if (ret < 0) {
+ error_setg(errp, "Floppy init failed.");
+ return;
+ }
- add_boot_device_path(isa->bootindexA, &dev->qdev, "/floppy@0");
- add_boot_device_path(isa->bootindexB, &dev->qdev, "/floppy@1");
-
- return ret;
+ add_boot_device_path(isa->bootindexA, dev, "/floppy@0");
+ add_boot_device_path(isa->bootindexB, dev, "/floppy@1");
}
static int sysbus_fdc_init1(SysBusDevice *dev)
@@ -2203,8 +2207,8 @@ static Property isa_fdc_properties[] = {
static void isabus_fdc_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
- ic->init = isabus_fdc_init1;
+
+ dc->realize = isabus_fdc_realize;
dc->fw_name = "fdc";
dc->no_user = 1;
dc->reset = fdctrl_external_reset_isa;