Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Also allow specification of sensor's initial value when it i...



details:   https://anonhg.NetBSD.org/src/rev/f4cf8b8b9b0e
branches:  trunk
changeset: 759775:f4cf8b8b9b0e
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Thu Dec 16 14:33:30 2010 +0000

description:
Also allow specification of sensor's initial value when it is loaded,
using "-i value=<value>".

Suggested by njoly@

diffstat:

 share/man/man4/swsensor.4 |   7 +++++--
 sys/dev/sysmon/swsensor.c |  11 +++++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diffs (60 lines):

diff -r 2d973df3a62d -r f4cf8b8b9b0e share/man/man4/swsensor.4
--- a/share/man/man4/swsensor.4 Thu Dec 16 13:02:51 2010 +0000
+++ b/share/man/man4/swsensor.4 Thu Dec 16 14:33:30 2010 +0000
@@ -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,
diff -r 2d973df3a62d -r f4cf8b8b9b0e sys/dev/sysmon/swsensor.c
--- a/sys/dev/sysmon/swsensor.c Thu Dec 16 13:02:51 2010 +0000
+++ b/sys/dev/sysmon/swsensor.c Thu Dec 16 14:33:30 2010 +0000
@@ -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);



Home | Main Index | Thread Index | Old Index