diff --git a/kernel/chips/lm80.c b/kernel/chips/lm80.c index 6d29c06f..1955d7e8 100644 --- a/kernel/chips/lm80.c +++ b/kernel/chips/lm80.c @@ -21,15 +21,9 @@ #include #include -#include -#include -#include -#include #include #include #include -#include -#include #include "version.h" MODULE_LICENSE("GPL"); @@ -75,8 +69,8 @@ SENSORS_INSMOD_1(lm80); 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_TO_REG(val) (SENSORS_LIMIT((val),0,255)) +#define IN_FROM_REG(val) (val) static inline unsigned char FAN_TO_REG(unsigned rpm, unsigned div) { @@ -94,12 +88,12 @@ static inline long TEMP_FROM_REG(u16 temp) { long res; - temp = temp >> 4; - if (temp < 0x0800) { - res = (625 * (long) temp); - } else { + temp >>= 4; + if (temp < 0x0800) + res = 625 * (long) temp; + else res = ((long) temp - 0x01000) * 625; - } + return res / 100; } @@ -114,10 +108,6 @@ static inline long TEMP_FROM_REG(u16 temp) #define DIV_FROM_REG(val) (1 << (val)) #define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) -/* For each registered LM80, we need to keep some data in memory. That - data is pointed to by lm80_list[NR]->data. The structure itself is - dynamically allocated, at the same time when a new lm80 client is - allocated. */ struct lm80_data { int sysctl_id; @@ -146,9 +136,8 @@ static int lm80_detect(struct i2c_adapter *adapter, int address, unsigned short flags, int kind); static int lm80_detach_client(struct i2c_client *client); -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_read_value(struct i2c_client *client, u8 reg); +static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value); static void lm80_update_client(struct i2c_client *client); static void lm80_init_client(struct i2c_client *client); @@ -374,7 +363,7 @@ static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value) return i2c_smbus_write_byte_data(client, reg, value); } -/* Called when we have found a new LM80. It should set limits, etc. */ +/* Called when we have found a new LM80. */ static void lm80_init_client(struct i2c_client *client) { /* Reset all except Watchdog values and last conversion values @@ -464,18 +453,18 @@ void lm80_in(struct i2c_client *client, int operation, int ctl_name, *nrels_mag = 2; else if (operation == SENSORS_PROC_REAL_READ) { lm80_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]); lm80_write_value(client, LM80_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]); lm80_write_value(client, LM80_REG_IN_MAX(nr), data->in_max[nr]); }