aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/setup-bus.c
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2012-01-21 05:08:30 -0500
committerJesse Barnes <jbarnes@virtuousgeek.org>2012-02-14 11:44:57 -0500
commitbffc56d41102705d809f88c29918a9c33d2900f7 (patch)
tree61889ca64ef9166ef17ea8555dc0c53c50149b16 /drivers/pci/setup-bus.c
parentb9b0bba96cf5acbf025f7829fbf6c09e74323b41 (diff)
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: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/setup-bus.c')
-rw-r--r--drivers/pci/setup-bus.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index a6e427adc36d..c845d18bb126 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -38,13 +38,15 @@ struct pci_dev_resource {
38 unsigned long flags; 38 unsigned long flags;
39}; 39};
40 40
41#define free_list(type, head) do { \ 41static void free_list(struct list_head *head)
42 struct type *dev_res, *tmp; \ 42{
43 list_for_each_entry_safe(dev_res, tmp, head, list) { \ 43 struct pci_dev_resource *dev_res, *tmp;
44 list_del(&dev_res->list); \ 44
45 kfree(dev_res); \ 45 list_for_each_entry_safe(dev_res, tmp, head, list) {
46 } \ 46 list_del(&dev_res->list);
47} while (0) 47 kfree(dev_res);
48 }
49}
48 50
49int pci_realloc_enable = 0; 51int pci_realloc_enable = 0;
50#define pci_realloc_enabled() pci_realloc_enable 52#define pci_realloc_enabled() pci_realloc_enable
@@ -329,7 +331,7 @@ static void __assign_resources_sorted(struct list_head *head,
329 /* Save original start, end, flags etc at first */ 331 /* Save original start, end, flags etc at first */
330 list_for_each_entry(dev_res, head, list) { 332 list_for_each_entry(dev_res, head, list) {
331 if (add_to_list(&save_head, dev_res->dev, dev_res->res, 0, 0)) { 333 if (add_to_list(&save_head, dev_res->dev, dev_res->res, 0, 0)) {
332 free_list(pci_dev_resource, &save_head); 334 free_list(&save_head);
333 goto requested_and_reassign; 335 goto requested_and_reassign;
334 } 336 }
335 } 337 }
@@ -347,12 +349,12 @@ static void __assign_resources_sorted(struct list_head *head,
347 /* Remove head list from realloc_head list */ 349 /* Remove head list from realloc_head list */
348 list_for_each_entry(dev_res, head, list) 350 list_for_each_entry(dev_res, head, list)
349 remove_from_list(realloc_head, dev_res->res); 351 remove_from_list(realloc_head, dev_res->res);
350 free_list(pci_dev_resource, &save_head); 352 free_list(&save_head);
351 free_list(pci_dev_resource, head); 353 free_list(head);
352 return; 354 return;
353 } 355 }
354 356
355 free_list(pci_dev_resource, &local_fail_head); 357 free_list(&local_fail_head);
356 /* Release assigned resource */ 358 /* Release assigned resource */
357 list_for_each_entry(dev_res, head, list) 359 list_for_each_entry(dev_res, head, list)
358 if (dev_res->res->parent) 360 if (dev_res->res->parent)
@@ -365,7 +367,7 @@ static void __assign_resources_sorted(struct list_head *head,
365 res->end = save_res->end; 367 res->end = save_res->end;
366 res->flags = save_res->flags; 368 res->flags = save_res->flags;
367 } 369 }
368 free_list(pci_dev_resource, &save_head); 370 free_list(&save_head);
369 371
370requested_and_reassign: 372requested_and_reassign:
371 /* Satisfy the must-have resource requests */ 373 /* Satisfy the must-have resource requests */
@@ -375,7 +377,7 @@ requested_and_reassign:
375 requests */ 377 requests */
376 if (realloc_head) 378 if (realloc_head)
377 reassign_resources_sorted(realloc_head, head); 379 reassign_resources_sorted(realloc_head, head);
378 free_list(pci_dev_resource, head); 380 free_list(head);
379} 381}
380 382
381static void pdev_assign_resources_sorted(struct pci_dev *dev, 383static void pdev_assign_resources_sorted(struct pci_dev *dev,
@@ -1298,7 +1300,7 @@ again:
1298 */ 1300 */
1299 failed_type &= type_mask; 1301 failed_type &= type_mask;
1300 if ((failed_type == IORESOURCE_IO) || (tried_times >= pci_try_num)) { 1302 if ((failed_type == IORESOURCE_IO) || (tried_times >= pci_try_num)) {
1301 free_list(pci_dev_resource, &fail_head); 1303 free_list(&fail_head);
1302 goto enable_and_dump; 1304 goto enable_and_dump;
1303 } 1305 }
1304 1306
@@ -1329,7 +1331,7 @@ again:
1329 if (fail_res->dev->subordinate) 1331 if (fail_res->dev->subordinate)
1330 res->flags = 0; 1332 res->flags = 0;
1331 } 1333 }
1332 free_list(pci_dev_resource, &fail_head); 1334 free_list(&fail_head);
1333 1335
1334 goto again; 1336 goto again;
1335 1337
@@ -1366,7 +1368,7 @@ again:
1366 1368
1367 if (tried_times >= 2) { 1369 if (tried_times >= 2) {
1368 /* still fail, don't need to try more */ 1370 /* still fail, don't need to try more */
1369 free_list(pci_dev_resource, &fail_head); 1371 free_list(&fail_head);
1370 goto enable_all; 1372 goto enable_all;
1371 } 1373 }
1372 1374
@@ -1394,7 +1396,7 @@ again:
1394 if (fail_res->dev->subordinate) 1396 if (fail_res->dev->subordinate)
1395 res->flags = 0; 1397 res->flags = 0;
1396 } 1398 }
1397 free_list(pci_dev_resource, &fail_head); 1399 free_list(&fail_head);
1398 1400
1399 goto again; 1401 goto again;
1400 1402