From owner-svn-src-all@FreeBSD.ORG Wed Jun 18 10:38:30 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 40117F1A; Wed, 18 Jun 2014 10:38:30 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 202872182; Wed, 18 Jun 2014 10:38:30 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5IAcTRQ077116; Wed, 18 Jun 2014 10:38:29 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5IAcT8X077115; Wed, 18 Jun 2014 10:38:29 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201406181038.s5IAcT8X077115@svn.freebsd.org> From: Marius Strobl Date: Wed, 18 Jun 2014 10:38:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r267604 - stable/8/sys/dev/acpica X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jun 2014 10:38:30 -0000 Author: marius Date: Wed Jun 18 10:38:29 2014 New Revision: 267604 URL: http://svnweb.freebsd.org/changeset/base/267604 Log: MFC: r220798 Fix a few acpi sysctls that want "IK" formatting to specify CTLTYPE_INT. MFC: r245266 Remove not very useful printf, that can be too chatty. MFC: r255077 Warn about insane _TMP temperature only once. Modified: stable/8/sys/dev/acpica/acpi_thermal.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/dev/ (props changed) stable/8/sys/dev/acpica/ (props changed) Modified: stable/8/sys/dev/acpica/acpi_thermal.c ============================================================================== --- stable/8/sys/dev/acpica/acpi_thermal.c Wed Jun 18 07:23:04 2014 (r267603) +++ stable/8/sys/dev/acpica/acpi_thermal.c Wed Jun 18 10:38:29 2014 (r267604) @@ -112,6 +112,7 @@ struct acpi_tz_softc { struct acpi_tz_zone tz_zone; /*Thermal zone parameters*/ int tz_validchecks; + int tz_insane_tmp_notified; /* passive cooling */ struct proc *tz_cooling_proc; @@ -162,6 +163,8 @@ static driver_t acpi_tz_driver = { sizeof(struct acpi_tz_softc), }; +static char *acpi_tz_tmp_name = "_TMP"; + static devclass_t acpi_tz_devclass; DRIVER_MODULE(acpi_tz, acpi, acpi_tz_driver, acpi_tz_devclass, 0, 0); MODULE_DEPEND(acpi_tz, acpi, 1, 1, 1); @@ -259,10 +262,10 @@ acpi_tz_attach(device_t dev) sc->tz_sysctl_tree = SYSCTL_ADD_NODE(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(acpi_tz_sysctl_tree), OID_AUTO, oidname, CTLFLAG_RD, 0, ""); - SYSCTL_ADD_OPAQUE(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree), - OID_AUTO, "temperature", CTLFLAG_RD, &sc->tz_temperature, - sizeof(sc->tz_temperature), "IK", - "current thermal zone temperature"); + SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree), + OID_AUTO, "temperature", CTLTYPE_INT | CTLFLAG_RD, + &sc->tz_temperature, 0, sysctl_handle_int, + "IK", "current thermal zone temperature"); SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree), OID_AUTO, "active", CTLTYPE_INT | CTLFLAG_RW, sc, 0, acpi_tz_active_sysctl, "I", "cooling is active"); @@ -288,9 +291,9 @@ acpi_tz_attach(device_t dev) sc, offsetof(struct acpi_tz_softc, tz_zone.crt), acpi_tz_temp_sysctl, "IK", "critical temp setpoint (shutdown now)"); - SYSCTL_ADD_OPAQUE(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree), - OID_AUTO, "_ACx", CTLFLAG_RD, &sc->tz_zone.ac, - sizeof(sc->tz_zone.ac), "IK", ""); + SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree), + OID_AUTO, "_ACx", CTLTYPE_INT | CTLFLAG_RD, + &sc->tz_zone.ac, 0, sysctl_handle_int, "IK", ""); SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree), OID_AUTO, "_TC1", CTLTYPE_INT | CTLFLAG_RW, sc, offsetof(struct acpi_tz_softc, tz_zone.tc1), @@ -456,12 +459,11 @@ acpi_tz_get_temperature(struct acpi_tz_s { int temp; ACPI_STATUS status; - static char *tmp_name = "_TMP"; ACPI_FUNCTION_NAME ("acpi_tz_get_temperature"); /* Evaluate the thermal zone's _TMP method. */ - status = acpi_GetInteger(sc->tz_handle, tmp_name, &temp); + status = acpi_GetInteger(sc->tz_handle, acpi_tz_tmp_name, &temp); if (ACPI_FAILURE(status)) { ACPI_VPRINT(sc->tz_dev, acpi_device_get_parent_softc(sc->tz_dev), "error fetching current temperature -- %s\n", @@ -470,7 +472,7 @@ acpi_tz_get_temperature(struct acpi_tz_s } /* Check it for validity. */ - acpi_tz_sanity(sc, &temp, tmp_name); + acpi_tz_sanity(sc, &temp, acpi_tz_tmp_name); if (temp == -1) return (FALSE); @@ -509,15 +511,8 @@ acpi_tz_monitor(void *Context) */ newactive = TZ_ACTIVE_NONE; for (i = TZ_NUMLEVELS - 1; i >= 0; i--) { - if (sc->tz_zone.ac[i] != -1 && temp >= sc->tz_zone.ac[i]) { + if (sc->tz_zone.ac[i] != -1 && temp >= sc->tz_zone.ac[i]) newactive = i; - if (sc->tz_active != newactive) { - ACPI_VPRINT(sc->tz_dev, - acpi_device_get_parent_softc(sc->tz_dev), - "_AC%d: temperature %d.%d >= setpoint %d.%d\n", i, - TZ_KELVTOC(temp), TZ_KELVTOC(sc->tz_zone.ac[i])); - } - } } /* @@ -703,10 +698,29 @@ static void acpi_tz_sanity(struct acpi_tz_softc *sc, int *val, char *what) { if (*val != -1 && (*val < TZ_ZEROC || *val > TZ_ZEROC + 2000)) { - device_printf(sc->tz_dev, "%s value is absurd, ignored (%d.%dC)\n", - what, TZ_KELVTOC(*val)); + /* + * If the value we are checking is _TMP, warn the user only + * once. This avoids spamming messages if, for instance, the + * sensor is broken and always returns an invalid temperature. + * + * This is only done for _TMP; other values always emit a + * warning. + */ + if (what != acpi_tz_tmp_name || !sc->tz_insane_tmp_notified) { + device_printf(sc->tz_dev, "%s value is absurd, ignored (%d.%dC)\n", + what, TZ_KELVTOC(*val)); + + /* Don't warn the user again if the read value doesn't improve. */ + if (what == acpi_tz_tmp_name) + sc->tz_insane_tmp_notified = 1; + } *val = -1; + return; } + + /* This value is correct. Warn if it's incorrect again. */ + if (what == acpi_tz_tmp_name) + sc->tz_insane_tmp_notified = 0; } /*