Source-Changes-HG archive

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

[src/netbsd-6]: src Pull up following revision(s) (requested by pgoyette in t...



details:   https://anonhg.NetBSD.org/src/rev/5f2125d0f966
branches:  netbsd-6
changeset: 775348:5f2125d0f966
user:      riz <riz%NetBSD.org@localhost>
date:      Wed Oct 17 21:13:38 2012 +0000

description:
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.

diffstat:

 share/man/man4/swsensor.4 |  13 ++++++++-----
 sys/dev/sysmon/swsensor.c |  28 +++++++++++++++++++++++-----
 2 files changed, 31 insertions(+), 10 deletions(-)

diffs (124 lines):

diff -r 9183af4bfd93 -r 5f2125d0f966 share/man/man4/swsensor.4
--- a/share/man/man4/swsensor.4 Wed Oct 17 21:06:55 2012 +0000
+++ b/share/man/man4/swsensor.4 Wed Oct 17 21:13:38 2012 +0000
@@ -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 @@
 .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 ,
diff -r 9183af4bfd93 -r 5f2125d0f966 sys/dev/sysmon/swsensor.c
--- a/sys/dev/sysmon/swsensor.c Wed Oct 17 21:06:55 2012 +0000
+++ b/sys/dev/sysmon/swsensor.c Wed Oct 17 21:13:38 2012 +0000
@@ -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 @@
 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 @@
        int ret;
        int node_sysctl_num;
        const struct sysctlnode *me = NULL;
+       const struct sysctlnode *me2;
 
        KASSERT(swsensor_sysctllog == NULL);
 
@@ -83,14 +86,24 @@
                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 @@
        /*
         * 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 @@
 
        /* 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) {



Home | Main Index | Thread Index | Old Index