diff options
author | Murali Karicheri <[email protected]> | 2015-03-03 12:52:11 -0500 |
---|---|---|
committer | Bjorn Helgaas <[email protected]> | 2015-03-03 14:42:57 -0600 |
commit | 6675a601d72be408025e675599702e30a99188aa (patch) | |
tree | 3eeb9457aba240725c97f1aff5eb944b9ef1a8c2 | |
parent | 0c79c81c779fe54e67c0ce8c1fda551ca57d8a35 (diff) |
PCI: Add helper functions pci_get[put]_host_bridge_device()
Add helper functions to get/put the root bus's host bridge device.
Tested-by: Suravee Suthikulpanit <[email protected]> (AMD Seattle)
Signed-off-by: Murali Karicheri <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Catalin Marinas <[email protected]>
Acked-by: Will Deacon <[email protected]>
CC: Joerg Roedel <[email protected]>
CC: Grant Likely <[email protected]>
CC: Rob Herring <[email protected]>
CC: Russell King <[email protected]>
CC: Arnd Bergmann <[email protected]>
-rw-r--r-- | drivers/pci/host-bridge.c | 14 | ||||
-rw-r--r-- | include/linux/pci.h | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c index 39b2dbe585aa..3e5bbf9e8889 100644 --- a/drivers/pci/host-bridge.c +++ b/drivers/pci/host-bridge.c @@ -23,6 +23,20 @@ static struct pci_host_bridge *find_pci_host_bridge(struct pci_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; + + kobject_get(&bridge->kobj); + return bridge; +} + +void pci_put_host_bridge_device(struct device *dev) +{ + kobject_put(&dev->kobj); +} + void pci_set_host_bridge_release(struct pci_host_bridge *bridge, void (*release_fn)(struct pci_host_bridge *), void *release_data) diff --git a/include/linux/pci.h b/include/linux/pci.h index 211e9da8a7d7..a379513bddef 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -510,6 +510,9 @@ static inline struct pci_dev *pci_upstream_bridge(struct pci_dev *dev) return dev->bus->self; } +struct device *pci_get_host_bridge_device(struct pci_dev *dev); +void pci_put_host_bridge_device(struct device *dev); + #ifdef CONFIG_PCI_MSI static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) { |