aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2010-02-23 12:24:31 -0500
committerJesse Barnes <jbarnes@virtuousgeek.org>2010-02-23 12:43:31 -0500
commit89a74ecccd1f78e51faf6287e5c0e93a92ac096e (patch)
tree6d167d73fb2cf5bb457b0b19145fcbf81cf441ef /drivers
parent2adf75160b10bf3f09ed7d3d04e937f923fc557e (diff)
PCI: add pci_bus_for_each_resource(), remove direct bus->resource[] refs
No functional change; this converts loops that iterate from 0 to PCI_BUS_NUM_RESOURCES through pci_bus resource[] table to use the pci_bus_for_each_resource() iterator instead. This doesn't change the way resources are stored; it merely removes dependencies on the fact that they're in a table. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/bus.c4
-rw-r--r--drivers/pci/hotplug/shpchp_sysfs.c9
-rw-r--r--drivers/pci/pci.c5
-rw-r--r--drivers/pci/setup-bus.c10
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c3
-rw-r--r--drivers/pcmcia/yenta_socket.c5
6 files changed, 15 insertions, 21 deletions
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index a26135bb0ff..e75d219fd10 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -43,6 +43,7 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
43 void *alignf_data) 43 void *alignf_data)
44{ 44{
45 int i, ret = -ENOMEM; 45 int i, ret = -ENOMEM;
46 struct resource *r;
46 resource_size_t max = -1; 47 resource_size_t max = -1;
47 48
48 type_mask |= IORESOURCE_IO | IORESOURCE_MEM; 49 type_mask |= IORESOURCE_IO | IORESOURCE_MEM;
@@ -51,8 +52,7 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
51 if (!(res->flags & IORESOURCE_MEM_64)) 52 if (!(res->flags & IORESOURCE_MEM_64))
52 max = PCIBIOS_MAX_MEM_32; 53 max = PCIBIOS_MAX_MEM_32;
53 54
54 for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) { 55 pci_bus_for_each_resource(bus, r, i) {
55 struct resource *r = bus->resource[i];
56 if (!r) 56 if (!r)
57 continue; 57 continue;
58 58
diff --git a/drivers/pci/hotplug/shpchp_sysfs.c b/drivers/pci/hotplug/shpchp_sysfs.c
index 29fa9d26ada..071b7dc0094 100644
--- a/drivers/pci/hotplug/shpchp_sysfs.c
+++ b/drivers/pci/hotplug/shpchp_sysfs.c
@@ -47,8 +47,7 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
47 bus = pdev->subordinate; 47 bus = pdev->subordinate;
48 48
49 out += sprintf(buf, "Free resources: memory\n"); 49 out += sprintf(buf, "Free resources: memory\n");
50 for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) { 50 pci_bus_for_each_resource(bus, res, index) {
51 res = bus->resource[index];
52 if (res && (res->flags & IORESOURCE_MEM) && 51 if (res && (res->flags & IORESOURCE_MEM) &&
53 !(res->flags & IORESOURCE_PREFETCH)) { 52 !(res->flags & IORESOURCE_PREFETCH)) {
54 out += sprintf(out, "start = %8.8llx, " 53 out += sprintf(out, "start = %8.8llx, "
@@ -58,8 +57,7 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
58 } 57 }
59 } 58 }
60 out += sprintf(out, "Free resources: prefetchable memory\n"); 59 out += sprintf(out, "Free resources: prefetchable memory\n");
61 for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) { 60 pci_bus_for_each_resource(bus, res, index) {
62 res = bus->resource[index];
63 if (res && (res->flags & IORESOURCE_MEM) && 61 if (res && (res->flags & IORESOURCE_MEM) &&
64 (res->flags & IORESOURCE_PREFETCH)) { 62 (res->flags & IORESOURCE_PREFETCH)) {
65 out += sprintf(out, "start = %8.8llx, " 63 out += sprintf(out, "start = %8.8llx, "
@@ -69,8 +67,7 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
69 } 67 }
70 } 68 }
71 out += sprintf(out, "Free resources: IO\n"); 69 out += sprintf(out, "Free resources: IO\n");
72 for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) { 70 pci_bus_for_each_resource(bus, res, index) {
73 res = bus->resource[index];
74 if (res && (res->flags & IORESOURCE_IO)) { 71 if (res && (res->flags & IORESOURCE_IO)) {
75 out += sprintf(out, "start = %8.8llx, " 72 out += sprintf(out, "start = %8.8llx, "
76 "length = %8.8llx\n", 73 "length = %8.8llx\n",
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index d62a5de8167..f4a2738bf0b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -386,10 +386,9 @@ pci_find_parent_resource(const struct pci_dev *dev, struct resource *res)
386{ 386{
387 const struct pci_bus *bus = dev->bus; 387 const struct pci_bus *bus = dev->bus;
388 int i; 388 int i;
389 struct resource *best = NULL; 389 struct resource *best = NULL, *r;
390 390
391 for(i = 0; i < PCI_BUS_NUM_RESOURCES; i++) { 391 pci_bus_for_each_resource(bus, r, i) {
392 struct resource *r = bus->resource[i];
393 if (!r) 392 if (!r)
394 continue; 393 continue;
395 if (res->start && !(res->start >= r->start && res->end <= r->end)) 394 if (res->start && !(res->start >= r->start && res->end <= r->end))
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 743ed8c48b9..bf32f07c4ef 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -387,8 +387,7 @@ static struct resource *find_free_bus_resource(struct pci_bus *bus, unsigned lon
387 unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM | 387 unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM |
388 IORESOURCE_PREFETCH; 388 IORESOURCE_PREFETCH;
389 389
390 for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) { 390 pci_bus_for_each_resource(bus, r, i) {
391 r = bus->resource[i];
392 if (r == &ioport_resource || r == &iomem_resource) 391 if (r == &ioport_resource || r == &iomem_resource)
393 continue; 392 continue;
394 if (r && (r->flags & type_mask) == type && !r->parent) 393 if (r && (r->flags & type_mask) == type && !r->parent)
@@ -803,11 +802,10 @@ static void __ref pci_bus_release_bridge_resources(struct pci_bus *bus,
803 802
804static void pci_bus_dump_res(struct pci_bus *bus) 803static void pci_bus_dump_res(struct pci_bus *bus)
805{ 804{
806 int i; 805 struct resource *res;
807 806 int i;
808 for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
809 struct resource *res = bus->resource[i];
810 807
808 pci_bus_for_each_resource(bus, res, i) {
811 if (!res || !res->end || !res->flags) 809 if (!res || !res->end || !res->flags)
812 continue; 810 continue;
813 811
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 45d75dc452f..c67638fe691 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -803,8 +803,7 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
803 return -EINVAL; 803 return -EINVAL;
804#endif 804#endif
805 805
806 for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) { 806 pci_bus_for_each_resource(s->cb_dev->bus, res, i) {
807 res = s->cb_dev->bus->resource[i];
808 if (!res) 807 if (!res)
809 continue; 808 continue;
810 809
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index e4d12acdd52..1f2039d5e96 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -649,9 +649,10 @@ static int yenta_search_one_res(struct resource *root, struct resource *res,
649static int yenta_search_res(struct yenta_socket *socket, struct resource *res, 649static int yenta_search_res(struct yenta_socket *socket, struct resource *res,
650 u32 min) 650 u32 min)
651{ 651{
652 struct resource *root;
652 int i; 653 int i;
653 for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) { 654
654 struct resource *root = socket->dev->bus->resource[i]; 655 pci_bus_for_each_resource(socket->dev->bus, root, i) {
655 if (!root) 656 if (!root)
656 continue; 657 continue;
657 658