ACPI: EC: PM: Avoid premature returns from acpi_s2idle_wake()
[sfrench/cifs-2.6.git] / drivers / acpi / ec.c
index b4c0152e92aa124ac0d92a778cf49a448f4a03cd..145ec0b6f20b177d64bc40661ccd3aedd9896d42 100644 (file)
@@ -1994,23 +1994,31 @@ void acpi_ec_set_gpe_wake_mask(u8 action)
                acpi_set_gpe_wake_mask(NULL, first_ec->gpe, action);
 }
 
-bool acpi_ec_other_gpes_active(void)
-{
-       return acpi_any_gpe_status_set(first_ec ? first_ec->gpe : U32_MAX);
-}
-
 bool acpi_ec_dispatch_gpe(void)
 {
        u32 ret;
 
        if (!first_ec)
+               return acpi_any_gpe_status_set(U32_MAX);
+
+       /*
+        * Report wakeup if the status bit is set for any enabled GPE other
+        * than the EC one.
+        */
+       if (acpi_any_gpe_status_set(first_ec->gpe))
+               return true;
+
+       if (ec_no_wakeup)
                return false;
 
+       /*
+        * Dispatch the EC GPE in-band, but do not report wakeup in any case
+        * to allow the caller to process events properly after that.
+        */
        ret = acpi_dispatch_gpe(NULL, first_ec->gpe);
-       if (ret == ACPI_INTERRUPT_HANDLED) {
+       if (ret == ACPI_INTERRUPT_HANDLED)
                pm_pr_dbg("EC GPE dispatched\n");
-               return true;
-       }
+
        return false;
 }
 #endif /* CONFIG_PM_SLEEP */