aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2012-01-21 05:08:28 -0500
committerJesse Barnes <jbarnes@virtuousgeek.org>2012-02-14 11:44:56 -0500
commit764242a0aec69e10b8dc0f4f0303a6800b09cf45 (patch)
treec61109a8d13c8b212be05c069d3339fdc73cfa14 /drivers
parentbdc4abecaeff30b3cc230b418a925999dda594c2 (diff)
PCI: Merge pci_dev_resource_x and pci_dev_resource
pci_dev_resource_x is a superset of pci_dev_resource and they're just temp structs used during resource reallocation. pci_dev_resource usage is quite limted. So just use pci_dev_resource_x, and rename it as new pci_dev_resource. -v2: According to Linus, Separate free_list change to another patch Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/setup-bus.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 4c5509e3c75a..af2a98a0ae7c 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -31,12 +31,6 @@ struct pci_dev_resource {
31 struct list_head list; 31 struct list_head list;
32 struct resource *res; 32 struct resource *res;
33 struct pci_dev *dev; 33 struct pci_dev *dev;
34};
35
36struct pci_dev_resource_x {
37 struct list_head list;
38 struct resource *res;
39 struct pci_dev *dev;
40 resource_size_t start; 34 resource_size_t start;
41 resource_size_t end; 35 resource_size_t end;
42 resource_size_t add_size; 36 resource_size_t add_size;
@@ -72,7 +66,7 @@ static int add_to_list(struct list_head *head,
72 struct pci_dev *dev, struct resource *res, 66 struct pci_dev *dev, struct resource *res,
73 resource_size_t add_size, resource_size_t min_align) 67 resource_size_t add_size, resource_size_t min_align)
74{ 68{
75 struct pci_dev_resource_x *tmp; 69 struct pci_dev_resource *tmp;
76 70
77 tmp = kzalloc(sizeof(*tmp), GFP_KERNEL); 71 tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
78 if (!tmp) { 72 if (!tmp) {
@@ -104,7 +98,7 @@ static void add_to_failed_list(struct list_head *head,
104static void remove_from_list(struct list_head *realloc_head, 98static void remove_from_list(struct list_head *realloc_head,
105 struct resource *res) 99 struct resource *res)
106{ 100{
107 struct pci_dev_resource_x *dev_res_x, *tmp; 101 struct pci_dev_resource *dev_res_x, *tmp;
108 102
109 list_for_each_entry_safe(dev_res_x, tmp, realloc_head, list) { 103 list_for_each_entry_safe(dev_res_x, tmp, realloc_head, list) {
110 if (dev_res_x->res == res) { 104 if (dev_res_x->res == res) {
@@ -118,7 +112,7 @@ static void remove_from_list(struct list_head *realloc_head,
118static resource_size_t get_res_add_size(struct list_head *realloc_head, 112static resource_size_t get_res_add_size(struct list_head *realloc_head,
119 struct resource *res) 113 struct resource *res)
120{ 114{
121 struct pci_dev_resource_x *dev_res_x; 115 struct pci_dev_resource *dev_res_x;
122 116
123 list_for_each_entry(dev_res_x, realloc_head, list) { 117 list_for_each_entry(dev_res_x, realloc_head, list) {
124 if (dev_res_x->res == res) { 118 if (dev_res_x->res == res) {
@@ -227,7 +221,7 @@ static void reassign_resources_sorted(struct list_head *realloc_head,
227 struct list_head *head) 221 struct list_head *head)
228{ 222{
229 struct resource *res; 223 struct resource *res;
230 struct pci_dev_resource_x *dev_res_x, *tmp; 224 struct pci_dev_resource *dev_res_x, *tmp;
231 struct pci_dev_resource *dev_res; 225 struct pci_dev_resource *dev_res;
232 resource_size_t add_size; 226 resource_size_t add_size;
233 int idx; 227 int idx;
@@ -325,7 +319,7 @@ static void __assign_resources_sorted(struct list_head *head,
325 */ 319 */
326 LIST_HEAD(save_head); 320 LIST_HEAD(save_head);
327 LIST_HEAD(local_fail_head); 321 LIST_HEAD(local_fail_head);
328 struct pci_dev_resource_x *dev_res_x; 322 struct pci_dev_resource *dev_res_x;
329 struct pci_dev_resource *dev_res; 323 struct pci_dev_resource *dev_res;
330 324
331 /* Check if optional add_size is there */ 325 /* Check if optional add_size is there */
@@ -335,7 +329,7 @@ static void __assign_resources_sorted(struct list_head *head,
335 /* Save original start, end, flags etc at first */ 329 /* Save original start, end, flags etc at first */
336 list_for_each_entry(dev_res, head, list) { 330 list_for_each_entry(dev_res, head, list) {
337 if (add_to_list(&save_head, dev_res->dev, dev_res->res, 0, 0)) { 331 if (add_to_list(&save_head, dev_res->dev, dev_res->res, 0, 0)) {
338 free_list(pci_dev_resource_x, &save_head); 332 free_list(pci_dev_resource, &save_head);
339 goto requested_and_reassign; 333 goto requested_and_reassign;
340 } 334 }
341 } 335 }
@@ -353,12 +347,12 @@ static void __assign_resources_sorted(struct list_head *head,
353 /* Remove head list from realloc_head list */ 347 /* Remove head list from realloc_head list */
354 list_for_each_entry(dev_res, head, list) 348 list_for_each_entry(dev_res, head, list)
355 remove_from_list(realloc_head, dev_res->res); 349 remove_from_list(realloc_head, dev_res->res);
356 free_list(pci_dev_resource_x, &save_head); 350 free_list(pci_dev_resource, &save_head);
357 free_list(pci_dev_resource, head); 351 free_list(pci_dev_resource, head);
358 return; 352 return;
359 } 353 }
360 354
361 free_list(pci_dev_resource_x, &local_fail_head); 355 free_list(pci_dev_resource, &local_fail_head);
362 /* Release assigned resource */ 356 /* Release assigned resource */
363 list_for_each_entry(dev_res, head, list) 357 list_for_each_entry(dev_res, head, list)
364 if (dev_res->res->parent) 358 if (dev_res->res->parent)
@@ -371,7 +365,7 @@ static void __assign_resources_sorted(struct list_head *head,
371 res->end = dev_res_x->end; 365 res->end = dev_res_x->end;
372 res->flags = dev_res_x->flags; 366 res->flags = dev_res_x->flags;
373 } 367 }
374 free_list(pci_dev_resource_x, &save_head); 368 free_list(pci_dev_resource, &save_head);
375 369
376requested_and_reassign: 370requested_and_reassign:
377 /* Satisfy the must-have resource requests */ 371 /* Satisfy the must-have resource requests */
@@ -1256,7 +1250,7 @@ pci_assign_unassigned_resources(void)
1256 int tried_times = 0; 1250 int tried_times = 0;
1257 enum release_type rel_type = leaf_only; 1251 enum release_type rel_type = leaf_only;
1258 LIST_HEAD(fail_head); 1252 LIST_HEAD(fail_head);
1259 struct pci_dev_resource_x *dev_res_x; 1253 struct pci_dev_resource *dev_res_x;
1260 unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM | 1254 unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM |
1261 IORESOURCE_PREFETCH; 1255 IORESOURCE_PREFETCH;
1262 unsigned long failed_type; 1256 unsigned long failed_type;
@@ -1304,7 +1298,7 @@ again:
1304 */ 1298 */
1305 failed_type &= type_mask; 1299 failed_type &= type_mask;
1306 if ((failed_type == IORESOURCE_IO) || (tried_times >= pci_try_num)) { 1300 if ((failed_type == IORESOURCE_IO) || (tried_times >= pci_try_num)) {
1307 free_list(pci_dev_resource_x, &fail_head); 1301 free_list(pci_dev_resource, &fail_head);
1308 goto enable_and_dump; 1302 goto enable_and_dump;
1309 } 1303 }
1310 1304
@@ -1335,7 +1329,7 @@ again:
1335 if (dev_res_x->dev->subordinate) 1329 if (dev_res_x->dev->subordinate)
1336 res->flags = 0; 1330 res->flags = 0;
1337 } 1331 }
1338 free_list(pci_dev_resource_x, &fail_head); 1332 free_list(pci_dev_resource, &fail_head);
1339 1333
1340 goto again; 1334 goto again;
1341 1335
@@ -1356,7 +1350,7 @@ void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge)
1356 want additional resources */ 1350 want additional resources */
1357 int tried_times = 0; 1351 int tried_times = 0;
1358 LIST_HEAD(fail_head); 1352 LIST_HEAD(fail_head);
1359 struct pci_dev_resource_x *dev_res_x; 1353 struct pci_dev_resource *dev_res_x;
1360 int retval; 1354 int retval;
1361 unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM | 1355 unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM |
1362 IORESOURCE_PREFETCH; 1356 IORESOURCE_PREFETCH;
@@ -1372,7 +1366,7 @@ again:
1372 1366
1373 if (tried_times >= 2) { 1367 if (tried_times >= 2) {
1374 /* still fail, don't need to try more */ 1368 /* still fail, don't need to try more */
1375 free_list(pci_dev_resource_x, &fail_head); 1369 free_list(pci_dev_resource, &fail_head);
1376 goto enable_all; 1370 goto enable_all;
1377 } 1371 }
1378 1372
@@ -1400,7 +1394,7 @@ again:
1400 if (dev_res_x->dev->subordinate) 1394 if (dev_res_x->dev->subordinate)
1401 res->flags = 0; 1395 res->flags = 0;
1402 } 1396 }
1403 free_list(pci_dev_resource_x, &fail_head); 1397 free_list(pci_dev_resource, &fail_head);
1404 1398
1405 goto again; 1399 goto again;
1406 1400