Skip to content

Commit c737ad7

Browse files
committed
input: macsmc-input: Fix wakeup from s2idle
Hard wakeup events are required to wake from s2idle. The comment in [1] to always send wakeup events is correct though. To combine both requirements use pm_wakeup_dev_event() and evaluate the previous conditions for calling pm_wakeup_hard_event() as hard parameters. The remark about always reporting KEY_POWER is only partially correct though. (Some) User space handles that indeed correctly but a system offering a agetty login prompt shuts down immediately after waking from s2idle. 1: https://lore.kernel.org/all/qffp7kadq3xojla5k6f5pr37irgytqfsqvabr6ydvulxnkcgnn@bv5mrraxrhhe/ Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 173d102 commit c737ad7

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

drivers/input/misc/macsmc-input.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,16 @@ static void macsmc_input_event_button(struct macsmc_input *smcin, unsigned long
4646
switch (button) {
4747
case BTN_POWER:
4848
case BTN_TOUCHID:
49-
if (smcin->wakeup_mode) {
50-
if (state)
51-
pm_wakeup_event(smcin->dev, 0);
52-
} else {
53-
input_report_key(smcin->input, KEY_POWER, state);
54-
input_sync(smcin->input);
55-
}
49+
pm_wakeup_dev_event(smcin->dev, 0, (smcin->wakeup_mode && state));
50+
/*
51+
* Suppress KEY_POWER reports when suspended to avoid powering down
52+
* immediately after waking from s2idle.
53+
* */
54+
if (smcin->wakeup_mode)
55+
return;
56+
57+
input_report_key(smcin->input, KEY_POWER, state);
58+
input_sync(smcin->input);
5659
break;
5760
case BTN_POWER_HELD_SHORT: /* power button held down; ignore */
5861
break;
@@ -80,9 +83,7 @@ static void macsmc_input_event_lid(struct macsmc_input *smcin, unsigned long eve
8083
{
8184
u8 lid_state = !!((event >> 8) & 0xff);
8285

83-
if (smcin->wakeup_mode && !lid_state)
84-
pm_wakeup_event(smcin->dev, 0);
85-
86+
pm_wakeup_dev_event(smcin->dev, 0, (smcin->wakeup_mode && !lid_state));
8687
input_report_switch(smcin->input, SW_LID, lid_state);
8788
input_sync(smcin->input);
8889
}

0 commit comments

Comments
 (0)