Introduced sane limits checking for all chip modules

Like the LM78 before, all chips now handle strange values written to /proc/...
with grace - that is, they convert them to the most sane value considering
the circumstances, instead of reacting with strange resulting values
(note that they were already crash-free).

I also removed a factor '2' in the computation of the fan speeds in the
gl518sm module. This is conforming with the sheet; if your fan gives two
'ticks' for each rotation, just modify sensors.conf.

I tried to introduce rounding and limit checking to the maxilife module.
The VID computation is not yet rounded - I need the real formula for that.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@382 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Frodo Looijaard committed 1999-04-11 21:23:57 +00:00
1 parent 3e38c3f87e
commit 76c1926109
8 files changed
+143 -150

No files matched your search

+17 -18
View File
@@ -80,35 +80,34 @@ static const char *version_str = "1.00 25/2/99 Fons Rademakers";
#define MAXI_REG_BIOS_CTRL 0x2a
#define MAXI_REG_LED_STATE 0x96
/* Conversions */
/* Conversions. Rounding and limit checking is only done on the TO_REG
variants. Note that you should be a bit careful with which arguments
these macros are called: arguments may be evaluated more than once.
Fixing this is just not worth it. */
/* 0xfe: fan off, 0xff: stopped (alarm) */
/* 19531 / val * 60 == 1171860 / val */
#define FAN_FROM_REG(val) ((val)==0xfe ? -1 : (val)==0xff ? 0 : \
(1171860 / (val)))
static inline unsigned char
FAN_TO_REG (unsigned rpm)
{
unsigned val;
if (rpm == 0)
return 255;
(val)==0x00 ? -1 : (1171860 / (val)))
val = 1171860 / rpm;
if (val > 255)
val = 255;
return val;
extern inline u8 FAN_TO_REG(long rpm)
{
if (rpm == 0)
return 255;
rpm = SENSORS_LIMIT(rpm,1,1000000);
return SENSORS_LIMIT((1171860 + rpm/2) / (rpm),1,254);
}
#define TEMP_FROM_REG(val) ((val) * 5)
#define TEMP_TO_REG(val) ((val) / 5)
#define TEMP_TO_REG(val) (SENSORS_LIMIT((val+2) / 5),0,0xff)
#define PLL_FROM_REG(val) (((val) * 1000) / 32)
#define PLL_TO_REG(val) (((val) * 32) / 1000)
#define PLL_TO_REG(val) (SENSORS_LIMIT((((val) * 32 + 500) / 1000),\
0,0xff))
#define VID_FROM_REG(val) ((val) ? (((val) * 27390) / 256) + 3208 : 0)
#define VID_TO_REG(val) ((((val) - 3208) * 256) / 27390)
#define VID_TO_REG(val) (SENSORS_LIMIT((((val) - 3208) * 256) / 27390, \
0,255))
#define ALARMS_FROM_REG(val) (val)
#ifdef MODULE
extern int init_module(void);
extern int cleanup_module(void);