fixed off-by-factor-of-2 of FAN_FROM_REG in w83781d.

Improved bounds checking for FAN_TO_REG in all files.
For lm78-compatible drivers, minimum speed is 2657 RPM when the
divisor is 2. Attempts to set lower than that now are set to 0.
Before was set to a random number.
Thanks Jeff Dairiki.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@330 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Mark D. Studebaker committed 1999-03-21 23:47:20 +00:00
1 parent 6a45415e5e
commit b73b2cc4ce
7 files changed
+92 -14

No files matched your search

+13 -1
View File
@@ -85,7 +85,19 @@ static const char *version = "1.00 25/2/99 Fons Rademakers";
/* 19531 / val * 60 == 1171860 / val */
#define FAN_FROM_REG(val) ((val)==0xfe ? -1 : (val)==0xff ? 0 : \
(1171860 / (val)))
#define FAN_TO_REG(val) (1171860 / (val))
static inline unsigned char
FAN_TO_REG (unsigned rpm)
{
unsigned val;
if (rpm == 0)
return 255;
val = 1171860 / rpm;
if (val > 255)
val = 255;
return val;
}
#define TEMP_FROM_REG(val) ((val) * 5)
#define TEMP_TO_REG(val) ((val) / 5)