diff options
author | Andreas Färber <afaerber@suse.de> | 2012-11-25 02:37:14 +0100 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2013-06-07 12:14:45 +0200 |
commit | db895a1e6a97e919f9b86d60c969377357b05066 (patch) | |
tree | 72f6786abe90f7fa77d2f10416df73cb9d62e35a /hw/char/serial-pci.c | |
parent | a3dcca567a1d4a5c79fb9c8fe2d9a21a4a7cebd5 (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/char/serial-pci.c')
-rw-r--r-- | hw/char/serial-pci.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c index 2138e35851..3bec8ebe7b 100644 --- a/hw/char/serial-pci.c +++ b/hw/char/serial-pci.c @@ -27,6 +27,7 @@ #include "hw/char/serial.h" #include "hw/pci/pci.h" +#include "qapi/qmp/qerror.h" #define PCI_SERIAL_MAX_PORTS 4 @@ -49,9 +50,15 @@ static int serial_pci_init(PCIDevice *dev) { PCISerialState *pci = DO_UPCAST(PCISerialState, dev, dev); SerialState *s = &pci->state; + Error *err = NULL; s->baudbase = 115200; - serial_init_core(s); + serial_realize_core(s, &err); + if (err != NULL) { + qerror_report_err(err); + error_free(err); + return -1; + } pci->dev.config[PCI_INTERRUPT_PIN] = 0x01; s->irq = pci->dev.irq[0]; @@ -80,6 +87,7 @@ static int multi_serial_pci_init(PCIDevice *dev) PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev); PCIMultiSerialState *pci = DO_UPCAST(PCIMultiSerialState, dev, dev); SerialState *s; + Error *err = NULL; int i; switch (pc->device_id) { @@ -102,7 +110,12 @@ static int multi_serial_pci_init(PCIDevice *dev) for (i = 0; i < pci->ports; i++) { s = pci->state + i; s->baudbase = 115200; - serial_init_core(s); + serial_realize_core(s, &err); + if (err != NULL) { + qerror_report_err(err); + error_free(err); + return -1; + } s->irq = pci->irqs[i]; pci->name[i] = g_strdup_printf("uart #%d", i+1); memory_region_init_io(&s->io, &serial_io_ops, s, pci->name[i], 8); |