From 76c19261095ce40a32348b16205a1ea1a7c56c2a Mon Sep 17 00:00:00 2001 From: Frodo Looijaard Date: Sun, 11 Apr 1999 21:23:57 +0000 Subject: [PATCH] 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 --- kernel/chips/adm1021.c | 6 ++- kernel/chips/adm9240.c | 47 +++++++++------------- kernel/chips/gl518sm.c | 31 +++++++-------- kernel/chips/lm75.c | 7 +++- kernel/chips/lm80.c | 55 +++++++++++++------------- kernel/chips/maxilife.c | 35 ++++++++--------- kernel/chips/sis5595.c | 26 ++++++------- kernel/chips/w83781d.c | 86 ++++++++++++++++++++--------------------- 8 files changed, 143 insertions(+), 150 deletions(-) diff --git a/kernel/chips/adm1021.c b/kernel/chips/adm1021.c index 43ffc6bc..1165af91 100644 --- a/kernel/chips/adm1021.c +++ b/kernel/chips/adm1021.c @@ -64,9 +64,13 @@ SENSORS_INSMOD_3(adm1021,max1617,max1617a); #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*/ #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 */ diff --git a/kernel/chips/adm9240.c b/kernel/chips/adm9240.c index 19ce7226..346ea9d7 100644 --- a/kernel/chips/adm9240.c +++ b/kernel/chips/adm9240.c @@ -123,36 +123,38 @@ SENSORS_INSMOD_2(adm9240,ds1780); #define ADM9240_REG_VID4 0x49 #define ADM9240_REG_TEMP_CONFIG 0x4B -/* Conversions. Rounding is only done on the TO_REG variants. */ -#define IN_TO_REG(val,nr) ((val) & 0xff) +/* 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 IN_TO_REG(val,nr) (SENSORS_LIMIT(((val) & 0xff),0,255)) #define IN_FROM_REG(val,nr) (val) -static inline unsigned char -FAN_TO_REG (unsigned rpm, unsigned divisor) +extern inline u8 FAN_TO_REG(long rpm, int div) { - unsigned val; - if (rpm == 0) - return 255; - - val = (1350000 + rpm * divisor / 2) / (rpm * divisor); - if (val > 255) - val = 255; - return val; + return 255; + rpm = SENSORS_LIMIT(rpm,1,1000000); + return SENSORS_LIMIT((1350000 + rpm*div/2) / (rpm*div),1,254); } + #define FAN_FROM_REG(val,div) ((val)==0?-1:\ (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_TO_REG(val) SENSORS_LIMIT(((val)<0?(((val)-50)/100):\ + ((val)+50)/100), \ + 0,255) + #define ALARMS_FROM_REG(val) (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_FROM_REG(val) (1 << (val)) +#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:\ (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_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_write_value(struct i2c_client *client, u8 register, u8 value); static void adm9240_update_client(struct i2c_client *client); @@ -500,15 +500,6 @@ void adm9240_dec_use (struct i2c_client *client) #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) { return 0xFF & smbus_read_byte_data(client->adapter,client->addr, reg); diff --git a/kernel/chips/gl518sm.c b/kernel/chips/gl518sm.c index 81f505ee..90cf83b5 100644 --- a/kernel/chips/gl518sm.c +++ b/kernel/chips/gl518sm.c @@ -67,31 +67,30 @@ SENSORS_INSMOD_2(gl518sm_r00,gl518sm_r80); #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) -static inline unsigned char -FAN_TO_REG (unsigned rpm, unsigned divisor) +extern inline u8 FAN_TO_REG(long rpm, int div) { - unsigned val; - if (rpm == 0) - return 255; - - val = (960000 + rpm * divisor) / (2 * rpm * divisor); - if (val > 255) - val = 255; - return val; + return 255; + rpm = SENSORS_LIMIT(rpm,1,1000000); + return SENSORS_LIMIT((960000 + rpm*div/2) / (rpm*div),1,254); } -#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 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 DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) diff --git a/kernel/chips/lm75.c b/kernel/chips/lm75.c index 4ee76c95..4e2f731c 100644 --- a/kernel/chips/lm75.c +++ b/kernel/chips/lm75.c @@ -43,9 +43,12 @@ SENSORS_INSMOD_1(lm75); #define LM75_REG_TEMP_HYST 0x02 #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_TO_REG(val) (((((val) + 2) / 5) << 7) & 0xff80) +#define TEMP_TO_REG(val) (SENSORS_LIMIT(((((val) + 2) / 5) << 7),0,0xffff)) /* Initial values */ #define LM75_INIT_TEMP_OS 600 diff --git a/kernel/chips/lm80.c b/kernel/chips/lm80.c index 2556fa51..078e30fe 100644 --- a/kernel/chips/lm80.c +++ b/kernel/chips/lm80.c @@ -70,32 +70,43 @@ SENSORS_INSMOD_1(lm80); #define LM80_REG_RES 0x06 -/* Conversions. Rounding is only done on the TO_REG variants. */ -#define IN_TO_REG(val,nr) ((val) & 0xff) +/* 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 IN_TO_REG(val,nr) (SENSORS_LIMIT((val),0,255)) #define IN_FROM_REG(val,nr) (val) -static inline unsigned char -FAN_TO_REG (unsigned rpm, unsigned divisor) +extern inline unsigned char +FAN_TO_REG (unsigned rpm, unsigned div) { - unsigned val; - if (rpm == 0) - return 255; - - val = (1350000 + rpm * divisor / 2) / (rpm * divisor); - if (val > 255) - val = 255; - return val; + return 255; + rpm = SENSORS_LIMIT(rpm,1,1000000); + return SENSORS_LIMIT((1350000 + rpm*div/2) / (rpm*div),1,254); } #define FAN_FROM_REG(val,div) ((val)==0?-1:\ (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_TO_REG(val) SENSORS_LIMIT(((val)<0?(((val)-50)/100):\ + ((val)+50)/100), \ + 0,255) + #define ALARMS_FROM_REG(val) (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_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_write_value(struct i2c_client *client, u8 register, u8 value); 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) { return smbus_read_byte_data(client->adapter,client->addr, reg); diff --git a/kernel/chips/maxilife.c b/kernel/chips/maxilife.c index 04525d8b..f31d6112 100644 --- a/kernel/chips/maxilife.c +++ b/kernel/chips/maxilife.c @@ -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); diff --git a/kernel/chips/sis5595.c b/kernel/chips/sis5595.c index 1fb935df..2b2886a0 100644 --- a/kernel/chips/sis5595.c +++ b/kernel/chips/sis5595.c @@ -83,26 +83,26 @@ SENSORS_INSMOD_1(sis5595); #define SIS5595_REG_CONFIG 0x40 -/* Conversions. Rounding is only done on the TO_REG variants. */ -#define IN_TO_REG(val) (((val) * 10 + 8)/16) +/* 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 IN_TO_REG(val) (SENSORS_LIMIT((((val) * 10 + 8)/16),0,255)) #define IN_FROM_REG(val) (((val) * 16) / 10) -static inline unsigned char -FAN_TO_REG (unsigned rpm, unsigned divisor) +extern inline u8 FAN_TO_REG(long rpm, int div) { - unsigned val; - if (rpm == 0) - return 255; - - val = (1350000 + rpm * divisor / 2) / (rpm * divisor); - if (val > 255) - val = 255; - return val; + return 255; + rpm = SENSORS_LIMIT(rpm,1,1000000); + return SENSORS_LIMIT((1350000 + rpm*div/2) / (rpm*div),1,254); } + #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 ALARMS_FROM_REG(val) (val) diff --git a/kernel/chips/w83781d.c b/kernel/chips/w83781d.c index fd3d561b..cc6c689d 100644 --- a/kernel/chips/w83781d.c +++ b/kernel/chips/w83781d.c @@ -137,36 +137,36 @@ static const u8 BIT_SCFG2[] = {0x10, 0x04, 0x08}; #define W83781D_REG_RT_IDX 0x50 #define W83781D_REG_RT_VAL 0x51 -/* Conversions. Rounding is only done on the TO_REG variants. */ -#define IN_TO_REG(val,nr) (((val) * 10 + 8)/16) -#define IN_FROM_REG(val,nr) (((val) * 16) / 10) +/* 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 IN_TO_REG(val) (SENSORS_LIMIT((((val) * 10 + 8)/16),0,255)) +#define IN_FROM_REG(val) (((val) * 16) / 10) -static inline unsigned char -FAN_TO_REG (unsigned rpm, unsigned divisor) +extern inline u8 FAN_TO_REG(long rpm, int div) { - unsigned val; - if (rpm == 0) - return 255; - - val = (1350000 + rpm * divisor / 2) / (rpm * divisor); - if (val > 255) - val = 255; - return val; + return 255; + rpm = SENSORS_LIMIT(rpm,1,1000000); + return SENSORS_LIMIT((1350000 + rpm*div/2) / (rpm*div),1,254); } + #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_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 VID_FROM_REG(val) ((val)==0x1f?0:(val)>=0x10?510-(val)*10:\ (val)>=0x06?0:205-(val)*5) #define ALARMS_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_TO_REG(val) ((val) & 0xffff) @@ -1015,59 +1015,59 @@ void w83781d_init_client(struct i2c_client *client) #endif 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), - IN_TO_REG(W83781D_INIT_IN_MAX_0,0)); + IN_TO_REG(W83781D_INIT_IN_MAX_0)); if(type != w83783s) { 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), - 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), - 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), - 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), - 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), - 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), - 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), - IN_TO_REG(W83781D_INIT_IN_MAX_4,4)); + IN_TO_REG(W83781D_INIT_IN_MAX_4)); if (type == w83781d) { 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), - IN_TO_REG(W83781D_INIT_IN_MAX_5,5)); + IN_TO_REG(W83781D_INIT_IN_MAX_5)); } else { 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), - IN_TO_REG(W83782D_INIT_IN_MAX_5,5)); + IN_TO_REG(W83782D_INIT_IN_MAX_5)); } if (type == w83781d) { 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), - IN_TO_REG(W83781D_INIT_IN_MAX_6,6)); + IN_TO_REG(W83781D_INIT_IN_MAX_6)); } else { 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), - IN_TO_REG(W83782D_INIT_IN_MAX_6,6)); + IN_TO_REG(W83782D_INIT_IN_MAX_6)); } if (type == w83782d) { 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), - 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), - 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), - 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), 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; else if (operation == SENSORS_PROC_REAL_READ) { w83781d_update_client(client); - results[0] = IN_FROM_REG(data->in_min[nr],nr); - results[1] = IN_FROM_REG(data->in_max[nr],nr); - results[2] = IN_FROM_REG(data->in[nr],nr); + results[0] = IN_FROM_REG(data->in_min[nr]); + results[1] = IN_FROM_REG(data->in_max[nr]); + results[2] = IN_FROM_REG(data->in[nr]); *nrels_mag = 3; } else if (operation == SENSORS_PROC_REAL_WRITE) { 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]); } 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]); } }