From 995549b77f41f6e119954ac21bb90a930da6a489 Mon Sep 17 00:00:00 2001 From: miod Date: Thu, 27 Apr 2023 19:06:57 +0000 Subject: [PATCH] Mark the fan speed sensor as invalid when it reports -1 RPM. This happens for a short while after suspend. ok deraadt@ kn@ --- sys/dev/acpi/acpithinkpad.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/dev/acpi/acpithinkpad.c b/sys/dev/acpi/acpithinkpad.c index 76257e0cb3c..d749588f27e 100644 --- a/sys/dev/acpi/acpithinkpad.c +++ b/sys/dev/acpi/acpithinkpad.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpithinkpad.c,v 1.71 2023/04/09 17:50:02 jcs Exp $ */ +/* $OpenBSD: acpithinkpad.c,v 1.72 2023/04/27 19:06:57 miod Exp $ */ /* * Copyright (c) 2008 joshua stein * @@ -287,7 +287,12 @@ thinkpad_sensor_refresh(void *arg) /* Read fan RPM */ acpiec_read(sc->sc_ec, THINKPAD_ECOFFSET_FANLO, 1, &lo); acpiec_read(sc->sc_ec, THINKPAD_ECOFFSET_FANHI, 1, &hi); - sc->sc_sens[THINKPAD_SENSOR_FANRPM].value = ((hi << 8L) + lo); + if (hi == 0xff && lo == 0xff) { + sc->sc_sens[THINKPAD_SENSOR_FANRPM].flags = SENSOR_FINVALID; + } else { + sc->sc_sens[THINKPAD_SENSOR_FANRPM].value = ((hi << 8L) + lo); + sc->sc_sens[THINKPAD_SENSOR_FANRPM].flags = 0; + } } void -- 2.20.1