Module Name: src
Committed By: pgoyette
Date: Sat Jun 4 02:02:55 UTC 2011
Modified Files:
src/sys/dev/sysmon: swsensor.c
Log Message:
Enable creation of value_{max,min,avg} entries via the proplist, as well
as setting the ENVSYS_FPERCENT flag
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 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/sys/dev/sysmon/swsensor.c
diff -u src/sys/dev/sysmon/swsensor.c:1.7 src/sys/dev/sysmon/swsensor.c:1.8
--- src/sys/dev/sysmon/swsensor.c:1.7 Fri Dec 17 13:37:37 2010
+++ src/sys/dev/sysmon/swsensor.c Sat Jun 4 02:02:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: swsensor.c,v 1.7 2010/12/17 13:37:37 pooka Exp $ */
+/* $NetBSD: swsensor.c,v 1.8 2011/06/04 02:02:55 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.7 2010/12/17 13:37:37 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: swsensor.c,v 1.8 2011/06/04 02:02:55 pgoyette Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -234,6 +234,40 @@
if (po != NULL && prop_object_type(po) == PROP_TYPE_NUMBER)
sw_sensor_value = prop_number_integer_value(po);
+ /* Retrieve any value_{max,min,avg} that might be present */
+ if (pd != NULL) {
+ po = prop_dictionary_get(pd, "value_max");
+ if (po != NULL && prop_object_type(po) == PROP_TYPE_NUMBER) {
+ swsensor_edata.value_max =
+ prop_number_integer_value(po);
+ swsensor_edata.flags |= ENVSYS_FVALID_MAX;
+ }
+
+ po = prop_dictionary_get(pd, "value_min");
+ if (po != NULL && prop_object_type(po) == PROP_TYPE_NUMBER) {
+ swsensor_edata.value_min =
+ prop_number_integer_value(po);
+ swsensor_edata.flags |= ENVSYS_FVALID_MIN;
+ }
+
+ po = prop_dictionary_get(pd, "value_avg");
+ if (po != NULL && prop_object_type(po) == PROP_TYPE_NUMBER) {
+ swsensor_edata.value_avg =
+ prop_number_integer_value(po);
+ swsensor_edata.flags |= ENVSYS_FVALID_AVG;
+ }
+ }
+
+ /* See if this sensor should report percentages vs raw values */
+ if (pd != NULL) {
+ po = prop_dictionary_get(pd, "percentage");
+ if (po != NULL &&
+ prop_object_type(po) == PROP_TYPE_BOOL &&
+ prop_bool_true(po))
+ swsensor_edata.flags |= ENVSYS_FPERCENT;
+ }
+
+ swsensor_edata.state = ENVSYS_SVALID;
swsensor_edata.value_cur = 0;
strlcpy(swsensor_edata.desc, "sensor", ENVSYS_DESCLEN);