[PATCH v2 07/11] input: macsmc-hid: New driver to handle the Apple Mac SMC buttons/lid
Janne Grunau
j at jannau.net
Tue Oct 21 14:35:20 PDT 2025
On Fri, Aug 29, 2025 at 11:11:22AM +0000, Dmitry Torokhov wrote:
> Hi James,
>
> On Wed, Aug 27, 2025 at 09:22:41PM +1000, James Calligeros wrote:
> > +static void macsmc_hid_event_button(struct macsmc_hid *smchid, unsigned long event)
> > +{
> > + u8 button = (event >> 8) & 0xff;
> > + u8 state = !!(event & 0xff);
> > +
> > + switch (button) {
> > + case BTN_POWER:
> > + case BTN_TOUCHID:
> > + if (smchid->wakeup_mode) {
> > + if (state)
> > + pm_wakeup_hard_event(smchid->dev);
> > + } else {
> > + input_report_key(smchid->input, KEY_POWER, state);
> > + input_sync(smchid->input);
> > + }
>
> I believe you should be using pm_wakeup_event() in all cases so that
> pressing power would interrupt suspend even if resume() handler has not
> been run yet.
pm_wakeup_event() does not wake from s2idle. pm_wakeup_dev_event()'s
`hard` parameter is explicitily documented to wake from s2idle. So using
pm_wakeup_dev_event and use `smchid->wakeup_mode && state` as hard
parameter seems the correct thing to do.
> Also I do not think suppressing KEY_POWER is needed.
> Userspace should be smart and decide whether to shutdown the system or
> not when receiving KEY_POWER depending on the overall system state.
Not all user space. Using the power button to wake from s2idle while
showing agetty's login prompt on a tty results in an immediate shutdown.
Janne
More information about the linux-arm-kernel
mailing list