Date: Tue, 8 Jun 2004 03:01:10 GMT From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 54388 for review Message-ID: <200406080301.i5831AXT012317@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=54388 Change 54388 by peter@peter_hammer on 2004/06/08 03:00:21 OK, thats the last straw! Teach sysctl subsystem about deci-Kelvins (the temperature units that acpi uses) hammer# sysctl hw.acpi.thermal.tz0 hw.acpi.thermal.tz0.temperature: 31.0C hw.acpi.thermal.tz0.active: -1 hw.acpi.thermal.tz0.thermal_flags: 0 hw.acpi.thermal.tz0._PSV: -1 hw.acpi.thermal.tz0._HOT: -1 hw.acpi.thermal.tz0._CRT: 75.0C hw.acpi.thermal.tz0._ACx: 50.0C -1 -1 -1 -1 -1 -1 -1 -1 -1 hammer# Affected files ... .. //depot/projects/hammer/sbin/sysctl/sysctl.c#12 edit .. //depot/projects/hammer/sys/dev/acpica/acpi_thermal.c#16 edit Differences ... ==== //depot/projects/hammer/sbin/sysctl/sysctl.c#12 (text+ko) ==== @@ -563,7 +563,12 @@ fputs(val, stdout); if(*fmt == 'U') printf(hflag ? "%'u" : "%u", *(unsigned int *)p); - else + else if (*fmt == 'K') { + if (*(int *)p < 0) + printf("%d", *(int *)p); + else + printf("%d.%dC", (*(int *)p - 2732) / 10, (*(int *)p - 2732) % 10); + } else printf(hflag ? "%'d" : "%d", *(int *)p); val = " "; len -= sizeof(int); @@ -580,7 +585,12 @@ fputs(val, stdout); if(*fmt == 'U') printf(hflag ? "%'lu" : "%lu", *(unsigned long *)p); - else + else if (*fmt == 'K') { + if (*(long *)p < 0) + printf("%ld", *(long *)p); + else + printf("%ld.%ldC", (*(long *)p - 2732) / 10, (*(long *)p - 2732) % 10); + } else printf(hflag ? "%'ld" : "%ld", *(long *)p); val = " "; len -= sizeof(long); ==== //depot/projects/hammer/sys/dev/acpica/acpi_thermal.c#16 (text+ko) ==== @@ -234,9 +234,9 @@ 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_INT(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree), - OID_AUTO, "temperature", CTLFLAG_RD, - &sc->tz_temperature, 0, "current thermal zone temperature"); + 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, "active", CTLTYPE_INT | CTLFLAG_RW, sc, 0, acpi_tz_active_sysctl, "I", ""); @@ -247,15 +247,15 @@ SYSCTL_ADD_INT(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree), OID_AUTO, "_PSV", CTLFLAG_RD, &sc->tz_zone.psv, 0, ""); - SYSCTL_ADD_INT(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree), - OID_AUTO, "_HOT", CTLFLAG_RD, - &sc->tz_zone.hot, 0, ""); - SYSCTL_ADD_INT(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree), - OID_AUTO, "_CRT", CTLFLAG_RD, - &sc->tz_zone.crt, 0, ""); + SYSCTL_ADD_OPAQUE(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree), + OID_AUTO, "_HOT", CTLFLAG_RD, &sc->tz_zone.hot, + sizeof(sc->tz_zone.hot), "IK", ""); + SYSCTL_ADD_OPAQUE(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree), + OID_AUTO, "_CRT", CTLFLAG_RD, &sc->tz_zone.crt, + sizeof(sc->tz_zone.crt), "IK", ""); 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), "I", ""); + sizeof(sc->tz_zone.ac), "IK", ""); /* * Register our power profile event handler, and flag it for a manual
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406080301.i5831AXT012317>