Return the struct pci_host_bridge corresponding to the given struct pci_bus.
Signed-off-by: Will Davis <wda...@nvidia.com> --- drivers/pci/host-bridge.c | 19 ++----------------- include/linux/pci.h | 7 +++++++ 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c index 5f4a2e0..6c2c82a 100644 --- a/drivers/pci/host-bridge.c +++ b/drivers/pci/host-bridge.c @@ -8,25 +8,10 @@ #include "pci.h" -static struct pci_bus *find_pci_root_bus(struct pci_bus *bus) -{ - while (bus->parent) - bus = bus->parent; - - return bus; -} - -struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus) -{ - struct pci_bus *root_bus = find_pci_root_bus(bus); - - return to_pci_host_bridge(root_bus->bridge); -} - struct device *pci_get_host_bridge_device(struct pci_dev *dev) { - struct pci_bus *root_bus = find_pci_root_bus(dev->bus); - struct device *bridge = root_bus->bridge; + struct pci_host_bridge *host_bridge = pci_find_host_bridge(dev->bus); + struct device *bridge = &host_bridge->dev; kobject_get(&bridge->kobj); return bridge; diff --git a/include/linux/pci.h b/include/linux/pci.h index 8a0321a..d58063e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -512,6 +512,13 @@ static inline struct pci_dev *pci_upstream_bridge(struct pci_dev *dev) return dev->bus->self; } +static inline struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus) +{ + while (bus->parent) + bus = bus->parent; + return to_pci_host_bridge(bus->bridge); +} + struct device *pci_get_host_bridge_device(struct pci_dev *dev); void pci_put_host_bridge_device(struct device *dev); -- 2.5.1 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu