pci: convert PCIUnregisterFunc to void

Not a single driver has any possibility of failure on their
exit function, let's keep it that way.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Alex Williamson 2012-07-03 22:39:27 -06:00 committed by Michael S. Tsirkin
parent 572992eefa
commit f90c2bcdbc
25 changed files with 47 additions and 83 deletions

View File

@ -1319,13 +1319,12 @@ static int ac97_initfn (PCIDevice *dev)
return 0;
}
static int ac97_exitfn (PCIDevice *dev)
static void ac97_exitfn (PCIDevice *dev)
{
AC97LinkState *s = DO_UPCAST (AC97LinkState, dev, dev);
memory_region_destroy (&s->io_nam);
memory_region_destroy (&s->io_nabm);
return 0;
}
int ac97_init (PCIBus *bus)

View File

@ -1192,7 +1192,7 @@ e1000_cleanup(VLANClientState *nc)
s->nic = NULL;
}
static int
static void
pci_e1000_uninit(PCIDevice *dev)
{
E1000State *d = DO_UPCAST(E1000State, dev, dev);
@ -1202,7 +1202,6 @@ pci_e1000_uninit(PCIDevice *dev)
memory_region_destroy(&d->mmio);
memory_region_destroy(&d->io);
qemu_del_vlan_client(&d->nic->nc);
return 0;
}
static NetClientInfo net_e1000_info = {

View File

@ -1831,7 +1831,7 @@ static void nic_cleanup(VLANClientState *nc)
s->nic = NULL;
}
static int pci_nic_uninit(PCIDevice *pci_dev)
static void pci_nic_uninit(PCIDevice *pci_dev)
{
EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
@ -1841,7 +1841,6 @@ static int pci_nic_uninit(PCIDevice *pci_dev)
vmstate_unregister(&pci_dev->qdev, s->vmstate, s);
eeprom93xx_free(&pci_dev->qdev, s->eeprom);
qemu_del_vlan_client(&s->nic->nc);
return 0;
}
static NetClientInfo net_eepro100_info = {

View File

@ -1018,12 +1018,11 @@ static int es1370_initfn (PCIDevice *dev)
return 0;
}
static int es1370_exitfn (PCIDevice *dev)
static void es1370_exitfn (PCIDevice *dev)
{
ES1370State *s = DO_UPCAST (ES1370State, dev, dev);
memory_region_destroy (&s->io);
return 0;
}
int es1370_init (PCIBus *bus)

View File

@ -295,7 +295,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev)
return 0;
}
static int pci_cmd646_ide_exitfn(PCIDevice *dev)
static void pci_cmd646_ide_exitfn(PCIDevice *dev)
{
PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev);
unsigned i;
@ -309,8 +309,6 @@ static int pci_cmd646_ide_exitfn(PCIDevice *dev)
memory_region_destroy(&d->cmd646_bar[i].data);
}
memory_region_destroy(&d->bmdma_bar);
return 0;
}
void pci_cmd646_ide_init(PCIBus *bus, DriveInfo **hd_table,

View File

@ -132,15 +132,13 @@ static int pci_ich9_ahci_init(PCIDevice *dev)
return 0;
}
static int pci_ich9_uninit(PCIDevice *dev)
static void pci_ich9_uninit(PCIDevice *dev)
{
struct AHCIPCIState *d;
d = DO_UPCAST(struct AHCIPCIState, card, dev);
msi_uninit(dev);
ahci_uninit(&d->ahci);
return 0;
}
static void ich_ahci_class_init(ObjectClass *klass, void *data)

View File

@ -199,7 +199,7 @@ PCIDevice *pci_piix3_xen_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn)
return dev;
}
static int pci_piix_ide_exitfn(PCIDevice *dev)
static void pci_piix_ide_exitfn(PCIDevice *dev)
{
PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev);
unsigned i;
@ -211,8 +211,6 @@ static int pci_piix_ide_exitfn(PCIDevice *dev)
memory_region_destroy(&d->bmdma[i].addr_ioport);
}
memory_region_destroy(&d->bmdma_bar);
return 0;
}
/* hd_table must contain 4 block drivers */

View File

@ -189,7 +189,7 @@ static int vt82c686b_ide_initfn(PCIDevice *dev)
return 0;
}
static int vt82c686b_ide_exitfn(PCIDevice *dev)
static void vt82c686b_ide_exitfn(PCIDevice *dev)
{
PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev);
unsigned i;
@ -201,8 +201,6 @@ static int vt82c686b_ide_exitfn(PCIDevice *dev)
memory_region_destroy(&d->bmdma[i].addr_ioport);
}
memory_region_destroy(&d->bmdma_bar);
return 0;
}
void vt82c686b_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn)

View File

