ACPI: Remove the wakeup.run_wake_count device field
authorRafael J. Wysocki <rjw@sisk.pl>
Tue, 8 Feb 2011 22:40:37 +0000 (23:40 +0100)
committerRafael J. Wysocki <rjw@sisk.pl>
Thu, 24 Feb 2011 18:58:53 +0000 (19:58 +0100)
The wakeup.run_wake_count ACPI device field is only used by the PCI
runtime PM code to "protect" devices from being prepared for
generating wakeup signals more than once in a row.  However, it
really doesn't provide any protection, because (1) all of the
functions it is supposed to protect use their own reference counters
effectively ensuring that the device will be set up for generating
wakeup signals just once and (2) the PCI runtime PM code uses
wakeup.run_wake_count in a racy way, since nothing prevents
acpi_dev_run_wake() from being called concurrently from two different
threads for the same device.

Remove the wakeup.run_wake_count ACPI device field which is
unnecessary, confusing and used in a wrong way.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
drivers/acpi/button.c
drivers/acpi/scan.c
drivers/pci/pci-acpi.c
include/acpi/acpi_bus.h

index 76bbb78a5ad957525c066b90ec2457ae533934e6..e643a0936dc4b304f277ee4f4d5aaaaed6cd3a12 100644 (file)
@@ -430,7 +430,6 @@ static int acpi_button_add(struct acpi_device *device)
                /* Button's GPE is run-wake GPE */
                acpi_enable_gpe(device->wakeup.gpe_device,
                                device->wakeup.gpe_number);
-               device->wakeup.run_wake_count++;
                device_set_wakeup_enable(&device->dev, true);
        }
 
@@ -453,7 +452,6 @@ static int acpi_button_remove(struct acpi_device *device, int type)
        if (device->wakeup.flags.valid) {
                acpi_disable_gpe(device->wakeup.gpe_device,
                                device->wakeup.gpe_number);
-               device->wakeup.run_wake_count--;
                device_set_wakeup_enable(&device->dev, false);
        }
 
index b99e624946074143a28f6c0a236b0d002426117a..b136c9c1e531954dc27cc4bed422e1618e7681ee 100644 (file)
@@ -797,7 +797,6 @@ static void acpi_bus_set_run_wake_flags(struct acpi_device *device)
        acpi_status status;
        acpi_event_status event_status;
 
-       device->wakeup.run_wake_count = 0;
        device->wakeup.flags.notifier_present = 0;
 
        /* Power button, Lid switch always enable wakeup */
index 6fe0772e0e7de2432d9353d8871b3bc5e8ba04ee..7c3b18e78cee148d889a8a63ccc2fd4785eab81a 100644 (file)
@@ -293,19 +293,11 @@ static int acpi_dev_run_wake(struct device *phys_dev, bool enable)
        }
 
        if (enable) {
-               if (!dev->wakeup.run_wake_count++) {
-                       acpi_enable_wakeup_device_power(dev, ACPI_STATE_S0);
-                       acpi_enable_gpe(dev->wakeup.gpe_device,
-                                       dev->wakeup.gpe_number);
-               }
-       } else if (dev->wakeup.run_wake_count > 0) {
-               if (!--dev->wakeup.run_wake_count) {
-                       acpi_disable_gpe(dev->wakeup.gpe_device,
-                                        dev->wakeup.gpe_number);
-                       acpi_disable_wakeup_device_power(dev);
-               }
+               acpi_enable_wakeup_device_power(dev, ACPI_STATE_S0);
+               acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number);
        } else {
-               error = -EALREADY;
+               acpi_disable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number);
+               acpi_disable_wakeup_device_power(dev);
        }
 
        return error;
index 78ca429929f7438959e6509dcd0f547cfb44afd5..f50ebb9bc53b806b7bb32d3fe242d017b164f40a 100644 (file)
@@ -250,7 +250,6 @@ struct acpi_device_wakeup {
        struct acpi_handle_list resources;
        struct acpi_device_wakeup_flags flags;
        int prepare_count;
-       int run_wake_count;
 };
 
 /* Device */