From: kettenis Date: Sun, 22 Jan 2023 13:14:21 +0000 (+0000) Subject: Simplify the (so far unused) apm_record_event() function a bit and use it X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=dcc3b6294b1491ca2d8b4f6dc2ba83a2fe5ac962;p=openbsd Simplify the (so far unused) apm_record_event() function a bit and use it to send a resume event to userland when we come out of suspend. ok deraadt@ --- diff --git a/sys/arch/arm64/dev/apm.c b/sys/arch/arm64/dev/apm.c index 8953d48961c..80b0d77f967 100644 --- a/sys/arch/arm64/dev/apm.c +++ b/sys/arch/arm64/dev/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.20 2023/01/09 20:29:35 kettenis Exp $ */ +/* $OpenBSD: apm.c,v 1.21 2023/01/22 13:14:21 kettenis Exp $ */ /*- * Copyright (c) 2001 Alexander Guy. All rights reserved. @@ -335,26 +335,18 @@ apm_setinfohook(int (*hook)(struct apm_power_info *)) } int -apm_record_event(u_int event, const char *src, const char *msg) +apm_record_event(u_int event) { + struct apm_softc *sc = apm_cd.cd_devs[0]; static int apm_evindex; - struct apm_softc *sc; - - /* apm0 only */ - if (apm_cd.cd_ndevs == 0 || (sc = apm_cd.cd_devs[0]) == NULL) - return ENXIO; - - if ((sc->sc_flags & SCFLAG_NOPRINT) == 0) - printf("%s: %s %s\n", sc->sc_dev.dv_xname, src, msg); /* skip if no user waiting */ - if ((sc->sc_flags & SCFLAG_OPEN) == 0) - return (1); + if (sc == NULL || (sc->sc_flags & SCFLAG_OPEN) == 0) + return 1; apm_evindex++; KNOTE(&sc->sc_note, APM_EVENT_COMPOSE(event, apm_evindex)); - - return (0); + return 0; } #ifdef SUSPEND @@ -440,6 +432,7 @@ sleep_resume(void *v) int suspend_finish(void *v) { + apm_record_event(APM_NORMAL_RESUME); return 0; } diff --git a/sys/arch/arm64/include/apmvar.h b/sys/arch/arm64/include/apmvar.h index 1544733d59f..1e5d83a7384 100644 --- a/sys/arch/arm64/include/apmvar.h +++ b/sys/arch/arm64/include/apmvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: apmvar.h,v 1.2 2019/01/23 09:57:36 phessler Exp $ */ +/* $OpenBSD: apmvar.h,v 1.3 2023/01/22 13:14:21 kettenis Exp $ */ /* * Copyright (c) 2001 Alexander Guy @@ -121,7 +121,7 @@ struct apm_ctl { #ifdef _KERNEL void apm_setinfohook(int (*)(struct apm_power_info *)); -int apm_record_event(u_int, const char *, const char *); +int apm_record_event(u_int); #endif #endif /* _MACHINE_APMVAR_H_ */