@ -1144,13 +1144,12 @@ static int intel_hda_init(PCIDevice *pci)
return 0;
}
static int intel_hda_exit(PCIDevice *pci)
static void intel_hda_exit(PCIDevice *pci)
{
IntelHDAState *d = DO_UPCAST(IntelHDAState, pci, pci);
msi_uninit(&d->pci);
memory_region_destroy(&d->mmio);
return 0;
}
static int intel_hda_post_load(void *opaque, int version)

View File

@ -96,7 +96,6 @@ static int ioh3420_initfn(PCIDevice *d)
PCIEPort *p = DO_UPCAST(PCIEPort, br, br);
PCIESlot *s = DO_UPCAST(PCIESlot, port, p);
int rc;
int tmp;
rc = pci_bridge_initfn(d);
if (rc < 0) {
@ -144,12 +143,11 @@ err_pcie_cap:
err_msi:
msi_uninit(d);
err_bridge:
tmp = pci_bridge_exitfn(d);
assert(!tmp);
pci_bridge_exitfn(d);
return rc;
}
static int ioh3420_exitfn(PCIDevice *d)
static void ioh3420_exitfn(PCIDevice *d)
{
PCIBridge* br = DO_UPCAST(PCIBridge, dev, d);
PCIEPort *p = DO_UPCAST(PCIEPort, br, br);
@ -159,7 +157,7 @@ static int ioh3420_exitfn(PCIDevice *d)
pcie_chassis_del_slot(s);
pcie_cap_exit(d);
msi_uninit(d);
return pci_bridge_exitfn(d);
pci_bridge_exitfn(d);
}
PCIESlot *ioh3420_init(PCIBus *bus, int devfn, bool multifunction,

View File

@ -760,7 +760,7 @@ static int pci_ivshmem_init(PCIDevice *dev)
return 0;
}
static int pci_ivshmem_uninit(PCIDevice *dev)
static void pci_ivshmem_uninit(PCIDevice *dev)
{
IVShmemState *s = DO_UPCAST(IVShmemState, dev, dev);
@ -775,8 +775,6 @@ static int pci_ivshmem_uninit(PCIDevice *dev)
memory_region_destroy(&s->ivshmem);
memory_region_destroy(&s->bar);
unregister_savevm(&dev->qdev, "ivshmem", s);
return 0;
}
static Property ivshmem_properties[] = {

View File

@ -2070,15 +2070,13 @@ static const VMStateDescription vmstate_lsi_scsi = {
}
};
static int lsi_scsi_uninit(PCIDevice *d)
static void lsi_scsi_uninit(PCIDevice *d)
{
LSIState *s = DO_UPCAST(LSIState, dev, d);
memory_region_destroy(&s->mmio_io);
memory_region_destroy(&s->ram_io);
memory_region_destroy(&s->io_io);
return 0;
}
static const struct SCSIBusInfo lsi_scsi_info = {

View File

@ -744,14 +744,13 @@ static int pci_ne2000_init(PCIDevice *pci_dev)
return 0;
}
static int pci_ne2000_exit(PCIDevice *pci_dev)
static void pci_ne2000_exit(PCIDevice *pci_dev)
{
PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
NE2000State *s = &d->ne2000;
memory_region_destroy(&s->io);
qemu_del_vlan_client(&s->nic->nc);
return 0;
}
static Property ne2000_properties[] = {

View File

@ -837,12 +837,10 @@ static int pci_unregister_device(DeviceState *dev)
{
PCIDevice *pci_dev = PCI_DEVICE(dev);
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
int ret = 0;
if (pc->exit)
ret = pc->exit(pci_dev);
if (ret)
return ret;
if (pc->exit) {
pc->exit(pci_dev);
}
pci_unregister_io_regions(pci_dev);
pci_del_option_rom(pci_dev);

View File

@ -85,7 +85,7 @@ typedef uint32_t PCIConfigReadFunc(PCIDevice *pci_dev,
uint32_t address, int len);
typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num,
pcibus_t addr, pcibus_t size, int type);
typedef int PCIUnregisterFunc(PCIDevice *pci_dev);
typedef void PCIUnregisterFunc(PCIDevice *pci_dev);
typedef struct PCIIORegion {
pcibus_t addr; /* current PCI mapping address. -1 means not mapped */

View File

@ -333,7 +333,7 @@ int pci_bridge_initfn(PCIDevice *dev)
}
/* default qdev clean up function for PCI-to-PCI bridge */
int pci_bridge_exitfn(PCIDevice *pci_dev)
void pci_bridge_exitfn(PCIDevice *pci_dev)
{
PCIBridge *s = DO_UPCAST(PCIBridge, dev, pci_dev);
assert(QLIST_EMPTY(&s->sec_bus.child));
@ -342,7 +342,6 @@ int pci_bridge_exitfn(PCIDevice *pci_dev)
memory_region_destroy(&s->address_space_mem);
memory_region_destroy(&s->address_space_io);
/* qbus_free() is called automatically by qdev_free() */
return 0;
}
/*

View File

@ -44,7 +44,7 @@ void pci_bridge_reset_reg(PCIDevice *dev);
void pci_bridge_reset(DeviceState *qdev);
int pci_bridge_initfn(PCIDevice *pci_dev);
int pci_bridge_exitfn(PCIDevice *pci_dev);
void pci_bridge_exitfn(PCIDevice *pci_dev);
/*

View File

@ -52,7 +52,8 @@ static int pci_bridge_dev_initfn(PCIDevice *dev)
{
PCIBridge *br = DO_UPCAST(PCIBridge, dev, dev);
PCIBridgeDev *bridge_dev = DO_UPCAST(PCIBridgeDev, bridge, br);
int err, ret;
int err;
pci_bridge_map_irq(br, NULL, pci_bridge_dev_map_irq_fn);
err = pci_bridge_initfn(dev);
if (err) {
@ -86,26 +87,22 @@ slotid_error:
shpc_cleanup(dev, &bridge_dev->bar);
shpc_error:
memory_region_destroy(&bridge_dev->bar);
ret = pci_bridge_exitfn(dev);
assert(!ret);
pci_bridge_exitfn(dev);
bridge_error:
return err;
}
static int pci_bridge_dev_exitfn(PCIDevice *dev)
static void pci_bridge_dev_exitfn(PCIDevice *dev)
{
PCIBridge *br = DO_UPCAST(PCIBridge, dev, dev);
PCIBridgeDev *bridge_dev = DO_UPCAST(PCIBridgeDev, bridge, br);
int ret;
if (msi_present(dev)) {
msi_uninit(dev);
}
slotid_cap_cleanup(dev);
shpc_cleanup(dev, &bridge_dev->bar);
memory_region_destroy(&bridge_dev->bar);
ret = pci_bridge_exitfn(dev);
assert(!ret);
return 0;
pci_bridge_exitfn(dev);
}
static void pci_bridge_dev_write_config(PCIDevice *d,

View File

@ -271,7 +271,7 @@ static void pci_pcnet_cleanup(VLANClientState *nc)
pcnet_common_cleanup(d);
}
static int pci_pcnet_uninit(PCIDevice *dev)
static void pci_pcnet_uninit(PCIDevice *dev)
{
PCIPCNetState *d = DO_UPCAST(PCIPCNetState, pci_dev, dev);
@ -280,7 +280,6 @@ static int pci_pcnet_uninit(PCIDevice *dev)
qemu_del_timer(d->state.poll_timer);
qemu_free_timer(d->state.poll_timer);
qemu_del_vlan_client(&d->state.nic->nc);
return 0;
}
static NetClientInfo net_pci_pcnet_info = {

View File

@ -3427,7 +3427,7 @@ static void rtl8139_cleanup(VLANClientState *nc)
s->nic = NULL;
}
static int pci_rtl8139_uninit(PCIDevice *dev)
static void pci_rtl8139_uninit(PCIDevice *dev)
{
RTL8139State *s = DO_UPCAST(RTL8139State, dev, dev);
@ -3440,7 +3440,6 @@ static int pci_rtl8139_uninit(PCIDevice *dev)
qemu_del_timer(s->timer);
qemu_free_timer(s->timer);
qemu_del_vlan_client(&s->nic->nc);
return 0;
}
static NetClientInfo net_rtl8139_info = {

View File

@ -1233,12 +1233,11 @@ static int usb_uhci_vt82c686b_initfn(PCIDevice *dev)
return usb_uhci_common_initfn(dev);
}
static int usb_uhci_exit(PCIDevice *dev)
static void usb_uhci_exit(PCIDevice *dev)
{
UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
memory_region_destroy(&s->io_bar);
return 0;
}
static Property uhci_properties[] = {

View File

@ -828,22 +828,21 @@ static int virtio_blk_init_pci(PCIDevice *pci_dev)
return 0;
}
static int virtio_exit_pci(PCIDevice *pci_dev)
static void virtio_exit_pci(PCIDevice *pci_dev)
{
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
memory_region_destroy(&proxy->bar);
msix_uninit_exclusive_bar(pci_dev);
return 0;
}
static int virtio_blk_exit_pci(PCIDevice *pci_dev)
static void virtio_blk_exit_pci(PCIDevice *pci_dev)
{
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
virtio_pci_stop_ioeventfd(proxy);
virtio_blk_exit(proxy->vdev);
return virtio_exit_pci(pci_dev);
virtio_exit_pci(pci_dev);
}
static int virtio_serial_init_pci(PCIDevice *pci_dev)
@ -868,13 +867,13 @@ static int virtio_serial_init_pci(PCIDevice *pci_dev)
return 0;
}
static int virtio_serial_exit_pci(PCIDevice *pci_dev)
static void virtio_serial_exit_pci(PCIDevice *pci_dev)
{
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
virtio_pci_stop_ioeventfd(proxy);
virtio_serial_exit(proxy->vdev);
return virtio_exit_pci(pci_dev);
virtio_exit_pci(pci_dev);
}
static int virtio_net_init_pci(PCIDevice *pci_dev)
@ -892,13 +891,13 @@ static int virtio_net_init_pci(PCIDevice *pci_dev)
return 0;
}
static int virtio_net_exit_pci(PCIDevice *pci_dev)
static void virtio_net_exit_pci(PCIDevice *pci_dev)
{
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
virtio_pci_stop_ioeventfd(proxy);
virtio_net_exit(proxy->vdev);
return virtio_exit_pci(pci_dev);
virtio_exit_pci(pci_dev);
}
static int virtio_balloon_init_pci(PCIDevice *pci_dev)
@ -919,13 +918,13 @@ static int virtio_balloon_init_pci(PCIDevice *pci_dev)
return 0;
}
static int virtio_balloon_exit_pci(PCIDevice *pci_dev)
static void virtio_balloon_exit_pci(PCIDevice *pci_dev)
{
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
virtio_pci_stop_ioeventfd(proxy);
virtio_balloon_exit(proxy->vdev);
return virtio_exit_pci(pci_dev);
virtio_exit_pci(pci_dev);
}
static Property virtio_blk_properties[] = {
@ -1074,12 +1073,12 @@ static int virtio_scsi_init_pci(PCIDevice *pci_dev)
return 0;
}
static int virtio_scsi_exit_pci(PCIDevice *pci_dev)
static void virtio_scsi_exit_pci(PCIDevice *pci_dev)
{
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
virtio_scsi_exit(proxy->vdev);
return virtio_exit_pci(pci_dev);
virtio_exit_pci(pci_dev);
}
static Property virtio_scsi_properties[] = {

View File

@ -411,13 +411,11 @@ static int i6300esb_init(PCIDevice *dev)
return 0;
}
static int i6300esb_exit(PCIDevice *dev)
static void i6300esb_exit(PCIDevice *dev)
{
I6300State *d = DO_UPCAST(I6300State, dev, dev);
memory_region_destroy(&d->io_mem);
return 0;
}
static WatchdogTimerModel model = {

View File

@ -60,7 +60,6 @@ static int xio3130_downstream_initfn(PCIDevice *d)
PCIEPort *p = DO_UPCAST(PCIEPort, br, br);
PCIESlot *s = DO_UPCAST(PCIESlot, port, p);
int rc;
int tmp;
rc = pci_bridge_initfn(d);
if (rc < 0) {
@ -108,12 +107,11 @@ err_pcie_cap:
err_msi:
msi_uninit(d);
err_bridge:
tmp = pci_bridge_exitfn(d);
assert(!tmp);
pci_bridge_exitfn(d);
return rc;
}
static int xio3130_downstream_exitfn(PCIDevice *d)
static void xio3130_downstream_exitfn(PCIDevice *d)
{
PCIBridge* br = DO_UPCAST(PCIBridge, dev, d);
PCIEPort *p = DO_UPCAST(PCIEPort, br, br);
@ -123,7 +121,7 @@ static int xio3130_downstream_exitfn(PCIDevice *d)
pcie_chassis_del_slot(s);
pcie_cap_exit(d);
msi_uninit(d);
return pci_bridge_exitfn(d);
pci_bridge_exitfn(d);
}
PCIESlot *xio3130_downstream_init(PCIBus *bus, int devfn, bool multifunction,

View File

@ -56,7 +56,6 @@ static int xio3130_upstream_initfn(PCIDevice *d)
PCIBridge* br = DO_UPCAST(PCIBridge, dev, d);
PCIEPort *p = DO_UPCAST(PCIEPort, br, br);
int rc;
int tmp;
rc = pci_bridge_initfn(d);
if (rc < 0) {
@ -95,17 +94,16 @@ err:
err_msi:
msi_uninit(d);
err_bridge:
tmp = pci_bridge_exitfn(d);
assert(!tmp);
pci_bridge_exitfn(d);
return rc;
}
static int xio3130_upstream_exitfn(PCIDevice *d)
static void xio3130_upstream_exitfn(PCIDevice *d)
{
pcie_aer_exit(d);
pcie_cap_exit(d);
msi_uninit(d);
return pci_bridge_exitfn(d);
pci_bridge_exitfn(d);
}
PCIEPort *xio3130_upstream_init(PCIBus *bus, int devfn, bool multifunction,