platform/x86: intel-vbtn: Rework wakeup handling in notify_handler()
authorHans de Goede <hdegoede@redhat.com>
Fri, 15 Jan 2021 16:18:47 +0000 (17:18 +0100)
committerHans de Goede <hdegoede@redhat.com>
Mon, 25 Jan 2021 20:34:18 +0000 (21:34 +0100)
Rework the wakeup path inside notify_handler() to special case the
buttons (KE_KEY) case instead of the switches case.

In case of a button wake event we want to skip reporting this,
mirroring how the drivers/acpi/button.c code skips the reporting
in the wakeup case (suspended flag set) too.

The reason to skip reporting in this case is that some Linux
desktop-environments will immediately resuspend if we report an
evdev event for the power-button press on wakeup.

Before this commit the skipping of the button-press was done
in a round-about way: In case of a wakeup the regular
sparse_keymap_report_event() would always be skipped by
an early return, and then to avoid not reporting switch changes
on wakeup there was a special KE_SW path with a duplicate
sparse_keymap_report_event() call.

This commit refactors the wakeup handling to explicitly skip the
reporting for button wake events, while using the regular
reporting path for non button (switches) wakeup events.

No intentional functional impact.

Cc: Elia Devito <eliadevito@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210115161850.117614-1-hdegoede@redhat.com
drivers/platform/x86/intel-vbtn.c

index 30a9062..e1bb37a 100644 (file)
@@ -131,22 +131,17 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
 
        if (priv->wakeup_mode) {
                ke = sparse_keymap_entry_from_scancode(priv->input_dev, event);
-               if (ke) {
-                       pm_wakeup_hard_event(&device->dev);
-
-                       /*
-                        * Switch events like tablet mode will wake the device
-                        * and report the new switch position to the input
-                        * subsystem.
-                        */
-                       if (ke->type == KE_SW)
-                               sparse_keymap_report_event(priv->input_dev,
-                                                          event,
-                                                          val,
-                                                          0);
+               if (!ke)
+                       goto out_unknown;
+
+               pm_wakeup_hard_event(&device->dev);
+
+               /*
+                * Skip reporting an evdev event for button wake events,
+                * mirroring how the drivers/acpi/button.c code skips this too.
+                */
+               if (ke->type == KE_KEY)
                        return;
-               }
-               goto out_unknown;
        }
 
        /*