Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86/x86 For 1's and 2's complement sensor data, con...



details:   https://anonhg.NetBSD.org/src/rev/df95d0f464f2
branches:  trunk
changeset: 778558:df95d0f464f2
user:      njoly <njoly%NetBSD.org@localhost>
date:      Wed Apr 04 17:44:31 2012 +0000

description:
For 1's and 2's complement sensor data, convert unsigned raw data to a
signed type before proceeding any computation. Fix handling of
negative temperatures that can be set for critmin/warnmin limits.

diffstat:

 sys/arch/x86/x86/ipmi.c |  13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diffs (41 lines):

diff -r 65e5bdbd5099 -r df95d0f464f2 sys/arch/x86/x86/ipmi.c
--- a/sys/arch/x86/x86/ipmi.c   Wed Apr 04 13:33:19 2012 +0000
+++ b/sys/arch/x86/x86/ipmi.c   Wed Apr 04 17:44:31 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipmi.c,v 1.52 2012/02/02 19:43:01 tls Exp $ */
+/*     $NetBSD: ipmi.c,v 1.53 2012/04/04 17:44:31 njoly Exp $ */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.52 2012/02/02 19:43:01 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.53 2012/04/04 17:44:31 njoly Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -1439,7 +1439,12 @@
 {
        int64_t M, B;
        char    K1, K2;
-       int64_t val, v1, v2;
+       int64_t val, v1, v2, vs;
+       int sign = (s1->units1 >> 6) & 0x3;
+
+       vs = (sign == 0x1 || sign == 0x2) ? (int8_t)v : v;
+       if ((vs < 0) && (sign == 0x1))
+               vs++;
 
        /* Calculate linear reading variables */
        M  = signextend((((short)(s1->m_tolerance & 0xC0)) << 2) + s1->m, 10);
@@ -1454,7 +1459,7 @@
         *  y = L(M*v * 10^(K2+adj) + B * 10^(K1+K2+adj)); */
        v1 = powx(FIX10, INT2FIX(K2 + adj));
        v2 = powx(FIX10, INT2FIX(K1 + K2 + adj));
-       val = M * v * v1 + B * v2;
+       val = M * vs * v1 + B * v2;
 
        /* Linearization function: y = f(x) 0 : y = x 1 : y = ln(x) 2 : y =
         * log10(x) 3 : y = log2(x) 4 : y = e^x 5 : y = 10^x 6 : y = 2^x 7 : y



Home | Main Index | Thread Index | Old Index