Module Name:    src
Committed By:   riz
Date:           Thu Apr 12 17:09:02 UTC 2012

Modified Files:
        src/sys/arch/x86/x86 [netbsd-6]: ipmi.c

Log Message:
Pull up following revision(s) (requested by njoly in ticket #176):
        sys/arch/x86/x86/ipmi.c: revision 1.53
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.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.52.2.1 src/sys/arch/x86/x86/ipmi.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/arch/x86/x86/ipmi.c
diff -u src/sys/arch/x86/x86/ipmi.c:1.52 src/sys/arch/x86/x86/ipmi.c:1.52.2.1
--- src/sys/arch/x86/x86/ipmi.c:1.52	Thu Feb  2 19:43:01 2012
+++ src/sys/arch/x86/x86/ipmi.c	Thu Apr 12 17:09:01 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipmi.c,v 1.52 2012/02/02 19:43:01 tls Exp $ */
+/*	$NetBSD: ipmi.c,v 1.52.2.1 2012/04/12 17:09:01 riz 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.52.2.1 2012/04/12 17:09:01 riz Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -1439,7 +1439,12 @@ ipmi_convert(uint8_t v, struct sdrtype1 
 {
 	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 @@ ipmi_convert(uint8_t v, struct sdrtype1 
 	 *  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

Reply via email to