Commit 5bcc2fb4 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Jesse Barnes

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: default avatarMatthew Garrett <mjg59@srcf.ucam.org>
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent 748df9a4
...@@ -111,12 +111,16 @@ static bool acpi_pci_can_wakeup(struct pci_dev *dev) ...@@ -111,12 +111,16 @@ static bool acpi_pci_can_wakeup(struct pci_dev *dev)
static int acpi_pci_sleep_wake(struct pci_dev *dev, bool enable) static int acpi_pci_sleep_wake(struct pci_dev *dev, bool enable)
{ {
int error = acpi_pm_device_sleep_wake(&dev->dev, enable); int error;
if (!acpi_pci_can_wakeup(dev))
return 0;
error = acpi_pm_device_sleep_wake(&dev->dev, enable);
if (!error) if (!error)
dev_printk(KERN_INFO, &dev->dev, dev_info(&dev->dev, "wake-up capability %s by ACPI\n",
"wake-up capability %s by ACPI\n",
enable ? "enabled" : "disabled"); enable ? "enabled" : "disabled");
return error; return error;
} }
......
...@@ -1220,8 +1220,7 @@ void pci_pme_active(struct pci_dev *dev, bool enable) ...@@ -1220,8 +1220,7 @@ void pci_pme_active(struct pci_dev *dev, bool enable)
*/ */
int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable)
{ {
int error = 0; int ret = 0;
bool pme_done = false;
if (enable && !device_may_wakeup(&dev->dev)) if (enable && !device_may_wakeup(&dev->dev))
return -EINVAL; return -EINVAL;
...@@ -1232,18 +1231,22 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) ...@@ -1232,18 +1231,22 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable)
* enable. To disable wake-up we call the platform first, for symmetry. * enable. To disable wake-up we call the platform first, for symmetry.
*/ */
if (!enable && platform_pci_can_wakeup(dev)) if (enable) {
error = platform_pci_sleep_wake(dev, false); int error;
if (!enable || pci_pme_capable(dev, state)) {
pci_pme_active(dev, enable);
pme_done = true;
}
if (enable && platform_pci_can_wakeup(dev)) if (pci_pme_capable(dev, state))
pci_pme_active(dev, true);
else
ret = 1;
error = platform_pci_sleep_wake(dev, true); error = platform_pci_sleep_wake(dev, true);
if (ret)
ret = error;
} else {
platform_pci_sleep_wake(dev, false);
pci_pme_active(dev, false);
}
return pme_done ? 0 : error; return ret;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment