[PATCH 07/36] PCI: Remove duplicated code for resource sorting

Yinghai Lu
2015-07-07T00:40:56Z

Now __sort_resources, and pdev_sort_resources all have sorting
code.

We can use __sort_resources calling and remove related code in
pdev_sort_resources.
As we are going to call __sort_resources several places, so choose to
keep __sort_resources instead.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/setup-bus.c | 22 +++-------------------
1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 81f6bc4..a7dbf54 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -210,9 +210,8 @@ static void pdev_sort_resources(struct pci_dev *dev,

for (i = 0; i < PCI_NUM_RESOURCES; i++) {
struct resource *r;
- struct pci_dev_resource *dev_res, *tmp;
+ struct pci_dev_resource *tmp;
resource_size_t r_align;
- struct list_head *n;

r = &dev->resource[i];

@@ -235,22 +234,7 @@ static void pdev_sort_resources(struct pci_dev *dev,
tmp->res = r;
tmp->dev = dev;

- /* fallback is smallest one or list is empty*/
- n = head;
- list_for_each_entry(dev_res, head, list) {
- resource_size_t align;
-
- align = __pci_resource_alignment(dev_res->dev,
- dev_res->res,
- realloc_head);
-
- if (r_align > align) {
- n = &dev_res->list;
- break;
- }
- }
- /* Insert it just before n*/
- list_add_tail(&tmp->list, n);
+ list_add_tail(&tmp->list, head);
}
}

@@ -553,9 +537,9 @@ static void __assign_resources_sorted(struct list_head *head,
}
free_list(&save_head);

+requested_and_reassign:
__sort_resources(head);

-requested_and_reassign:
/* Satisfy the must-have resource requests */
assign_requested_resources_sorted(head, fail_head);

--
1.8.4.5