diff options
author | Ram Pai <linuxram@us.ibm.com> | 2011-02-15 02:43:18 +0100 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2011-03-04 19:46:04 +0100 |
commit | 094732a520caae81ae1532af29da82a4fa953472 (patch) | |
tree | 8c1b7ed35d86187032372b6e0db690c04b10a6bc /drivers/pci/setup-bus.c | |
parent | PCI: refactor io size calculation code (diff) | |
download | linux-094732a520caae81ae1532af29da82a4fa953472.tar.xz linux-094732a520caae81ae1532af29da82a4fa953472.zip |
PCI: data structure agnostic free list function
Replace free_failed_list() with a free_list() call. free_list() can
handle 'resource_list_x', 'resource_list' and any linked list linked
through ->next
Signed-off-by: Ram Pai <linuxram@us.ibm.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/setup-bus.c')
-rw-r--r-- | drivers/pci/setup-bus.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 21212155eaba..bcf5752f6907 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -36,6 +36,16 @@ struct resource_list_x { unsigned long flags; }; +#define free_list(type, head) do { \ + struct type *list, *tmp; \ + for (list = (head)->next; list;) { \ + tmp = list; \ + list = list->next; \ + kfree(tmp); \ + } \ + (head)->next = NULL; \ +} while (0) + static void add_to_failed_list(struct resource_list_x *head, struct pci_dev *dev, struct resource *res) { @@ -58,19 +68,6 @@ static void add_to_failed_list(struct resource_list_x *head, list->next = tmp; } -static void free_failed_list(struct resource_list_x *head) -{ - struct resource_list_x *list, *tmp; - - for (list = head->next; list;) { - tmp = list; - list = list->next; - kfree(tmp); - } - - head->next = NULL; -} - static void __dev_sort_resources(struct pci_dev *dev, struct resource_list *head) { @@ -900,7 +897,7 @@ again: if (tried_times >= 2) { /* still fail, don't need to try more */ - free_failed_list(&head); + free_list(resource_list_x, &head); goto enable_all; } @@ -931,7 +928,7 @@ again: list = list->next; } - free_failed_list(&head); + free_list(resource_list_x, &head); goto again; |