From 81a322d4a1b68d47908a6630bf22897a289722aa Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 14 Aug 2009 10:36:05 +0200 Subject: qdev: add return value to init() callbacks. Sorry folks, but it has to be. One more of these invasive qdev patches. We have a serious design bug in the qdev interface: device init callbacks can't signal failure because the init() callback has no return value. This patch fixes it. We have already one case in-tree where this is needed: Try -device virtio-blk-pci (without drive= specified) and watch qemu segfault. This patch fixes it. With usb+scsi being converted to qdev we'll get more devices where the init callback can fail for various reasons. Signed-off-by: Gerd Hoffmann Signed-off-by: Anthony Liguori --- hw/grackle_pci.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'hw/grackle_pci.c') diff --git a/hw/grackle_pci.c b/hw/grackle_pci.c index 5b6778ed4a..38e2fe4869 100644 --- a/hw/grackle_pci.c +++ b/hw/grackle_pci.c @@ -152,7 +152,7 @@ PCIBus *pci_grackle_init(uint32_t base, qemu_irq *pic) return d->host_state.bus; } -static void pci_grackle_init_device(SysBusDevice *dev) +static int pci_grackle_init_device(SysBusDevice *dev) { GrackleState *s; int pci_mem_config, pci_mem_data; @@ -171,9 +171,10 @@ static void pci_grackle_init_device(SysBusDevice *dev) &s->host_state); qemu_register_reset(pci_grackle_reset, &s->host_state); pci_grackle_reset(&s->host_state); + return 0; } -static void pci_dec_21154_init_device(SysBusDevice *dev) +static int pci_dec_21154_init_device(SysBusDevice *dev) { GrackleState *s; int pci_mem_config, pci_mem_data; @@ -187,9 +188,10 @@ static void pci_dec_21154_init_device(SysBusDevice *dev) &s->host_state); sysbus_init_mmio(dev, 0x1000, pci_mem_config); sysbus_init_mmio(dev, 0x1000, pci_mem_data); + return 0; } -static void grackle_pci_host_init(PCIDevice *d) +static int grackle_pci_host_init(PCIDevice *d) { pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_MOTOROLA); pci_config_set_device_id(d->config, PCI_DEVICE_ID_MOTOROLA_MPC106); @@ -197,9 +199,10 @@ static void grackle_pci_host_init(PCIDevice *d) d->config[0x09] = 0x01; pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); d->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type + return 0; } -static void dec_21154_pci_host_init(PCIDevice *d) +static int dec_21154_pci_host_init(PCIDevice *d) { /* PCI2PCI bridge same values as PearPC - check this */ pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_DEC); @@ -223,6 +226,7 @@ static void dec_21154_pci_host_init(PCIDevice *d) d->config[0x25] = 0x84; d->config[0x26] = 0x00; // prefetchable_memory_limit d->config[0x27] = 0x85; + return 0; } static PCIDeviceInfo grackle_pci_host_info = { -- cgit v1.2.3