[PATCH -v2 03/26] PCI: Add pci_dev_resource_idx()

From: Yinghai Lu
Date: Mon Mar 19 2012 - 01:55:38 EST


Signed-off-by: Yinghai Lu <yinghai@xxxxxxxxxx>
---
drivers/pci/probe.c | 12 ++++++++++++
include/linux/pci.h | 1 +
2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 87e87b5..7d5550a 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -85,6 +85,18 @@ struct resource *pci_dev_resource_n(struct pci_dev *dev, int n)
return NULL;
}

+int pci_dev_resource_idx(struct pci_dev *dev, struct resource *res)
+{
+ int i;
+ struct resource *r;
+
+ for_each_pci_dev_all_resource(dev, r, i)
+ if (r == res)
+ return i;
+
+ return -1;
+}
+
static u64 pci_size(u64 base, u64 maxbase, u64 mask)
{
u64 size = mask & maxbase; /* Find the significant bits */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 2b1fff8..e3f9ae1 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -348,6 +348,7 @@ struct pci_dev {
};

struct resource *pci_dev_resource_n(struct pci_dev *dev, int n);
+int pci_dev_resource_idx(struct pci_dev *dev, struct resource *res);

#define resno_is_for_bridge(n) \
((n) >= PCI_BRIDGE_RESOURCES && (n) <= PCI_BRIDGE_RESOURCE_END)
--
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/