diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2010-02-23 12:24:31 -0500 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2010-02-23 12:43:31 -0500 |
commit | 89a74ecccd1f78e51faf6287e5c0e93a92ac096e (patch) | |
tree | 6d167d73fb2cf5bb457b0b19145fcbf81cf441ef /drivers/pci | |
parent | 2adf75160b10bf3f09ed7d3d04e937f923fc557e (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/pci')
-rw-r--r-- | drivers/pci/bus.c | 4 | ||||
-rw-r--r-- | drivers/pci/hotplug/shpchp_sysfs.c | 9 | ||||
-rw-r--r-- | drivers/pci/pci.c | 5 | ||||
-rw-r--r-- | drivers/pci/setup-bus.c | 10 |
4 files changed, 11 insertions, 17 deletions
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index a26135bb0ffd..e75d219fd107 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 29fa9d26adae..071b7dc0094b 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 d62a5de81672..f4a2738bf0bf 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 743ed8c48b9c..bf32f07c4efb 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 | ||
804 | static void pci_bus_dump_res(struct pci_bus *bus) | 803 | static 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 | ||