diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2009-08-14 10:36:05 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-08-27 20:43:28 -0500 |
commit | 81a322d4a1b68d47908a6630bf22897a289722aa (patch) | |
tree | cdca9840d0620d9e0b46d7b81c58abe04a372b78 /hw/musicpal.c | |
parent | 24e6f3551f3c8ea7cc7524a3e64e84beca59618f (diff) |
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 <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/musicpal.c')
-rw-r--r-- | hw/musicpal.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/hw/musicpal.c b/hw/musicpal.c index 097a1f70e8..1c4f17cb90 100644 --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -365,7 +365,7 @@ static void eth_cleanup(VLANClientState *vc) qemu_free(s); } -static void mv88w8618_eth_init(SysBusDevice *dev) +static int mv88w8618_eth_init(SysBusDevice *dev) { mv88w8618_eth_state *s = FROM_SYSBUS(mv88w8618_eth_state, dev); @@ -376,6 +376,7 @@ static void mv88w8618_eth_init(SysBusDevice *dev) s->mmio_index = cpu_register_io_memory(mv88w8618_eth_readfn, mv88w8618_eth_writefn, s); sysbus_init_mmio(dev, MP_ETH_SIZE, s->mmio_index); + return 0; } /* LCD register offsets */ @@ -544,7 +545,7 @@ static CPUWriteMemoryFunc * const musicpal_lcd_writefn[] = { musicpal_lcd_write }; -static void musicpal_lcd_init(SysBusDevice *dev) +static int musicpal_lcd_init(SysBusDevice *dev) { musicpal_lcd_state *s = FROM_SYSBUS(musicpal_lcd_state, dev); int iomemtype; @@ -560,6 +561,8 @@ static void musicpal_lcd_init(SysBusDevice *dev) qemu_console_resize(s->ds, 128*3, 64*3); qdev_init_gpio_in(&dev->qdev, musicpal_lcd_gpio_brigthness_in, 3); + + return 0; } /* PIC register offsets */ @@ -642,7 +645,7 @@ static CPUWriteMemoryFunc * const mv88w8618_pic_writefn[] = { mv88w8618_pic_write }; -static void mv88w8618_pic_init(SysBusDevice *dev) +static int mv88w8618_pic_init(SysBusDevice *dev) { mv88w8618_pic_state *s = FROM_SYSBUS(mv88w8618_pic_state, dev); int iomemtype; @@ -654,6 +657,7 @@ static void mv88w8618_pic_init(SysBusDevice *dev) sysbus_init_mmio(dev, MP_PIC_SIZE, iomemtype); qemu_register_reset(mv88w8618_pic_reset, s); + return 0; } /* PIT register offsets */ @@ -761,7 +765,7 @@ static CPUWriteMemoryFunc * const mv88w8618_pit_writefn[] = { mv88w8618_pit_write }; -static void mv88w8618_pit_init(SysBusDevice *dev) +static int mv88w8618_pit_init(SysBusDevice *dev) { int iomemtype; mv88w8618_pit_state *s = FROM_SYSBUS(mv88w8618_pit_state, dev); @@ -776,6 +780,7 @@ static void mv88w8618_pit_init(SysBusDevice *dev) iomemtype = cpu_register_io_memory(mv88w8618_pit_readfn, mv88w8618_pit_writefn, s); sysbus_init_mmio(dev, MP_PIT_SIZE, iomemtype); + return 0; } /* Flash config register offsets */ @@ -824,7 +829,7 @@ static CPUWriteMemoryFunc * const mv88w8618_flashcfg_writefn[] = { mv88w8618_flashcfg_write }; -static void mv88w8618_flashcfg_init(SysBusDevice *dev) +static int mv88w8618_flashcfg_init(SysBusDevice *dev) { int iomemtype; mv88w8618_flashcfg_state *s = FROM_SYSBUS(mv88w8618_flashcfg_state, dev); @@ -833,6 +838,7 @@ static void mv88w8618_flashcfg_init(SysBusDevice *dev) iomemtype = cpu_register_io_memory(mv88w8618_flashcfg_readfn, mv88w8618_flashcfg_writefn, s); sysbus_init_mmio(dev, MP_FLASHCFG_SIZE, iomemtype); + return 0; } /* Misc register offsets */ @@ -913,13 +919,14 @@ static CPUWriteMemoryFunc * const mv88w8618_wlan_writefn[] = { mv88w8618_wlan_write, }; -static void mv88w8618_wlan_init(SysBusDevice *dev) +static int mv88w8618_wlan_init(SysBusDevice *dev) { int iomemtype; iomemtype = cpu_register_io_memory(mv88w8618_wlan_readfn, mv88w8618_wlan_writefn, NULL); sysbus_init_mmio(dev, MP_WLAN_SIZE, iomemtype); + return 0; } /* GPIO register offsets */ @@ -1120,7 +1127,7 @@ static void musicpal_gpio_reset(musicpal_gpio_state *s) s->isr = 0; } -static void musicpal_gpio_init(SysBusDevice *dev) +static int musicpal_gpio_init(SysBusDevice *dev) { musicpal_gpio_state *s = FROM_SYSBUS(musicpal_gpio_state, dev); int iomemtype; @@ -1137,6 +1144,8 @@ static void musicpal_gpio_init(SysBusDevice *dev) qdev_init_gpio_out(&dev->qdev, s->out, 5); /* 10 gpio button input + 1 I2C data input */ qdev_init_gpio_in(&dev->qdev, musicpal_gpio_irq, 11); + + return 0; } /* Keyboard codes & masks */ @@ -1244,7 +1253,7 @@ static void musicpal_key_event(void *opaque, int keycode) s->kbd_extended = 0; } -static void musicpal_key_init(SysBusDevice *dev) +static int musicpal_key_init(SysBusDevice *dev) { musicpal_key_state *s = FROM_SYSBUS(musicpal_key_state, dev); @@ -1257,6 +1266,8 @@ static void musicpal_key_init(SysBusDevice *dev) qdev_init_gpio_out(&dev->qdev, s->out, 10); qemu_add_kbd_event_handler(musicpal_key_event, s); + + return 0; } static struct arm_boot_info musicpal_binfo = { |