diff options
Diffstat (limited to 'drivers/hwmon/ds1621.c')
| -rw-r--r-- | drivers/hwmon/ds1621.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 203f9c7abb20..478eb4bb8570 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
| 29 | #include <linux/hwmon.h> | 29 | #include <linux/hwmon.h> |
| 30 | #include <linux/err.h> | 30 | #include <linux/err.h> |
| 31 | #include <linux/mutex.h> | ||
| 31 | #include "lm75.h" | 32 | #include "lm75.h" |
| 32 | 33 | ||
| 33 | /* Addresses to scan */ | 34 | /* Addresses to scan */ |
| @@ -72,7 +73,7 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low") | |||
| 72 | struct ds1621_data { | 73 | struct ds1621_data { |
| 73 | struct i2c_client client; | 74 | struct i2c_client client; |
| 74 | struct class_device *class_dev; | 75 | struct class_device *class_dev; |
| 75 | struct semaphore update_lock; | 76 | struct mutex update_lock; |
| 76 | char valid; /* !=0 if following fields are valid */ | 77 | char valid; /* !=0 if following fields are valid */ |
| 77 | unsigned long last_updated; /* In jiffies */ | 78 | unsigned long last_updated; /* In jiffies */ |
| 78 | 79 | ||
| @@ -156,10 +157,10 @@ static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *at | |||
| 156 | struct ds1621_data *data = ds1621_update_client(dev); \ | 157 | struct ds1621_data *data = ds1621_update_client(dev); \ |
| 157 | u16 val = LM75_TEMP_TO_REG(simple_strtoul(buf, NULL, 10)); \ | 158 | u16 val = LM75_TEMP_TO_REG(simple_strtoul(buf, NULL, 10)); \ |
| 158 | \ | 159 | \ |
| 159 | down(&data->update_lock); \ | 160 | mutex_lock(&data->update_lock); \ |
| 160 | data->value = val; \ | 161 | data->value = val; \ |
| 161 | ds1621_write_value(client, reg, data->value); \ | 162 | ds1621_write_value(client, reg, data->value); \ |
| 162 | up(&data->update_lock); \ | 163 | mutex_unlock(&data->update_lock); \ |
| 163 | return count; \ | 164 | return count; \ |
| 164 | } | 165 | } |
| 165 | 166 | ||
| @@ -242,7 +243,7 @@ static int ds1621_detect(struct i2c_adapter *adapter, int address, | |||
| 242 | /* Fill in remaining client fields and put it into the global list */ | 243 | /* Fill in remaining client fields and put it into the global list */ |
| 243 | strlcpy(new_client->name, "ds1621", I2C_NAME_SIZE); | 244 | strlcpy(new_client->name, "ds1621", I2C_NAME_SIZE); |
| 244 | data->valid = 0; | 245 | data->valid = 0; |
| 245 | init_MUTEX(&data->update_lock); | 246 | mutex_init(&data->update_lock); |
| 246 | 247 | ||
| 247 | /* Tell the I2C layer a new client has arrived */ | 248 | /* Tell the I2C layer a new client has arrived */ |
| 248 | if ((err = i2c_attach_client(new_client))) | 249 | if ((err = i2c_attach_client(new_client))) |
| @@ -297,7 +298,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev) | |||
| 297 | struct ds1621_data *data = i2c_get_clientdata(client); | 298 | struct ds1621_data *data = i2c_get_clientdata(client); |
| 298 | u8 new_conf; | 299 | u8 new_conf; |
| 299 | 300 | ||
| 300 | down(&data->update_lock); | 301 | mutex_lock(&data->update_lock); |
| 301 | 302 | ||
| 302 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 303 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
| 303 | || !data->valid) { | 304 | || !data->valid) { |
| @@ -327,7 +328,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev) | |||
| 327 | data->valid = 1; | 328 | data->valid = 1; |
| 328 | } | 329 | } |
| 329 | 330 | ||
| 330 | up(&data->update_lock); | 331 | mutex_unlock(&data->update_lock); |
| 331 | 332 | ||
| 332 | return data; | 333 | return data; |
| 333 | } | 334 | } |
