X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fi2c%2Fchips%2Fds1621.c;h=bb1fefb2162ecccf67c1447852f84ccf5024c64d;hb=f7f1b0f1e2fbadeab12d24236000e778aa9b1ead;hp=753bfc6a31772b81712949076c6f2eb5bb523346;hpb=e3f6fb6212a7102bdb56ba38fa1e98fe72950475;p=linux-2.6.git diff --git a/drivers/i2c/chips/ds1621.c b/drivers/i2c/chips/ds1621.c index 753bfc6a3..bb1fefb21 100644 --- a/drivers/i2c/chips/ds1621.c +++ b/drivers/i2c/chips/ds1621.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include "lm75.h" @@ -95,8 +96,6 @@ static struct i2c_driver ds1621_driver = { .detach_client = ds1621_detach_client, }; -static int ds1621_id; - /* All registers are word-sized, except for the configuration register. DS1621 uses a high-byte first convention, which is exactly opposite to the usual practice. */ @@ -154,8 +153,12 @@ static ssize_t set_temp_##suffix(struct device *dev, const char *buf, \ { \ struct i2c_client *client = to_i2c_client(dev); \ struct ds1621_data *data = ds1621_update_client(dev); \ - data->value = LM75_TEMP_TO_REG(simple_strtoul(buf, NULL, 10)); \ + u16 val = LM75_TEMP_TO_REG(simple_strtoul(buf, NULL, 10)); \ + \ + down(&data->update_lock); \ + data->value = val; \ ds1621_write_value(client, reg, data->value); \ + up(&data->update_lock); \ return count; \ } @@ -236,8 +239,6 @@ int ds1621_detect(struct i2c_adapter *adapter, int address, /* Fill in remaining client fields and put it into the global list */ strlcpy(new_client->name, "ds1621", I2C_NAME_SIZE); - - new_client->id = ds1621_id++; data->valid = 0; init_MUTEX(&data->update_lock); @@ -288,8 +289,8 @@ static struct ds1621_data *ds1621_update_client(struct device *dev) down(&data->update_lock); - if ((jiffies - data->last_updated > HZ + HZ / 2) || - (jiffies < data->last_updated) || !data->valid) { + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { dev_dbg(&client->dev, "Starting ds1621 update\n");