Fix setting voltage limits. This got broken by my previous

fix of inaccurate voltage roundings.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2478 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare committed 2004-04-25 19:43:54 +00:00
1 parent f5a0f7d493
commit 80968de0a9
1 file changed
+6 -6
+6 -6
View File
@@ -109,7 +109,7 @@ static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e };
#define VIA686A_TEMP_MODE_MASK 0x3F
#define VIA686A_TEMP_MODE_CONTINUOUS (0x00)
/* Conversions. Rounding and limit checking is only done on the TO_REG
/* Conversions. Limit checking is only done on the TO_REG
variants. */
/********* VOLTAGE CONVERSIONS (Bob Dougherty) ********/
@@ -128,22 +128,22 @@ static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e };
static inline u8 IN_TO_REG(long val, int inNum)
{
/* To avoid floating point, we multiply constants by 10 (100 for +12V).
Rounding is done (1205000 is actually 1330000 - 125000).
Rounding is done (120500 is actually 133000 - 12500).
Remember that val is expressed in 0.01V/bit, which is why we divide
by an additional 1000 (10000 for +12V): 100 for val and 10 (100)
for the constants. */
if (inNum <= 1)
return (u8)
SENSORS_LIMIT((val * 21024 - 1205000) / 250000, 0, 255);
SENSORS_LIMIT((val * 21024 - 120500) / 25000, 0, 255);
else if (inNum == 2)
return (u8)
SENSORS_LIMIT((val * 15737 - 1205000) / 250000, 0, 255);
SENSORS_LIMIT((val * 15737 - 120500) / 25000, 0, 255);
else if (inNum == 3)
return (u8)
SENSORS_LIMIT((val * 10108 - 1205000) / 250000, 0, 255);
SENSORS_LIMIT((val * 10108 - 120500) / 25000, 0, 255);
else
return (u8)
SENSORS_LIMIT((val * 41714 - 12050000) / 2500000, 0, 255);
SENSORS_LIMIT((val * 41714 - 1205000) / 250000, 0, 255);
}
static inline long IN_FROM_REG(u8 val, int inNum)