提交 3c299dc2 编写于 作者: A Andrew Patterson 提交者: Jesse Barnes

PCI: add pci_get_domain_bus_and_slot function

Added the pci_get_domain_and_slot_function which is analogous to
pci_get_bus_and_slot. It returns a pci_dev given a domain (segment) number,
bus number, and devnr. Like pci_get_bus_and_slot,
pci_get_domain_bus_and_slot holds a reference to the returned pci_dev.

Converted pci_get_bus_and_slot to a wrapper that calls
pci_get_domain_bus_and_slot with the domain hard-coded to 0.

This routine was patterned off code suggested by Bjorn Helgaas.
Acked-by: NHuang Ying <ying.huang@intel.com>
Signed-off-by: NAndrew Patterson <andrew.patterson@hp.com>
Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
上级 bc577d2b
...@@ -149,32 +149,33 @@ struct pci_dev * pci_get_slot(struct pci_bus *bus, unsigned int devfn) ...@@ -149,32 +149,33 @@ struct pci_dev * pci_get_slot(struct pci_bus *bus, unsigned int devfn)
} }
/** /**
* pci_get_bus_and_slot - locate PCI device from a given PCI bus & slot * pci_get_domain_bus_and_slot - locate PCI device for a given PCI domain (segment), bus, and slot
* @bus: number of PCI bus on which desired PCI device resides * @domain: PCI domain/segment on which the PCI device resides.
* @devfn: encodes number of PCI slot in which the desired PCI * @bus: PCI bus on which desired PCI device resides
* device resides and the logical device number within that slot * @devfn: encodes number of PCI slot in which the desired PCI device
* in case of multi-function devices. * resides and the logical device number within that slot in case of
* * multi-function devices.
* Note: the bus/slot search is limited to PCI domain (segment) 0.
* *
* Given a PCI bus and slot/function number, the desired PCI device * Given a PCI domain, bus, and slot/function number, the desired PCI
* is located in system global list of PCI devices. If the device * device is located in the list of PCI devices. If the device is
* is found, a pointer to its data structure is returned. If no * found, its reference count is increased and this function returns a
* device is found, %NULL is returned. The returned device has its * pointer to its data structure. The caller must decrement the
* reference count bumped by one. * reference count by calling pci_dev_put(). If no device is found,
* %NULL is returned.
*/ */
struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
struct pci_dev * pci_get_bus_and_slot(unsigned int bus, unsigned int devfn) unsigned int devfn)
{ {
struct pci_dev *dev = NULL; struct pci_dev *dev = NULL;
while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
if (pci_domain_nr(dev->bus) == 0 && if (pci_domain_nr(dev->bus) == domain &&
(dev->bus->number == bus && dev->devfn == devfn)) (dev->bus->number == bus && dev->devfn == devfn))
return dev; return dev;
} }
return NULL; return NULL;
} }
EXPORT_SYMBOL(pci_get_domain_bus_and_slot);
static int match_pci_dev_by_id(struct device *dev, void *data) static int match_pci_dev_by_id(struct device *dev, void *data)
{ {
...@@ -354,5 +355,4 @@ EXPORT_SYMBOL(pci_find_next_bus); ...@@ -354,5 +355,4 @@ EXPORT_SYMBOL(pci_find_next_bus);
EXPORT_SYMBOL(pci_get_device); EXPORT_SYMBOL(pci_get_device);
EXPORT_SYMBOL(pci_get_subsys); EXPORT_SYMBOL(pci_get_subsys);
EXPORT_SYMBOL(pci_get_slot); EXPORT_SYMBOL(pci_get_slot);
EXPORT_SYMBOL(pci_get_bus_and_slot);
EXPORT_SYMBOL(pci_get_class); EXPORT_SYMBOL(pci_get_class);
...@@ -636,7 +636,13 @@ struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device, ...@@ -636,7 +636,13 @@ struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
unsigned int ss_vendor, unsigned int ss_device, unsigned int ss_vendor, unsigned int ss_device,
struct pci_dev *from); struct pci_dev *from);
struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn); struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn);
struct pci_dev *pci_get_bus_and_slot(unsigned int bus, unsigned int devfn); struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
unsigned int devfn);
static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
unsigned int devfn)
{
return pci_get_domain_bus_and_slot(0, bus, devfn);
}
struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from); struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from);
int pci_dev_present(const struct pci_device_id *ids); int pci_dev_present(const struct pci_device_id *ids);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册