# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1227524601 0
# Node ID 5888ffa4b252f11749b3fde82eeb5ab68bb2e537
# Parent df84c4c22a0a692ef8da7d31108b2d6055fef675
pci: small fix of aerdrv_core, add one new function of get_device by BDF
Signed-off-by: Jiang Yunhong<yunhong.jiang@xxxxxxxxx>
Signed-off-by: Ke Liping<liping.ke@xxxxxxxxx>
---
drivers/pci/pcie/aer/aerdrv_core.c | 2 +-
drivers/pci/search.c | 31 +++++++++++++++++++++++++++++++
include/linux/pci.h | 6 ++++++
3 files changed, 38 insertions(+), 1 deletion(-)
diff -r df84c4c22a0a -r 5888ffa4b252 drivers/pci/pcie/aer/aerdrv_core.c
--- a/drivers/pci/pcie/aer/aerdrv_core.c Mon Nov 24 11:02:43 2008 +0000
+++ b/drivers/pci/pcie/aer/aerdrv_core.c Mon Nov 24 11:03:21 2008 +0000
@@ -263,7 +263,7 @@ static void report_resume(struct pci_dev
if (!dev->driver ||
!dev->driver->err_handler ||
- !dev->driver->err_handler->slot_reset)
+ !dev->driver->err_handler->resume)
return;
err_handler = dev->driver->err_handler;
diff -r df84c4c22a0a -r 5888ffa4b252 drivers/pci/search.c
--- a/drivers/pci/search.c Mon Nov 24 11:02:43 2008 +0000
+++ b/drivers/pci/search.c Mon Nov 24 11:03:21 2008 +0000
@@ -380,6 +380,36 @@ exit:
up_read(&pci_bus_sem);
return found;
}
+
+/**
+ * pci_get_bus_and_slot - locate PCI device from a given PCI bus & slot
+ * @bus: number of PCI bus on which desired PCI device resides
+ * @devfn: encodes number of PCI slot in which the desired PCI
+ * device 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
+ * is located in system global list of PCI devices. If the device
+ * is found, a pointer to its data structure is returned. If no
+ * device is found, %NULL is returned. The returned device has its
+ * reference count bumped by one.
+ */
+
+struct pci_dev * pci_get_bus_and_slot(unsigned int bus, unsigned int devfn)
+{
+ struct pci_dev *dev = NULL;
+
+ while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+ if (pci_domain_nr(dev->bus) == 0 &&
+ (dev->bus->number == bus && dev->devfn == devfn))
+ return dev;
+ }
+ return NULL;
+}
+
+
EXPORT_SYMBOL(pci_dev_present);
EXPORT_SYMBOL(pci_find_bus);
@@ -390,4 +420,5 @@ EXPORT_SYMBOL(pci_get_device);
EXPORT_SYMBOL(pci_get_device);
EXPORT_SYMBOL(pci_get_subsys);
EXPORT_SYMBOL(pci_get_slot);
+EXPORT_SYMBOL(pci_get_bus_and_slot);
EXPORT_SYMBOL(pci_get_class);
diff -r df84c4c22a0a -r 5888ffa4b252 include/linux/pci.h
--- a/include/linux/pci.h Mon Nov 24 11:02:43 2008 +0000
+++ b/include/linux/pci.h Mon Nov 24 11:03:21 2008 +0000
@@ -456,6 +456,7 @@ struct pci_dev *pci_get_subsys (unsigned
unsigned int ss_vendor, unsigned int ss_device,
struct pci_dev *from);
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_class (unsigned int class, struct pci_dev *from);
int pci_dev_present(const struct pci_device_id *ids);
@@ -655,6 +656,11 @@ static inline struct pci_dev *pci_find_s
static inline struct pci_dev *pci_find_slot(unsigned int bus, unsigned int
devfn)
{ return NULL; }
+
+static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus, unsigned
int devfn)
+{
+ return NULL;
+}
static inline struct pci_dev *pci_get_device (unsigned int vendor, unsigned
int device, struct pci_dev *from)
{ return NULL; }
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|