Skip to content

Commit

Permalink
PCI: data structure agnostic free list function
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ram Pai authored and Jesse Barnes committed Mar 4, 2011
1 parent 13583b1 commit 094732a
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions drivers/pci/setup-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -900,7 +897,7 @@ void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge)

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;
}

Expand Down Expand Up @@ -931,7 +928,7 @@ void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge)

list = list->next;
}
free_failed_list(&head);
free_list(resource_list_x, &head);

goto again;

Expand Down

0 comments on commit 094732a

Please sign in to comment.