From: Mario Limonciello <mario.limonciello@xxxxxxx> commit a7e23ec17feec ("ACPI: button: Install notifier for system events as well") modified the ACPI button behavior to send `ACPI_BUTTON_NOTIFY_WAKE` events. This caused a regression on a "Dell Optiplex 3040" sending `KEY_POWER` randomly at runtime. Adjust logic so that `ACPI_BUTTON_NOTIFY_WAKE` can not send `KEY_POWER` unless system is suspended. Fixes: a7e23ec17feec ("ACPI: button: Install notifier for system events as well") Reported-by: Ian Laurie <nixuser@xxxxxxxx> Closes: https://lore.kernel.org/linux-acpi/CAJZ5v0hbA6bqxHupTh4NZR-GVSb9M5RL7JSb2yQgvYYJg+z2aQ@xxxxxxxxxxxxxx/T/#md8071e480212201f23e4929607386750d3b6bc13 Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2357044 Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx> --- Cc: Yijun Shen <yijun_shen@xxxxxxxx> Cc: Richard Gong <richard_gong@xxxxxxx> --- drivers/acpi/button.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 90b09840536dd..515224943c3cf 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -444,10 +444,18 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data) struct input_dev *input; int keycode; + button = acpi_driver_data(device); + switch (event) { case ACPI_BUTTON_NOTIFY_STATUS: + acpi_pm_wakeup_event(&device->dev); + if (button->suspended) + return; break; case ACPI_BUTTON_NOTIFY_WAKE: + acpi_pm_wakeup_event(&device->dev); + if (!button->suspended) + return; break; default: acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n", @@ -455,12 +463,6 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data) return; } - acpi_pm_wakeup_event(&device->dev); - - button = acpi_driver_data(device); - if (button->suspended) - return; - input = button->input; keycode = test_bit(KEY_SLEEP, input->keybit) ? KEY_SLEEP : KEY_POWER; -- 2.43.0