summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2013-11-06 10:11:48 -0700
committerJiri Slaby <jslaby@suse.cz>2014-09-03 10:54:30 +0200
commit5d1ab637d00b258f7852c963771ed4f1fd0b2de3 (patch)
tree4de4c586f37b48dc6c6993add3997d96fee393e5
parentc27a4fe151abf351665639eef0ee2fef7e6fb4f9 (diff)
downloadlwn-5d1ab637d00b258f7852c963771ed4f1fd0b2de3.tar.gz
lwn-5d1ab637d00b258f7852c963771ed4f1fd0b2de3.zip
PCI: Add pci_upstream_bridge()
commit c6bde215acfd637708142ae671843b6f0eadbc6d upstream. This adds a pci_upstream_bridge() interface to find the PCI-to-PCI bridge upstream from a device. This is typically just "dev->bus->self", but in the case of a VF on a virtual bus, we have to start from the corresponding PF. Returns NULL if there is no upstream PCI bridge, i.e., if the device is on a root bus. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
-rw-r--r--include/linux/pci.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h
index da172f956ad6..db4ce115705e 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -478,6 +478,15 @@ static inline bool pci_is_root_bus(struct pci_bus *pbus)
return !(pbus->parent);
}
+static inline struct pci_dev *pci_upstream_bridge(struct pci_dev *dev)
+{
+ dev = pci_physfn(dev);
+ if (pci_is_root_bus(dev->bus))
+ return NULL;
+
+ return dev->bus->self;
+}
+
#ifdef CONFIG_PCI_MSI
static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev)
{