[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1365806683-26717-5-git-send-email-yinghai@kernel.org>
Date: Fri, 12 Apr 2013 15:44:18 -0700
From: Yinghai Lu <yinghai@...nel.org>
To: Bjorn Helgaas <bhelgaas@...gle.com>, Ram Pai <linuxram@...ibm.com>
Cc: linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
Yinghai Lu <yinghai@...nel.org>
Subject: [PATCH v4 04/29] PCI: Add pci_dev_resource_idx() helper
Use resource pointer to get index in pci resources array/list.
-v2: export symbol for acpiphp compiling error, found by
Steven Newbury <steve@...wbury.org.uk>
Signed-off-by: Yinghai Lu <yinghai@...nel.org>
---
drivers/pci/probe.c | 9 +++++++++
include/linux/pci.h | 1 +
2 files changed, 10 insertions(+)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 9cb3eb3..1df75f7 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -114,6 +114,15 @@ struct resource *pci_dev_resource_n(struct pci_dev *dev, int n)
}
EXPORT_SYMBOL(pci_dev_resource_n);
+int pci_dev_resource_idx(struct pci_dev *dev, struct resource *res)
+{
+ if (res >= dev->resource &&
+ res <= dev->resource + (PCI_NUM_RESOURCES - 1))
+ return res - dev->resource;
+
+ 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 6d450d2..f4da78d 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -354,6 +354,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);
static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
{
--
1.8.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists