Skip to contentSkip to conversation

PCI / PM: Remove unnecessary error variable from acpi_dev_run_wake()

PATCH Applied Rafael J. Wysocki 3 participants 4 messages Sep 27, 2011 – Oct 14, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI / PM: Remove unnecessary error variable from acpi_dev_run_wake()

From: Rafael J. Wysocki <[email protected]>

The error variable in acpi_dev_run_wake() is not really used, so remove it.

---
 drivers/pci/pci-acpi.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pci/pci-acpi.c +1 -2
Index: linux/drivers/pci/pci-acpi.c
===================================================================
@@ -282,7 +282,6 @@ static int acpi_dev_run_wake(struct devi
 {
 	struct acpi_device *dev;
 	acpi_handle handle;
-	int error = -ENODEV;
 
 	if (!device_run_wake(phys_dev))
 		return -EINVAL;
@@ -302,7 +301,7 @@ static int acpi_dev_run_wake(struct devi
 		acpi_disable_wakeup_device_power(dev);
 	}
 
-	return error;
+	return 0;
 }
 
 static void acpi_pci_propagate_run_wake(struct pci_bus *bus, bool enable)
maintainer
#1 lore raw
Quoted 23 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

The error variable in acpi_dev_run_wake() is not really used, so remove it.

---
 drivers/pci/pci-acpi.c |    3 +--

 1 file changed, 1 insertion(+), 2 deletions(-)

Index: linux/drivers/pci/pci-acpi.c
===================================================================

drivers/pci/pci-acpi.c +0 -1
@@ -282,7 +282,6 @@ static int acpi_dev_run_wake(struct devi
  {
        struct acpi_device *dev;
        acpi_handle handle;
-       int error = -ENODEV;
 
        if (!device_run_wake(phys_dev))
                return -EINVAL;

drivers/pci/pci-acpi.c static int acpi_dev_run_wake(struct devi · line 307

Quoted 8 lines
drivers/pci/pci-acpi.c +1 -1
@@ -302,7 +301,7 @@ static int acpi_dev_run_wake(struct devi
                acpi_disable_wakeup_device_power(dev);
        }
 
-       return error;
+       return 0;
  }
 
  static void acpi_pci_propagate_run_wake(struct pci_bus *bus, bool enable)

This looks like the right thing to do, but the current changelog suggests that we're just removing unused code.

But in fact, we'll now return 0 (success) when we used to return -ENODEV, so the behavior of the callers will change (probably fixing some bugs). Do you want to mention that in the changelog as well?

I'm assuming this is for the 3.2 merge window, since it doesn't look like a regression fix.

Bjorn

#2 lore raw
Quoted 31 lines · Bjorn Helgaas
Quoted 30 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

The error variable in acpi_dev_run_wake() is not really used, so remove it.

---
 drivers/pci/pci-acpi.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Index: linux/drivers/pci/pci-acpi.c
===================================================================

drivers/pci/pci-acpi.c +1 -2
@@ -282,7 +282,6 @@ static int acpi_dev_run_wake(struct devi
 {
       struct acpi_device *dev;
       acpi_handle handle;
-       int error = -ENODEV;
 
       if (!device_run_wake(phys_dev))
               return -EINVAL;
@@ -302,7 +301,7 @@ static int acpi_dev_run_wake(struct devi
               acpi_disable_wakeup_device_power(dev);
       }
 
-       return error;
+       return 0;
 }
 
Quoted 8 lines

drivers/pci/pci-acpi.c static int acpi_dev_run_wake(struct devi · line 307

Quoted 1 line
drivers/pci/pci-acpi.c +0 -0
 static void acpi_pci_propagate_run_wake(struct pci_bus *bus, bool enable)

This looks like the right thing to do, but the current changelog suggests that we're just removing unused code.

But in fact, we'll now return 0 (success) when we used to return -ENODEV, so the behavior of the callers will change (probably fixing some bugs). Do you want to mention that in the changelog as well?

Yes, good idea.

Quoted 2 lines

I'm assuming this is for the 3.2 merge window, since it doesn't look like a regression fix.

Yes, it's 3.2 material.

Below is an updated patch.

Thanks,
Rafael

---
From: Rafael J. Wysocki <[email protected]>
Subject: PCI / PM: Return correct result from acpi_dev_run_wake()

The result returned by acpi_dev_run_wake() is always either -EINVAL or -ENODEV, while obviously it should return 0 on success. The problem is that the leftover error variable, that's not really used in the function, is initialized with -ENODEV and then returned without modification.

To fix this issue remove the error variable from acpi_dev_run_wake() and make the function return 0 on success as appropriate.

---
 drivers/pci/pci-acpi.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pci/pci-acpi.c +1 -2
Index: linux/drivers/pci/pci-acpi.c
===================================================================
@@ -282,7 +282,6 @@ static int acpi_dev_run_wake(struct devi
 {
 	struct acpi_device *dev;
 	acpi_handle handle;
-	int error = -ENODEV;
 
 	if (!device_run_wake(phys_dev))
 		return -EINVAL;
@@ -302,7 +301,7 @@ static int acpi_dev_run_wake(struct devi
 		acpi_disable_wakeup_device_power(dev);
 	}
 
-	return error;
+	return 0;
 }
 
 static void acpi_pci_propagate_run_wake(struct pci_bus *bus, bool enable)
Applied
#3 lore raw
Quoted 10 lines · On Wed, 28 Sep 2011 21:44:36 +0200 "Rafael J. Wysocki" <[email protected]> wrote:

---
From: Rafael J. Wysocki <[email protected]>
Subject: PCI / PM: Return correct result from acpi_dev_run_wake()

The result returned by acpi_dev_run_wake() is always either -EINVAL or -ENODEV, while obviously it should return 0 on success. The problem is that the leftover error variable, that's not really used in the function, is initialized with -ENODEV and then returned without modification.

Quoted 4 lines

To fix this issue remove the error variable from acpi_dev_run_wake() and make the function return 0 on success as appropriate.

Applied to linux-next, thanks.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center