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 -2
View File
@@ -65,8 +65,19 @@
#define IN_TO_REG(val,nr) ((val) & 0xff)
#define IN_FROM_REG(val,nr) (val)
#define FAN_TO_REG(val,div) ((val)==0?255:\
((1350000+(val)*(div)/2)/((val)*(div))) & 0xff)
static inline unsigned char
FAN_TO_REG (unsigned rpm, unsigned divisor)
{
unsigned val;
if (rpm == 0)
return 255;
val = (1350000 + rpm * divisor / 2) / (rpm * divisor);
if (val > 255)
val = 255;
return val;
}
#define FAN_FROM_REG(val,div) ((val)==0?-1:\
(val)==255?0:1350000/((div)*(val)))