diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2006-05-27 21:33:48 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2006-05-27 21:33:48 +0000 |
commit | fa684f767950757c9352593cbf4c6935d9b38b3a (patch) | |
tree | 0edc4c18ca4afaa1d78a17a29bc4e46367ac4c99 | |
parent | e4ffca7586b8d05bd23c7244d31928deaf5d259a (diff) |
factor out sensor_probe from sensor_scan so we can probe a sensors when
we know its idea without scanning all again
-rw-r--r-- | usr.sbin/ntpd/sensors.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/usr.sbin/ntpd/sensors.c b/usr.sbin/ntpd/sensors.c index 59e306f8353..d493b4476eb 100644 --- a/usr.sbin/ntpd/sensors.c +++ b/usr.sbin/ntpd/sensors.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensors.c,v 1.3 2006/05/27 21:27:34 henning Exp $ */ +/* $OpenBSD: sensors.c,v 1.4 2006/05/27 21:33:47 henning Exp $ */ /* * Copyright (c) 2006 Henning Brauer <henning@openbsd.org> @@ -34,6 +34,7 @@ #define SENSORS_MAX 255 #define _PATH_DEV_HOTPLUG "/dev/hotplug" +void sensor_probe(struct ntpd_conf *, int); void sensor_add(struct ntpd_conf *, struct sensor *); void @@ -45,26 +46,32 @@ sensor_init(struct ntpd_conf *conf) void sensor_scan(struct ntpd_conf *conf) { - struct sensor sensor; int i; + + for (i = 0; i < SENSORS_MAX; i++) + sensor_probe(conf, i); +} + +void +sensor_probe(struct ntpd_conf *conf, int id) +{ int mib[3]; size_t len; + struct sensor sensor; mib[0] = CTL_HW; mib[1] = HW_SENSORS; + mib[2] = id; - for (i = 0; i < SENSORS_MAX; i++) { - mib[2] = i; - len = sizeof(sensor); - if (sysctl(mib, 3, &sensor, &len, NULL, 0) == -1) { - if (errno != ENOENT) - log_warn("sensor_scan sysctl"); - break; - } - - if (sensor.type == SENSOR_TIMEDELTA) - sensor_add(conf, &sensor); + len = sizeof(sensor); + if (sysctl(mib, 3, &sensor, &len, NULL, 0) == -1) { + if (errno != ENOENT) + log_warn("sensor_probe sysctl"); + return; } + + if (sensor.type == SENSOR_TIMEDELTA) + sensor_add(conf, &sensor); } void |