diff options
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r-- | drivers/pci/pci.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index a04197ce767d..dbfe7c4f3776 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -1910,7 +1910,7 @@ void pci_pme_active(struct pci_dev *dev, bool enable) | |||
1910 | EXPORT_SYMBOL(pci_pme_active); | 1910 | EXPORT_SYMBOL(pci_pme_active); |
1911 | 1911 | ||
1912 | /** | 1912 | /** |
1913 | * pci_enable_wake - enable PCI device as wakeup event source | 1913 | * __pci_enable_wake - enable PCI device as wakeup event source |
1914 | * @dev: PCI device affected | 1914 | * @dev: PCI device affected |
1915 | * @state: PCI state from which device will issue wakeup events | 1915 | * @state: PCI state from which device will issue wakeup events |
1916 | * @enable: True to enable event generation; false to disable | 1916 | * @enable: True to enable event generation; false to disable |
@@ -1928,7 +1928,7 @@ EXPORT_SYMBOL(pci_pme_active); | |||
1928 | * Error code depending on the platform is returned if both the platform and | 1928 | * Error code depending on the platform is returned if both the platform and |
1929 | * the native mechanism fail to enable the generation of wake-up events | 1929 | * the native mechanism fail to enable the generation of wake-up events |
1930 | */ | 1930 | */ |
1931 | int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) | 1931 | static int __pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) |
1932 | { | 1932 | { |
1933 | int ret = 0; | 1933 | int ret = 0; |
1934 | 1934 | ||
@@ -1969,6 +1969,23 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) | |||
1969 | 1969 | ||
1970 | return ret; | 1970 | return ret; |
1971 | } | 1971 | } |
1972 | |||
1973 | /** | ||
1974 | * pci_enable_wake - change wakeup settings for a PCI device | ||
1975 | * @pci_dev: Target device | ||
1976 | * @state: PCI state from which device will issue wakeup events | ||
1977 | * @enable: Whether or not to enable event generation | ||
1978 | * | ||
1979 | * If @enable is set, check device_may_wakeup() for the device before calling | ||
1980 | * __pci_enable_wake() for it. | ||
1981 | */ | ||
1982 | int pci_enable_wake(struct pci_dev *pci_dev, pci_power_t state, bool enable) | ||
1983 | { | ||
1984 | if (enable && !device_may_wakeup(&pci_dev->dev)) | ||
1985 | return -EINVAL; | ||
1986 | |||
1987 | return __pci_enable_wake(pci_dev, state, enable); | ||
1988 | } | ||
1972 | EXPORT_SYMBOL(pci_enable_wake); | 1989 | EXPORT_SYMBOL(pci_enable_wake); |
1973 | 1990 | ||
1974 | /** | 1991 | /** |
@@ -1981,9 +1998,9 @@ EXPORT_SYMBOL(pci_enable_wake); | |||
1981 | * should not be called twice in a row to enable wake-up due to PCI PM vs ACPI | 1998 | * should not be called twice in a row to enable wake-up due to PCI PM vs ACPI |
1982 | * ordering constraints. | 1999 | * ordering constraints. |
1983 | * | 2000 | * |
1984 | * This function only returns error code if the device is not capable of | 2001 | * This function only returns error code if the device is not allowed to wake |
1985 | * generating PME# from both D3_hot and D3_cold, and the platform is unable to | 2002 | * up the system from sleep or it is not capable of generating PME# from both |
1986 | * enable wake-up power for it. | 2003 | * D3_hot and D3_cold and the platform is unable to enable wake-up power for it. |
1987 | */ | 2004 | */ |
1988 | int pci_wake_from_d3(struct pci_dev *dev, bool enable) | 2005 | int pci_wake_from_d3(struct pci_dev *dev, bool enable) |
1989 | { | 2006 | { |
@@ -2114,7 +2131,7 @@ int pci_finish_runtime_suspend(struct pci_dev *dev) | |||
2114 | 2131 | ||
2115 | dev->runtime_d3cold = target_state == PCI_D3cold; | 2132 | dev->runtime_d3cold = target_state == PCI_D3cold; |
2116 | 2133 | ||
2117 | pci_enable_wake(dev, target_state, pci_dev_run_wake(dev)); | 2134 | __pci_enable_wake(dev, target_state, pci_dev_run_wake(dev)); |
2118 | 2135 | ||
2119 | error = pci_set_power_state(dev, target_state); | 2136 | error = pci_set_power_state(dev, target_state); |
2120 | 2137 | ||
@@ -2138,16 +2155,16 @@ bool pci_dev_run_wake(struct pci_dev *dev) | |||
2138 | { | 2155 | { |
2139 | struct pci_bus *bus = dev->bus; | 2156 | struct pci_bus *bus = dev->bus; |
2140 | 2157 | ||
2141 | if (device_can_wakeup(&dev->dev)) | ||
2142 | return true; | ||
2143 | |||
2144 | if (!dev->pme_support) | 2158 | if (!dev->pme_support) |
2145 | return false; | 2159 | return false; |
2146 | 2160 | ||
2147 | /* PME-capable in principle, but not from the target power state */ | 2161 | /* PME-capable in principle, but not from the target power state */ |
2148 | if (!pci_pme_capable(dev, pci_target_state(dev, false))) | 2162 | if (!pci_pme_capable(dev, pci_target_state(dev, true))) |
2149 | return false; | 2163 | return false; |
2150 | 2164 | ||
2165 | if (device_can_wakeup(&dev->dev)) | ||
2166 | return true; | ||
2167 | |||
2151 | while (bus->parent) { | 2168 | while (bus->parent) { |
2152 | struct pci_dev *bridge = bus->self; | 2169 | struct pci_dev *bridge = bus->self; |
2153 | 2170 | ||