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
+142 -149

No files matched your search

+5 -1
View File
@@ -64,9 +64,13 @@ SENSORS_INSMOD_3(adm1021,max1617,max1617a);
#define ADM1021_REG_ONESHOT 0x0F #define ADM1021_REG_ONESHOT 0x0F
/* 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. */
/* Conversions note: 1021 uses normal integer signed-byte format*/ /* Conversions note: 1021 uses normal integer signed-byte format*/
#define TEMP_FROM_REG(val) (val > 127 ? val-256 : val) #define TEMP_FROM_REG(val) (val > 127 ? val-256 : val)
#define TEMP_TO_REG(val) (val < 0 ? val+256 : val) #define TEMP_TO_REG(val) (SENSORS_LIMIT((val < 0 ? val+256 : val),0,255))
/* Initial values */ /* Initial values */
+19 -28
View File
@@ -123,36 +123,38 @@ SENSORS_INSMOD_2(adm9240,ds1780);
#define ADM9240_REG_VID4 0x49 #define ADM9240_REG_VID4 0x49
#define ADM9240_REG_TEMP_CONFIG 0x4B #define ADM9240_REG_TEMP_CONFIG 0x4B
/* Conversions. Rounding is only done on the TO_REG variants. */ /* Conversions. Rounding and limit checking is only done on the TO_REG
#define IN_TO_REG(val,nr) ((val) & 0xff) 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. */
#define IN_TO_REG(val,nr) (SENSORS_LIMIT(((val) & 0xff),0,255))
#define IN_FROM_REG(val,nr) (val) #define IN_FROM_REG(val,nr) (val)
static inline unsigned char extern inline u8 FAN_TO_REG(long rpm, int div)
FAN_TO_REG (unsigned rpm, unsigned divisor)
{ {
unsigned val;
if (rpm == 0) if (rpm == 0)
return 255; return 255;
rpm = SENSORS_LIMIT(rpm,1,1000000);
val = (1350000 + rpm * divisor / 2) / (rpm * divisor); return SENSORS_LIMIT((1350000 + rpm*div/2) / (rpm*div),1,254);
if (val > 255)
val = 255;
return val;
} }
#define FAN_FROM_REG(val,div) ((val)==0?-1:\ #define FAN_FROM_REG(val,div) ((val)==0?-1:\
(val)==255?0:1350000/((div)*(val))) (val)==255?0:1350000/((div)*(val)))
#define TEMP_FROM_REG(val) adm9240_temp_from_reg(val) #define TEMP_FROM_REG(temp) \
((temp)<256?((((temp)&0x1fe) >> 1) * 10) + ((temp) & 1) * 5: \
((((temp)&0x1fe) >> 1) -255) * 10 - ((temp) & 1) * 5) \
#define TEMP_LIMIT_TO_REG(val) (((val)<0?(((val)-50)/100)&0xff:\
((val)+50)/100) & 0xff)
#define TEMP_LIMIT_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*100) #define TEMP_LIMIT_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*100)
#define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT(((val)<0?(((val)-50)/100):\
((val)+50)/100), \
0,255)
#define ALARMS_FROM_REG(val) (val) #define ALARMS_FROM_REG(val) (val)
#define DIV_FROM_REG(val) (1 << val) #define DIV_FROM_REG(val) (1 << (val))
#define DIV_TO_REG(val) (val==1?0:(val==2?1:(val==4?2:3))) #define DIV_TO_REG(val) ((val)==1?0:((val)==8?3:((val)==4?2:1)))
#define VID_FROM_REG(val) ((val)==0x1f?0:(val)>=0x10?510-(val)*10:\ #define VID_FROM_REG(val) ((val)==0x1f?0:(val)>=0x10?510-(val)*10:\
(val)>=0x06?0:205-(val)*5) (val)>=0x06?0:205-(val)*5)
@@ -243,8 +245,6 @@ static int adm9240_command(struct i2c_client *client, unsigned int cmd,
static void adm9240_inc_use (struct i2c_client *client); static void adm9240_inc_use (struct i2c_client *client);
static void adm9240_dec_use (struct i2c_client *client); static void adm9240_dec_use (struct i2c_client *client);
static long adm9240_temp_from_reg(u16 regs);
static int adm9240_read_value(struct i2c_client *client, u8 register); static int adm9240_read_value(struct i2c_client *client, u8 register);
static int adm9240_write_value(struct i2c_client *client, u8 register, u8 value); static int adm9240_write_value(struct i2c_client *client, u8 register, u8 value);
static void adm9240_update_client(struct i2c_client *client); static void adm9240_update_client(struct i2c_client *client);
@@ -500,15 +500,6 @@ void adm9240_dec_use (struct i2c_client *client)
#endif #endif
} }
long adm9240_temp_from_reg(u16 temp)
{
if (temp < 256)
return (((temp & 0x1fe) >> 1) * 10) + ((temp & 1) * 5);
else
return ((((temp & 0x01fe) >> 1) - 255) * 10) - ((temp & 1) * 5);
}
int adm9240_read_value(struct i2c_client *client, u8 reg) int adm9240_read_value(struct i2c_client *client, u8 reg)
{ {
return 0xFF & smbus_read_byte_data(client->adapter,client->addr, reg); return 0xFF & smbus_read_byte_data(client->adapter,client->addr, reg);
+15 -16
View File
@@ -67,31 +67,30 @@ SENSORS_INSMOD_2(gl518sm_r00,gl518sm_r80);
#define GL518_REG_VDD 0x15 #define GL518_REG_VDD 0x15
/* Conversions. Rounding is only done on the TO_REG variants. */ /* 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. */
#define TEMP_TO_REG(val) (((((val)<0?(val)-5:(val)+5) / 10) + 119) & 0xff) #define TEMP_TO_REG(val) (SENSORS_LIMIT(((((val)<0?(val)-5:(val)+5) / 10)+119),\
0,255))
#define TEMP_FROM_REG(val) (((val) - 119) * 10) #define TEMP_FROM_REG(val) (((val) - 119) * 10)
static inline unsigned char extern inline u8 FAN_TO_REG(long rpm, int div)
FAN_TO_REG (unsigned rpm, unsigned divisor)
{ {
unsigned val;
if (rpm == 0) if (rpm == 0)
return 255; return 255;
rpm = SENSORS_LIMIT(rpm,1,1000000);
val = (960000 + rpm * divisor) / (2 * rpm * divisor); return SENSORS_LIMIT((960000 + rpm*div/2) / (rpm*div),1,254);
if (val > 255)
val = 255;
return val;
} }
#define FAN_FROM_REG(val,div) \
( (val)==0 ? 0 : (val)==255 ? 0 : (960000/(2*(val)*(div))) )
#define IN_TO_REG(val) ((((val)*10+8)/19) & 0xff) #define FAN_FROM_REG(val,div) \
( (val)==0 ? 0 : (val)==255 ? 0 : (960000/((val)*(div))) )
#define IN_TO_REG(val) (SENSORS_LIMIT((((val)*10+8)/19),0,255))
#define IN_FROM_REG(val) (((val)*19)/10) #define IN_FROM_REG(val) (((val)*19)/10)
#define VDD_TO_REG(val) ((((val)*10+11)/23) & 0xff) #define VDD_TO_REG(val) (SENSORS_LIMIT((((val)*10+11)/23),0,255))
#define VDD_FROM_REG(val) (((val)*23)/10) #define VDD_FROM_REG(val) (((val)*23)/10)
#define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) #define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1)
+5 -2
View File
@@ -43,9 +43,12 @@ SENSORS_INSMOD_1(lm75);
#define LM75_REG_TEMP_HYST 0x02 #define LM75_REG_TEMP_HYST 0x02
#define LM75_REG_TEMP_OS 0x03 #define LM75_REG_TEMP_OS 0x03
/* 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. */
#define TEMP_FROM_REG(val) (((val) >> 7) * 5) #define TEMP_FROM_REG(val) (((val) >> 7) * 5)
#define TEMP_TO_REG(val) (((((val) + 2) / 5) << 7) & 0xff80) #define TEMP_TO_REG(val) (SENSORS_LIMIT(((((val) + 2) / 5) << 7),0,0xffff))
/* Initial values */ /* Initial values */
#define LM75_INIT_TEMP_OS 600 #define LM75_INIT_TEMP_OS 600
+26 -29
View File
@@ -70,32 +70,43 @@ SENSORS_INSMOD_1(lm80);
#define LM80_REG_RES 0x06 #define LM80_REG_RES 0x06
/* Conversions. Rounding is only done on the TO_REG variants. */ /* Conversions. Rounding and limit checking is only done on the TO_REG
#define IN_TO_REG(val,nr) ((val) & 0xff) 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. */
#define IN_TO_REG(val,nr) (SENSORS_LIMIT((val),0,255))
#define IN_FROM_REG(val,nr) (val) #define IN_FROM_REG(val,nr) (val)
static inline unsigned char extern inline unsigned char
FAN_TO_REG (unsigned rpm, unsigned divisor) FAN_TO_REG (unsigned rpm, unsigned div)
{ {
unsigned val;
if (rpm == 0) if (rpm == 0)
return 255; return 255;
rpm = SENSORS_LIMIT(rpm,1,1000000);
val = (1350000 + rpm * divisor / 2) / (rpm * divisor); return SENSORS_LIMIT((1350000 + rpm*div/2) / (rpm*div),1,254);
if (val > 255)
val = 255;
return val;
} }
#define FAN_FROM_REG(val,div) ((val)==0?-1:\ #define FAN_FROM_REG(val,div) ((val)==0?-1:\
(val)==255?0:1350000/((div)*(val))) (val)==255?0:1350000/((div)*(val)))
#define TEMP_FROM_REG(val) lm80_temp_from_reg(val) extern inline long TEMP_FROM_REG(u16 temp)
{
long res;
res = ((temp & 0xff00) >> 8) * 10000 + ((temp & 0x10) >> 4) * 5000 +
((temp & 0x20) >> 5) * 2500 + ((temp & 0x40) >> 6) * 1250 +
((temp & 0x80) >> 7) * 625;
temp /= 100;
if (temp >= 0x80 * 100)
temp = - (0x100 * 100 - temp);
return temp;
}
#define TEMP_LIMIT_TO_REG(val) (((val)<0?(((val)-50)/100)&0xff:\
((val)+50)/100) & 0xff)
#define TEMP_LIMIT_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*100) #define TEMP_LIMIT_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*100)
#define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT(((val)<0?(((val)-50)/100):\
((val)+50)/100), \
0,255)
#define ALARMS_FROM_REG(val) (val) #define ALARMS_FROM_REG(val) (val)
#define DIV_FROM_REG(val) (1 << (val)) #define DIV_FROM_REG(val) (1 << (val))
@@ -191,8 +202,6 @@ static int lm80_command(struct i2c_client *client, unsigned int cmd,
static void lm80_inc_use (struct i2c_client *client); static void lm80_inc_use (struct i2c_client *client);
static void lm80_dec_use (struct i2c_client *client); static void lm80_dec_use (struct i2c_client *client);
static long lm80_temp_from_reg(u16 regs);
static int lm80_read_value(struct i2c_client *client, u8 register); static int lm80_read_value(struct i2c_client *client, u8 register);
static int lm80_write_value(struct i2c_client *client, u8 register, u8 value); static int lm80_write_value(struct i2c_client *client, u8 register, u8 value);
static void lm80_update_client(struct i2c_client *client); static void lm80_update_client(struct i2c_client *client);
@@ -426,18 +435,6 @@ void lm80_dec_use (struct i2c_client *client)
} }
long lm80_temp_from_reg(u16 temp)
{
long res;
res = ((temp & 0xff00) >> 8) * 10000 + ((temp & 0x10) >> 4) * 5000 +
((temp & 0x20) >> 5) * 2500 + ((temp & 0x40) >> 6) * 1250 +
((temp & 0x80) >> 7) * 625;
temp /= 100;
if (temp >= 0x80 * 100)
temp = - (0x100 * 100 - temp);
return temp;
}
int lm80_read_value(struct i2c_client *client, u8 reg) int lm80_read_value(struct i2c_client *client, u8 reg)
{ {
return smbus_read_byte_data(client->adapter,client->addr, reg); return smbus_read_byte_data(client->adapter,client->addr, reg);
+16 -17
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_BIOS_CTRL 0x2a
#define MAXI_REG_LED_STATE 0x96 #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) */ /* 0xfe: fan off, 0xff: stopped (alarm) */
/* 19531 / val * 60 == 1171860 / val */ /* 19531 / val * 60 == 1171860 / val */
#define FAN_FROM_REG(val) ((val)==0xfe ? -1 : (val)==0xff ? 0 : \ #define FAN_FROM_REG(val) ((val)==0xfe ? -1 : (val)==0xff ? 0 : \
(1171860 / (val))) (val)==0x00 ? -1 : (1171860 / (val)))
static inline unsigned char
FAN_TO_REG (unsigned rpm) extern inline u8 FAN_TO_REG(long rpm)
{ {
unsigned val;
if (rpm == 0) if (rpm == 0)
return 255; return 255;
rpm = SENSORS_LIMIT(rpm,1,1000000);
val = 1171860 / rpm; return SENSORS_LIMIT((1171860 + rpm/2) / (rpm),1,254);
if (val > 255)
val = 255;
return val;
} }
#define TEMP_FROM_REG(val) ((val) * 5) #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_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_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) #define ALARMS_FROM_REG(val) (val)
#ifdef MODULE #ifdef MODULE
extern int init_module(void); extern int init_module(void);
extern int cleanup_module(void); extern int cleanup_module(void);
+13 -13
View File
@@ -83,26 +83,26 @@ SENSORS_INSMOD_1(sis5595);
#define SIS5595_REG_CONFIG 0x40 #define SIS5595_REG_CONFIG 0x40
/* Conversions. Rounding is only done on the TO_REG variants. */ /* Conversions. Rounding and limit checking is only done on the TO_REG
#define IN_TO_REG(val) (((val) * 10 + 8)/16) 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. */
#define IN_TO_REG(val) (SENSORS_LIMIT((((val) * 10 + 8)/16),0,255))
#define IN_FROM_REG(val) (((val) * 16) / 10) #define IN_FROM_REG(val) (((val) * 16) / 10)
static inline unsigned char extern inline u8 FAN_TO_REG(long rpm, int div)
FAN_TO_REG (unsigned rpm, unsigned divisor)
{ {
unsigned val;
if (rpm == 0) if (rpm == 0)
return 255; return 255;
rpm = SENSORS_LIMIT(rpm,1,1000000);
val = (1350000 + rpm * divisor / 2) / (rpm * divisor); return SENSORS_LIMIT((1350000 + rpm*div/2) / (rpm*div),1,254);
if (val > 255)
val = 255;
return val;
} }
#define FAN_FROM_REG(val,div) ((val)==0?-1:(val)==255?0:1350000/((val)*(div))) #define FAN_FROM_REG(val,div) ((val)==0?-1:(val)==255?0:1350000/((val)*(div)))
#define TEMP_TO_REG(val) (((val)<0?(((val)-5)/10)&0xff:((val)+5)/10) & 0xff) #define TEMP_TO_REG(val) (SENSORS_LIMIT(((val)<0?(((val)-5)/10):\
((val)+5)/10),0,255))
#define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*10) #define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*10)
#define ALARMS_FROM_REG(val) (val) #define ALARMS_FROM_REG(val) (val)
+43 -43
View File
@@ -137,36 +137,36 @@ static const u8 BIT_SCFG2[] = {0x10, 0x04, 0x08};
#define W83781D_REG_RT_IDX 0x50 #define W83781D_REG_RT_IDX 0x50
#define W83781D_REG_RT_VAL 0x51 #define W83781D_REG_RT_VAL 0x51
/* Conversions. Rounding is only done on the TO_REG variants. */ /* Conversions. Rounding and limit checking is only done on the TO_REG
#define IN_TO_REG(val,nr) (((val) * 10 + 8)/16) variants. Note that you should be a bit careful with which arguments
#define IN_FROM_REG(val,nr) (((val) * 16) / 10) these macros are called: arguments may be evaluated more than once.
Fixing this is just not worth it. */
#define IN_TO_REG(val) (SENSORS_LIMIT((((val) * 10 + 8)/16),0,255))
#define IN_FROM_REG(val) (((val) * 16) / 10)
static inline unsigned char extern inline u8 FAN_TO_REG(long rpm, int div)
FAN_TO_REG (unsigned rpm, unsigned divisor)
{ {
unsigned val;
if (rpm == 0) if (rpm == 0)
return 255; return 255;
rpm = SENSORS_LIMIT(rpm,1,1000000);
val = (1350000 + rpm * divisor / 2) / (rpm * divisor); return SENSORS_LIMIT((1350000 + rpm*div/2) / (rpm*div),1,254);
if (val > 255)
val = 255;
return val;
} }
#define FAN_FROM_REG(val,div) ((val)==0?-1:(val)==255?0:1350000/((val)*(div))) #define FAN_FROM_REG(val,div) ((val)==0?-1:(val)==255?0:1350000/((val)*(div)))
#define TEMP_TO_REG(val) (((val)<0?(((val)-5)/10)&0xff:((val)+5)/10) & 0xff) #define TEMP_TO_REG(val) (SENSORS_LIMIT(((val)<0?(((val)-5)/10):\
((val)+5)/10),0,255))
#define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*10) #define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*10)
#define TEMP_ADD_TO_REG(val) (((((val) + 2) / 5) << 7) & 0xff80) #define TEMP_ADD_TO_REG(val) (SENSORS_LIMIT(((((val) + 2) / 5) << 7),\
0,0xffff))
#define TEMP_ADD_FROM_REG(val) (((val) >> 7) * 5) #define TEMP_ADD_FROM_REG(val) (((val) >> 7) * 5)
#define VID_FROM_REG(val) ((val)==0x1f?0:(val)>=0x10?510-(val)*10:\ #define VID_FROM_REG(val) ((val)==0x1f?0:(val)>=0x10?510-(val)*10:\
(val)>=0x06?0:205-(val)*5) (val)>=0x06?0:205-(val)*5)
#define ALARMS_FROM_REG(val) (val) #define ALARMS_FROM_REG(val) (val)
#define PWM_FROM_REG(val) (val) #define PWM_FROM_REG(val) (val)
#define PWM_TO_REG(val) ((val) & 0xff) #define PWM_TO_REG(val) (SENSORS_LIMIT((val),0,255))
#define BEEPS_FROM_REG(val) (val) #define BEEPS_FROM_REG(val) (val)
#define BEEPS_TO_REG(val) ((val) & 0xffff) #define BEEPS_TO_REG(val) ((val) & 0xffff)
@@ -1015,59 +1015,59 @@ void w83781d_init_client(struct i2c_client *client)
#endif #endif
w83781d_write_value(client,W83781D_REG_IN_MIN(0), w83781d_write_value(client,W83781D_REG_IN_MIN(0),
IN_TO_REG(W83781D_INIT_IN_MIN_0,0)); IN_TO_REG(W83781D_INIT_IN_MIN_0));
w83781d_write_value(client,W83781D_REG_IN_MAX(0), w83781d_write_value(client,W83781D_REG_IN_MAX(0),
IN_TO_REG(W83781D_INIT_IN_MAX_0,0)); IN_TO_REG(W83781D_INIT_IN_MAX_0));
if(type != w83783s) { if(type != w83783s) {
w83781d_write_value(client,W83781D_REG_IN_MIN(1), w83781d_write_value(client,W83781D_REG_IN_MIN(1),
IN_TO_REG(W83781D_INIT_IN_MIN_1,1)); IN_TO_REG(W83781D_INIT_IN_MIN_1));
w83781d_write_value(client,W83781D_REG_IN_MAX(1), w83781d_write_value(client,W83781D_REG_IN_MAX(1),
IN_TO_REG(W83781D_INIT_IN_MAX_1,1)); IN_TO_REG(W83781D_INIT_IN_MAX_1));
} }
w83781d_write_value(client,W83781D_REG_IN_MIN(2), w83781d_write_value(client,W83781D_REG_IN_MIN(2),
IN_TO_REG(W83781D_INIT_IN_MIN_2,2)); IN_TO_REG(W83781D_INIT_IN_MIN_2));
w83781d_write_value(client,W83781D_REG_IN_MAX(2), w83781d_write_value(client,W83781D_REG_IN_MAX(2),
IN_TO_REG(W83781D_INIT_IN_MAX_2,2)); IN_TO_REG(W83781D_INIT_IN_MAX_2));
w83781d_write_value(client,W83781D_REG_IN_MIN(3), w83781d_write_value(client,W83781D_REG_IN_MIN(3),
IN_TO_REG(W83781D_INIT_IN_MIN_3,3)); IN_TO_REG(W83781D_INIT_IN_MIN_3));
w83781d_write_value(client,W83781D_REG_IN_MAX(3), w83781d_write_value(client,W83781D_REG_IN_MAX(3),
IN_TO_REG(W83781D_INIT_IN_MAX_3,3)); IN_TO_REG(W83781D_INIT_IN_MAX_3));
w83781d_write_value(client,W83781D_REG_IN_MIN(4), w83781d_write_value(client,W83781D_REG_IN_MIN(4),
IN_TO_REG(W83781D_INIT_IN_MIN_4,4)); IN_TO_REG(W83781D_INIT_IN_MIN_4));
w83781d_write_value(client,W83781D_REG_IN_MAX(4), w83781d_write_value(client,W83781D_REG_IN_MAX(4),
IN_TO_REG(W83781D_INIT_IN_MAX_4,4)); IN_TO_REG(W83781D_INIT_IN_MAX_4));
if (type == w83781d) { if (type == w83781d) {
w83781d_write_value(client,W83781D_REG_IN_MIN(5), w83781d_write_value(client,W83781D_REG_IN_MIN(5),
IN_TO_REG(W83781D_INIT_IN_MIN_5,5)); IN_TO_REG(W83781D_INIT_IN_MIN_5));
w83781d_write_value(client,W83781D_REG_IN_MAX(5), w83781d_write_value(client,W83781D_REG_IN_MAX(5),
IN_TO_REG(W83781D_INIT_IN_MAX_5,5)); IN_TO_REG(W83781D_INIT_IN_MAX_5));
} else { } else {
w83781d_write_value(client,W83781D_REG_IN_MIN(5), w83781d_write_value(client,W83781D_REG_IN_MIN(5),
IN_TO_REG(W83782D_INIT_IN_MIN_5,5)); IN_TO_REG(W83782D_INIT_IN_MIN_5));
w83781d_write_value(client,W83781D_REG_IN_MAX(5), w83781d_write_value(client,W83781D_REG_IN_MAX(5),
IN_TO_REG(W83782D_INIT_IN_MAX_5,5)); IN_TO_REG(W83782D_INIT_IN_MAX_5));
} }
if (type == w83781d) { if (type == w83781d) {
w83781d_write_value(client,W83781D_REG_IN_MIN(6), w83781d_write_value(client,W83781D_REG_IN_MIN(6),
IN_TO_REG(W83781D_INIT_IN_MIN_6,6)); IN_TO_REG(W83781D_INIT_IN_MIN_6));
w83781d_write_value(client,W83781D_REG_IN_MAX(6), w83781d_write_value(client,W83781D_REG_IN_MAX(6),
IN_TO_REG(W83781D_INIT_IN_MAX_6,6)); IN_TO_REG(W83781D_INIT_IN_MAX_6));
} else { } else {
w83781d_write_value(client,W83781D_REG_IN_MIN(6), w83781d_write_value(client,W83781D_REG_IN_MIN(6),
IN_TO_REG(W83782D_INIT_IN_MIN_6,6)); IN_TO_REG(W83782D_INIT_IN_MIN_6));
w83781d_write_value(client,W83781D_REG_IN_MAX(6), w83781d_write_value(client,W83781D_REG_IN_MAX(6),
IN_TO_REG(W83782D_INIT_IN_MAX_6,6)); IN_TO_REG(W83782D_INIT_IN_MAX_6));
} }
if (type == w83782d) { if (type == w83782d) {
w83781d_write_value(client,W83781D_REG_IN_MIN(7), w83781d_write_value(client,W83781D_REG_IN_MIN(7),
IN_TO_REG(W83781D_INIT_IN_MIN_7,7)); IN_TO_REG(W83781D_INIT_IN_MIN_7));
w83781d_write_value(client,W83781D_REG_IN_MAX(7), w83781d_write_value(client,W83781D_REG_IN_MAX(7),
IN_TO_REG(W83781D_INIT_IN_MAX_7,7)); IN_TO_REG(W83781D_INIT_IN_MAX_7));
w83781d_write_value(client,W83781D_REG_IN_MIN(8), w83781d_write_value(client,W83781D_REG_IN_MIN(8),
IN_TO_REG(W83781D_INIT_IN_MIN_8,8)); IN_TO_REG(W83781D_INIT_IN_MIN_8));
w83781d_write_value(client,W83781D_REG_IN_MAX(8), w83781d_write_value(client,W83781D_REG_IN_MAX(8),
IN_TO_REG(W83781D_INIT_IN_MAX_8,8)); IN_TO_REG(W83781D_INIT_IN_MAX_8));
} }
w83781d_write_value(client,W83781D_REG_FAN_MIN(1), w83781d_write_value(client,W83781D_REG_FAN_MIN(1),
FAN_TO_REG(W83781D_INIT_FAN_MIN_1,2)); FAN_TO_REG(W83781D_INIT_FAN_MIN_1,2));
@@ -1196,17 +1196,17 @@ void w83781d_in(struct i2c_client *client, int operation, int ctl_name,
*nrels_mag = 2; *nrels_mag = 2;
else if (operation == SENSORS_PROC_REAL_READ) { else if (operation == SENSORS_PROC_REAL_READ) {
w83781d_update_client(client); w83781d_update_client(client);
results[0] = IN_FROM_REG(data->in_min[nr],nr); results[0] = IN_FROM_REG(data->in_min[nr]);
results[1] = IN_FROM_REG(data->in_max[nr],nr); results[1] = IN_FROM_REG(data->in_max[nr]);
results[2] = IN_FROM_REG(data->in[nr],nr); results[2] = IN_FROM_REG(data->in[nr]);
*nrels_mag = 3; *nrels_mag = 3;
} else if (operation == SENSORS_PROC_REAL_WRITE) { } else if (operation == SENSORS_PROC_REAL_WRITE) {
if (*nrels_mag >= 1) { if (*nrels_mag >= 1) {
data->in_min[nr] = IN_TO_REG(results[0],nr); data->in_min[nr] = IN_TO_REG(results[0]);
w83781d_write_value(client,W83781D_REG_IN_MIN(nr),data->in_min[nr]); w83781d_write_value(client,W83781D_REG_IN_MIN(nr),data->in_min[nr]);
} }
if (*nrels_mag >= 2) { if (*nrels_mag >= 2) {
data->in_max[nr] = IN_TO_REG(results[1],nr); data->in_max[nr] = IN_TO_REG(results[1]);
w83781d_write_value(client,W83781D_REG_IN_MAX(nr),data->in_max[nr]); w83781d_write_value(client,W83781D_REG_IN_MAX(nr),data->in_max[nr]);
} }
} }