mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
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>
This commit is contained in:
parent
cdc57472dc
commit
fd56e0612b
20 changed files with 102 additions and 92 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue