From db895a1e6a97e919f9b86d60c969377357b05066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 25 Nov 2012 02:37:14 +0100 Subject: isa: Use realizefn for ISADevice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- hw/block/fdc.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'hw/block/fdc.c') 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; -- cgit v1.2.3