lkml.org 
[lkml]   [2012]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH -v2 03/26] PCI: Add pci_dev_resource_idx()
Date
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
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


\
 
 \ /
  Last update: 2012-03-19 06:57    [W:0.128 / U:0.956 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site