From: deraadt Date: Wed, 16 Feb 2022 06:47:28 +0000 (+0000) Subject: If the lid is closed, suspend_finish() now returns EAGAIN, so go to the top X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=fd33afa7d077ee50df018d6d60f253c17f939f38;p=openbsd If the lid is closed, suspend_finish() now returns EAGAIN, so go to the top and restart the suspend all over again. This was previously done by issuing a task to the acpi thread, but this is simpler. (I want to try to duplicate these tests earlier in the resume path...) --- diff --git a/sys/kern/subr_suspend.c b/sys/kern/subr_suspend.c index 32df53fa4d0..e02cabb2f10 100644 --- a/sys/kern/subr_suspend.c +++ b/sys/kern/subr_suspend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_suspend.c,v 1.8 2022/02/16 06:41:27 deraadt Exp $ */ +/* $OpenBSD: subr_suspend.c,v 1.9 2022/02/16 06:47:28 deraadt Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * Copyright (c) 2005 Jordan Hargrave @@ -38,15 +38,19 @@ int sleep_state(void *v, int sleepmode) { - int error = ENXIO; + int error, s; extern int perflevel; - size_t rndbuflen = 0; - char *rndbuf = NULL; - int s; + size_t rndbuflen; + char *rndbuf; #if NSOFTRAID > 0 extern void sr_quiesce(void); #endif +top: + error = ENXIO; + rndbuf = NULL; + rndbuflen = 0; + if (sleep_showstate(v, sleepmode)) return EOPNOTSUPP; @@ -187,7 +191,8 @@ fail_alloc: if (cpu_setperf != NULL) cpu_setperf(perflevel); - suspend_finish(v); + if (suspend_finish(v) == EAGAIN) + goto top; return (error); }