vserver 2.0 rc7
[linux-2.6.git] / drivers / i2c / chips / max1619.c
index bc7e22f..5afa961 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/jiffies.h>
 #include <linux/i2c.h>
 #include <linux/i2c-sensor.h>
 
@@ -116,12 +117,6 @@ struct max1619_data {
        u8 alarms; 
 };
 
-/*
- * Internal variables
- */
-
-static int max1619_id;
-
 /*
  * Sysfs stuff
  */
@@ -146,8 +141,11 @@ static ssize_t set_##value(struct device *dev, const char *buf, \
        struct i2c_client *client = to_i2c_client(dev); \
        struct max1619_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; \
 }
 
@@ -267,7 +265,6 @@ static int max1619_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 = max1619_id++;
        data->valid = 0;
        init_MUTEX(&data->update_lock);
 
@@ -331,10 +328,7 @@ static struct max1619_data *max1619_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) {
                dev_dbg(&client->dev, "Updating max1619 data.\n");
                data->temp_input1 = i2c_smbus_read_byte_data(client,
                                        MAX1619_REG_R_LOCAL_TEMP);