Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: Introduce pci_dev_for_each_resource()

Instead of open-coding it everywhere introduce a tiny helper that can be
used to iterate over each resource of a PCI device, and convert the most
obvious users into it.

While at it drop doubled empty line before pdev_sort_resources().

No functional changes intended.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230330162434.35055-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Krzysztof Wilczyński <kw@linux.com>

authored by

Mika Westerberg and committed by
Bjorn Helgaas
09cc9006 144d204d

+111 -132
+1
.clang-format
··· 520 520 - 'of_property_for_each_string' 521 521 - 'of_property_for_each_u32' 522 522 - 'pci_bus_for_each_resource' 523 + - 'pci_dev_for_each_resource' 523 524 - 'pci_doe_for_each_off' 524 525 - 'pcl_for_each_chunk' 525 526 - 'pcl_for_each_segment'
+2 -3
arch/alpha/kernel/pci.c
··· 288 288 struct pci_bus *child_bus; 289 289 290 290 list_for_each_entry(dev, &b->devices, bus_list) { 291 + struct resource *r; 291 292 int i; 292 293 293 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 294 - struct resource *r = &dev->resource[i]; 295 - 294 + pci_dev_for_each_resource(dev, r, i) { 296 295 if (r->parent || !r->start || !r->flags) 297 296 continue; 298 297 if (pci_has_flag(PCI_PROBE_ONLY) ||
+7 -9
arch/arm/kernel/bios32.c
··· 142 142 */ 143 143 static void pci_fixup_dec21285(struct pci_dev *dev) 144 144 { 145 - int i; 146 - 147 145 if (dev->devfn == 0) { 146 + struct resource *r; 147 + 148 148 dev->class &= 0xff; 149 149 dev->class |= PCI_CLASS_BRIDGE_HOST << 8; 150 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 151 - dev->resource[i].start = 0; 152 - dev->resource[i].end = 0; 153 - dev->resource[i].flags = 0; 150 + pci_dev_for_each_resource(dev, r) { 151 + r->start = 0; 152 + r->end = 0; 153 + r->flags = 0; 154 154 } 155 155 } 156 156 } ··· 162 162 static void pci_fixup_ide_bases(struct pci_dev *dev) 163 163 { 164 164 struct resource *r; 165 - int i; 166 165 167 166 if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE) 168 167 return; 169 168 170 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 171 - r = dev->resource + i; 169 + pci_dev_for_each_resource(dev, r) { 172 170 if ((r->start & ~0x80) == 0x374) { 173 171 r->start |= 2; 174 172 r->end = r->start;
+5 -5
arch/arm/mach-dove/pcie.c
··· 142 142 static void rc_pci_fixup(struct pci_dev *dev) 143 143 { 144 144 if (dev->bus->parent == NULL && dev->devfn == 0) { 145 - int i; 145 + struct resource *r; 146 146 147 147 dev->class &= 0xff; 148 148 dev->class |= PCI_CLASS_BRIDGE_HOST << 8; 149 - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 150 - dev->resource[i].start = 0; 151 - dev->resource[i].end = 0; 152 - dev->resource[i].flags = 0; 149 + pci_dev_for_each_resource(dev, r) { 150 + r->start = 0; 151 + r->end = 0; 152 + r->flags = 0; 153 153 } 154 154 } 155 155 }
+5 -5
arch/arm/mach-mv78xx0/pcie.c
··· 186 186 static void rc_pci_fixup(struct pci_dev *dev) 187 187 { 188 188 if (dev->bus->parent == NULL && dev->devfn == 0) { 189 - int i; 189 + struct resource *r; 190 190 191 191 dev->class &= 0xff; 192 192 dev->class |= PCI_CLASS_BRIDGE_HOST << 8; 193 - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 194 - dev->resource[i].start = 0; 195 - dev->resource[i].end = 0; 196 - dev->resource[i].flags = 0; 193 + pci_dev_for_each_resource(dev, r) { 194 + r->start = 0; 195 + r->end = 0; 196 + r->flags = 0; 197 197 } 198 198 } 199 199 }
+5 -5
arch/arm/mach-orion5x/pci.c
··· 522 522 static void rc_pci_fixup(struct pci_dev *dev) 523 523 { 524 524 if (dev->bus->parent == NULL && dev->devfn == 0) { 525 - int i; 525 + struct resource *r; 526 526 527 527 dev->class &= 0xff; 528 528 dev->class |= PCI_CLASS_BRIDGE_HOST << 8; 529 - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 530 - dev->resource[i].start = 0; 531 - dev->resource[i].end = 0; 532 - dev->resource[i].flags = 0; 529 + pci_dev_for_each_resource(dev, r) { 530 + r->start = 0; 531 + r->end = 0; 532 + r->flags = 0; 533 533 } 534 534 } 535 535 }
+4 -4
arch/mips/pci/ops-bcm63xx.c
··· 413 413 static void bcm63xx_fixup(struct pci_dev *dev) 414 414 { 415 415 static int io_window = -1; 416 - int i, found, new_io_window; 416 + int found, new_io_window; 417 + struct resource *r; 417 418 u32 val; 418 419 419 420 /* look for any io resource */ 420 421 found = 0; 421 - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 422 - if (pci_resource_flags(dev, i) & IORESOURCE_IO) { 422 + pci_dev_for_each_resource(dev, r) { 423 + if (resource_type(r) == IORESOURCE_IO) { 423 424 found = 1; 424 425 break; 425 426 } 426 427 } 427 - 428 428 if (!found) 429 429 return; 430 430
+1 -2
arch/mips/pci/pci-legacy.c
··· 249 249 250 250 pci_read_config_word(dev, PCI_COMMAND, &cmd); 251 251 old_cmd = cmd; 252 - for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) { 252 + pci_dev_for_each_resource(dev, r, idx) { 253 253 /* Only set up the requested stuff */ 254 254 if (!(mask & (1<<idx))) 255 255 continue; 256 256 257 - r = &dev->resource[idx]; 258 257 if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM))) 259 258 continue; 260 259 if ((idx == PCI_ROM_RESOURCE) &&
+11 -10
arch/powerpc/kernel/pci-common.c
··· 880 880 static void pcibios_fixup_resources(struct pci_dev *dev) 881 881 { 882 882 struct pci_controller *hose = pci_bus_to_host(dev->bus); 883 + struct resource *res; 883 884 int i; 884 885 885 886 if (!hose) { ··· 892 891 if (dev->is_virtfn) 893 892 return; 894 893 895 - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 896 - struct resource *res = dev->resource + i; 894 + pci_dev_for_each_resource(dev, res, i) { 897 895 struct pci_bus_region reg; 896 + 898 897 if (!res->flags) 899 898 continue; 900 899 ··· 1453 1452 struct pci_bus *child_bus; 1454 1453 1455 1454 list_for_each_entry(dev, &bus->devices, bus_list) { 1455 + struct resource *r; 1456 1456 int i; 1457 1457 1458 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 1459 - struct resource *r = &dev->resource[i]; 1460 - 1458 + pci_dev_for_each_resource(dev, r, i) { 1461 1459 if (r->parent || !r->start || !r->flags) 1462 1460 continue; 1463 1461 ··· 1705 1705 1706 1706 static void fixup_hide_host_resource_fsl(struct pci_dev *dev) 1707 1707 { 1708 - int i, class = dev->class >> 8; 1708 + int class = dev->class >> 8; 1709 1709 /* When configured as agent, programming interface = 1 */ 1710 1710 int prog_if = dev->class & 0xf; 1711 + struct resource *r; 1711 1712 1712 1713 if ((class == PCI_CLASS_PROCESSOR_POWERPC || 1713 1714 class == PCI_CLASS_BRIDGE_OTHER) && 1714 1715 (dev->hdr_type == PCI_HEADER_TYPE_NORMAL) && 1715 1716 (prog_if == 0) && 1716 1717 (dev->bus->parent == NULL)) { 1717 - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 1718 - dev->resource[i].start = 0; 1719 - dev->resource[i].end = 0; 1720 - dev->resource[i].flags = 0; 1718 + pci_dev_for_each_resource(dev, r) { 1719 + r->start = 0; 1720 + r->end = 0; 1721 + r->flags = 0; 1721 1722 } 1722 1723 } 1723 1724 }
+4 -4
arch/powerpc/platforms/4xx/pci.c
··· 57 57 static void fixup_ppc4xx_pci_bridge(struct pci_dev *dev) 58 58 { 59 59 struct pci_controller *hose; 60 - int i; 60 + struct resource *r; 61 61 62 62 if (dev->devfn != 0 || dev->bus->self != NULL) 63 63 return; ··· 79 79 /* Hide the PCI host BARs from the kernel as their content doesn't 80 80 * fit well in the resource management 81 81 */ 82 - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 83 - dev->resource[i].start = dev->resource[i].end = 0; 84 - dev->resource[i].flags = 0; 82 + pci_dev_for_each_resource(dev, r) { 83 + r->start = r->end = 0; 84 + r->flags = 0; 85 85 } 86 86 87 87 printk(KERN_INFO "PCI: Hiding 4xx host bridge resources %s\n",
+2 -3
arch/powerpc/platforms/52xx/mpc52xx_pci.c
··· 327 327 static void 328 328 mpc52xx_pci_fixup_resources(struct pci_dev *dev) 329 329 { 330 - int i; 330 + struct resource *res; 331 331 332 332 pr_debug("%s() %.4x:%.4x\n", __func__, dev->vendor, dev->device); 333 333 334 334 /* We don't rely on boot loader for PCI and resets all 335 335 devices */ 336 - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 337 - struct resource *res = &dev->resource[i]; 336 + pci_dev_for_each_resource(dev, res) { 338 337 if (res->end > res->start) { /* Only valid resources */ 339 338 res->end -= res->start; 340 339 res->start = 0;
+8 -8
arch/powerpc/platforms/pseries/pci.c
··· 240 240 */ 241 241 static void fixup_winbond_82c105(struct pci_dev* dev) 242 242 { 243 - int i; 243 + struct resource *r; 244 244 unsigned int reg; 245 245 246 246 if (!machine_is(pseries)) ··· 251 251 /* Enable LEGIRQ to use INTC instead of ISA interrupts */ 252 252 pci_write_config_dword(dev, 0x40, reg | (1<<11)); 253 253 254 - for (i = 0; i < DEVICE_COUNT_RESOURCE; ++i) { 254 + pci_dev_for_each_resource(dev, r) { 255 255 /* zap the 2nd function of the winbond chip */ 256 - if (dev->resource[i].flags & IORESOURCE_IO 257 - && dev->bus->number == 0 && dev->devfn == 0x81) 258 - dev->resource[i].flags &= ~IORESOURCE_IO; 259 - if (dev->resource[i].start == 0 && dev->resource[i].end) { 260 - dev->resource[i].flags = 0; 261 - dev->resource[i].end = 0; 256 + if (dev->bus->number == 0 && dev->devfn == 0x81 && 257 + r->flags & IORESOURCE_IO) 258 + r->flags &= ~IORESOURCE_IO; 259 + if (r->start == 0 && r->end) { 260 + r->flags = 0; 261 + r->end = 0; 262 262 } 263 263 } 264 264 }
+5 -5
arch/sh/drivers/pci/pcie-sh7786.c
··· 140 140 * Prevent enumeration of root complex resources. 141 141 */ 142 142 if (pci_is_root_bus(dev->bus) && dev->devfn == 0) { 143 - int i; 143 + struct resource *r; 144 144 145 - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 146 - dev->resource[i].start = 0; 147 - dev->resource[i].end = 0; 148 - dev->resource[i].flags = 0; 145 + pci_dev_for_each_resource(dev, r) { 146 + r->start = 0; 147 + r->end = 0; 148 + r->flags = 0; 149 149 } 150 150 } 151 151 }
+2 -3
arch/sparc/kernel/leon_pci.c
··· 62 62 63 63 int pcibios_enable_device(struct pci_dev *dev, int mask) 64 64 { 65 + struct resource *res; 65 66 u16 cmd, oldcmd; 66 67 int i; 67 68 68 69 pci_read_config_word(dev, PCI_COMMAND, &cmd); 69 70 oldcmd = cmd; 70 71 71 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 72 - struct resource *res = &dev->resource[i]; 73 - 72 + pci_dev_for_each_resource(dev, res, i) { 74 73 /* Only set up the requested stuff */ 75 74 if (!(mask & (1<<i))) 76 75 continue;
+4 -6
arch/sparc/kernel/pci.c
··· 663 663 struct pci_dev *dev; 664 664 665 665 list_for_each_entry(dev, &bus->devices, bus_list) { 666 + struct resource *r; 666 667 int i; 667 668 668 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 669 - struct resource *r = &dev->resource[i]; 670 - 669 + pci_dev_for_each_resource(dev, r, i) { 671 670 if (r->parent || !r->start || !r->flags) 672 671 continue; 673 672 ··· 723 724 724 725 int pcibios_enable_device(struct pci_dev *dev, int mask) 725 726 { 727 + struct resource *res; 726 728 u16 cmd, oldcmd; 727 729 int i; 728 730 729 731 pci_read_config_word(dev, PCI_COMMAND, &cmd); 730 732 oldcmd = cmd; 731 733 732 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 733 - struct resource *res = &dev->resource[i]; 734 - 734 + pci_dev_for_each_resource(dev, res, i) { 735 735 /* Only set up the requested stuff */ 736 736 if (!(mask & (1<<i))) 737 737 continue;
+2 -3
arch/sparc/kernel/pcic.c
··· 643 643 644 644 int pcibios_enable_device(struct pci_dev *dev, int mask) 645 645 { 646 + struct resource *res; 646 647 u16 cmd, oldcmd; 647 648 int i; 648 649 649 650 pci_read_config_word(dev, PCI_COMMAND, &cmd); 650 651 oldcmd = cmd; 651 652 652 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 653 - struct resource *res = &dev->resource[i]; 654 - 653 + pci_dev_for_each_resource(dev, res, i) { 655 654 /* Only set up the requested stuff */ 656 655 if (!(mask & (1<<i))) 657 656 continue;
+2 -3
drivers/pci/remove.c
··· 5 5 6 6 static void pci_free_resources(struct pci_dev *dev) 7 7 { 8 - int i; 8 + struct resource *res; 9 9 10 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 11 - struct resource *res = dev->resource + i; 10 + pci_dev_for_each_resource(dev, res) { 12 11 if (res->parent) 13 12 release_resource(res); 14 13 }
+10 -17
drivers/pci/setup-bus.c
··· 124 124 return dev_res ? dev_res->min_align : 0; 125 125 } 126 126 127 - 128 127 /* Sort resources by alignment */ 129 128 static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head) 130 129 { 130 + struct resource *r; 131 131 int i; 132 132 133 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 134 - struct resource *r; 133 + pci_dev_for_each_resource(dev, r, i) { 135 134 struct pci_dev_resource *dev_res, *tmp; 136 135 resource_size_t r_align; 137 136 struct list_head *n; 138 - 139 - r = &dev->resource[i]; 140 137 141 138 if (r->flags & IORESOURCE_PCI_FIXED) 142 139 continue; ··· 892 895 893 896 min_align = window_alignment(bus, IORESOURCE_IO); 894 897 list_for_each_entry(dev, &bus->devices, bus_list) { 895 - int i; 898 + struct resource *r; 896 899 897 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 898 - struct resource *r = &dev->resource[i]; 900 + pci_dev_for_each_resource(dev, r) { 899 901 unsigned long r_size; 900 902 901 903 if (r->parent || !(r->flags & IORESOURCE_IO)) ··· 1010 1014 size = 0; 1011 1015 1012 1016 list_for_each_entry(dev, &bus->devices, bus_list) { 1017 + struct resource *r; 1013 1018 int i; 1014 1019 1015 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 1016 - struct resource *r = &dev->resource[i]; 1020 + pci_dev_for_each_resource(dev, r, i) { 1017 1021 resource_size_t r_size; 1018 1022 1019 1023 if (r->parent || (r->flags & IORESOURCE_PCI_FIXED) || ··· 1354 1358 */ 1355 1359 static void pdev_assign_fixed_resources(struct pci_dev *dev) 1356 1360 { 1357 - int i; 1361 + struct resource *r; 1358 1362 1359 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 1363 + pci_dev_for_each_resource(dev, r) { 1360 1364 struct pci_bus *b; 1361 - struct resource *r = &dev->resource[i]; 1362 1365 1363 1366 if (r->parent || !(r->flags & IORESOURCE_PCI_FIXED) || 1364 1367 !(r->flags & (IORESOURCE_IO | IORESOURCE_MEM))) ··· 1790 1795 struct resource *mmio, 1791 1796 struct resource *mmio_pref) 1792 1797 { 1793 - int i; 1798 + struct resource *res; 1794 1799 1795 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 1796 - struct resource *res = &dev->resource[i]; 1797 - 1800 + pci_dev_for_each_resource(dev, res) { 1798 1801 if (resource_type(res) == IORESOURCE_IO) { 1799 1802 remove_dev_resource(io, dev, res); 1800 1803 } else if (resource_type(res) == IORESOURCE_MEM) {
+1 -3
drivers/pci/setup-res.c
··· 484 484 pci_read_config_word(dev, PCI_COMMAND, &cmd); 485 485 old_cmd = cmd; 486 486 487 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 487 + pci_dev_for_each_resource(dev, r, i) { 488 488 if (!(mask & (1 << i))) 489 489 continue; 490 - 491 - r = &dev->resource[i]; 492 490 493 491 if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM))) 494 492 continue;
+5 -12
drivers/pci/vgaarb.c
··· 548 548 #if defined(CONFIG_X86) || defined(CONFIG_IA64) 549 549 u64 base = screen_info.lfb_base; 550 550 u64 size = screen_info.lfb_size; 551 + struct resource *r; 551 552 u64 limit; 552 - resource_size_t start, end; 553 - unsigned long flags; 554 - int i; 555 553 556 554 /* Select the device owning the boot framebuffer if there is one */ 557 555 ··· 559 561 limit = base + size; 560 562 561 563 /* Does firmware framebuffer belong to us? */ 562 - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 563 - flags = pci_resource_flags(pdev, i); 564 - 565 - if ((flags & IORESOURCE_MEM) == 0) 564 + pci_dev_for_each_resource(pdev, r) { 565 + if (resource_type(r) != IORESOURCE_MEM) 566 566 continue; 567 567 568 - start = pci_resource_start(pdev, i); 569 - end = pci_resource_end(pdev, i); 570 - 571 - if (!start || !end) 568 + if (!r->start || !r->end) 572 569 continue; 573 570 574 - if (base < start || limit >= end) 571 + if (base < r->start || limit >= r->end) 575 572 continue; 576 573 577 574 return true;
+1 -3
drivers/pci/xen-pcifront.c
··· 390 390 int i; 391 391 struct resource *r; 392 392 393 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 394 - r = &dev->resource[i]; 395 - 393 + pci_dev_for_each_resource(dev, r, i) { 396 394 if (!r->parent && r->start && r->flags) { 397 395 dev_info(&pdev->xdev->dev, "claiming resource %s/%d\n", 398 396 pci_name(dev), i);
+10 -19
drivers/pnp/quirks.c
··· 229 229 static void quirk_system_pci_resources(struct pnp_dev *dev) 230 230 { 231 231 struct pci_dev *pdev = NULL; 232 - struct resource *res; 233 - resource_size_t pnp_start, pnp_end, pci_start, pci_end; 232 + struct resource *res, *r; 234 233 int i, j; 235 234 236 235 /* ··· 242 243 * so they won't be claimed by the PNP system driver. 243 244 */ 244 245 for_each_pci_dev(pdev) { 245 - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 246 - unsigned long flags, type; 246 + pci_dev_for_each_resource(pdev, r, i) { 247 + unsigned long type = resource_type(r); 247 248 248 - flags = pci_resource_flags(pdev, i); 249 - type = flags & (IORESOURCE_IO | IORESOURCE_MEM); 250 - if (!type || pci_resource_len(pdev, i) == 0) 249 + if (!(type == IORESOURCE_IO || type == IORESOURCE_MEM) || 250 + resource_size(r) == 0) 251 251 continue; 252 252 253 - if (flags & IORESOURCE_UNSET) 253 + if (r->flags & IORESOURCE_UNSET) 254 254 continue; 255 255 256 - pci_start = pci_resource_start(pdev, i); 257 - pci_end = pci_resource_end(pdev, i); 258 256 for (j = 0; 259 257 (res = pnp_get_resource(dev, type, j)); j++) { 260 258 if (res->start == 0 && res->end == 0) 261 259 continue; 262 260 263 - pnp_start = res->start; 264 - pnp_end = res->end; 265 - 266 261 /* 267 262 * If the PNP region doesn't overlap the PCI 268 263 * region at all, there's no problem. 269 264 */ 270 - if (pnp_end < pci_start || pnp_start > pci_end) 265 + if (!resource_overlaps(res, r)) 271 266 continue; 272 267 273 268 /* ··· 271 278 * PNP device describes a bridge with PCI 272 279 * behind it. 273 280 */ 274 - if (pnp_start <= pci_start && 275 - pnp_end >= pci_end) 281 + if (res->start <= r->start && res->end >= r->end) 276 282 continue; 277 283 278 284 /* ··· 280 288 * driver from requesting its resources. 281 289 */ 282 290 dev_warn(&dev->dev, 283 - "disabling %pR because it overlaps " 284 - "%s BAR %d %pR\n", res, 285 - pci_name(pdev), i, &pdev->resource[i]); 291 + "disabling %pR because it overlaps %s BAR %d %pR\n", 292 + res, pci_name(pdev), i, r); 286 293 res->flags |= IORESOURCE_DISABLED; 287 294 } 288 295 }
+14
include/linux/pci.h
··· 2002 2002 (pci_resource_end((dev), (bar)) ? \ 2003 2003 resource_size(pci_resource_n((dev), (bar))) : 0) 2004 2004 2005 + #define __pci_dev_for_each_res0(dev, res, ...) \ 2006 + for (unsigned int __b = 0; \ 2007 + res = pci_resource_n(dev, __b), __b < PCI_NUM_RESOURCES; \ 2008 + __b++) 2009 + 2010 + #define __pci_dev_for_each_res1(dev, res, __b) \ 2011 + for (__b = 0; \ 2012 + res = pci_resource_n(dev, __b), __b < PCI_NUM_RESOURCES; \ 2013 + __b++) 2014 + 2015 + #define pci_dev_for_each_resource(dev, res, ...) \ 2016 + CONCATENATE(__pci_dev_for_each_res, COUNT_ARGS(__VA_ARGS__)) \ 2017 + (dev, res, __VA_ARGS__) 2018 + 2005 2019 /* 2006 2020 * Similar to the helpers above, these manipulate per-pci_dev 2007 2021 * driver-specific data. They are really just a wrapper around