Commit 41ccebae authored by Bjorn Helgaas's avatar Bjorn Helgaas

PCI/PME: Restructure pcie_pme_suspend() to prevent compiler warning

Previously we had this:

  if (wakeup)
    ret = enable_irq_wake(...);
  if (!wakeup || ret)
    ...

"ret" is only evaluated when "wakeup" is true, and it is always initialized
in that case, but gcc isn't smart enough to figure that out and warns:

  drivers/pci/pcie/pme.c:414:14: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]

Restructure the code slightly to make it easier for gcc (and maybe for
humans as well).
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com
parent 4e48fe41
...@@ -396,7 +396,7 @@ static int pcie_pme_suspend(struct pcie_device *srv) ...@@ -396,7 +396,7 @@ static int pcie_pme_suspend(struct pcie_device *srv)
{ {
struct pcie_pme_service_data *data = get_service_data(srv); struct pcie_pme_service_data *data = get_service_data(srv);
struct pci_dev *port = srv->port; struct pci_dev *port = srv->port;
bool wakeup; bool wakeup, wake_irq_enabled = false;
int ret; int ret;
if (device_may_wakeup(&port->dev)) { if (device_may_wakeup(&port->dev)) {
...@@ -409,9 +409,12 @@ static int pcie_pme_suspend(struct pcie_device *srv) ...@@ -409,9 +409,12 @@ static int pcie_pme_suspend(struct pcie_device *srv)
spin_lock_irq(&data->lock); spin_lock_irq(&data->lock);
if (wakeup) { if (wakeup) {
ret = enable_irq_wake(srv->irq); ret = enable_irq_wake(srv->irq);
data->suspend_level = PME_SUSPEND_WAKEUP; if (ret == 0) {
data->suspend_level = PME_SUSPEND_WAKEUP;
wake_irq_enabled = true;
}
} }
if (!wakeup || ret) { if (!wake_irq_enabled) {
pcie_pme_interrupt_enable(port, false); pcie_pme_interrupt_enable(port, false);
pcie_clear_root_pme_status(port); pcie_clear_root_pme_status(port);
data->suspend_level = PME_SUSPEND_NOIRQ; data->suspend_level = PME_SUSPEND_NOIRQ;
......
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