Commit bffc56d4 authored by Yinghai Lu's avatar Yinghai Lu Committed by Jesse Barnes

PCI: make free_list() into a function

After merging struct pci_dev_resource_x and pci_dev_resource,
We can use a function instead of macro now.
Signed-off-by: default avatarYinghai Lu <yinghai@kernel.org>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent b9b0bba9
...@@ -38,13 +38,15 @@ struct pci_dev_resource { ...@@ -38,13 +38,15 @@ struct pci_dev_resource {
unsigned long flags; unsigned long flags;
}; };
#define free_list(type, head) do { \ static void free_list(struct list_head *head)
struct type *dev_res, *tmp; \ {
list_for_each_entry_safe(dev_res, tmp, head, list) { \ struct pci_dev_resource *dev_res, *tmp;
list_del(&dev_res->list); \
kfree(dev_res); \ list_for_each_entry_safe(dev_res, tmp, head, list) {
} \ list_del(&dev_res->list);
} while (0) kfree(dev_res);
}
}
int pci_realloc_enable = 0; int pci_realloc_enable = 0;
#define pci_realloc_enabled() pci_realloc_enable #define pci_realloc_enabled() pci_realloc_enable
...@@ -329,7 +331,7 @@ static void __assign_resources_sorted(struct list_head *head, ...@@ -329,7 +331,7 @@ static void __assign_resources_sorted(struct list_head *head,
/* Save original start, end, flags etc at first */ /* Save original start, end, flags etc at first */
list_for_each_entry(dev_res, head, list) { list_for_each_entry(dev_res, head, list) {
if (add_to_list(&save_head, dev_res->dev, dev_res->res, 0, 0)) { if (add_to_list(&save_head, dev_res->dev, dev_res->res, 0, 0)) {
free_list(pci_dev_resource, &save_head); free_list(&save_head);
goto requested_and_reassign; goto requested_and_reassign;
} }
} }
...@@ -347,12 +349,12 @@ static void __assign_resources_sorted(struct list_head *head, ...@@ -347,12 +349,12 @@ static void __assign_resources_sorted(struct list_head *head,
/* Remove head list from realloc_head list */ /* Remove head list from realloc_head list */
list_for_each_entry(dev_res, head, list) list_for_each_entry(dev_res, head, list)
remove_from_list(realloc_head, dev_res->res); remove_from_list(realloc_head, dev_res->res);
free_list(pci_dev_resource, &save_head); free_list(&save_head);
free_list(pci_dev_resource, head); free_list(head);
return; return;
} }
free_list(pci_dev_resource, &local_fail_head); free_list(&local_fail_head);
/* Release assigned resource */ /* Release assigned resource */
list_for_each_entry(dev_res, head, list) list_for_each_entry(dev_res, head, list)
if (dev_res->res->parent) if (dev_res->res->parent)
...@@ -365,7 +367,7 @@ static void __assign_resources_sorted(struct list_head *head, ...@@ -365,7 +367,7 @@ static void __assign_resources_sorted(struct list_head *head,
res->end = save_res->end; res->end = save_res->end;
res->flags = save_res->flags; res->flags = save_res->flags;
} }
free_list(pci_dev_resource, &save_head); free_list(&save_head);
requested_and_reassign: requested_and_reassign:
/* Satisfy the must-have resource requests */ /* Satisfy the must-have resource requests */
...@@ -375,7 +377,7 @@ static void __assign_resources_sorted(struct list_head *head, ...@@ -375,7 +377,7 @@ static void __assign_resources_sorted(struct list_head *head,
requests */ requests */
if (realloc_head) if (realloc_head)
reassign_resources_sorted(realloc_head, head); reassign_resources_sorted(realloc_head, head);
free_list(pci_dev_resource, head); free_list(head);
} }
static void pdev_assign_resources_sorted(struct pci_dev *dev, static void pdev_assign_resources_sorted(struct pci_dev *dev,
...@@ -1298,7 +1300,7 @@ pci_assign_unassigned_resources(void) ...@@ -1298,7 +1300,7 @@ pci_assign_unassigned_resources(void)
*/ */
failed_type &= type_mask; failed_type &= type_mask;
if ((failed_type == IORESOURCE_IO) || (tried_times >= pci_try_num)) { if ((failed_type == IORESOURCE_IO) || (tried_times >= pci_try_num)) {
free_list(pci_dev_resource, &fail_head); free_list(&fail_head);
goto enable_and_dump; goto enable_and_dump;
} }
...@@ -1329,7 +1331,7 @@ pci_assign_unassigned_resources(void) ...@@ -1329,7 +1331,7 @@ pci_assign_unassigned_resources(void)
if (fail_res->dev->subordinate) if (fail_res->dev->subordinate)
res->flags = 0; res->flags = 0;
} }
free_list(pci_dev_resource, &fail_head); free_list(&fail_head);
goto again; goto again;
...@@ -1366,7 +1368,7 @@ void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge) ...@@ -1366,7 +1368,7 @@ void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge)
if (tried_times >= 2) { if (tried_times >= 2) {
/* still fail, don't need to try more */ /* still fail, don't need to try more */
free_list(pci_dev_resource, &fail_head); free_list(&fail_head);
goto enable_all; goto enable_all;
} }
...@@ -1394,7 +1396,7 @@ void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge) ...@@ -1394,7 +1396,7 @@ void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge)
if (fail_res->dev->subordinate) if (fail_res->dev->subordinate)
res->flags = 0; res->flags = 0;
} }
free_list(pci_dev_resource, &fail_head); free_list(&fail_head);
goto again; goto again;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment