X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fi2c%2Fchips%2Flm83.c;h=7e4cb6bd7fead05a1c273e9b84e19a4f1a9afdd4;hb=9e1bf581d67d87a1d7fc0ea500729e3a03643a26;hp=552321e05a2fd16888430c56441018df4fe21947;hpb=8d40237c730b8be87c1b80a5d96b9c603fefa829;p=linux-2.6.git diff --git a/drivers/i2c/chips/lm83.c b/drivers/i2c/chips/lm83.c index 552321e05..7e4cb6bd7 100644 --- a/drivers/i2c/chips/lm83.c +++ b/drivers/i2c/chips/lm83.c @@ -40,11 +40,11 @@ * addresses. */ -static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, - 0x29, 0x2a, 0x2b, - 0x4c, 0x4d, 0x4e, - I2C_CLIENT_END }; +static unsigned short normal_i2c[] = { I2C_CLIENT_END }; +static unsigned short normal_i2c_range[] = { 0x18, 0x1a, 0x29, 0x2b, + 0x4c, 0x4e, I2C_CLIENT_END }; static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; +static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END }; /* * Insmod parameters @@ -80,14 +80,13 @@ SENSORS_INSMOD_1(lm83); /* * Conversions and various macros - * The LM83 uses signed 8-bit values with LSB = 1 degree Celcius. + * The LM83 uses signed 8-bit values. */ -#define TEMP_FROM_REG(val) ((val) * 1000) -#define TEMP_TO_REG(val) ((val) <= -128000 ? -128 : \ - (val) >= 127000 ? 127 : \ - (val) < 0 ? ((val) - 500) / 1000 : \ - ((val) + 500) / 1000) +#define TEMP_FROM_REG(val) (((val) > 127 ? (val) - 0x100 : (val)) * 1000) +#define TEMP_TO_REG(val) ((val) <= -50000 ? -50 + 0x100 : (val) >= 127000 ? 127 : \ + (val) > -500 ? ((val)+500) / 1000 : \ + ((val)-500) / 1000 + 0x100) static const u8 LM83_REG_R_TEMP[] = { LM83_REG_R_LOCAL_TEMP, @@ -143,9 +142,9 @@ struct lm83_data { unsigned long last_updated; /* in jiffies */ /* registers values */ - s8 temp_input[4]; - s8 temp_high[4]; - s8 temp_crit; + u8 temp_input[4]; + u8 temp_high[4]; + u8 temp_crit; u16 alarms; /* bitvector, combined */ }; @@ -153,7 +152,7 @@ struct lm83_data { * Internal variables */ -static int lm83_id; +static int lm83_id = 0; /* * Sysfs stuff @@ -181,8 +180,7 @@ static ssize_t set_temp_##suffix(struct device *dev, const char *buf, \ { \ struct i2c_client *client = to_i2c_client(dev); \ struct lm83_data *data = i2c_get_clientdata(client); \ - long val = simple_strtol(buf, NULL, 10); \ - data->value = TEMP_TO_REG(val); \ + data->value = TEMP_TO_REG(simple_strtol(buf, NULL, 10)); \ i2c_smbus_write_byte_data(client, reg, data->value); \ return count; \ }