Module Name: src
Committed By: pgoyette
Date: Thu Dec 16 14:33:31 UTC 2010
Modified Files:
src/share/man/man4: swsensor.4
src/sys/dev/sysmon: swsensor.c
Log Message:
Also allow specification of sensor's initial value when it is loaded,
using "-i value=<value>".
Suggested by njoly@
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/swsensor.4
cvs rdiff -u -r1.5 -r1.6 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.4 src/share/man/man4/swsensor.4:1.5
--- src/share/man/man4/swsensor.4:1.4 Sat Dec 11 15:49:34 2010
+++ src/share/man/man4/swsensor.4 Thu Dec 16 14:33:30 2010
@@ -1,4 +1,4 @@
-.\" $NetBSD: swsensor.4,v 1.4 2010/12/11 15:49:34 wiz Exp $
+.\" $NetBSD: swsensor.4,v 1.5 2010/12/16 14:33:30 pgoyette 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 December 9, 2010
+.Dd December 16, 2010
.Dt SWSENSOR 4
.Os
.Sh NAME
@@ -77,6 +77,9 @@
is set to 1 or 2)
.It Li "type"
Override the sensor's unit/type.
+.It Li "value"
+Provide an initial value for the sensor.
+If this is omitted, the sensor's initial value is set to zero.
.El
.Pp
For example,
Index: src/sys/dev/sysmon/swsensor.c
diff -u src/sys/dev/sysmon/swsensor.c:1.5 src/sys/dev/sysmon/swsensor.c:1.6
--- src/sys/dev/sysmon/swsensor.c:1.5 Sat Dec 11 04:13:03 2010
+++ src/sys/dev/sysmon/swsensor.c Thu Dec 16 14:33:30 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: swsensor.c,v 1.5 2010/12/11 04:13:03 pgoyette Exp $ */
+/* $NetBSD: swsensor.c,v 1.6 2010/12/16 14:33:30 pgoyette 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.5 2010/12/11 04:13:03 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: swsensor.c,v 1.6 2010/12/16 14:33:30 pgoyette Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -227,6 +227,13 @@
&sw_sensor_deflims, &sw_sensor_defprops);
}
+ /* See if an initial value was specified */
+ if (pd != NULL)
+ po = prop_dictionary_get(pd, "value");
+
+ if (po != NULL && prop_object_type(po) == PROP_TYPE_NUMBER)
+ sw_sensor_value = prop_number_integer_value(po);
+
swsensor_edata.value_cur = 0;
strlcpy(swsensor_edata.desc, "sensor", ENVSYS_DESCLEN);