From 4e599feccaa51cc151fc47aafce40cfa0c071aef Mon Sep 17 00:00:00 2001 From: deraadt Date: Wed, 16 Feb 2022 07:13:09 +0000 Subject: [PATCH] if the lids indicate we are not supposed to wakeup, return EAGAIN rather than scheduling an acpi thread --- sys/dev/acpi/acpi_x86.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/sys/dev/acpi/acpi_x86.c b/sys/dev/acpi/acpi_x86.c index 295912dc224..b9a2980cbcf 100644 --- a/sys/dev/acpi/acpi_x86.c +++ b/sys/dev/acpi/acpi_x86.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi_x86.c,v 1.8 2022/02/16 06:41:27 deraadt Exp $ */ +/* $OpenBSD: acpi_x86.c,v 1.9 2022/02/16 07:13:09 deraadt Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * Copyright (c) 2005 Jordan Hargrave @@ -155,17 +155,28 @@ sleep_resume(void *v) return 0; } + +static int +checklids(struct acpi_softc *sc) +{ + extern int lid_action; + int lids; + + lids = acpibtn_numopenlids(); + if (lids == 0 && lid_action != 0) + return EAGAIN; + return 0; +} + + int suspend_finish(void *v) { struct acpi_softc *sc = v; - extern int lid_action; acpi_record_event(sc, APM_NORMAL_RESUME); acpi_indicator(sc, ACPI_SST_WORKING); /* If we woke up but all the lids are closed, go back to sleep */ - if (acpibtn_numopenlids() == 0 && lid_action != 0) - acpi_addtask(sc, acpi_sleep_task, sc, sc->sc_state); - return 0; + return checklids(sc); } -- 2.20.1