diff options
Diffstat (limited to 'drivers/hwmon/lm90.c')
-rw-r--r-- | drivers/hwmon/lm90.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 5679464447cc..d9eeaf7585bd 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
@@ -78,6 +78,7 @@ | |||
78 | #include <linux/hwmon-sysfs.h> | 78 | #include <linux/hwmon-sysfs.h> |
79 | #include <linux/hwmon.h> | 79 | #include <linux/hwmon.h> |
80 | #include <linux/err.h> | 80 | #include <linux/err.h> |
81 | #include <linux/mutex.h> | ||
81 | 82 | ||
82 | /* | 83 | /* |
83 | * Addresses to scan | 84 | * Addresses to scan |
@@ -201,7 +202,7 @@ static struct i2c_driver lm90_driver = { | |||
201 | struct lm90_data { | 202 | struct lm90_data { |
202 | struct i2c_client client; | 203 | struct i2c_client client; |
203 | struct class_device *class_dev; | 204 | struct class_device *class_dev; |
204 | struct semaphore update_lock; | 205 | struct mutex update_lock; |
205 | char valid; /* zero until following fields are valid */ | 206 | char valid; /* zero until following fields are valid */ |
206 | unsigned long last_updated; /* in jiffies */ | 207 | unsigned long last_updated; /* in jiffies */ |
207 | int kind; | 208 | int kind; |
@@ -247,13 +248,13 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, | |||
247 | long val = simple_strtol(buf, NULL, 10); | 248 | long val = simple_strtol(buf, NULL, 10); |
248 | int nr = attr->index; | 249 | int nr = attr->index; |
249 | 250 | ||
250 | down(&data->update_lock); | 251 | mutex_lock(&data->update_lock); |
251 | if (data->kind == adt7461) | 252 | if (data->kind == adt7461) |
252 | data->temp8[nr] = TEMP1_TO_REG_ADT7461(val); | 253 | data->temp8[nr] = TEMP1_TO_REG_ADT7461(val); |
253 | else | 254 | else |
254 | data->temp8[nr] = TEMP1_TO_REG(val); | 255 | data->temp8[nr] = TEMP1_TO_REG(val); |
255 | i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]); | 256 | i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]); |
256 | up(&data->update_lock); | 257 | mutex_unlock(&data->update_lock); |
257 | return count; | 258 | return count; |
258 | } | 259 | } |
259 | 260 | ||
@@ -281,7 +282,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, | |||
281 | long val = simple_strtol(buf, NULL, 10); | 282 | long val = simple_strtol(buf, NULL, 10); |
282 | int nr = attr->index; | 283 | int nr = attr->index; |
283 | 284 | ||
284 | down(&data->update_lock); | 285 | mutex_lock(&data->update_lock); |
285 | if (data->kind == adt7461) | 286 | if (data->kind == adt7461) |
286 | data->temp11[nr] = TEMP2_TO_REG_ADT7461(val); | 287 | data->temp11[nr] = TEMP2_TO_REG_ADT7461(val); |
287 | else | 288 | else |
@@ -290,7 +291,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, | |||
290 | data->temp11[nr] >> 8); | 291 | data->temp11[nr] >> 8); |
291 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], | 292 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], |
292 | data->temp11[nr] & 0xff); | 293 | data->temp11[nr] & 0xff); |
293 | up(&data->update_lock); | 294 | mutex_unlock(&data->update_lock); |
294 | return count; | 295 | return count; |
295 | } | 296 | } |
296 | 297 | ||
@@ -311,11 +312,11 @@ static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy, | |||
311 | long val = simple_strtol(buf, NULL, 10); | 312 | long val = simple_strtol(buf, NULL, 10); |
312 | long hyst; | 313 | long hyst; |
313 | 314 | ||
314 | down(&data->update_lock); | 315 | mutex_lock(&data->update_lock); |
315 | hyst = TEMP1_FROM_REG(data->temp8[3]) - val; | 316 | hyst = TEMP1_FROM_REG(data->temp8[3]) - val; |
316 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, | 317 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, |
317 | HYST_TO_REG(hyst)); | 318 | HYST_TO_REG(hyst)); |
318 | up(&data->update_lock); | 319 | mutex_unlock(&data->update_lock); |
319 | return count; | 320 | return count; |
320 | } | 321 | } |
321 | 322 | ||
@@ -558,7 +559,7 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
558 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 559 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
559 | data->valid = 0; | 560 | data->valid = 0; |
560 | data->kind = kind; | 561 | data->kind = kind; |
561 | init_MUTEX(&data->update_lock); | 562 | mutex_init(&data->update_lock); |
562 | 563 | ||
563 | /* Tell the I2C layer a new client has arrived */ | 564 | /* Tell the I2C layer a new client has arrived */ |
564 | if ((err = i2c_attach_client(new_client))) | 565 | if ((err = i2c_attach_client(new_client))) |
@@ -646,7 +647,7 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
646 | struct i2c_client *client = to_i2c_client(dev); | 647 | struct i2c_client *client = to_i2c_client(dev); |
647 | struct lm90_data *data = i2c_get_clientdata(client); | 648 | struct lm90_data *data = i2c_get_clientdata(client); |
648 | 649 | ||
649 | down(&data->update_lock); | 650 | mutex_lock(&data->update_lock); |
650 | 651 | ||
651 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 652 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
652 | u8 oldh, newh, l; | 653 | u8 oldh, newh, l; |
@@ -692,7 +693,7 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
692 | data->valid = 1; | 693 | data->valid = 1; |
693 | } | 694 | } |
694 | 695 | ||
695 | up(&data->update_lock); | 696 | mutex_unlock(&data->update_lock); |
696 | 697 | ||
697 | return data; | 698 | return data; |
698 | } | 699 | } |