[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1332136129-14010-3-git-send-email-yinghai@kernel.org>
Date: Sun, 18 Mar 2012 22:48:25 -0700
From: Yinghai Lu <yinghai@...nel.org>
To: Jesse Barnes <jbarnes@...tuousgeek.org>, x86 <x86@...nel.org>
Cc: Bjorn Helgaas <bhelgaas@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
Yinghai Lu <yinghai@...nel.org>
Subject: [PATCH -v2 02/26] PCI: Add for_each_resource helpers to make resource loop easier.
Signed-off-by: Yinghai Lu <yinghai@...nel.org>
---
include/linux/pci.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index bb81080..2b1fff8 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -349,6 +349,55 @@ struct pci_dev {
struct resource *pci_dev_resource_n(struct pci_dev *dev, int n);
+#define resno_is_for_bridge(n) \
+ ((n) >= PCI_BRIDGE_RESOURCES && (n) <= PCI_BRIDGE_RESOURCE_END)
+
+/* all (include bridge) resources */
+#define for_each_pci_dev_all_resource(dev, res, i) \
+ for (i = 0; \
+ (res = pci_dev_resource_n(dev, i)) || i < PCI_NUM_RESOURCES; \
+ i++)
+/* exclude bridge resources */
+#define for_each_pci_dev_nobridge_resource(dev, res, i) \
+ for (i = 0; \
+ (res = pci_dev_resource_n(dev, i)) || i < PCI_NUM_RESOURCES; \
+ i = (i != (PCI_BRIDGE_RESOURCES - 1)) ? (i+1) : PCI_NUM_RESOURCES)
+/* exclude bridge and IOV resources */
+#define for_each_pci_dev_base_resource(dev, res, i) \
+ for (i = 0; \
+ (res = pci_dev_resource_n(dev, i)) || i < PCI_NUM_RESOURCES; \
+ i = (i != PCI_ROM_RESOURCE) ? (i+1) : PCI_NUM_RESOURCES)
+/* exclude ROM and bridge and IOV resources */
+#define for_each_pci_dev_base_norom_resource(dev, res, i) \
+ for (i = 0; \
+ (res = pci_dev_resource_n(dev, i)) || i < PCI_NUM_RESOURCES; \
+ i = (i != (PCI_ROM_RESOURCE-1)) ? (i+1) : PCI_NUM_RESOURCES)
+/* exclude IOV resources */
+#define for_each_pci_dev_noiov_resource(dev, res, i) \
+ for (i = 0; \
+ (res = pci_dev_resource_n(dev, i)) || i < PCI_NUM_RESOURCES; \
+ i = (i != PCI_ROM_RESOURCE) ? (i+1) : PCI_BRIDGE_RESOURCES)
+/* only std resources */
+#define for_each_pci_dev_std_resource(dev, res, i) \
+ for (i = PCI_STD_RESOURCES; \
+ (res = pci_dev_resource_n(dev, i)) && i < (PCI_STD_RESOURCE_END+1); \
+ i++)
+/* only IOV resources */
+#define for_each_pci_dev_iov_resource(dev, res, i) \
+ for (i = PCI_IOV_RESOURCES; \
+ (res = pci_dev_resource_n(dev, i)) && i < (PCI_IOV_RESOURCE_END+1); \
+ i++)
+/* only bridge resources */
+#define for_each_pci_dev_bridge_resource(dev, res, i) \
+ for (i = PCI_BRIDGE_RESOURCES; \
+ (res = pci_dev_resource_n(dev, i)) && i < (PCI_BRIDGE_RESOURCE_END+1); \
+ i++)
+/* only addon resources */
+#define for_each_pci_dev_addon_resource(dev, res, i) \
+ for (i = PCI_NUM_RESOURCES; \
+ (res = pci_dev_resource_n(dev, i)); \
+ i++)
+
static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
{
#ifdef CONFIG_PCI_IOV
--
1.7.7
--
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