]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ACPI / PM: Drop run_wake from struct acpi_device_wakeup_flags
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 23 Jun 2017 23:53:14 +0000 (01:53 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 27 Jun 2017 23:52:15 +0000 (01:52 +0200)
The run_wake flag in struct acpi_device_wakeup_flags stores the
information on whether or not the device can generate wakeup
signals at run time, but in ACPI that really is equivalent to
being able to generate wakeup signals at all.

In fact, run_wake will always be set after successful executeion of
acpi_setup_gpe_for_wake(), but if that fails, the device will not be
able to use a wakeup GPE at all, so it won't be able to wake up the
systems from sleep states too.  Hence, run_wake actually means that
the device is capable of triggering wakeup and so it is equivalent
to the valid flag.

For this reason, drop run_wake from struct acpi_device_wakeup_flags
and make sure that the valid flag is only set if
acpi_setup_gpe_for_wake() has been successful.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/acpi/pci_root.c
drivers/acpi/proc.c
drivers/acpi/scan.c
drivers/pci/pci-acpi.c
include/acpi/acpi_bus.h

index 919be0aa2578760d466031f866a0e8772adf7f97..783acbe255208f4ae607a3e0908832879b00320e 100644 (file)
@@ -608,7 +608,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
                pcie_no_aspm();
 
        pci_acpi_add_bus_pm_notifier(device);
-       if (device->wakeup.flags.run_wake)
+       if (device->wakeup.flags.valid)
                device_set_run_wake(root->bus->bridge, true);
 
        if (hotadd) {
index a34669cc823b5b836a800bf6798599ce7f88907e..85ac848ac6ab60dbd5488c36de79cd7b62fbceba 100644 (file)
@@ -42,7 +42,7 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
 
                if (!dev->physical_node_count) {
                        seq_printf(seq, "%c%-8s\n",
-                               dev->wakeup.flags.run_wake ? '*' : ' ',
+                               dev->wakeup.flags.valid ? '*' : ' ',
                                device_may_wakeup(&dev->dev) ?
                                        "enabled" : "disabled");
                } else {
@@ -58,7 +58,7 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
                                        seq_printf(seq, "\t\t");
 
                                seq_printf(seq, "%c%-8s  %s:%s\n",
-                                       dev->wakeup.flags.run_wake ? '*' : ' ',
+                                       dev->wakeup.flags.valid ? '*' : ' ',
                                        (device_may_wakeup(&dev->dev) ||
                                        device_may_wakeup(ldev)) ?
                                        "enabled" : "disabled",
index 3a10d7573477e7dea0139c5f885e9514a1886a7a..49849667cd3fa73bbe5b49b25200ab92dab320c6 100644 (file)
@@ -835,7 +835,7 @@ static int acpi_bus_extract_wakeup_device_power_package(acpi_handle handle,
        return err;
 }
 
-static void acpi_wakeup_gpe_init(struct acpi_device *device)
+static bool acpi_wakeup_gpe_init(struct acpi_device *device)
 {
        static const struct acpi_device_id button_device_ids[] = {
                {"PNP0C0C", 0},
@@ -845,13 +845,11 @@ static void acpi_wakeup_gpe_init(struct acpi_device *device)
        };
        struct acpi_device_wakeup *wakeup = &device->wakeup;
        acpi_status status;
-       acpi_event_status event_status;
 
        wakeup->flags.notifier_present = 0;
 
        /* Power button, Lid switch always enable wakeup */
        if (!acpi_match_device_ids(device, button_device_ids)) {
-               wakeup->flags.run_wake = 1;
                if (!acpi_match_device_ids(device, &button_device_ids[1])) {
                        /* Do not use Lid/sleep button for S5 wakeup */
                        if (wakeup->sleep_state == ACPI_STATE_S5)
@@ -859,17 +857,12 @@ static void acpi_wakeup_gpe_init(struct acpi_device *device)
                }
                acpi_mark_gpe_for_wake(wakeup->gpe_device, wakeup->gpe_number);
                device_set_wakeup_capable(&device->dev, true);
-               return;
+               return true;
        }
 
-       acpi_setup_gpe_for_wake(device->handle, wakeup->gpe_device,
-                               wakeup->gpe_number);
-       status = acpi_get_gpe_status(wakeup->gpe_device, wakeup->gpe_number,
-                                    &event_status);
-       if (ACPI_FAILURE(status))
-               return;
-
-       wakeup->flags.run_wake = !!(event_status & ACPI_EVENT_FLAG_HAS_HANDLER);
+       status = acpi_setup_gpe_for_wake(device->handle, wakeup->gpe_device,
+                                        wakeup->gpe_number);
+       return ACPI_SUCCESS(status);
 }
 
 static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
@@ -887,10 +880,10 @@ static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
                return;
        }
 
-       device->wakeup.flags.valid = 1;
+       device->wakeup.flags.valid = acpi_wakeup_gpe_init(device);
        device->wakeup.prepare_count = 0;
-       acpi_wakeup_gpe_init(device);
-       /* Call _PSW/_DSW object to disable its ability to wake the sleeping
+       /*
+        * Call _PSW/_DSW object to disable its ability to wake the sleeping
         * system for the ACPI device with the _PRW object.
         * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW.
         * So it is necessary to call _DSW object first. Only when it is not
index 61296f20c37a04e1353fc71c9fe11d889b5a855e..f084046e1feb71ac06a36d382bace082b243612b 100644 (file)
@@ -777,9 +777,8 @@ static void pci_acpi_setup(struct device *dev)
                return;
 
        device_set_wakeup_capable(dev, true);
+       device_set_run_wake(dev, true);
        acpi_pci_sleep_wake(pci_dev, false);
-       if (adev->wakeup.flags.run_wake)
-               device_set_run_wake(dev, true);
 }
 
 static void pci_acpi_cleanup(struct device *dev)
index 30f3dc845aa48aa5a06e374191064b938d58a04d..72e32bd1e333d3240fd773531fca35f9ddfc438c 100644 (file)
@@ -314,7 +314,6 @@ struct acpi_device_perf {
 /* Wakeup Management */
 struct acpi_device_wakeup_flags {
        u8 valid:1;             /* Can successfully enable wakeup? */
-       u8 run_wake:1;          /* Run-Wake GPE devices */
        u8 notifier_present:1;  /* Wake-up notify handler has been installed */
        u8 enabled:1;           /* Enabled for wakeup */
 };