From 40a6e0e631c026a4e83444e0b448f9dac9532b21 Mon Sep 17 00:00:00 2001 From: Philip Edelbrock Date: Thu, 3 Aug 2000 23:01:30 +0000 Subject: [PATCH] (Phil) It should now handle negative temps going to and from registers. I tested the new macros from a simple stand alone C app, but actual system testing is still desired. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@852 7894878c-1315-0410-8ee3-d5d059ff63e0 --- kernel/chips/lm75.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/chips/lm75.c b/kernel/chips/lm75.c index f759ff42..d806c6e5 100644 --- a/kernel/chips/lm75.c +++ b/kernel/chips/lm75.c @@ -58,7 +58,7 @@ SENSORS_INSMOD_1(lm75); these macros are called: arguments may be evaluated more than once. Fixing this is just not worth it. */ #define TEMP_FROM_REG(val) ((((val & 0x7fff) >> 7) * 5) | ((val & 0x8000)?-256:0)) -#define TEMP_TO_REG(val) (SENSORS_LIMIT(((((val) + 2) / 5) << 7),0,0xffff)) +#define TEMP_TO_REG(val) (SENSORS_LIMIT((val<0?(0x200+((val)/5))<<7:(((val) + 2) / 5) << 7),0,0xffff)) /* Initial values */ #define LM75_INIT_TEMP_OS 600