From: miod Date: Thu, 27 Apr 2023 19:06:57 +0000 (+0000) Subject: Mark the fan speed sensor as invalid when it reports -1 RPM. This happens for X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=995549b77f41f6e119954ac21bb90a930da6a489;p=openbsd Mark the fan speed sensor as invalid when it reports -1 RPM. This happens for a short while after suspend. ok deraadt@ kn@ --- 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