From: patrick Date: Thu, 10 Nov 2022 16:20:54 +0000 (+0000) Subject: Apparently we receive interrupts for both powerkey press and release, which X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2da809330b846850adb44772016fa9d334f78392;p=openbsd Apparently we receive interrupts for both powerkey press and release, which isn't quite helpful when it's used to come back from suspend and then the second interrupt initiates powerdown. Ignore press, but handle release. ok kettenis@ --- diff --git a/sys/dev/fdt/qcpon.c b/sys/dev/fdt/qcpon.c index 0e23d507eb1..ee1f387cedb 100644 --- a/sys/dev/fdt/qcpon.c +++ b/sys/dev/fdt/qcpon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qcpon.c,v 1.1 2022/11/08 19:44:28 patrick Exp $ */ +/* $OpenBSD: qcpon.c,v 1.2 2022/11/10 16:20:54 patrick Exp $ */ /* * Copyright (c) 2022 Patrick Wildt * @@ -40,6 +40,7 @@ struct qcpon_softc { int8_t sc_sid; void *sc_pwrkey_ih; + int sc_pwrkey_debounce; struct task sc_powerdown_task; }; @@ -104,6 +105,11 @@ qcpon_pwrkey_intr(void *arg) { struct qcpon_softc *sc = arg; + /* Ignore presses, handle releases. */ + sc->sc_pwrkey_debounce = (sc->sc_pwrkey_debounce + 1) % 2; + if (sc->sc_pwrkey_debounce == 1) + return 1; + task_add(systq, &sc->sc_powerdown_task); return 1; }