vserver 2.0 rc7
[linux-2.6.git] / drivers / i2c / chips / lm83.c
index 552321e..3dafe60 100644 (file)
@@ -31,6 +31,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>
 
@@ -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");