]> err.no Git - linux-2.6/blobdiff - drivers/pci/pcie/aspm.c
Merge git://git.infradead.org/battery-2.6
[linux-2.6] / drivers / pci / pcie / aspm.c
index 1a5adeb10c95633b4356258d3bf32e556810b7b4..61fedb2448b603e8658916a230e33220df7aeb5a 100644 (file)
@@ -16,9 +16,7 @@
 #include <linux/pm.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/aspm.h>
-#include <acpi/acpi_bus.h>
-#include <linux/pci-acpi.h>
+#include <linux/pci-aspm.h>
 #include "../pci.h"
 
 #ifdef MODULE_PARAM_PREFIX
@@ -269,7 +267,7 @@ static void pcie_aspm_get_cap_device(struct pci_dev *pdev, u32 *state,
        *state = (reg32 & PCI_EXP_LNKCAP_ASPMS) >> 10;
        if (*state != PCIE_LINK_STATE_L0S &&
                *state != (PCIE_LINK_STATE_L1|PCIE_LINK_STATE_L0S))
-               * state = 0;
+               *state = 0;
        if (*state == 0)
                return;
 
@@ -619,7 +617,7 @@ void pci_disable_link_state(struct pci_dev *pdev, int state)
        if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT ||
            pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM)
                parent = pdev;
-       if (!parent)
+       if (!parent || !parent->link_state)
                return;
 
        down_read(&pci_bus_sem);
@@ -754,7 +752,7 @@ void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev)
        struct pcie_link_state *link_state = pdev->link_state;
 
        if (!pdev->is_pcie || (pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT &&
-               pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM))
+               pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) || !link_state)
                return;
 
        if (link_state->support_state)
@@ -770,7 +768,7 @@ void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev)
        struct pcie_link_state *link_state = pdev->link_state;
 
        if (!pdev->is_pcie || (pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT &&
-               pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM))
+               pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) || !link_state)
                return;
 
        if (link_state->support_state)
@@ -790,12 +788,23 @@ static int __init pcie_aspm_disable(char *str)
 
 __setup("pcie_noaspm", pcie_aspm_disable);
 
+#ifdef CONFIG_ACPI
+#include <acpi/acpi_bus.h>
+#include <linux/pci-acpi.h>
+static void pcie_aspm_platform_init(void)
+{
+       pcie_osc_support_set(OSC_ACTIVE_STATE_PWR_SUPPORT|
+               OSC_CLOCK_PWR_CAPABILITY_SUPPORT);
+}
+#else
+static inline void pcie_aspm_platform_init(void) { }
+#endif
+
 static int __init pcie_aspm_init(void)
 {
        if (aspm_disabled)
                return 0;
-       pci_osc_support_set(OSC_ACTIVE_STATE_PWR_SUPPORT|
-               OSC_CLOCK_PWR_CAPABILITY_SUPPORT);
+       pcie_aspm_platform_init();
        return 0;
 }