aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/search.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/search.c')
-rw-r--r--drivers/pci/search.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index ec415352d9ba..6dae87143258 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -26,14 +26,14 @@ pci_find_upstream_pcie_bridge(struct pci_dev *pdev)
26{ 26{
27 struct pci_dev *tmp = NULL; 27 struct pci_dev *tmp = NULL;
28 28
29 if (pdev->is_pcie) 29 if (pci_is_pcie(pdev))
30 return NULL; 30 return NULL;
31 while (1) { 31 while (1) {
32 if (pci_is_root_bus(pdev->bus)) 32 if (pci_is_root_bus(pdev->bus))
33 break; 33 break;
34 pdev = pdev->bus->self; 34 pdev = pdev->bus->self;
35 /* a p2p bridge */ 35 /* a p2p bridge */
36 if (!pdev->is_pcie) { 36 if (!pci_is_pcie(pdev)) {
37 tmp = pdev; 37 tmp = pdev;
38 continue; 38 continue;
39 } 39 }
@@ -149,32 +149,33 @@ struct pci_dev * pci_get_slot(struct pci_bus *bus, unsigned int devfn)
149} 149}
150 150
151/** 151/**
152 * pci_get_bus_and_slot - locate PCI device from a given PCI bus & slot 152 * pci_get_domain_bus_and_slot - locate PCI device for a given PCI domain (segment), bus, and slot
153 * @bus: number of PCI bus on which desired PCI device resides 153 * @domain: PCI domain/segment on which the PCI device resides.
154 * @devfn: encodes number of PCI slot in which the desired PCI 154 * @bus: PCI bus on which desired PCI device resides
155 * device resides and the logical device number within that slot 155 * @devfn: encodes number of PCI slot in which the desired PCI device
156 * in case of multi-function devices. 156 * resides and the logical device number within that slot in case of
157 * 157 * multi-function devices.
158 * Note: the bus/slot search is limited to PCI domain (segment) 0.
159 * 158 *
160 * Given a PCI bus and slot/function number, the desired PCI device 159 * Given a PCI domain, bus, and slot/function number, the desired PCI
161 * is located in system global list of PCI devices. If the device 160 * device is located in the list of PCI devices. If the device is
162 * is found, a pointer to its data structure is returned. If no 161 * found, its reference count is increased and this function returns a
163 * device is found, %NULL is returned. The returned device has its 162 * pointer to its data structure. The caller must decrement the
164 * reference count bumped by one. 163 * reference count by calling pci_dev_put(). If no device is found,
164 * %NULL is returned.
165 */ 165 */
166 166struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
167struct pci_dev * pci_get_bus_and_slot(unsigned int bus, unsigned int devfn) 167 unsigned int devfn)
168{ 168{
169 struct pci_dev *dev = NULL; 169 struct pci_dev *dev = NULL;
170 170
171 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { 171 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
172 if (pci_domain_nr(dev->bus) == 0 && 172 if (pci_domain_nr(dev->bus) == domain &&
173 (dev->bus->number == bus && dev->devfn == devfn)) 173 (dev->bus->number == bus && dev->devfn == devfn))
174 return dev; 174 return dev;
175 } 175 }
176 return NULL; 176 return NULL;
177} 177}
178EXPORT_SYMBOL(pci_get_domain_bus_and_slot);
178 179
179static int match_pci_dev_by_id(struct device *dev, void *data) 180static int match_pci_dev_by_id(struct device *dev, void *data)
180{ 181{
@@ -354,5 +355,4 @@ EXPORT_SYMBOL(pci_find_next_bus);
354EXPORT_SYMBOL(pci_get_device); 355EXPORT_SYMBOL(pci_get_device);
355EXPORT_SYMBOL(pci_get_subsys); 356EXPORT_SYMBOL(pci_get_subsys);
356EXPORT_SYMBOL(pci_get_slot); 357EXPORT_SYMBOL(pci_get_slot);
357EXPORT_SYMBOL(pci_get_bus_and_slot);
358EXPORT_SYMBOL(pci_get_class); 358EXPORT_SYMBOL(pci_get_class);