Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1324549

[PATCH 3/3] PCI/PME: Restructure pcie_pme_suspend() to prevent compiler warning

From Bjorn Helgaas <bhelgaas@google.com>
Newsgroups linux.kernel
Subject [PATCH 3/3] PCI/PME: Restructure pcie_pme_suspend() to prevent compiler warning
Date 2016-02-02 20:30 +0100
Message-ID <qXOOe-7LC-11@gated-at.bofh.it> (permalink)
References <qXOOd-7LC-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 drivers/pci/pcie/pme.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c
index 5695861..1ae4c73 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)
 {
 	struct pcie_pme_service_data *data = get_service_data(srv);
 	struct pci_dev *port = srv->port;
-	bool wakeup;
+	bool wakeup, wake_irq_enabled = false;
 	int ret;
 
 	if (device_may_wakeup(&port->dev)) {
@@ -409,9 +409,12 @@ static int pcie_pme_suspend(struct pcie_device *srv)
 	spin_lock_irq(&data->lock);
 	if (wakeup) {
 		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_clear_root_pme_status(port);
 		data->suspend_level = PME_SUSPEND_NOIRQ;

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/3] PCI: Clean up warnings Bjorn Helgaas <bhelgaas@google.com> - 2016-02-02 20:30 +0100
  [PATCH 1/3] PCI: Check device_attach() return value always Bjorn Helgaas <bhelgaas@google.com> - 2016-02-02 20:30 +0100
  [PATCH 3/3] PCI/PME: Restructure pcie_pme_suspend() to prevent  compiler warning Bjorn Helgaas <bhelgaas@google.com> - 2016-02-02 20:30 +0100
  [PATCH 2/3] PCI/PME: Remove redundant port lookup Bjorn Helgaas <bhelgaas@google.com> - 2016-02-02 20:30 +0100
  Re: [PATCH 0/3] PCI: Clean up warnings "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-02-03 02:40 +0100
  Re: [PATCH 0/3] PCI: Clean up warnings Bjorn Helgaas <helgaas@kernel.org> - 2016-02-05 23:40 +0100

csiph-web