diff --git a/kernel/chips/it87.c b/kernel/chips/it87.c index e62f6508..007dae69 100644 --- a/kernel/chips/it87.c +++ b/kernel/chips/it87.c @@ -137,12 +137,12 @@ static int init = 1; #define THERMISTOR 2 #define PIIDIODE 3 -/* Conversions. Rounding and limit checking is only done on the TO_REG +/* Conversions. 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) +#define IN_FROM_REG(val) (((val) * 16 + 5) / 10) static inline u8 FAN_TO_REG(long rpm, int div) { diff --git a/kernel/chips/lm78.c b/kernel/chips/lm78.c index 1dc69bbd..ce146885 100644 --- a/kernel/chips/lm78.c +++ b/kernel/chips/lm78.c @@ -73,12 +73,12 @@ SENSORS_INSMOD_3(lm78, lm78j, lm79); #define LM78_REG_I2C_ADDR 0x48 -/* Conversions. Rounding and limit checking is only done on the TO_REG +/* Conversions. 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) +#define IN_FROM_REG(val) (((val) * 16 + 5) / 10) static inline u8 FAN_TO_REG(long rpm, int div) { diff --git a/kernel/chips/mtp008.c b/kernel/chips/mtp008.c index ae5b0513..c8c5d224 100644 --- a/kernel/chips/mtp008.c +++ b/kernel/chips/mtp008.c @@ -102,7 +102,7 @@ SENSORS_INSMOD_1(mtp008); #define PIIDIODE 3 /* - * Conversion routines and macros. Rounding and limit checking is only done on + * Conversion routines and macros. Limit checking is only done on * the TO_REG variants. * * Note that IN values are expressed as 100 times the actual voltage to avoid @@ -110,7 +110,7 @@ SENSORS_INSMOD_1(mtp008); * 409 (0V to 4.096V). */ #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 + 5) / 10) /* * The fan cotation count (as stored in the register) is calculated using the diff --git a/kernel/chips/sis5595.c b/kernel/chips/sis5595.c index b0dc2ebc..d4350fba 100644 --- a/kernel/chips/sis5595.c +++ b/kernel/chips/sis5595.c @@ -138,13 +138,13 @@ static int blacklist[] = { #define SIS5595_REG_ALARM2 0x42 #define SIS5595_REG_FANDIV 0x47 -/* Conversions. Rounding and limit checking is only done on the TO_REG +/* Conversions. 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) +#define IN_FROM_REG(val) (((val) * 16 + 5) / 10) static inline u8 FAN_TO_REG(long rpm, int div) { diff --git a/kernel/chips/w83627hf.c b/kernel/chips/w83627hf.c index b2a11312..83ff5a92 100644 --- a/kernel/chips/w83627hf.c +++ b/kernel/chips/w83627hf.c @@ -199,12 +199,12 @@ static const u8 BIT_SCFG1[] = { 0x02, 0x04, 0x08 }; static const u8 BIT_SCFG2[] = { 0x10, 0x20, 0x40 }; #define W83781D_DEFAULT_BETA 3435 -/* Conversions. Rounding and limit checking is only done on the TO_REG +/* Conversions. 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) +#define IN_FROM_REG(val) (((val) * 16 + 5) / 10) static inline u8 FAN_TO_REG(long rpm, int div) {