All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] PCI: Clean up warnings
@ 2016-02-02 19:20 Bjorn Helgaas
  2016-02-02 19:20 ` [PATCH 1/3] PCI: Check device_attach() return value always Bjorn Helgaas
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2016-02-02 19:20 UTC (permalink / raw)
  To: linux-pci; +Cc: Rafael J. Wysocki, Yinghai Lu, linux-kernel

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(-)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] PCI: Check device_attach() return value always
  2016-02-02 19:20 [PATCH 0/3] PCI: Clean up warnings Bjorn Helgaas
@ 2016-02-02 19:20 ` Bjorn Helgaas
  2016-02-02 19:20 ` [PATCH 2/3] PCI/PME: Remove redundant port lookup Bjorn Helgaas
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2016-02-02 19:20 UTC (permalink / raw)
  To: linux-pci; +Cc: Rafael J. Wysocki, Yinghai Lu, linux-kernel

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;
 }

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] PCI/PME: Remove redundant port lookup
  2016-02-02 19:20 [PATCH 0/3] PCI: Clean up warnings Bjorn Helgaas
  2016-02-02 19:20 ` [PATCH 1/3] PCI: Check device_attach() return value always Bjorn Helgaas
@ 2016-02-02 19:20 ` Bjorn Helgaas
  2016-02-02 19:20 ` [PATCH 3/3] PCI/PME: Restructure pcie_pme_suspend() to prevent compiler warning Bjorn Helgaas
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2016-02-02 19:20 UTC (permalink / raw)
  To: linux-pci; +Cc: Rafael J. Wysocki, Yinghai Lu, linux-kernel

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;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] PCI/PME: Restructure pcie_pme_suspend() to prevent compiler warning
  2016-02-02 19:20 [PATCH 0/3] PCI: Clean up warnings Bjorn Helgaas
  2016-02-02 19:20 ` [PATCH 1/3] PCI: Check device_attach() return value always Bjorn Helgaas
  2016-02-02 19:20 ` [PATCH 2/3] PCI/PME: Remove redundant port lookup Bjorn Helgaas
@ 2016-02-02 19:20 ` Bjorn Helgaas
  2016-02-03  1:31 ` [PATCH 0/3] PCI: Clean up warnings Rafael J. Wysocki
  2016-02-05 22:36 ` Bjorn Helgaas
  4 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2016-02-02 19:20 UTC (permalink / raw)
  To: linux-pci; +Cc: Rafael J. Wysocki, Yinghai Lu, linux-kernel

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;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] PCI: Clean up warnings
  2016-02-02 19:20 [PATCH 0/3] PCI: Clean up warnings Bjorn Helgaas
                   ` (2 preceding siblings ...)
  2016-02-02 19:20 ` [PATCH 3/3] PCI/PME: Restructure pcie_pme_suspend() to prevent compiler warning Bjorn Helgaas
@ 2016-02-03  1:31 ` Rafael J. Wysocki
  2016-02-05 22:36 ` Bjorn Helgaas
  4 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2016-02-03  1:31 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, Rafael J. Wysocki, Yinghai Lu, linux-kernel

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] PCI: Clean up warnings
  2016-02-02 19:20 [PATCH 0/3] PCI: Clean up warnings Bjorn Helgaas
                   ` (3 preceding siblings ...)
  2016-02-03  1:31 ` [PATCH 0/3] PCI: Clean up warnings Rafael J. Wysocki
@ 2016-02-05 22:36 ` Bjorn Helgaas
  4 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2016-02-05 22:36 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, Rafael J. Wysocki, Yinghai Lu, linux-kernel

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-02-05 22:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-02 19:20 [PATCH 0/3] PCI: Clean up warnings Bjorn Helgaas
2016-02-02 19:20 ` [PATCH 1/3] PCI: Check device_attach() return value always Bjorn Helgaas
2016-02-02 19:20 ` [PATCH 2/3] PCI/PME: Remove redundant port lookup Bjorn Helgaas
2016-02-02 19:20 ` [PATCH 3/3] PCI/PME: Restructure pcie_pme_suspend() to prevent compiler warning Bjorn Helgaas
2016-02-03  1:31 ` [PATCH 0/3] PCI: Clean up warnings Rafael J. Wysocki
2016-02-05 22:36 ` Bjorn Helgaas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.