diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2009-09-08 17:12:59 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-09-09 17:19:00 -0400 |
commit | 5bcc2fb4e8157d829a38093b98e23329ac8acff7 (patch) | |
tree | 458960ac494d1427ec96cbbfcaa68bd7c0e0b778 /drivers/pci/pci.c | |
parent | 748df9a4c65625c386674c9b54dde73de6cc5af5 (diff) |
PCI PM: Simplify PCI wake-up code
Rework the PCI wake-up code so that it's easier to read without
changing the functionality.
Reviewed-by: Matthew Garrett <mjg59@srcf.ucam.org>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r-- | drivers/pci/pci.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 8c663d628d03..84a6d6d30c5a 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -1220,8 +1220,7 @@ void pci_pme_active(struct pci_dev *dev, bool enable) | |||
1220 | */ | 1220 | */ |
1221 | int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) | 1221 | int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) |
1222 | { | 1222 | { |
1223 | int error = 0; | 1223 | int ret = 0; |
1224 | bool pme_done = false; | ||
1225 | 1224 | ||
1226 | if (enable && !device_may_wakeup(&dev->dev)) | 1225 | if (enable && !device_may_wakeup(&dev->dev)) |
1227 | return -EINVAL; | 1226 | return -EINVAL; |
@@ -1232,18 +1231,22 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) | |||
1232 | * enable. To disable wake-up we call the platform first, for symmetry. | 1231 | * enable. To disable wake-up we call the platform first, for symmetry. |
1233 | */ | 1232 | */ |
1234 | 1233 | ||
1235 | if (!enable && platform_pci_can_wakeup(dev)) | 1234 | if (enable) { |
1236 | error = platform_pci_sleep_wake(dev, false); | 1235 | int error; |
1237 | |||
1238 | if (!enable || pci_pme_capable(dev, state)) { | ||
1239 | pci_pme_active(dev, enable); | ||
1240 | pme_done = true; | ||
1241 | } | ||
1242 | 1236 | ||
1243 | if (enable && platform_pci_can_wakeup(dev)) | 1237 | if (pci_pme_capable(dev, state)) |
1238 | pci_pme_active(dev, true); | ||
1239 | else | ||
1240 | ret = 1; | ||
1244 | error = platform_pci_sleep_wake(dev, true); | 1241 | error = platform_pci_sleep_wake(dev, true); |
1242 | if (ret) | ||
1243 | ret = error; | ||
1244 | } else { | ||
1245 | platform_pci_sleep_wake(dev, false); | ||
1246 | pci_pme_active(dev, false); | ||
1247 | } | ||
1245 | 1248 | ||
1246 | return pme_done ? 0 : error; | 1249 | return ret; |
1247 | } | 1250 | } |
1248 | 1251 | ||
1249 | /** | 1252 | /** |