X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fi2c%2Fchips%2Flm83.c;h=3dafe60766ad9de9848dbe48df1cea8507bb4033;hb=f7f1b0f1e2fbadeab12d24236000e778aa9b1ead;hp=552321e05a2fd16888430c56441018df4fe21947;hpb=e3f6fb6212a7102bdb56ba38fa1e98fe72950475;p=linux-2.6.git diff --git a/drivers/i2c/chips/lm83.c b/drivers/i2c/chips/lm83.c index 552321e05..3dafe6076 100644 --- a/drivers/i2c/chips/lm83.c +++ b/drivers/i2c/chips/lm83.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -149,12 +150,6 @@ struct lm83_data { u16 alarms; /* bitvector, combined */ }; -/* - * Internal variables - */ - -static int lm83_id; - /* * Sysfs stuff */ @@ -182,8 +177,11 @@ 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); \ + \ + down(&data->update_lock); \ data->value = TEMP_TO_REG(val); \ i2c_smbus_write_byte_data(client, reg, data->value); \ + up(&data->update_lock); \ return count; \ } set_temp(high1, temp_high[0], LM83_REG_W_LOCAL_HIGH); @@ -312,7 +310,6 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) /* We can fill in the remaining client fields */ strlcpy(new_client->name, name, I2C_NAME_SIZE); - new_client->id = lm83_id++; data->valid = 0; init_MUTEX(&data->update_lock); @@ -369,9 +366,7 @@ static struct lm83_data *lm83_update_device(struct device *dev) down(&data->update_lock); - if ((jiffies - data->last_updated > HZ * 2) || - (jiffies < data->last_updated) || - !data->valid) { + if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { int nr; dev_dbg(&client->dev, "Updating lm83 data.\n");