summaryrefslogtreecommitdiff
path: root/hw/pci.c
diff options
context:
space:
mode:
authorBlue Swirl <blauwirbel@gmail.com>2011-02-05 14:34:32 +0000
committerBlue Swirl <blauwirbel@gmail.com>2011-02-12 08:27:58 +0000
commit7cc050b1659545d0c87108c17f0bf78561efcf9a (patch)
tree19ad3d4af3aec212dc1cd8590d2f8cc54fa7bf23 /hw/pci.c
parent0bcdeda7e478f1ce1345585d8240e8d5a9b274d5 (diff)
downloadqemu-7cc050b1659545d0c87108c17f0bf78561efcf9a.zip
pci: add creation functions that may fail
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw/pci.c')
-rw-r--r--hw/pci.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/hw/pci.c b/hw/pci.c
index d5bbba975b..5e6e216487 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1708,6 +1708,21 @@ PCIDevice *pci_create_multifunction(PCIBus *bus, int devfn, bool multifunction,
return DO_UPCAST(PCIDevice, qdev, dev);
}
+PCIDevice *pci_try_create_multifunction(PCIBus *bus, int devfn,
+ bool multifunction,
+ const char *name)
+{
+ DeviceState *dev;
+
+ dev = qdev_try_create(&bus->qbus, name);
+ if (!dev) {
+ return NULL;
+ }
+ qdev_prop_set_uint32(dev, "addr", devfn);
+ qdev_prop_set_bit(dev, "multifunction", multifunction);
+ return DO_UPCAST(PCIDevice, qdev, dev);
+}
+
PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn,
bool multifunction,
const char *name)
@@ -1727,6 +1742,11 @@ PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name)
return pci_create_simple_multifunction(bus, devfn, false, name);
}
+PCIDevice *pci_try_create(PCIBus *bus, int devfn, const char *name)
+{
+ return pci_try_create_multifunction(bus, devfn, false, name);
+}
+
static int pci_find_space(PCIDevice *pdev, uint8_t size)
{
int config_size = pci_config_size(pdev);