From 1083ba8345743cc13d95100f510570ab00fbed09 Mon Sep 17 00:00:00 2001 From: rpokala Date: Thu, 8 Feb 2018 09:24:23 +0000 Subject: [PATCH] jedec_ts(4) uses a sysctl format specifier of "IK4", to indicate that it reports milliKelvin. However, sysctl(8) on stable/10 only knows about "IK", without a numeric suffix, which represents deciKelvin. Adjust the format specifier, and round the temperature value reported. Reviewed by: avg Sponsored by: Panasas Differential Revision: https://reviews.freebsd.org/D14055 git-svn-id: svn://svn.freebsd.org/base/stable/10@329015 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/jedec_ts/jedec_ts.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/dev/jedec_ts/jedec_ts.c b/sys/dev/jedec_ts/jedec_ts.c index 5483d15b0..fd487e88d 100644 --- a/sys/dev/jedec_ts/jedec_ts.c +++ b/sys/dev/jedec_ts/jedec_ts.c @@ -192,6 +192,10 @@ ts_temp_sysctl(SYSCTL_HANDLER_ARGS) if ((val & 0x1000) != 0) temp = -temp; temp = temp * 625 + 2731500; + + /* sysctl(8) reports deciKelvin, so round accordingly. */ + temp = (temp + 500) / 1000; + err = sysctl_handle_int(oidp, &temp, 0, req); return (err); } @@ -245,7 +249,7 @@ ts_attach(device_t dev) tree = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); SYSCTL_ADD_PROC(ctx, tree, OID_AUTO, "temp", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, dev, 0, - ts_temp_sysctl, "IK4", "Current temperature"); + ts_temp_sysctl, "IK", "Current temperature"); return (0); } -- 2.45.0