aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorJiang Liu <jiang.liu@huawei.com>2012-06-22 02:55:18 -0400
committerBjorn Helgaas <bhelgaas@google.com>2012-06-22 17:17:06 -0400
commit66e8850a2a34e6c52105d92a0f0054b304cb7140 (patch)
tree1c8049a3684439f7ffba279f8923efc30d1c0be7 /arch/x86
parentc0fa40784cce9cc66b54499a3762cfe07e35353f (diff)
x86/PCI: simplify pci_mmcfg_late_insert_resources()
Reduce redundant code to simplify pci_mmcfg_late_insert_resources(). Reviewed-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Jiang Liu <liuj97@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/pci/mmconfig-shared.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c
index 19fc42b9f823..332fabdeff43 100644
--- a/arch/x86/pci/mmconfig-shared.c
+++ b/arch/x86/pci/mmconfig-shared.c
@@ -26,7 +26,6 @@
26#define PREFIX "PCI: " 26#define PREFIX "PCI: "
27 27
28/* Indicate if the mmcfg resources have been placed into the resource table. */ 28/* Indicate if the mmcfg resources have been placed into the resource table. */
29static int __initdata pci_mmcfg_resources_inserted;
30static bool pci_mmcfg_running_state; 29static bool pci_mmcfg_running_state;
31static bool pci_mmcfg_arch_init_failed; 30static bool pci_mmcfg_arch_init_failed;
32static DEFINE_MUTEX(pci_mmcfg_lock); 31static DEFINE_MUTEX(pci_mmcfg_lock);
@@ -373,18 +372,6 @@ static int __init pci_mmcfg_check_hostbridge(void)
373 return !list_empty(&pci_mmcfg_list); 372 return !list_empty(&pci_mmcfg_list);
374} 373}
375 374
376static void __init pci_mmcfg_insert_resources(void)
377{
378 struct pci_mmcfg_region *cfg;
379
380 list_for_each_entry(cfg, &pci_mmcfg_list, list)
381 if (!cfg->res.parent)
382 insert_resource(&iomem_resource, &cfg->res);
383
384 /* Mark that the resources have been inserted. */
385 pci_mmcfg_resources_inserted = 1;
386}
387
388static acpi_status __devinit check_mcfg_resource(struct acpi_resource *res, 375static acpi_status __devinit check_mcfg_resource(struct acpi_resource *res,
389 void *data) 376 void *data)
390{ 377{
@@ -668,11 +655,7 @@ static void __init __pci_mmcfg_init(int early)
668 if (pci_mmcfg_arch_init()) 655 if (pci_mmcfg_arch_init())
669 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; 656 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
670 else { 657 else {
671 /* 658 free_all_mmcfg();
672 * Signal not to attempt to insert mmcfg resources because
673 * the architecture mmcfg setup could not initialize.
674 */
675 pci_mmcfg_resources_inserted = 1;
676 pci_mmcfg_arch_init_failed = true; 659 pci_mmcfg_arch_init_failed = true;
677 } 660 }
678} 661}
@@ -689,15 +672,12 @@ void __init pci_mmcfg_late_init(void)
689 672
690static int __init pci_mmcfg_late_insert_resources(void) 673static int __init pci_mmcfg_late_insert_resources(void)
691{ 674{
675 struct pci_mmcfg_region *cfg;
676
692 pci_mmcfg_running_state = true; 677 pci_mmcfg_running_state = true;
693 678
694 /* 679 /* If we are not using MMCONFIG, don't insert the resources. */
695 * If resources are already inserted or we are not using MMCONFIG, 680 if ((pci_probe & PCI_PROBE_MMCONF) == 0)
696 * don't insert the resources.
697 */
698 if ((pci_mmcfg_resources_inserted == 1) ||
699 (pci_probe & PCI_PROBE_MMCONF) == 0 ||
700 list_empty(&pci_mmcfg_list))
701 return 1; 681 return 1;
702 682
703 /* 683 /*
@@ -705,7 +685,9 @@ static int __init pci_mmcfg_late_insert_resources(void)
705 * marked so it won't cause request errors when __request_region is 685 * marked so it won't cause request errors when __request_region is
706 * called. 686 * called.
707 */ 687 */
708 pci_mmcfg_insert_resources(); 688 list_for_each_entry(cfg, &pci_mmcfg_list, list)
689 if (!cfg->res.parent)
690 insert_resource(&iomem_resource, &cfg->res);
709 691
710 return 0; 692 return 0;
711} 693}