Module Name: src Committed By: riz Date: Wed Oct 17 21:13:39 UTC 2012
Modified Files: src/share/man/man4 [netbsd-6]: swsensor.4 src/sys/dev/sysmon [netbsd-6]: swsensor.c Log Message: Pull up following revision(s) (requested by pgoyette in ticket #546): sys/dev/sysmon/swsensor.c: revision 1.13 share/man/man4/swsensor.4: revision 1.11 share/man/man4/swsensor.4: revision 1.12 Add hw.swsensor.state variable for additional control capability. Mention the new sysctl variable just created. Drop trailing whitespace. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.10.4.1 src/share/man/man4/swsensor.4 cvs rdiff -u -r1.12 -r1.12.8.1 src/sys/dev/sysmon/swsensor.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/share/man/man4/swsensor.4 diff -u src/share/man/man4/swsensor.4:1.10 src/share/man/man4/swsensor.4:1.10.4.1 --- src/share/man/man4/swsensor.4:1.10 Sun Jun 19 07:17:18 2011 +++ src/share/man/man4/swsensor.4 Wed Oct 17 21:13:39 2012 @@ -1,4 +1,4 @@ -.\" $NetBSD: swsensor.4,v 1.10 2011/06/19 07:17:18 wiz Exp $ +.\" $NetBSD: swsensor.4,v 1.10.4.1 2012/10/17 21:13:39 riz Exp $ .\" .\" Copyright (c) 2010 The NetBSD Foundation .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd June 19, 2011 +.Dd August 27, 2012 .Dt SWSENSOR 4 .Os .Sh NAME @@ -112,10 +112,13 @@ while .Dl Ic modload -i mode=1 -i limit=50 swsensor will create a sensor which has an initial, device-provided limit of 50. .Pp -The sensor's raw value can be manually updated by modifying the +The sensor's raw value and state can be manually updated by modifying the .Xr sysctl 8 -variable -.Dq hw.swsensor.cur_value . +variables +.Dq hw.swsensor.cur_value +and +.Dq hw.swsensor.state +variables respectively. .Sh SEE ALSO .Xr modctl 2 , .Xr envstat 8 , Index: src/sys/dev/sysmon/swsensor.c diff -u src/sys/dev/sysmon/swsensor.c:1.12 src/sys/dev/sysmon/swsensor.c:1.12.8.1 --- src/sys/dev/sysmon/swsensor.c:1.12 Sun Jun 19 15:52:48 2011 +++ src/sys/dev/sysmon/swsensor.c Wed Oct 17 21:13:38 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: swsensor.c,v 1.12 2011/06/19 15:52:48 pgoyette Exp $ */ +/* $NetBSD: swsensor.c,v 1.12.8.1 2012/10/17 21:13:38 riz Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: swsensor.c,v 1.12 2011/06/19 15:52:48 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: swsensor.c,v 1.12.8.1 2012/10/17 21:13:38 riz Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -48,11 +48,13 @@ int swsensorattach(int); static struct sysctllog *swsensor_sysctllog = NULL; static int sensor_value_sysctl = 0; +static int sensor_state_sysctl = 0; static struct sysmon_envsys *swsensor_sme; static envsys_data_t swsensor_edata; static int32_t sw_sensor_value; +static int32_t sw_sensor_state; static int32_t sw_sensor_limit; static int32_t sw_sensor_mode; static int32_t sw_sensor_defprops; @@ -71,6 +73,7 @@ sysctl_swsensor_setup(void) int ret; int node_sysctl_num; const struct sysctlnode *me = NULL; + const struct sysctlnode *me2; KASSERT(swsensor_sysctllog == NULL); @@ -83,14 +86,24 @@ sysctl_swsensor_setup(void) return; node_sysctl_num = me->sysctl_num; - ret = sysctl_createv(&swsensor_sysctllog, 0, NULL, &me, + ret = sysctl_createv(&swsensor_sysctllog, 0, NULL, &me2, CTLFLAG_READWRITE, CTLTYPE_INT, "cur_value", NULL, NULL, 0, &sw_sensor_value, 0, CTL_HW, node_sysctl_num, CTL_CREATE, CTL_EOL); if (ret == 0) - sensor_value_sysctl = me->sysctl_num; + sensor_value_sysctl = me2->sysctl_num; + + node_sysctl_num = me->sysctl_num; + ret = sysctl_createv(&swsensor_sysctllog, 0, NULL, &me2, + CTLFLAG_READWRITE, + CTLTYPE_INT, "state", NULL, + NULL, 0, &sw_sensor_state, 0, + CTL_HW, node_sysctl_num, CTL_CREATE, CTL_EOL); + + if (ret == 0) + sensor_state_sysctl = me2->sysctl_num; } /* @@ -115,8 +128,12 @@ swsensor_refresh(struct sysmon_envsys *s /* * Set state. If we're handling the limits ourselves, do the * compare; otherwise just assume the value is valid. + * If sensor state has been set from userland (via sysctl), + * just report that value. */ - if ((sw_sensor_mode == 2) && (edata->upropset & PROP_CRITMIN) && + if (sw_sensor_state != ENVSYS_SVALID) + edata->state = sw_sensor_state; + else if ((sw_sensor_mode == 2) && (edata->upropset & PROP_CRITMIN) && (edata->upropset & PROP_DRIVER_LIMITS) && (edata->value_cur < edata->limits.sel_critmin)) edata->state = ENVSYS_SCRITUNDER; @@ -321,6 +338,7 @@ swsensor_init(void *arg) /* Wait for refresh to validate the sensor value */ swsensor_edata.state = ENVSYS_SINVALID; + sw_sensor_state = ENVSYS_SVALID; error = sysmon_envsys_sensor_attach(swsensor_sme, &swsensor_edata); if (error != 0) {