diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2016-02-05 15:57:19 -0500 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2016-02-05 17:28:03 -0500 |
commit | 41ccebaecef50e56f822791a52b7bd9e9608e5e6 (patch) | |
tree | bfab3c754454654b0b88b5c2edcf49f2a1652af6 | |
parent | 4e48fe4148698ffd3935800f4967362e80a7ae92 (diff) |
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: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com
-rw-r--r-- | drivers/pci/pcie/pme.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c index 56958618ec26..1ae4c73e7a3c 100644 --- a/drivers/pci/pcie/pme.c +++ b/drivers/pci/pcie/pme.c | |||
@@ -396,7 +396,7 @@ static int pcie_pme_suspend(struct pcie_device *srv) | |||
396 | { | 396 | { |
397 | struct pcie_pme_service_data *data = get_service_data(srv); | 397 | struct pcie_pme_service_data *data = get_service_data(srv); |
398 | struct pci_dev *port = srv->port; | 398 | struct pci_dev *port = srv->port; |
399 | bool wakeup; | 399 | bool wakeup, wake_irq_enabled = false; |
400 | int ret; | 400 | int ret; |
401 | 401 | ||
402 | if (device_may_wakeup(&port->dev)) { | 402 | if (device_may_wakeup(&port->dev)) { |
@@ -409,9 +409,12 @@ static int pcie_pme_suspend(struct pcie_device *srv) | |||
409 | spin_lock_irq(&data->lock); | 409 | spin_lock_irq(&data->lock); |
410 | if (wakeup) { | 410 | if (wakeup) { |
411 | ret = enable_irq_wake(srv->irq); | 411 | ret = enable_irq_wake(srv->irq); |
412 | data->suspend_level = PME_SUSPEND_WAKEUP; | 412 | if (ret == 0) { |
413 | data->suspend_level = PME_SUSPEND_WAKEUP; | ||
414 | wake_irq_enabled = true; | ||
415 | } | ||
413 | } | 416 | } |
414 | if (!wakeup || ret) { | 417 | if (!wake_irq_enabled) { |
415 | pcie_pme_interrupt_enable(port, false); | 418 | pcie_pme_interrupt_enable(port, false); |
416 | pcie_clear_root_pme_status(port); | 419 | pcie_clear_root_pme_status(port); |
417 | data->suspend_level = PME_SUSPEND_NOIRQ; | 420 | data->suspend_level = PME_SUSPEND_NOIRQ; |