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


Groups > linux.kernel > #1324544 > unrolled thread

[PATCH 0/3] PCI: Clean up warnings

Started byBjorn Helgaas <bhelgaas@google.com>
First post2016-02-02 20:30 +0100
Last post2016-02-05 23:40 +0100
Articles 6 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [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

#1324544 — [PATCH 0/3] PCI: Clean up warnings

FromBjorn Helgaas <bhelgaas@google.com>
Date2016-02-02 20:30 +0100
Subject[PATCH 0/3] PCI: Clean up warnings
Message-ID<qXOOd-7LC-1@gated-at.bofh.it>
I'm on a quest to clean up compiler warnings in drivers/pci.  I'd like to
be able to treat warnings as errors, at least for the 0day build robot.

---

Bjorn Helgaas (3):
      PCI: Check device_attach() return value always
      PCI/PME: Remove redundant port lookup
      PCI/PME: Restructure pcie_pme_suspend() to prevent compiler warning


 drivers/pci/bus.c      |    7 ++++++-
 drivers/pci/pcie/pme.c |   11 ++++++-----
 2 files changed, 12 insertions(+), 6 deletions(-)

[toc] | [next] | [standalone]


#1324548 — [PATCH 1/3] PCI: Check device_attach() return value always

FromBjorn Helgaas <bhelgaas@google.com>
Date2016-02-02 20:30 +0100
Subject[PATCH 1/3] PCI: Check device_attach() return value always
Message-ID<qXOOe-7LC-17@gated-at.bofh.it>
In reply to#1324544
Previously we checked the device_attach() return value only when
CONFIG_BUG=y.  That caused this warning in builds where CONFIG_BUG is not
set:

  drivers/pci/bus.c:237:6: warning: variable 'retval' set but not used [-Wunused-but-set-variable]

Check the return value of device_attach() always and clean up after
failure.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/bus.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 89b3bef..f2187d4 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -291,7 +291,12 @@ void pci_bus_add_device(struct pci_dev *dev)
 
 	dev->match_driver = true;
 	retval = device_attach(&dev->dev);
-	WARN_ON(retval < 0);
+	if (retval < 0) {
+		dev_warn(&dev->dev, "device attach failed (%d)\n", retval);
+		pci_proc_detach_device(dev);
+		pci_remove_sysfs_dev_files(dev);
+		return;
+	}
 
 	dev->is_added = 1;
 }

[toc] | [prev] | [next] | [standalone]


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

FromBjorn Helgaas <bhelgaas@google.com>
Date2016-02-02 20:30 +0100
Subject[PATCH 3/3] PCI/PME: Restructure pcie_pme_suspend() to prevent compiler warning
Message-ID<qXOOe-7LC-11@gated-at.bofh.it>
In reply to#1324544
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;

[toc] | [prev] | [next] | [standalone]


#1324550 — [PATCH 2/3] PCI/PME: Remove redundant port lookup

FromBjorn Helgaas <bhelgaas@google.com>
Date2016-02-02 20:30 +0100
Subject[PATCH 2/3] PCI/PME: Remove redundant port lookup
Message-ID<qXOOe-7LC-21@gated-at.bofh.it>
In reply to#1324544
We've already looked up srv->port a few lines earlier, and there's no need
to do it again.  Remove the redundant lookup.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pcie/pme.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c
index 63fc639..5695861 100644
--- a/drivers/pci/pcie/pme.c
+++ b/drivers/pci/pcie/pme.c
@@ -412,8 +412,6 @@ static int pcie_pme_suspend(struct pcie_device *srv)
 		data->suspend_level = PME_SUSPEND_WAKEUP;
 	}
 	if (!wakeup || ret) {
-		struct pci_dev *port = srv->port;
-
 		pcie_pme_interrupt_enable(port, false);
 		pcie_clear_root_pme_status(port);
 		data->suspend_level = PME_SUSPEND_NOIRQ;

[toc] | [prev] | [next] | [standalone]


#1324807

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2016-02-03 02:40 +0100
Message-ID<qXUAi-3B6-3@gated-at.bofh.it>
In reply to#1324544
On Tuesday, February 02, 2016 01:20:28 PM Bjorn Helgaas wrote:
> I'm on a quest to clean up compiler warnings in drivers/pci.  I'd like to
> be able to treat warnings as errors, at least for the 0day build robot.
> 
> ---
> 
> Bjorn Helgaas (3):
>       PCI: Check device_attach() return value always
>       PCI/PME: Remove redundant port lookup
>       PCI/PME: Restructure pcie_pme_suspend() to prevent compiler warning
> 
> 
>  drivers/pci/bus.c      |    7 ++++++-
>  drivers/pci/pcie/pme.c |   11 ++++++-----
>  2 files changed, 12 insertions(+), 6 deletions(-)

ACK for all of the above, where applicable. :-)

Thanks,
Rafael

[toc] | [prev] | [next] | [standalone]


#1328107

FromBjorn Helgaas <helgaas@kernel.org>
Date2016-02-05 23:40 +0100
Message-ID<qYXcK-6kF-17@gated-at.bofh.it>
In reply to#1324544
On Tue, Feb 02, 2016 at 01:20:28PM -0600, Bjorn Helgaas wrote:
> I'm on a quest to clean up compiler warnings in drivers/pci.  I'd like to
> be able to treat warnings as errors, at least for the 0day build robot.
> 
> ---
> 
> Bjorn Helgaas (3):
>       PCI: Check device_attach() return value always
>       PCI/PME: Remove redundant port lookup
>       PCI/PME: Restructure pcie_pme_suspend() to prevent compiler warning
> 
> 
>  drivers/pci/bus.c      |    7 ++++++-
>  drivers/pci/pcie/pme.c |   11 ++++++-----
>  2 files changed, 12 insertions(+), 6 deletions(-)

I applied these, with Rafael's ack, to pci/misc for v4.6.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web