aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/pci/acpi.c
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2012-04-02 21:31:53 -0400
committerBjorn Helgaas <bhelgaas@google.com>2012-04-30 16:52:43 -0400
commit35cb05e5bdac209cfdfafbe50d89ee7069cb6237 (patch)
tree333b7682f5dc68e54dd2427e80be19c31fbe0e28 /arch/x86/pci/acpi.c
parentfe05725ff97530e26109a0c3d52cef7fff326e15 (diff)
x86/PCI: embed pci_sysdata into pci_root_info on ACPI path
Embed the x86 struct pci_sysdata in the struct pci_root_info so it will be automatically freed in the remove path. Signed-off-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'arch/x86/pci/acpi.c')
-rw-r--r--arch/x86/pci/acpi.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 23e7361b1747..8a17b23f8c84 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -13,6 +13,7 @@ struct pci_root_info {
13 unsigned int res_num; 13 unsigned int res_num;
14 struct resource *res; 14 struct resource *res;
15 int busnum; 15 int busnum;
16 struct pci_sysdata sd;
16}; 17};
17 18
18static bool pci_use_crs = true; 19static bool pci_use_crs = true;
@@ -410,26 +411,16 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
410 if (node != -1 && !node_online(node)) 411 if (node != -1 && !node_online(node))
411 node = -1; 412 node = -1;
412 413
413 /* Allocate per-root-bus (not per bus) arch-specific data. 414 info = kzalloc(sizeof(*info), GFP_KERNEL);
414 * TODO: leak; this memory is never freed. 415 if (!info) {
415 * It's arguable whether it's worth the trouble to care.
416 */
417 sd = kzalloc(sizeof(*sd), GFP_KERNEL);
418 if (!sd) {
419 printk(KERN_WARNING "pci_bus %04x:%02x: " 416 printk(KERN_WARNING "pci_bus %04x:%02x: "
420 "ignored (out of memory)\n", domain, busnum); 417 "ignored (out of memory)\n", domain, busnum);
421 return NULL; 418 return NULL;
422 } 419 }
423 420
421 sd = &info->sd;
424 sd->domain = domain; 422 sd->domain = domain;
425 sd->node = node; 423 sd->node = node;
426 info = kzalloc(sizeof(*info), GFP_KERNEL);
427 if (!info) {
428 kfree(sd);
429 printk(KERN_WARNING "pci_bus %04x:%02x: "
430 "ignored (out of memory)\n", domain, busnum);
431 return NULL;
432 }
433 /* 424 /*
434 * Maybe the desired pci bus has been already scanned. In such case 425 * Maybe the desired pci bus has been already scanned. In such case
435 * it is unnecessary to scan the pci bus with the given domain,busnum. 426 * it is unnecessary to scan the pci bus with the given domain,busnum.
@@ -442,7 +433,6 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
442 */ 433 */
443 memcpy(bus->sysdata, sd, sizeof(*sd)); 434 memcpy(bus->sysdata, sd, sizeof(*sd));
444 kfree(info); 435 kfree(info);
445 kfree(sd);
446 } else { 436 } else {
447 probe_pci_root_info(info, device, busnum, domain); 437 probe_pci_root_info(info, device, busnum, domain);
448 438
@@ -484,9 +474,6 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
484 } 474 }
485 } 475 }
486 476
487 if (!bus)
488 kfree(sd);
489
490 if (bus && node != -1) { 477 if (bus && node != -1) {
491#ifdef CONFIG_ACPI_NUMA 478#ifdef CONFIG_ACPI_NUMA
492 if (pxm >= 0) 479 if (pxm >= 0)