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

Configure Feed

Select the types of activity you want to include in your feed.

PCI: Fetch dev_res to local var in __assign_resources_sorted()

__assign_resources_sorted() calls get_res_add_size() and
get_res_add_align(), each walking through the realloc_head list to
relocate the corresponding pci_dev_resource entry.

Fetch the pci_dev_resource entry into a local variable to avoid double
walk.

In addition, reverse logic to reduce indentation level.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20251219174036.16738-10-ilpo.jarvinen@linux.intel.com

authored by

Ilpo Järvinen and committed by
Bjorn Helgaas
e112fbb2 4bee4fc0

+16 -15
+16 -15
drivers/pci/setup-bus.c
··· 596 596 LIST_HEAD(local_fail_head); 597 597 LIST_HEAD(dummy_head); 598 598 struct pci_dev_resource *save_res; 599 - struct pci_dev_resource *dev_res, *tmp_res, *dev_res2; 599 + struct pci_dev_resource *dev_res, *tmp_res, *dev_res2, *addsize_res; 600 600 struct resource *res; 601 601 struct pci_dev *dev; 602 602 unsigned long fail_type; 603 - resource_size_t add_align, align; 603 + resource_size_t align; 604 604 605 605 if (!realloc_head) 606 606 realloc_head = &dummy_head; ··· 621 621 list_for_each_entry_safe(dev_res, tmp_res, head, list) { 622 622 res = dev_res->res; 623 623 624 - res->end += get_res_add_size(realloc_head, res); 624 + addsize_res = res_to_dev_res(realloc_head, res); 625 + if (!addsize_res) 626 + continue; 625 627 628 + res->end += addsize_res->add_size; 626 629 /* 627 630 * There are two kinds of additional resources in the list: 628 631 * 1. bridge resource -- IORESOURCE_STARTALIGN ··· 635 632 if (!(res->flags & IORESOURCE_STARTALIGN)) 636 633 continue; 637 634 638 - add_align = get_res_add_align(realloc_head, res); 639 - 635 + if (addsize_res->min_align <= res->start) 636 + continue; 640 637 /* 641 638 * The "head" list is sorted by alignment so resources with 642 639 * bigger alignment will be assigned first. After we ··· 644 641 * need to reorder the list by alignment to make it 645 642 * consistent. 646 643 */ 647 - if (add_align > res->start) { 648 - resource_set_range(res, add_align, resource_size(res)); 644 + resource_set_range(res, addsize_res->min_align, 645 + resource_size(res)); 649 646 650 - list_for_each_entry(dev_res2, head, list) { 651 - align = pci_resource_alignment(dev_res2->dev, 652 - dev_res2->res); 653 - if (add_align > align) { 654 - list_move_tail(&dev_res->list, 655 - &dev_res2->list); 656 - break; 657 - } 647 + list_for_each_entry(dev_res2, head, list) { 648 + align = pci_resource_alignment(dev_res2->dev, 649 + dev_res2->res); 650 + if (addsize_res->min_align > align) { 651 + list_move_tail(&dev_res->list, &dev_res2->list); 652 + break; 658 653 } 659 654 } 660 655