aboutsummaryrefslogtreecommitdiff
path: root/include/hw/pci
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2017-11-29 19:46:27 +1100
committerMichael S. Tsirkin <mst@redhat.com>2017-12-05 19:13:45 +0200
commitfd56e0612b6454a282fa6a953fdb09281a98c589 (patch)
tree28a829abaa964f8ed4834c2ed10441e2878ad2c8 /include/hw/pci
parentcdc57472dcc2ddc440545bde26791a11b42232b6 (diff)
downloadqemu-fd56e0612b6454a282fa6a953fdb09281a98c589.zip
qemu-fd56e0612b6454a282fa6a953fdb09281a98c589.tar.gz
qemu-fd56e0612b6454a282fa6a953fdb09281a98c589.tar.bz2
pci: Eliminate redundant PCIDevice::bus pointer
The bus pointer in PCIDevice is basically redundant with QOM information. It's always initialized to the qdev_get_parent_bus(), the only difference is the type. Therefore this patch eliminates the field, instead creating a pci_get_bus() helper to do the type mangling to derive it conveniently from the QOM Device object underneath. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
Diffstat (limited to 'include/hw/pci')
-rw-r--r--include/hw/pci/pci.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index e451235..597ffb7 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -285,7 +285,6 @@ struct PCIDevice {
uint8_t *used;
/* the following fields are read only */
- PCIBus *bus;
int32_t devfn;
/* Cached device to fetch requester ID from, to avoid the PCI
* tree walking every time we invoke PCI request (e.g.,
@@ -435,10 +434,14 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
PCIDevice *pci_vga_init(PCIBus *bus);
+static inline PCIBus *pci_get_bus(const PCIDevice *dev)
+{
+ return PCI_BUS(qdev_get_parent_bus(DEVICE(dev)));
+}
int pci_bus_num(PCIBus *s);
static inline int pci_dev_bus_num(const PCIDevice *dev)
{
- return pci_bus_num(dev->bus);
+ return pci_bus_num(pci_get_bus(dev));
}
int pci_bus_numa_node(PCIBus *bus);
@@ -745,7 +748,7 @@ static inline uint32_t pci_config_size(const PCIDevice *d)
static inline uint16_t pci_get_bdf(PCIDevice *dev)
{
- return PCI_BUILD_BDF(pci_bus_num(dev->bus), dev->devfn);
+ return PCI_BUILD_BDF(pci_bus_num(pci_get_bus(dev)), dev->devfn);
}
uint16_t pci_requester_id(PCIDevice *dev);