mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
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 <[email protected]> Signed-off-by: Jesse Barnes <[email protected]>
This commit is contained in:
parent
2adf75160b
commit
89a74ecccd
11 changed files with 32 additions and 41 deletions
|
|
@ -43,6 +43,7 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
|
|||
void *alignf_data)
|
||||
{
|
||||
int i, ret = -ENOMEM;
|
||||
struct resource *r;
|
||||
resource_size_t max = -1;
|
||||
|
||||
type_mask |= IORESOURCE_IO | IORESOURCE_MEM;
|
||||
|
|
@ -51,8 +52,7 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
|
|||
if (!(res->flags & IORESOURCE_MEM_64))
|
||||
max = PCIBIOS_MAX_MEM_32;
|
||||
|
||||
for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
|
||||
struct resource *r = bus->resource[i];
|
||||
pci_bus_for_each_resource(bus, r, i) {
|
||||
if (!r)
|
||||
continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,8 +47,7 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
|
|||
bus = pdev->subordinate;
|
||||
|
||||
out += sprintf(buf, "Free resources: memory\n");
|
||||
for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) {
|
||||
res = bus->resource[index];
|
||||
pci_bus_for_each_resource(bus, res, index) {
|
||||
if (res && (res->flags & IORESOURCE_MEM) &&
|
||||
!(res->flags & IORESOURCE_PREFETCH)) {
|
||||
out += sprintf(out, "start = %8.8llx, "
|
||||
|
|
@ -58,8 +57,7 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
|
|||
}
|
||||
}
|
||||
out += sprintf(out, "Free resources: prefetchable memory\n");
|
||||
for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) {
|
||||
res = bus->resource[index];
|
||||
pci_bus_for_each_resource(bus, res, index) {
|
||||
if (res && (res->flags & IORESOURCE_MEM) &&
|
||||
(res->flags & IORESOURCE_PREFETCH)) {
|
||||
out += sprintf(out, "start = %8.8llx, "
|
||||
|
|
@ -69,8 +67,7 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
|
|||
}
|
||||
}
|
||||
out += sprintf(out, "Free resources: IO\n");
|
||||
for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) {
|
||||
res = bus->resource[index];
|
||||
pci_bus_for_each_resource(bus, res, index) {
|
||||
if (res && (res->flags & IORESOURCE_IO)) {
|
||||
out += sprintf(out, "start = %8.8llx, "
|
||||
"length = %8.8llx\n",
|
||||
|
|
|
|||
|
|
@ -386,10 +386,9 @@ pci_find_parent_resource(const struct pci_dev *dev, struct resource *res)
|
|||
{
|
||||
const struct pci_bus *bus = dev->bus;
|
||||
int i;
|
||||
struct resource *best = NULL;
|
||||
struct resource *best = NULL, *r;
|
||||
|
||||
for(i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
|
||||
struct resource *r = bus->resource[i];
|
||||
pci_bus_for_each_resource(bus, r, i) {
|
||||
if (!r)
|
||||
continue;
|
||||
if (res->start && !(res->start >= r->start && res->end <= r->end))
|
||||
|
|
|
|||
|
|
@ -387,8 +387,7 @@ static struct resource *find_free_bus_resource(struct pci_bus *bus, unsigned lon
|
|||
unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM |
|
||||
IORESOURCE_PREFETCH;
|
||||
|
||||
for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
|
||||
r = bus->resource[i];
|
||||
pci_bus_for_each_resource(bus, r, i) {
|
||||
if (r == &ioport_resource || r == &iomem_resource)
|
||||
continue;
|
||||
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,
|
|||
|
||||
static void pci_bus_dump_res(struct pci_bus *bus)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
|
||||
struct resource *res = bus->resource[i];
|
||||
struct resource *res;
|
||||
int i;
|
||||
|
||||
pci_bus_for_each_resource(bus, res, i) {
|
||||
if (!res || !res->end || !res->flags)
|
||||
continue;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue