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 02/26] PCI: Add for_each_resource helpers to make resource loop easier.
Date
Signed-off-by: Yinghai Lu <yinghai@kernel.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


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