aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hwmon/adm1021.c13
-rw-r--r--drivers/hwmon/adm1025.c25
-rw-r--r--drivers/hwmon/adm1026.c87
-rw-r--r--drivers/hwmon/adm1031.c49
-rw-r--r--drivers/hwmon/adm9240.c29
-rw-r--r--drivers/hwmon/asb100.c45
-rw-r--r--drivers/hwmon/atxp1.c9
-rw-r--r--drivers/hwmon/ds1621.c13
-rw-r--r--drivers/hwmon/fscher.c41
-rw-r--r--drivers/hwmon/fscpos.c29
-rw-r--r--drivers/hwmon/gl518sm.c25
-rw-r--r--drivers/hwmon/gl520sm.c45
-rw-r--r--drivers/hwmon/hdaps.c37
-rw-r--r--drivers/hwmon/it87.c61
-rw-r--r--drivers/hwmon/lm63.c29
-rw-r--r--drivers/hwmon/lm75.c13
-rw-r--r--drivers/hwmon/lm77.c21
-rw-r--r--drivers/hwmon/lm78.c47
-rw-r--r--drivers/hwmon/lm80.c27
-rw-r--r--drivers/hwmon/lm83.c13
-rw-r--r--drivers/hwmon/lm85.c67
-rw-r--r--drivers/hwmon/lm87.c39
-rw-r--r--drivers/hwmon/lm90.c21
-rw-r--r--drivers/hwmon/lm92.c17
-rw-r--r--drivers/hwmon/max1619.c13
-rw-r--r--drivers/hwmon/pc87360.c61
-rw-r--r--drivers/hwmon/sis5595.c47
-rw-r--r--drivers/hwmon/smsc47b397.c17
-rw-r--r--drivers/hwmon/smsc47m1.c41
-rw-r--r--drivers/hwmon/via686a.c33
-rw-r--r--drivers/hwmon/vt8231.c51
-rw-r--r--drivers/hwmon/w83627ehf.c33
-rw-r--r--drivers/hwmon/w83627hf.c57
-rw-r--r--drivers/hwmon/w83781d.c55
-rw-r--r--drivers/hwmon/w83792d.c9
-rw-r--r--drivers/hwmon/w83l785ts.c9
36 files changed, 632 insertions, 596 deletions
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c
index 665612729cb9..2b6e74dd4a82 100644
--- a/drivers/hwmon/adm1021.c
+++ b/drivers/hwmon/adm1021.c
@@ -26,6 +26,7 @@
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/hwmon.h> 27#include <linux/hwmon.h>
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/mutex.h>
29 30
30 31
31/* Addresses to scan */ 32/* Addresses to scan */
@@ -92,7 +93,7 @@ struct adm1021_data {
92 struct class_device *class_dev; 93 struct class_device *class_dev;
93 enum chips type; 94 enum chips type;
94 95
95 struct semaphore update_lock; 96 struct mutex update_lock;
96 char valid; /* !=0 if following fields are valid */ 97 char valid; /* !=0 if following fields are valid */
97 unsigned long last_updated; /* In jiffies */ 98 unsigned long last_updated; /* In jiffies */
98 99
@@ -162,10 +163,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
162 struct adm1021_data *data = i2c_get_clientdata(client); \ 163 struct adm1021_data *data = i2c_get_clientdata(client); \
163 int temp = simple_strtoul(buf, NULL, 10); \ 164 int temp = simple_strtoul(buf, NULL, 10); \
164 \ 165 \
165 down(&data->update_lock); \ 166 mutex_lock(&data->update_lock); \
166 data->value = TEMP_TO_REG(temp); \ 167 data->value = TEMP_TO_REG(temp); \
167 adm1021_write_value(client, reg, data->value); \ 168 adm1021_write_value(client, reg, data->value); \
168 up(&data->update_lock); \ 169 mutex_unlock(&data->update_lock); \
169 return count; \ 170 return count; \
170} 171}
171set(temp_max, ADM1021_REG_TOS_W); 172set(temp_max, ADM1021_REG_TOS_W);
@@ -275,7 +276,7 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
275 strlcpy(new_client->name, type_name, I2C_NAME_SIZE); 276 strlcpy(new_client->name, type_name, I2C_NAME_SIZE);
276 data->type = kind; 277 data->type = kind;
277 data->valid = 0; 278 data->valid = 0;
278 init_MUTEX(&data->update_lock); 279 mutex_init(&data->update_lock);
279 280
280 /* Tell the I2C layer a new client has arrived */ 281 /* Tell the I2C layer a new client has arrived */
281 if ((err = i2c_attach_client(new_client))) 282 if ((err = i2c_attach_client(new_client)))
@@ -351,7 +352,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
351 struct i2c_client *client = to_i2c_client(dev); 352 struct i2c_client *client = to_i2c_client(dev);
352 struct adm1021_data *data = i2c_get_clientdata(client); 353 struct adm1021_data *data = i2c_get_clientdata(client);
353 354
354 down(&data->update_lock); 355 mutex_lock(&data->update_lock);
355 356
356 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 357 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
357 || !data->valid) { 358 || !data->valid) {
@@ -375,7 +376,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
375 data->valid = 1; 376 data->valid = 1;
376 } 377 }
377 378
378 up(&data->update_lock); 379 mutex_unlock(&data->update_lock);
379 380
380 return data; 381 return data;
381} 382}
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c
index 9331c56d2ba6..a4c859c9fbf8 100644
--- a/drivers/hwmon/adm1025.c
+++ b/drivers/hwmon/adm1025.c
@@ -53,6 +53,7 @@
53#include <linux/hwmon.h> 53#include <linux/hwmon.h>
54#include <linux/hwmon-vid.h> 54#include <linux/hwmon-vid.h>
55#include <linux/err.h> 55#include <linux/err.h>
56#include <linux/mutex.h>
56 57
57/* 58/*
58 * Addresses to scan 59 * Addresses to scan
@@ -133,7 +134,7 @@ static struct i2c_driver adm1025_driver = {
133struct adm1025_data { 134struct adm1025_data {
134 struct i2c_client client; 135 struct i2c_client client;
135 struct class_device *class_dev; 136 struct class_device *class_dev;
136 struct semaphore update_lock; 137 struct mutex update_lock;
137 char valid; /* zero until following fields are valid */ 138 char valid; /* zero until following fields are valid */
138 unsigned long last_updated; /* in jiffies */ 139 unsigned long last_updated; /* in jiffies */
139 140
@@ -207,11 +208,11 @@ static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute
207 struct adm1025_data *data = i2c_get_clientdata(client); \ 208 struct adm1025_data *data = i2c_get_clientdata(client); \
208 long val = simple_strtol(buf, NULL, 10); \ 209 long val = simple_strtol(buf, NULL, 10); \
209 \ 210 \
210 down(&data->update_lock); \ 211 mutex_lock(&data->update_lock); \
211 data->in_min[offset] = IN_TO_REG(val, in_scale[offset]); \ 212 data->in_min[offset] = IN_TO_REG(val, in_scale[offset]); \
212 i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(offset), \ 213 i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(offset), \
213 data->in_min[offset]); \ 214 data->in_min[offset]); \
214 up(&data->update_lock); \ 215 mutex_unlock(&data->update_lock); \
215 return count; \ 216 return count; \
216} \ 217} \
217static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ 218static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
@@ -221,11 +222,11 @@ static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute
221 struct adm1025_data *data = i2c_get_clientdata(client); \ 222 struct adm1025_data *data = i2c_get_clientdata(client); \
222 long val = simple_strtol(buf, NULL, 10); \ 223 long val = simple_strtol(buf, NULL, 10); \
223 \ 224 \
224 down(&data->update_lock); \ 225 mutex_lock(&data->update_lock); \
225 data->in_max[offset] = IN_TO_REG(val, in_scale[offset]); \ 226 data->in_max[offset] = IN_TO_REG(val, in_scale[offset]); \
226 i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(offset), \ 227 i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(offset), \
227 data->in_max[offset]); \ 228 data->in_max[offset]); \
228 up(&data->update_lock); \ 229 mutex_unlock(&data->update_lock); \
229 return count; \ 230 return count; \
230} \ 231} \
231static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ 232static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \
@@ -247,11 +248,11 @@ static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribut
247 struct adm1025_data *data = i2c_get_clientdata(client); \ 248 struct adm1025_data *data = i2c_get_clientdata(client); \
248 long val = simple_strtol(buf, NULL, 10); \ 249 long val = simple_strtol(buf, NULL, 10); \
249 \ 250 \
250 down(&data->update_lock); \ 251 mutex_lock(&data->update_lock); \
251 data->temp_min[offset-1] = TEMP_TO_REG(val); \ 252 data->temp_min[offset-1] = TEMP_TO_REG(val); \
252 i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(offset-1), \ 253 i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(offset-1), \
253 data->temp_min[offset-1]); \ 254 data->temp_min[offset-1]); \
254 up(&data->update_lock); \ 255 mutex_unlock(&data->update_lock); \
255 return count; \ 256 return count; \
256} \ 257} \
257static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ 258static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
@@ -261,11 +262,11 @@ static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribut
261 struct adm1025_data *data = i2c_get_clientdata(client); \ 262 struct adm1025_data *data = i2c_get_clientdata(client); \
262 long val = simple_strtol(buf, NULL, 10); \ 263 long val = simple_strtol(buf, NULL, 10); \
263 \ 264 \
264 down(&data->update_lock); \ 265 mutex_lock(&data->update_lock); \
265 data->temp_max[offset-1] = TEMP_TO_REG(val); \ 266 data->temp_max[offset-1] = TEMP_TO_REG(val); \
266 i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(offset-1), \ 267 i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(offset-1), \
267 data->temp_max[offset-1]); \ 268 data->temp_max[offset-1]); \
268 up(&data->update_lock); \ 269 mutex_unlock(&data->update_lock); \
269 return count; \ 270 return count; \
270} \ 271} \
271static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ 272static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
@@ -404,7 +405,7 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind)
404 /* We can fill in the remaining client fields */ 405 /* We can fill in the remaining client fields */
405 strlcpy(new_client->name, name, I2C_NAME_SIZE); 406 strlcpy(new_client->name, name, I2C_NAME_SIZE);
406 data->valid = 0; 407 data->valid = 0;
407 init_MUTEX(&data->update_lock); 408 mutex_init(&data->update_lock);
408 409
409 /* Tell the I2C layer a new client has arrived */ 410 /* Tell the I2C layer a new client has arrived */
410 if ((err = i2c_attach_client(new_client))) 411 if ((err = i2c_attach_client(new_client)))
@@ -523,7 +524,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
523 struct i2c_client *client = to_i2c_client(dev); 524 struct i2c_client *client = to_i2c_client(dev);
524 struct adm1025_data *data = i2c_get_clientdata(client); 525 struct adm1025_data *data = i2c_get_clientdata(client);
525 526
526 down(&data->update_lock); 527 mutex_lock(&data->update_lock);
527 528
528 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { 529 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
529 int i; 530 int i;
@@ -558,7 +559,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
558 data->valid = 1; 559 data->valid = 1;
559 } 560 }
560 561
561 up(&data->update_lock); 562 mutex_unlock(&data->update_lock);
562 563
563 return data; 564 return data;
564} 565}
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c
index fefe6e74fd02..8646ec1e9667 100644
--- a/drivers/hwmon/adm1026.c
+++ b/drivers/hwmon/adm1026.c
@@ -32,6 +32,7 @@
32#include <linux/hwmon-sysfs.h> 32#include <linux/hwmon-sysfs.h>
33#include <linux/hwmon-vid.h> 33#include <linux/hwmon-vid.h>
34#include <linux/err.h> 34#include <linux/err.h>
35#include <linux/mutex.h>
35 36
36/* Addresses to scan */ 37/* Addresses to scan */
37static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; 38static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
@@ -260,10 +261,10 @@ struct pwm_data {
260struct adm1026_data { 261struct adm1026_data {
261 struct i2c_client client; 262 struct i2c_client client;
262 struct class_device *class_dev; 263 struct class_device *class_dev;
263 struct semaphore lock; 264 struct mutex lock;
264 enum chips type; 265 enum chips type;
265 266
266 struct semaphore update_lock; 267 struct mutex update_lock;
267 int valid; /* !=0 if following fields are valid */ 268 int valid; /* !=0 if following fields are valid */
268 unsigned long last_reading; /* In jiffies */ 269 unsigned long last_reading; /* In jiffies */
269 unsigned long last_config; /* In jiffies */ 270 unsigned long last_config; /* In jiffies */
@@ -575,7 +576,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev)
575 int i; 576 int i;
576 long value, alarms, gpio; 577 long value, alarms, gpio;
577 578
578 down(&data->update_lock); 579 mutex_lock(&data->update_lock);
579 if (!data->valid 580 if (!data->valid
580 || time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) { 581 || time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) {
581 /* Things that change quickly */ 582 /* Things that change quickly */
@@ -710,7 +711,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev)
710 dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n"); 711 dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n");
711 data->vid = (data->gpio >> 11) & 0x1f; 712 data->vid = (data->gpio >> 11) & 0x1f;
712 data->valid = 1; 713 data->valid = 1;
713 up(&data->update_lock); 714 mutex_unlock(&data->update_lock);
714 return data; 715 return data;
715} 716}
716 717
@@ -739,10 +740,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
739 struct adm1026_data *data = i2c_get_clientdata(client); 740 struct adm1026_data *data = i2c_get_clientdata(client);
740 int val = simple_strtol(buf, NULL, 10); 741 int val = simple_strtol(buf, NULL, 10);
741 742
742 down(&data->update_lock); 743 mutex_lock(&data->update_lock);
743 data->in_min[nr] = INS_TO_REG(nr, val); 744 data->in_min[nr] = INS_TO_REG(nr, val);
744 adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]); 745 adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]);
745 up(&data->update_lock); 746 mutex_unlock(&data->update_lock);
746 return count; 747 return count;
747} 748}
748static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, 749static ssize_t show_in_max(struct device *dev, struct device_attribute *attr,
@@ -762,10 +763,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
762 struct adm1026_data *data = i2c_get_clientdata(client); 763 struct adm1026_data *data = i2c_get_clientdata(client);
763 int val = simple_strtol(buf, NULL, 10); 764 int val = simple_strtol(buf, NULL, 10);
764 765
765 down(&data->update_lock); 766 mutex_lock(&data->update_lock);
766 data->in_max[nr] = INS_TO_REG(nr, val); 767 data->in_max[nr] = INS_TO_REG(nr, val);
767 adm1026_write_value(client, ADM1026_REG_IN_MAX[nr], data->in_max[nr]); 768 adm1026_write_value(client, ADM1026_REG_IN_MAX[nr], data->in_max[nr]);
768 up(&data->update_lock); 769 mutex_unlock(&data->update_lock);
769 return count; 770 return count;
770} 771}
771 772
@@ -813,10 +814,10 @@ static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr, c
813 struct adm1026_data *data = i2c_get_clientdata(client); 814 struct adm1026_data *data = i2c_get_clientdata(client);
814 int val = simple_strtol(buf, NULL, 10); 815 int val = simple_strtol(buf, NULL, 10);
815 816
816 down(&data->update_lock); 817 mutex_lock(&data->update_lock);
817 data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET); 818 data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET);
818 adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]); 819 adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]);
819 up(&data->update_lock); 820 mutex_unlock(&data->update_lock);
820 return count; 821 return count;
821} 822}
822static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf) 823static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf)
@@ -831,10 +832,10 @@ static ssize_t set_in16_max(struct device *dev, struct device_attribute *attr, c
831 struct adm1026_data *data = i2c_get_clientdata(client); 832 struct adm1026_data *data = i2c_get_clientdata(client);
832 int val = simple_strtol(buf, NULL, 10); 833 int val = simple_strtol(buf, NULL, 10);
833 834
834 down(&data->update_lock); 835 mutex_lock(&data->update_lock);
835 data->in_max[16] = INS_TO_REG(16, val+NEG12_OFFSET); 836 data->in_max[16] = INS_TO_REG(16, val+NEG12_OFFSET);
836 adm1026_write_value(client, ADM1026_REG_IN_MAX[16], data->in_max[16]); 837 adm1026_write_value(client, ADM1026_REG_IN_MAX[16], data->in_max[16]);
837 up(&data->update_lock); 838 mutex_unlock(&data->update_lock);
838 return count; 839 return count;
839} 840}
840 841
@@ -874,11 +875,11 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
874 struct adm1026_data *data = i2c_get_clientdata(client); 875 struct adm1026_data *data = i2c_get_clientdata(client);
875 int val = simple_strtol(buf, NULL, 10); 876 int val = simple_strtol(buf, NULL, 10);
876 877
877 down(&data->update_lock); 878 mutex_lock(&data->update_lock);
878 data->fan_min[nr] = FAN_TO_REG(val, data->fan_div[nr]); 879 data->fan_min[nr] = FAN_TO_REG(val, data->fan_div[nr]);
879 adm1026_write_value(client, ADM1026_REG_FAN_MIN(nr), 880 adm1026_write_value(client, ADM1026_REG_FAN_MIN(nr),
880 data->fan_min[nr]); 881 data->fan_min[nr]);
881 up(&data->update_lock); 882 mutex_unlock(&data->update_lock);
882 return count; 883 return count;
883} 884}
884 885
@@ -939,7 +940,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
939 if (new_div == 0) { 940 if (new_div == 0) {
940 return -EINVAL; 941 return -EINVAL;
941 } 942 }
942 down(&data->update_lock); 943 mutex_lock(&data->update_lock);
943 orig_div = data->fan_div[nr]; 944 orig_div = data->fan_div[nr];
944 data->fan_div[nr] = DIV_FROM_REG(new_div); 945 data->fan_div[nr] = DIV_FROM_REG(new_div);
945 946
@@ -958,7 +959,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
958 if (data->fan_div[nr] != orig_div) { 959 if (data->fan_div[nr] != orig_div) {
959 fixup_fan_min(dev,nr,orig_div); 960 fixup_fan_min(dev,nr,orig_div);
960 } 961 }
961 up(&data->update_lock); 962 mutex_unlock(&data->update_lock);
962 return count; 963 return count;
963} 964}
964 965
@@ -1001,11 +1002,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
1001 struct adm1026_data *data = i2c_get_clientdata(client); 1002 struct adm1026_data *data = i2c_get_clientdata(client);
1002 int val = simple_strtol(buf, NULL, 10); 1003 int val = simple_strtol(buf, NULL, 10);
1003 1004
1004 down(&data->update_lock); 1005 mutex_lock(&data->update_lock);
1005 data->temp_min[nr] = TEMP_TO_REG(val); 1006 data->temp_min[nr] = TEMP_TO_REG(val);
1006 adm1026_write_value(client, ADM1026_REG_TEMP_MIN[nr], 1007 adm1026_write_value(client, ADM1026_REG_TEMP_MIN[nr],
1007 data->temp_min[nr]); 1008 data->temp_min[nr]);
1008 up(&data->update_lock); 1009 mutex_unlock(&data->update_lock);
1009 return count; 1010 return count;
1010} 1011}
1011static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, 1012static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr,
@@ -1025,11 +1026,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
1025 struct adm1026_data *data = i2c_get_clientdata(client); 1026 struct adm1026_data *data = i2c_get_clientdata(client);
1026 int val = simple_strtol(buf, NULL, 10); 1027 int val = simple_strtol(buf, NULL, 10);
1027 1028
1028 down(&data->update_lock); 1029 mutex_lock(&data->update_lock);
1029 data->temp_max[nr] = TEMP_TO_REG(val); 1030 data->temp_max[nr] = TEMP_TO_REG(val);
1030 adm1026_write_value(client, ADM1026_REG_TEMP_MAX[nr], 1031 adm1026_write_value(client, ADM1026_REG_TEMP_MAX[nr],
1031 data->temp_max[nr]); 1032 data->temp_max[nr]);
1032 up(&data->update_lock); 1033 mutex_unlock(&data->update_lock);
1033 return count; 1034 return count;
1034} 1035}
1035 1036
@@ -1064,11 +1065,11 @@ static ssize_t set_temp_offset(struct device *dev,
1064 struct adm1026_data *data = i2c_get_clientdata(client); 1065 struct adm1026_data *data = i2c_get_clientdata(client);
1065 int val = simple_strtol(buf, NULL, 10); 1066 int val = simple_strtol(buf, NULL, 10);
1066 1067
1067 down(&data->update_lock); 1068 mutex_lock(&data->update_lock);
1068 data->temp_offset[nr] = TEMP_TO_REG(val); 1069 data->temp_offset[nr] = TEMP_TO_REG(val);
1069 adm1026_write_value(client, ADM1026_REG_TEMP_OFFSET[nr], 1070 adm1026_write_value(client, ADM1026_REG_TEMP_OFFSET[nr],
1070 data->temp_offset[nr]); 1071 data->temp_offset[nr]);
1071 up(&data->update_lock); 1072 mutex_unlock(&data->update_lock);
1072 return count; 1073 return count;
1073} 1074}
1074 1075
@@ -1115,11 +1116,11 @@ static ssize_t set_temp_auto_point1_temp(struct device *dev,
1115 struct adm1026_data *data = i2c_get_clientdata(client); 1116 struct adm1026_data *data = i2c_get_clientdata(client);
1116 int val = simple_strtol(buf, NULL, 10); 1117 int val = simple_strtol(buf, NULL, 10);
1117 1118
1118 down(&data->update_lock); 1119 mutex_lock(&data->update_lock);
1119 data->temp_tmin[nr] = TEMP_TO_REG(val); 1120 data->temp_tmin[nr] = TEMP_TO_REG(val);
1120 adm1026_write_value(client, ADM1026_REG_TEMP_TMIN[nr], 1121 adm1026_write_value(client, ADM1026_REG_TEMP_TMIN[nr],
1121 data->temp_tmin[nr]); 1122 data->temp_tmin[nr]);
1122 up(&data->update_lock); 1123 mutex_unlock(&data->update_lock);
1123 return count; 1124 return count;
1124} 1125}
1125 1126
@@ -1150,11 +1151,11 @@ static ssize_t set_temp_crit_enable(struct device *dev,
1150 int val = simple_strtol(buf, NULL, 10); 1151 int val = simple_strtol(buf, NULL, 10);
1151 1152
1152 if ((val == 1) || (val==0)) { 1153 if ((val == 1) || (val==0)) {
1153 down(&data->update_lock); 1154 mutex_lock(&data->update_lock);
1154 data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4); 1155 data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4);
1155 adm1026_write_value(client, ADM1026_REG_CONFIG1, 1156 adm1026_write_value(client, ADM1026_REG_CONFIG1,
1156 data->config1); 1157 data->config1);
1157 up(&data->update_lock); 1158 mutex_unlock(&data->update_lock);
1158 } 1159 }
1159 return count; 1160 return count;
1160} 1161}
@@ -1184,11 +1185,11 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
1184 struct adm1026_data *data = i2c_get_clientdata(client); 1185 struct adm1026_data *data = i2c_get_clientdata(client);
1185 int val = simple_strtol(buf, NULL, 10); 1186 int val = simple_strtol(buf, NULL, 10);
1186 1187
1187 down(&data->update_lock); 1188 mutex_lock(&data->update_lock);
1188 data->temp_crit[nr] = TEMP_TO_REG(val); 1189 data->temp_crit[nr] = TEMP_TO_REG(val);
1189 adm1026_write_value(client, ADM1026_REG_TEMP_THERM[nr], 1190 adm1026_write_value(client, ADM1026_REG_TEMP_THERM[nr],
1190 data->temp_crit[nr]); 1191 data->temp_crit[nr]);
1191 up(&data->update_lock); 1192 mutex_unlock(&data->update_lock);
1192 return count; 1193 return count;
1193} 1194}
1194 1195
@@ -1212,10 +1213,10 @@ static ssize_t set_analog_out_reg(struct device *dev, struct device_attribute *a
1212 struct adm1026_data *data = i2c_get_clientdata(client); 1213 struct adm1026_data *data = i2c_get_clientdata(client);
1213 int val = simple_strtol(buf, NULL, 10); 1214 int val = simple_strtol(buf, NULL, 10);
1214 1215
1215 down(&data->update_lock); 1216 mutex_lock(&data->update_lock);
1216 data->analog_out = DAC_TO_REG(val); 1217 data->analog_out = DAC_TO_REG(val);
1217 adm1026_write_value(client, ADM1026_REG_DAC, data->analog_out); 1218 adm1026_write_value(client, ADM1026_REG_DAC, data->analog_out);
1218 up(&data->update_lock); 1219 mutex_unlock(&data->update_lock);
1219 return count; 1220 return count;
1220} 1221}
1221 1222
@@ -1267,7 +1268,7 @@ static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr,
1267 int val = simple_strtol(buf, NULL, 10); 1268 int val = simple_strtol(buf, NULL, 10);
1268 unsigned long mask; 1269 unsigned long mask;
1269 1270
1270 down(&data->update_lock); 1271 mutex_lock(&data->update_lock);
1271 data->alarm_mask = val & 0x7fffffff; 1272 data->alarm_mask = val & 0x7fffffff;
1272 mask = data->alarm_mask 1273 mask = data->alarm_mask
1273 | (data->gpio_mask & 0x10000 ? 0x80000000 : 0); 1274 | (data->gpio_mask & 0x10000 ? 0x80000000 : 0);
@@ -1282,7 +1283,7 @@ static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr,
1282 mask >>= 8; 1283 mask >>= 8;
1283 adm1026_write_value(client, ADM1026_REG_MASK4, 1284 adm1026_write_value(client, ADM1026_REG_MASK4,
1284 mask & 0xff); 1285 mask & 0xff);
1285 up(&data->update_lock); 1286 mutex_unlock(&data->update_lock);
1286 return count; 1287 return count;
1287} 1288}
1288 1289
@@ -1303,7 +1304,7 @@ static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const
1303 int val = simple_strtol(buf, NULL, 10); 1304 int val = simple_strtol(buf, NULL, 10);
1304 long gpio; 1305 long gpio;
1305 1306
1306 down(&data->update_lock); 1307 mutex_lock(&data->update_lock);
1307 data->gpio = val & 0x1ffff; 1308 data->gpio = val & 0x1ffff;
1308 gpio = data->gpio; 1309 gpio = data->gpio;
1309 adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7,gpio & 0xff); 1310 adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7,gpio & 0xff);
@@ -1311,7 +1312,7 @@ static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const
1311 adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15,gpio & 0xff); 1312 adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15,gpio & 0xff);
1312 gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f); 1313 gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f);
1313 adm1026_write_value(client, ADM1026_REG_STATUS4,gpio & 0xff); 1314 adm1026_write_value(client, ADM1026_REG_STATUS4,gpio & 0xff);
1314 up(&data->update_lock); 1315 mutex_unlock(&data->update_lock);
1315 return count; 1316 return count;
1316} 1317}
1317 1318
@@ -1331,7 +1332,7 @@ static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr,
1331 int val = simple_strtol(buf, NULL, 10); 1332 int val = simple_strtol(buf, NULL, 10);
1332 long mask; 1333 long mask;
1333 1334
1334 down(&data->update_lock); 1335 mutex_lock(&data->update_lock);
1335 data->gpio_mask = val & 0x1ffff; 1336 data->gpio_mask = val & 0x1ffff;
1336 mask = data->gpio_mask; 1337 mask = data->gpio_mask;
1337 adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7,mask & 0xff); 1338 adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7,mask & 0xff);
@@ -1339,7 +1340,7 @@ static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr,
1339 adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15,mask & 0xff); 1340 adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15,mask & 0xff);
1340 mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f); 1341 mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f);
1341 adm1026_write_value(client, ADM1026_REG_MASK1,mask & 0xff); 1342 adm1026_write_value(client, ADM1026_REG_MASK1,mask & 0xff);
1342 up(&data->update_lock); 1343 mutex_unlock(&data->update_lock);
1343 return count; 1344 return count;
1344} 1345}
1345 1346
@@ -1359,10 +1360,10 @@ static ssize_t set_pwm_reg(struct device *dev, struct device_attribute *attr, co
1359 if (data->pwm1.enable == 1) { 1360 if (data->pwm1.enable == 1) {
1360 int val = simple_strtol(buf, NULL, 10); 1361 int val = simple_strtol(buf, NULL, 10);
1361 1362
1362 down(&data->update_lock); 1363 mutex_lock(&data->update_lock);
1363 data->pwm1.pwm = PWM_TO_REG(val); 1364 data->pwm1.pwm = PWM_TO_REG(val);
1364 adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); 1365 adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm);
1365 up(&data->update_lock); 1366 mutex_unlock(&data->update_lock);
1366 } 1367 }
1367 return count; 1368 return count;
1368} 1369}
@@ -1378,14 +1379,14 @@ static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *att
1378 struct adm1026_data *data = i2c_get_clientdata(client); 1379 struct adm1026_data *data = i2c_get_clientdata(client);
1379 int val = simple_strtol(buf, NULL, 10); 1380 int val = simple_strtol(buf, NULL, 10);
1380 1381
1381 down(&data->update_lock); 1382 mutex_lock(&data->update_lock);
1382 data->pwm1.auto_pwm_min = SENSORS_LIMIT(val,0,255); 1383 data->pwm1.auto_pwm_min = SENSORS_LIMIT(val,0,255);
1383 if (data->pwm1.enable == 2) { /* apply immediately */ 1384 if (data->pwm1.enable == 2) { /* apply immediately */
1384 data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | 1385 data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) |
1385 PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); 1386 PWM_MIN_TO_REG(data->pwm1.auto_pwm_min));
1386 adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); 1387 adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm);
1387 } 1388 }
1388 up(&data->update_lock); 1389 mutex_unlock(&data->update_lock);
1389 return count; 1390 return count;
1390} 1391}
1391static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf) 1392static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf)
@@ -1406,7 +1407,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr,
1406 int old_enable; 1407 int old_enable;
1407 1408
1408 if ((val >= 0) && (val < 3)) { 1409 if ((val >= 0) && (val < 3)) {
1409 down(&data->update_lock); 1410 mutex_lock(&data->update_lock);
1410 old_enable = data->pwm1.enable; 1411 old_enable = data->pwm1.enable;
1411 data->pwm1.enable = val; 1412 data->pwm1.enable = val;
1412 data->config1 = (data->config1 & ~CFG1_PWM_AFC) 1413 data->config1 = (data->config1 & ~CFG1_PWM_AFC)
@@ -1424,7 +1425,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr,
1424 adm1026_write_value(client, ADM1026_REG_PWM, 1425 adm1026_write_value(client, ADM1026_REG_PWM,
1425 data->pwm1.pwm); 1426 data->pwm1.pwm);
1426 } 1427 }
1427 up(&data->update_lock); 1428 mutex_unlock(&data->update_lock);
1428 } 1429 }
1429 return count; 1430 return count;
1430} 1431}
@@ -1541,7 +1542,7 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
1541 /* Fill in the remaining client fields */ 1542 /* Fill in the remaining client fields */
1542 data->type = kind; 1543 data->type = kind;
1543 data->valid = 0; 1544 data->valid = 0;
1544 init_MUTEX(&data->update_lock); 1545 mutex_init(&data->update_lock);
1545 1546
1546 /* Tell the I2C layer a new client has arrived */ 1547 /* Tell the I2C layer a new client has arrived */
1547 if ((err = i2c_attach_client(new_client))) 1548 if ((err = i2c_attach_client(new_client)))
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c
index d06397966081..3bf2da621aed 100644
--- a/drivers/hwmon/adm1031.c
+++ b/drivers/hwmon/adm1031.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 32
32/* Following macros takes channel parameter starting from 0 to 2 */ 33/* Following macros takes channel parameter starting from 0 to 2 */
33#define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr)) 34#define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr))
@@ -70,7 +71,7 @@ typedef u8 auto_chan_table_t[8][2];
70struct adm1031_data { 71struct adm1031_data {
71 struct i2c_client client; 72 struct i2c_client client;
72 struct class_device *class_dev; 73 struct class_device *class_dev;
73 struct semaphore update_lock; 74 struct mutex update_lock;
74 int chip_type; 75 int chip_type;
75 char valid; /* !=0 if following fields are valid */ 76 char valid; /* !=0 if following fields are valid */
76 unsigned long last_updated; /* In jiffies */ 77 unsigned long last_updated; /* In jiffies */
@@ -262,10 +263,10 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr)
262 263
263 old_fan_mode = data->conf1; 264 old_fan_mode = data->conf1;
264 265
265 down(&data->update_lock); 266 mutex_lock(&data->update_lock);
266 267
267 if ((ret = get_fan_auto_nearest(data, nr, val, data->conf1, &reg))) { 268 if ((ret = get_fan_auto_nearest(data, nr, val, data->conf1, &reg))) {
268 up(&data->update_lock); 269 mutex_unlock(&data->update_lock);
269 return ret; 270 return ret;
270 } 271 }
271 if (((data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1)) & ADM1031_CONF1_AUTO_MODE) ^ 272 if (((data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1)) & ADM1031_CONF1_AUTO_MODE) ^
@@ -288,7 +289,7 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr)
288 } 289 }
289 data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1); 290 data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1);
290 adm1031_write_value(client, ADM1031_REG_CONF1, data->conf1); 291 adm1031_write_value(client, ADM1031_REG_CONF1, data->conf1);
291 up(&data->update_lock); 292 mutex_unlock(&data->update_lock);
292 return count; 293 return count;
293} 294}
294 295
@@ -329,11 +330,11 @@ set_auto_temp_min(struct device *dev, const char *buf, size_t count, int nr)
329 struct adm1031_data *data = i2c_get_clientdata(client); 330 struct adm1031_data *data = i2c_get_clientdata(client);
330 int val = simple_strtol(buf, NULL, 10); 331 int val = simple_strtol(buf, NULL, 10);
331 332
332 down(&data->update_lock); 333 mutex_lock(&data->update_lock);
333 data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]); 334 data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]);
334 adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), 335 adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr),
335 data->auto_temp[nr]); 336 data->auto_temp[nr]);
336 up(&data->update_lock); 337 mutex_unlock(&data->update_lock);
337 return count; 338 return count;
338} 339}
339static ssize_t show_auto_temp_max(struct device *dev, char *buf, int nr) 340static ssize_t show_auto_temp_max(struct device *dev, char *buf, int nr)
@@ -349,11 +350,11 @@ set_auto_temp_max(struct device *dev, const char *buf, size_t count, int nr)
349 struct adm1031_data *data = i2c_get_clientdata(client); 350 struct adm1031_data *data = i2c_get_clientdata(client);
350 int val = simple_strtol(buf, NULL, 10); 351 int val = simple_strtol(buf, NULL, 10);
351 352
352 down(&data->update_lock); 353 mutex_lock(&data->update_lock);
353 data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr], data->pwm[nr]); 354 data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr], data->pwm[nr]);
354 adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), 355 adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr),
355 data->temp_max[nr]); 356 data->temp_max[nr]);
356 up(&data->update_lock); 357 mutex_unlock(&data->update_lock);
357 return count; 358 return count;
358} 359}
359 360
@@ -405,11 +406,11 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr)
405 int val = simple_strtol(buf, NULL, 10); 406 int val = simple_strtol(buf, NULL, 10);
406 int reg; 407 int reg;
407 408
408 down(&data->update_lock); 409 mutex_lock(&data->update_lock);
409 if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) && 410 if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) &&
410 (((val>>4) & 0xf) != 5)) { 411 (((val>>4) & 0xf) != 5)) {
411 /* In automatic mode, the only PWM accepted is 33% */ 412 /* In automatic mode, the only PWM accepted is 33% */
412 up(&data->update_lock); 413 mutex_unlock(&data->update_lock);
413 return -EINVAL; 414 return -EINVAL;
414 } 415 }
415 data->pwm[nr] = PWM_TO_REG(val); 416 data->pwm[nr] = PWM_TO_REG(val);
@@ -417,7 +418,7 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr)
417 adm1031_write_value(client, ADM1031_REG_PWM, 418 adm1031_write_value(client, ADM1031_REG_PWM,
418 nr ? ((data->pwm[nr] << 4) & 0xf0) | (reg & 0xf) 419 nr ? ((data->pwm[nr] << 4) & 0xf0) | (reg & 0xf)
419 : (data->pwm[nr] & 0xf) | (reg & 0xf0)); 420 : (data->pwm[nr] & 0xf) | (reg & 0xf0));
420 up(&data->update_lock); 421 mutex_unlock(&data->update_lock);
421 return count; 422 return count;
422} 423}
423 424
@@ -511,7 +512,7 @@ set_fan_min(struct device *dev, const char *buf, size_t count, int nr)
511 struct adm1031_data *data = i2c_get_clientdata(client); 512 struct adm1031_data *data = i2c_get_clientdata(client);
512 int val = simple_strtol(buf, NULL, 10); 513 int val = simple_strtol(buf, NULL, 10);
513 514
514 down(&data->update_lock); 515 mutex_lock(&data->update_lock);
515 if (val) { 516 if (val) {
516 data->fan_min[nr] = 517 data->fan_min[nr] =
517 FAN_TO_REG(val, FAN_DIV_FROM_REG(data->fan_div[nr])); 518 FAN_TO_REG(val, FAN_DIV_FROM_REG(data->fan_div[nr]));
@@ -519,7 +520,7 @@ set_fan_min(struct device *dev, const char *buf, size_t count, int nr)
519 data->fan_min[nr] = 0xff; 520 data->fan_min[nr] = 0xff;
520 } 521 }
521 adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), data->fan_min[nr]); 522 adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), data->fan_min[nr]);
522 up(&data->update_lock); 523 mutex_unlock(&data->update_lock);
523 return count; 524 return count;
524} 525}
525static ssize_t 526static ssize_t
@@ -540,7 +541,7 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr)
540 if (tmp == 0xff) 541 if (tmp == 0xff)
541 return -EINVAL; 542 return -EINVAL;
542 543
543 down(&data->update_lock); 544 mutex_lock(&data->update_lock);
544 old_div = FAN_DIV_FROM_REG(data->fan_div[nr]); 545 old_div = FAN_DIV_FROM_REG(data->fan_div[nr]);
545 data->fan_div[nr] = (tmp & 0xC0) | (0x3f & data->fan_div[nr]); 546 data->fan_div[nr] = (tmp & 0xC0) | (0x3f & data->fan_div[nr]);
546 new_min = data->fan_min[nr] * old_div / 547 new_min = data->fan_min[nr] * old_div /
@@ -553,7 +554,7 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr)
553 data->fan_div[nr]); 554 data->fan_div[nr]);
554 adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), 555 adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr),
555 data->fan_min[nr]); 556 data->fan_min[nr]);
556 up(&data->update_lock); 557 mutex_unlock(&data->update_lock);
557 return count; 558 return count;
558} 559}
559 560
@@ -627,11 +628,11 @@ set_temp_min(struct device *dev, const char *buf, size_t count, int nr)
627 628
628 val = simple_strtol(buf, NULL, 10); 629 val = simple_strtol(buf, NULL, 10);
629 val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); 630 val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875);
630 down(&data->update_lock); 631 mutex_lock(&data->update_lock);
631 data->temp_min[nr] = TEMP_TO_REG(val); 632 data->temp_min[nr] = TEMP_TO_REG(val);
632 adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr), 633 adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr),
633 data->temp_min[nr]); 634 data->temp_min[nr]);
634 up(&data->update_lock); 635 mutex_unlock(&data->update_lock);
635 return count; 636 return count;
636} 637}
637static ssize_t 638static ssize_t
@@ -643,11 +644,11 @@ set_temp_max(struct device *dev, const char *buf, size_t count, int nr)
643 644
644 val = simple_strtol(buf, NULL, 10); 645 val = simple_strtol(buf, NULL, 10);
645 val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); 646 val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875);
646 down(&data->update_lock); 647 mutex_lock(&data->update_lock);
647 data->temp_max[nr] = TEMP_TO_REG(val); 648 data->temp_max[nr] = TEMP_TO_REG(val);
648 adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr), 649 adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr),
649 data->temp_max[nr]); 650 data->temp_max[nr]);
650 up(&data->update_lock); 651 mutex_unlock(&data->update_lock);
651 return count; 652 return count;
652} 653}
653static ssize_t 654static ssize_t
@@ -659,11 +660,11 @@ set_temp_crit(struct device *dev, const char *buf, size_t count, int nr)
659 660
660 val = simple_strtol(buf, NULL, 10); 661 val = simple_strtol(buf, NULL, 10);
661 val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); 662 val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875);
662 down(&data->update_lock); 663 mutex_lock(&data->update_lock);
663 data->temp_crit[nr] = TEMP_TO_REG(val); 664 data->temp_crit[nr] = TEMP_TO_REG(val);
664 adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr), 665 adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr),
665 data->temp_crit[nr]); 666 data->temp_crit[nr]);
666 up(&data->update_lock); 667 mutex_unlock(&data->update_lock);
667 return count; 668 return count;
668} 669}
669 670
@@ -778,7 +779,7 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
778 779
779 strlcpy(new_client->name, name, I2C_NAME_SIZE); 780 strlcpy(new_client->name, name, I2C_NAME_SIZE);
780 data->valid = 0; 781 data->valid = 0;
781 init_MUTEX(&data->update_lock); 782 mutex_init(&data->update_lock);
782 783
783 /* Tell the I2C layer a new client has arrived */ 784 /* Tell the I2C layer a new client has arrived */
784 if ((err = i2c_attach_client(new_client))) 785 if ((err = i2c_attach_client(new_client)))
@@ -891,7 +892,7 @@ static struct adm1031_data *adm1031_update_device(struct device *dev)
891 struct adm1031_data *data = i2c_get_clientdata(client); 892 struct adm1031_data *data = i2c_get_clientdata(client);
892 int chan; 893 int chan;
893 894
894 down(&data->update_lock); 895 mutex_lock(&data->update_lock);
895 896
896 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 897 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
897 || !data->valid) { 898 || !data->valid) {
@@ -965,7 +966,7 @@ static struct adm1031_data *adm1031_update_device(struct device *dev)
965 data->valid = 1; 966 data->valid = 1;
966 } 967 }
967 968
968 up(&data->update_lock); 969 mutex_unlock(&data->update_lock);
969 970
970 return data; 971 return data;
971} 972}
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
index 5ddc22fea4a3..43f6991b588c 100644
--- a/drivers/hwmon/adm9240.c
+++ b/drivers/hwmon/adm9240.c
@@ -49,6 +49,7 @@
49#include <linux/hwmon.h> 49#include <linux/hwmon.h>
50#include <linux/hwmon-vid.h> 50#include <linux/hwmon-vid.h>
51#include <linux/err.h> 51#include <linux/err.h>
52#include <linux/mutex.h>
52 53
53/* Addresses to scan */ 54/* Addresses to scan */
54static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, 55static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
@@ -150,7 +151,7 @@ struct adm9240_data {
150 enum chips type; 151 enum chips type;
151 struct i2c_client client; 152 struct i2c_client client;
152 struct class_device *class_dev; 153 struct class_device *class_dev;
153 struct semaphore update_lock; 154 struct mutex update_lock;
154 char valid; 155 char valid;
155 unsigned long last_updated_measure; 156 unsigned long last_updated_measure;
156 unsigned long last_updated_config; 157 unsigned long last_updated_config;
@@ -195,11 +196,11 @@ static ssize_t set_max(struct device *dev, struct device_attribute *devattr,
195 struct adm9240_data *data = i2c_get_clientdata(client); 196 struct adm9240_data *data = i2c_get_clientdata(client);
196 long val = simple_strtol(buf, NULL, 10); 197 long val = simple_strtol(buf, NULL, 10);
197 198
198 down(&data->update_lock); 199 mutex_lock(&data->update_lock);
199 data->temp_max[attr->index] = TEMP_TO_REG(val); 200 data->temp_max[attr->index] = TEMP_TO_REG(val);
200 i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index), 201 i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index),
201 data->temp_max[attr->index]); 202 data->temp_max[attr->index]);
202 up(&data->update_lock); 203 mutex_unlock(&data->update_lock);
203 return count; 204 return count;
204} 205}
205 206
@@ -246,11 +247,11 @@ static ssize_t set_in_min(struct device *dev,
246 struct adm9240_data *data = i2c_get_clientdata(client); 247 struct adm9240_data *data = i2c_get_clientdata(client);
247 unsigned long val = simple_strtoul(buf, NULL, 10); 248 unsigned long val = simple_strtoul(buf, NULL, 10);
248 249
249 down(&data->update_lock); 250 mutex_lock(&data->update_lock);
250 data->in_min[attr->index] = IN_TO_REG(val, attr->index); 251 data->in_min[attr->index] = IN_TO_REG(val, attr->index);
251 i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index), 252 i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index),
252 data->in_min[attr->index]); 253 data->in_min[attr->index]);
253 up(&data->update_lock); 254 mutex_unlock(&data->update_lock);
254 return count; 255 return count;
255} 256}
256 257
@@ -263,11 +264,11 @@ static ssize_t set_in_max(struct device *dev,
263 struct adm9240_data *data = i2c_get_clientdata(client); 264 struct adm9240_data *data = i2c_get_clientdata(client);
264 unsigned long val = simple_strtoul(buf, NULL, 10); 265 unsigned long val = simple_strtoul(buf, NULL, 10);
265 266
266 down(&data->update_lock); 267 mutex_lock(&data->update_lock);
267 data->in_max[attr->index] = IN_TO_REG(val, attr->index); 268 data->in_max[attr->index] = IN_TO_REG(val, attr->index);
268 i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index), 269 i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index),
269 data->in_max[attr->index]); 270 data->in_max[attr->index]);
270 up(&data->update_lock); 271 mutex_unlock(&data->update_lock);
271 return count; 272 return count;
272} 273}
273 274
@@ -350,7 +351,7 @@ static ssize_t set_fan_min(struct device *dev,
350 int nr = attr->index; 351 int nr = attr->index;
351 u8 new_div; 352 u8 new_div;
352 353
353 down(&data->update_lock); 354 mutex_lock(&data->update_lock);
354 355
355 if (!val) { 356 if (!val) {
356 data->fan_min[nr] = 255; 357 data->fan_min[nr] = 255;
@@ -390,7 +391,7 @@ static ssize_t set_fan_min(struct device *dev,
390 i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr), 391 i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr),
391 data->fan_min[nr]); 392 data->fan_min[nr]);
392 393
393 up(&data->update_lock); 394 mutex_unlock(&data->update_lock);
394 return count; 395 return count;
395} 396}
396 397
@@ -439,10 +440,10 @@ static ssize_t set_aout(struct device *dev,
439 struct adm9240_data *data = i2c_get_clientdata(client); 440 struct adm9240_data *data = i2c_get_clientdata(client);
440 unsigned long val = simple_strtol(buf, NULL, 10); 441 unsigned long val = simple_strtol(buf, NULL, 10);
441 442
442 down(&data->update_lock); 443 mutex_lock(&data->update_lock);
443 data->aout = AOUT_TO_REG(val); 444 data->aout = AOUT_TO_REG(val);
444 i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout); 445 i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout);
445 up(&data->update_lock); 446 mutex_unlock(&data->update_lock);
446 return count; 447 return count;
447} 448}
448static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); 449static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);
@@ -539,7 +540,7 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
539 /* fill in the remaining client fields and attach */ 540 /* fill in the remaining client fields and attach */
540 strlcpy(new_client->name, name, I2C_NAME_SIZE); 541 strlcpy(new_client->name, name, I2C_NAME_SIZE);
541 data->type = kind; 542 data->type = kind;
542 init_MUTEX(&data->update_lock); 543 mutex_init(&data->update_lock);
543 544
544 if ((err = i2c_attach_client(new_client))) 545 if ((err = i2c_attach_client(new_client)))
545 goto exit_free; 546 goto exit_free;
@@ -691,7 +692,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
691 struct adm9240_data *data = i2c_get_clientdata(client); 692 struct adm9240_data *data = i2c_get_clientdata(client);
692 int i; 693 int i;
693 694
694 down(&data->update_lock); 695 mutex_lock(&data->update_lock);
695 696
696 /* minimum measurement cycle: 1.75 seconds */ 697 /* minimum measurement cycle: 1.75 seconds */
697 if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4)) 698 if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4))
@@ -771,7 +772,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
771 data->last_updated_config = jiffies; 772 data->last_updated_config = jiffies;
772 data->valid = 1; 773 data->valid = 1;
773 } 774 }
774 up(&data->update_lock); 775 mutex_unlock(&data->update_lock);
775 return data; 776 return data;
776} 777}
777 778
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c
index ae9de63cf2e0..65b2709f750c 100644
--- a/drivers/hwmon/asb100.c
+++ b/drivers/hwmon/asb100.c
@@ -44,6 +44,7 @@
44#include <linux/err.h> 44#include <linux/err.h>
45#include <linux/init.h> 45#include <linux/init.h>
46#include <linux/jiffies.h> 46#include <linux/jiffies.h>
47#include <linux/mutex.h>
47#include "lm75.h" 48#include "lm75.h"
48 49
49/* 50/*
@@ -182,10 +183,10 @@ static u8 DIV_TO_REG(long val)
182struct asb100_data { 183struct asb100_data {
183 struct i2c_client client; 184 struct i2c_client client;
184 struct class_device *class_dev; 185 struct class_device *class_dev;
185 struct semaphore lock; 186 struct mutex lock;
186 enum chips type; 187 enum chips type;
187 188
188 struct semaphore update_lock; 189 struct mutex update_lock;
189 unsigned long last_updated; /* In jiffies */ 190 unsigned long last_updated; /* In jiffies */
190 191
191 /* array of 2 pointers to subclients */ 192 /* array of 2 pointers to subclients */
@@ -245,11 +246,11 @@ static ssize_t set_in_##reg(struct device *dev, const char *buf, \
245 struct asb100_data *data = i2c_get_clientdata(client); \ 246 struct asb100_data *data = i2c_get_clientdata(client); \
246 unsigned long val = simple_strtoul(buf, NULL, 10); \ 247 unsigned long val = simple_strtoul(buf, NULL, 10); \
247 \ 248 \
248 down(&data->update_lock); \ 249 mutex_lock(&data->update_lock); \
249 data->in_##reg[nr] = IN_TO_REG(val); \ 250 data->in_##reg[nr] = IN_TO_REG(val); \
250 asb100_write_value(client, ASB100_REG_IN_##REG(nr), \ 251 asb100_write_value(client, ASB100_REG_IN_##REG(nr), \
251 data->in_##reg[nr]); \ 252 data->in_##reg[nr]); \
252 up(&data->update_lock); \ 253 mutex_unlock(&data->update_lock); \
253 return count; \ 254 return count; \
254} 255}
255 256
@@ -331,10 +332,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
331 struct asb100_data *data = i2c_get_clientdata(client); 332 struct asb100_data *data = i2c_get_clientdata(client);
332 u32 val = simple_strtoul(buf, NULL, 10); 333 u32 val = simple_strtoul(buf, NULL, 10);
333 334
334 down(&data->update_lock); 335 mutex_lock(&data->update_lock);
335 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 336 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
336 asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); 337 asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]);
337 up(&data->update_lock); 338 mutex_unlock(&data->update_lock);
338 return count; 339 return count;
339} 340}
340 341
@@ -351,7 +352,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
351 unsigned long val = simple_strtoul(buf, NULL, 10); 352 unsigned long val = simple_strtoul(buf, NULL, 10);
352 int reg; 353 int reg;
353 354
354 down(&data->update_lock); 355 mutex_lock(&data->update_lock);
355 356
356 min = FAN_FROM_REG(data->fan_min[nr], 357 min = FAN_FROM_REG(data->fan_min[nr],
357 DIV_FROM_REG(data->fan_div[nr])); 358 DIV_FROM_REG(data->fan_div[nr]));
@@ -381,7 +382,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
381 FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 382 FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
382 asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); 383 asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]);
383 384
384 up(&data->update_lock); 385 mutex_unlock(&data->update_lock);
385 386
386 return count; 387 return count;
387} 388}
@@ -461,7 +462,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \
461 struct asb100_data *data = i2c_get_clientdata(client); \ 462 struct asb100_data *data = i2c_get_clientdata(client); \
462 unsigned long val = simple_strtoul(buf, NULL, 10); \ 463 unsigned long val = simple_strtoul(buf, NULL, 10); \
463 \ 464 \
464 down(&data->update_lock); \ 465 mutex_lock(&data->update_lock); \
465 switch (nr) { \ 466 switch (nr) { \
466 case 1: case 2: \ 467 case 1: case 2: \
467 data->reg[nr] = LM75_TEMP_TO_REG(val); \ 468 data->reg[nr] = LM75_TEMP_TO_REG(val); \
@@ -472,7 +473,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \
472 } \ 473 } \
473 asb100_write_value(client, ASB100_REG_TEMP_##REG(nr+1), \ 474 asb100_write_value(client, ASB100_REG_TEMP_##REG(nr+1), \
474 data->reg[nr]); \ 475 data->reg[nr]); \
475 up(&data->update_lock); \ 476 mutex_unlock(&data->update_lock); \
476 return count; \ 477 return count; \
477} 478}
478 479
@@ -574,11 +575,11 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const
574 struct asb100_data *data = i2c_get_clientdata(client); 575 struct asb100_data *data = i2c_get_clientdata(client);
575 unsigned long val = simple_strtoul(buf, NULL, 10); 576 unsigned long val = simple_strtoul(buf, NULL, 10);
576 577
577 down(&data->update_lock); 578 mutex_lock(&data->update_lock);
578 data->pwm &= 0x80; /* keep the enable bit */ 579 data->pwm &= 0x80; /* keep the enable bit */
579 data->pwm |= (0x0f & ASB100_PWM_TO_REG(val)); 580 data->pwm |= (0x0f & ASB100_PWM_TO_REG(val));
580 asb100_write_value(client, ASB100_REG_PWM1, data->pwm); 581 asb100_write_value(client, ASB100_REG_PWM1, data->pwm);
581 up(&data->update_lock); 582 mutex_unlock(&data->update_lock);
582 return count; 583 return count;
583} 584}
584 585
@@ -595,11 +596,11 @@ static ssize_t set_pwm_enable1(struct device *dev, struct device_attribute *attr
595 struct asb100_data *data = i2c_get_clientdata(client); 596 struct asb100_data *data = i2c_get_clientdata(client);
596 unsigned long val = simple_strtoul(buf, NULL, 10); 597 unsigned long val = simple_strtoul(buf, NULL, 10);
597 598
598 down(&data->update_lock); 599 mutex_lock(&data->update_lock);
599 data->pwm &= 0x0f; /* keep the duty cycle bits */ 600 data->pwm &= 0x0f; /* keep the duty cycle bits */
600 data->pwm |= (val ? 0x80 : 0x00); 601 data->pwm |= (val ? 0x80 : 0x00);
601 asb100_write_value(client, ASB100_REG_PWM1, data->pwm); 602 asb100_write_value(client, ASB100_REG_PWM1, data->pwm);
602 up(&data->update_lock); 603 mutex_unlock(&data->update_lock);
603 return count; 604 return count;
604} 605}
605 606
@@ -729,7 +730,7 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
729 } 730 }
730 731
731 new_client = &data->client; 732 new_client = &data->client;
732 init_MUTEX(&data->lock); 733 mutex_init(&data->lock);
733 i2c_set_clientdata(new_client, data); 734 i2c_set_clientdata(new_client, data);
734 new_client->addr = address; 735 new_client->addr = address;
735 new_client->adapter = adapter; 736 new_client->adapter = adapter;
@@ -789,7 +790,7 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
789 data->type = kind; 790 data->type = kind;
790 791
791 data->valid = 0; 792 data->valid = 0;
792 init_MUTEX(&data->update_lock); 793 mutex_init(&data->update_lock);
793 794
794 /* Tell the I2C layer a new client has arrived */ 795 /* Tell the I2C layer a new client has arrived */
795 if ((err = i2c_attach_client(new_client))) 796 if ((err = i2c_attach_client(new_client)))
@@ -885,7 +886,7 @@ static int asb100_read_value(struct i2c_client *client, u16 reg)
885 struct i2c_client *cl; 886 struct i2c_client *cl;
886 int res, bank; 887 int res, bank;
887 888
888 down(&data->lock); 889 mutex_lock(&data->lock);
889 890
890 bank = (reg >> 8) & 0x0f; 891 bank = (reg >> 8) & 0x0f;
891 if (bank > 2) 892 if (bank > 2)
@@ -919,7 +920,7 @@ static int asb100_read_value(struct i2c_client *client, u16 reg)
919 if (bank > 2) 920 if (bank > 2)
920 i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); 921 i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0);
921 922
922 up(&data->lock); 923 mutex_unlock(&data->lock);
923 924
924 return res; 925 return res;
925} 926}
@@ -930,7 +931,7 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
930 struct i2c_client *cl; 931 struct i2c_client *cl;
931 int bank; 932 int bank;
932 933
933 down(&data->lock); 934 mutex_lock(&data->lock);
934 935
935 bank = (reg >> 8) & 0x0f; 936 bank = (reg >> 8) & 0x0f;
936 if (bank > 2) 937 if (bank > 2)
@@ -960,7 +961,7 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
960 if (bank > 2) 961 if (bank > 2)
961 i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); 962 i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0);
962 963
963 up(&data->lock); 964 mutex_unlock(&data->lock);
964} 965}
965 966
966static void asb100_init_client(struct i2c_client *client) 967static void asb100_init_client(struct i2c_client *client)
@@ -984,7 +985,7 @@ static struct asb100_data *asb100_update_device(struct device *dev)
984 struct asb100_data *data = i2c_get_clientdata(client); 985 struct asb100_data *data = i2c_get_clientdata(client);
985 int i; 986 int i;
986 987
987 down(&data->update_lock); 988 mutex_lock(&data->update_lock);
988 989
989 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 990 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
990 || !data->valid) { 991 || !data->valid) {
@@ -1042,7 +1043,7 @@ static struct asb100_data *asb100_update_device(struct device *dev)
1042 dev_dbg(&client->dev, "... device update complete\n"); 1043 dev_dbg(&client->dev, "... device update complete\n");
1043 } 1044 }
1044 1045
1045 up(&data->update_lock); 1046 mutex_unlock(&data->update_lock);
1046 1047
1047 return data; 1048 return data;
1048} 1049}
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c
index b0c490073c8e..728a1e8b9190 100644
--- a/drivers/hwmon/atxp1.c
+++ b/drivers/hwmon/atxp1.c
@@ -26,6 +26,7 @@
26#include <linux/hwmon.h> 26#include <linux/hwmon.h>
27#include <linux/hwmon-vid.h> 27#include <linux/hwmon-vid.h>
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/mutex.h>
29 30
30MODULE_LICENSE("GPL"); 31MODULE_LICENSE("GPL");
31MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); 32MODULE_DESCRIPTION("System voltages control via Attansic ATXP1");
@@ -60,7 +61,7 @@ static struct i2c_driver atxp1_driver = {
60struct atxp1_data { 61struct atxp1_data {
61 struct i2c_client client; 62 struct i2c_client client;
62 struct class_device *class_dev; 63 struct class_device *class_dev;
63 struct semaphore update_lock; 64 struct mutex update_lock;
64 unsigned long last_updated; 65 unsigned long last_updated;
65 u8 valid; 66 u8 valid;
66 struct { 67 struct {
@@ -80,7 +81,7 @@ static struct atxp1_data * atxp1_update_device(struct device *dev)
80 client = to_i2c_client(dev); 81 client = to_i2c_client(dev);
81 data = i2c_get_clientdata(client); 82 data = i2c_get_clientdata(client);
82 83
83 down(&data->update_lock); 84 mutex_lock(&data->update_lock);
84 85
85 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { 86 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
86 87
@@ -93,7 +94,7 @@ static struct atxp1_data * atxp1_update_device(struct device *dev)
93 data->valid = 1; 94 data->valid = 1;
94 } 95 }
95 96
96 up(&data->update_lock); 97 mutex_unlock(&data->update_lock);
97 98
98 return(data); 99 return(data);
99} 100}
@@ -309,7 +310,7 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
309 310
310 data->valid = 0; 311 data->valid = 0;
311 312
312 init_MUTEX(&data->update_lock); 313 mutex_init(&data->update_lock);
313 314
314 err = i2c_attach_client(new_client); 315 err = i2c_attach_client(new_client);
315 316
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")
72struct ds1621_data { 73struct 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}
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c
index 25409181d1eb..6bc76b407636 100644
--- a/drivers/hwmon/fscher.c
+++ b/drivers/hwmon/fscher.c
@@ -33,6 +33,7 @@
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <linux/hwmon.h> 34#include <linux/hwmon.h>
35#include <linux/err.h> 35#include <linux/err.h>
36#include <linux/mutex.h>
36 37
37/* 38/*
38 * Addresses to scan 39 * Addresses to scan
@@ -133,7 +134,7 @@ static struct i2c_driver fscher_driver = {
133struct fscher_data { 134struct fscher_data {
134 struct i2c_client client; 135 struct i2c_client client;
135 struct class_device *class_dev; 136 struct class_device *class_dev;
136 struct semaphore update_lock; 137 struct mutex update_lock;
137 char valid; /* zero until following fields are valid */ 138 char valid; /* zero until following fields are valid */
138 unsigned long last_updated; /* in jiffies */ 139 unsigned long last_updated; /* in jiffies */
139 140
@@ -332,7 +333,7 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
332 * global list */ 333 * global list */
333 strlcpy(new_client->name, "fscher", I2C_NAME_SIZE); 334 strlcpy(new_client->name, "fscher", I2C_NAME_SIZE);
334 data->valid = 0; 335 data->valid = 0;
335 init_MUTEX(&data->update_lock); 336 mutex_init(&data->update_lock);
336 337
337 /* Tell the I2C layer a new client has arrived */ 338 /* Tell the I2C layer a new client has arrived */
338 if ((err = i2c_attach_client(new_client))) 339 if ((err = i2c_attach_client(new_client)))
@@ -417,7 +418,7 @@ static struct fscher_data *fscher_update_device(struct device *dev)
417 struct i2c_client *client = to_i2c_client(dev); 418 struct i2c_client *client = to_i2c_client(dev);
418 struct fscher_data *data = i2c_get_clientdata(client); 419 struct fscher_data *data = i2c_get_clientdata(client);
419 420
420 down(&data->update_lock); 421 mutex_lock(&data->update_lock);
421 422
422 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { 423 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
423 424
@@ -457,7 +458,7 @@ static struct fscher_data *fscher_update_device(struct device *dev)
457 data->valid = 1; 458 data->valid = 1;
458 } 459 }
459 460
460 up(&data->update_lock); 461 mutex_unlock(&data->update_lock);
461 462
462 return data; 463 return data;
463} 464}
@@ -472,10 +473,10 @@ static ssize_t set_fan_status(struct i2c_client *client, struct fscher_data *dat
472 /* bits 0..1, 3..7 reserved => mask with 0x04 */ 473 /* bits 0..1, 3..7 reserved => mask with 0x04 */
473 unsigned long v = simple_strtoul(buf, NULL, 10) & 0x04; 474 unsigned long v = simple_strtoul(buf, NULL, 10) & 0x04;
474 475
475 down(&data->update_lock); 476 mutex_lock(&data->update_lock);
476 data->fan_status[FAN_INDEX_FROM_NUM(nr)] &= ~v; 477 data->fan_status[FAN_INDEX_FROM_NUM(nr)] &= ~v;
477 fscher_write_value(client, reg, v); 478 fscher_write_value(client, reg, v);
478 up(&data->update_lock); 479 mutex_unlock(&data->update_lock);
479 return count; 480 return count;
480} 481}
481 482
@@ -490,10 +491,10 @@ static ssize_t set_pwm(struct i2c_client *client, struct fscher_data *data,
490{ 491{
491 unsigned long v = simple_strtoul(buf, NULL, 10); 492 unsigned long v = simple_strtoul(buf, NULL, 10);
492 493
493 down(&data->update_lock); 494 mutex_lock(&data->update_lock);
494 data->fan_min[FAN_INDEX_FROM_NUM(nr)] = v > 0xff ? 0xff : v; 495 data->fan_min[FAN_INDEX_FROM_NUM(nr)] = v > 0xff ? 0xff : v;
495 fscher_write_value(client, reg, data->fan_min[FAN_INDEX_FROM_NUM(nr)]); 496 fscher_write_value(client, reg, data->fan_min[FAN_INDEX_FROM_NUM(nr)]);
496 up(&data->update_lock); 497 mutex_unlock(&data->update_lock);
497 return count; 498 return count;
498} 499}
499 500
@@ -518,14 +519,14 @@ static ssize_t set_fan_div(struct i2c_client *client, struct fscher_data *data,
518 return -EINVAL; 519 return -EINVAL;
519 } 520 }
520 521
521 down(&data->update_lock); 522 mutex_lock(&data->update_lock);
522 523
523 /* bits 2..7 reserved => mask with 0x03 */ 524 /* bits 2..7 reserved => mask with 0x03 */
524 data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] &= ~0x03; 525 data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] &= ~0x03;
525 data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] |= v; 526 data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] |= v;
526 527
527 fscher_write_value(client, reg, data->fan_ripple[FAN_INDEX_FROM_NUM(nr)]); 528 fscher_write_value(client, reg, data->fan_ripple[FAN_INDEX_FROM_NUM(nr)]);
528 up(&data->update_lock); 529 mutex_unlock(&data->update_lock);
529 return count; 530 return count;
530} 531}
531 532
@@ -552,10 +553,10 @@ static ssize_t set_temp_status(struct i2c_client *client, struct fscher_data *da
552 /* bits 2..7 reserved, 0 read only => mask with 0x02 */ 553 /* bits 2..7 reserved, 0 read only => mask with 0x02 */
553 unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02; 554 unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02;
554 555
555 down(&data->update_lock); 556 mutex_lock(&data->update_lock);
556 data->temp_status[TEMP_INDEX_FROM_NUM(nr)] &= ~v; 557 data->temp_status[TEMP_INDEX_FROM_NUM(nr)] &= ~v;
557 fscher_write_value(client, reg, v); 558 fscher_write_value(client, reg, v);
558 up(&data->update_lock); 559 mutex_unlock(&data->update_lock);
559 return count; 560 return count;
560} 561}
561 562
@@ -609,10 +610,10 @@ static ssize_t set_control(struct i2c_client *client, struct fscher_data *data,
609 /* bits 1..7 reserved => mask with 0x01 */ 610 /* bits 1..7 reserved => mask with 0x01 */
610 unsigned long v = simple_strtoul(buf, NULL, 10) & 0x01; 611 unsigned long v = simple_strtoul(buf, NULL, 10) & 0x01;
611 612
612 down(&data->update_lock); 613 mutex_lock(&data->update_lock);
613 data->global_control &= ~v; 614 data->global_control &= ~v;
614 fscher_write_value(client, reg, v); 615 fscher_write_value(client, reg, v);
615 up(&data->update_lock); 616 mutex_unlock(&data->update_lock);
616 return count; 617 return count;
617} 618}
618 619
@@ -631,11 +632,11 @@ static ssize_t set_watchdog_control(struct i2c_client *client, struct
631 /* bits 0..3 reserved => mask with 0xf0 */ 632 /* bits 0..3 reserved => mask with 0xf0 */
632 unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; 633 unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0;
633 634
634 down(&data->update_lock); 635 mutex_lock(&data->update_lock);
635 data->watchdog[2] &= ~0xf0; 636 data->watchdog[2] &= ~0xf0;
636 data->watchdog[2] |= v; 637 data->watchdog[2] |= v;
637 fscher_write_value(client, reg, data->watchdog[2]); 638 fscher_write_value(client, reg, data->watchdog[2]);
638 up(&data->update_lock); 639 mutex_unlock(&data->update_lock);
639 return count; 640 return count;
640} 641}
641 642
@@ -651,10 +652,10 @@ static ssize_t set_watchdog_status(struct i2c_client *client, struct fscher_data
651 /* bits 0, 2..7 reserved => mask with 0x02 */ 652 /* bits 0, 2..7 reserved => mask with 0x02 */
652 unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02; 653 unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02;
653 654
654 down(&data->update_lock); 655 mutex_lock(&data->update_lock);
655 data->watchdog[1] &= ~v; 656 data->watchdog[1] &= ~v;
656 fscher_write_value(client, reg, v); 657 fscher_write_value(client, reg, v);
657 up(&data->update_lock); 658 mutex_unlock(&data->update_lock);
658 return count; 659 return count;
659} 660}
660 661
@@ -669,10 +670,10 @@ static ssize_t set_watchdog_preset(struct i2c_client *client, struct fscher_data
669{ 670{
670 unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; 671 unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff;
671 672
672 down(&data->update_lock); 673 mutex_lock(&data->update_lock);
673 data->watchdog[0] = v; 674 data->watchdog[0] = v;
674 fscher_write_value(client, reg, data->watchdog[0]); 675 fscher_write_value(client, reg, data->watchdog[0]);
675 up(&data->update_lock); 676 mutex_unlock(&data->update_lock);
676 return count; 677 return count;
677} 678}
678 679
diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c
index 6d0146b57020..758978e1bfe0 100644
--- a/drivers/hwmon/fscpos.c
+++ b/drivers/hwmon/fscpos.c
@@ -37,6 +37,7 @@
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/hwmon.h> 38#include <linux/hwmon.h>
39#include <linux/err.h> 39#include <linux/err.h>
40#include <linux/mutex.h>
40 41
41/* 42/*
42 * Addresses to scan 43 * Addresses to scan
@@ -114,7 +115,7 @@ static struct i2c_driver fscpos_driver = {
114struct fscpos_data { 115struct fscpos_data {
115 struct i2c_client client; 116 struct i2c_client client;
116 struct class_device *class_dev; 117 struct class_device *class_dev;
117 struct semaphore update_lock; 118 struct mutex update_lock;
118 char valid; /* 0 until following fields are valid */ 119 char valid; /* 0 until following fields are valid */
119 unsigned long last_updated; /* In jiffies */ 120 unsigned long last_updated; /* In jiffies */
120 121
@@ -208,13 +209,13 @@ static ssize_t set_fan_ripple(struct i2c_client *client, struct fscpos_data
208 return -EINVAL; 209 return -EINVAL;
209 } 210 }
210 211
211 down(&data->update_lock); 212 mutex_lock(&data->update_lock);
212 /* bits 2..7 reserved => mask with 0x03 */ 213 /* bits 2..7 reserved => mask with 0x03 */
213 data->fan_ripple[nr - 1] &= ~0x03; 214 data->fan_ripple[nr - 1] &= ~0x03;
214 data->fan_ripple[nr - 1] |= v; 215 data->fan_ripple[nr - 1] |= v;
215 216
216 fscpos_write_value(client, reg, data->fan_ripple[nr - 1]); 217 fscpos_write_value(client, reg, data->fan_ripple[nr - 1]);
217 up(&data->update_lock); 218 mutex_unlock(&data->update_lock);
218 return count; 219 return count;
219} 220}
220 221
@@ -232,10 +233,10 @@ static ssize_t set_pwm(struct i2c_client *client, struct fscpos_data *data,
232 if (v < 0) v = 0; 233 if (v < 0) v = 0;
233 if (v > 255) v = 255; 234 if (v > 255) v = 255;
234 235
235 down(&data->update_lock); 236 mutex_lock(&data->update_lock);
236 data->pwm[nr - 1] = v; 237 data->pwm[nr - 1] = v;
237 fscpos_write_value(client, reg, data->pwm[nr - 1]); 238 fscpos_write_value(client, reg, data->pwm[nr - 1]);
238 up(&data->update_lock); 239 mutex_unlock(&data->update_lock);
239 return count; 240 return count;
240} 241}
241 242
@@ -278,11 +279,11 @@ static ssize_t set_wdog_control(struct i2c_client *client, struct fscpos_data
278 /* bits 0..3 reserved => mask with 0xf0 */ 279 /* bits 0..3 reserved => mask with 0xf0 */
279 unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; 280 unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0;
280 281
281 down(&data->update_lock); 282 mutex_lock(&data->update_lock);
282 data->wdog_control &= ~0xf0; 283 data->wdog_control &= ~0xf0;
283 data->wdog_control |= v; 284 data->wdog_control |= v;
284 fscpos_write_value(client, reg, data->wdog_control); 285 fscpos_write_value(client, reg, data->wdog_control);
285 up(&data->update_lock); 286 mutex_unlock(&data->update_lock);
286 return count; 287 return count;
287} 288}
288 289
@@ -304,10 +305,10 @@ static ssize_t set_wdog_state(struct i2c_client *client, struct fscpos_data
304 return -EINVAL; 305 return -EINVAL;
305 } 306 }
306 307
307 down(&data->update_lock); 308 mutex_lock(&data->update_lock);
308 data->wdog_state &= ~v; 309 data->wdog_state &= ~v;
309 fscpos_write_value(client, reg, v); 310 fscpos_write_value(client, reg, v);
310 up(&data->update_lock); 311 mutex_unlock(&data->update_lock);
311 return count; 312 return count;
312} 313}
313 314
@@ -321,10 +322,10 @@ static ssize_t set_wdog_preset(struct i2c_client *client, struct fscpos_data
321{ 322{
322 unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; 323 unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff;
323 324
324 down(&data->update_lock); 325 mutex_lock(&data->update_lock);
325 data->wdog_preset = v; 326 data->wdog_preset = v;
326 fscpos_write_value(client, reg, data->wdog_preset); 327 fscpos_write_value(client, reg, data->wdog_preset);
327 up(&data->update_lock); 328 mutex_unlock(&data->update_lock);
328 return count; 329 return count;
329} 330}
330 331
@@ -483,7 +484,7 @@ static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind)
483 strlcpy(new_client->name, "fscpos", I2C_NAME_SIZE); 484 strlcpy(new_client->name, "fscpos", I2C_NAME_SIZE);
484 485
485 data->valid = 0; 486 data->valid = 0;
486 init_MUTEX(&data->update_lock); 487 mutex_init(&data->update_lock);
487 488
488 /* Tell the I2C layer a new client has arrived */ 489 /* Tell the I2C layer a new client has arrived */
489 if ((err = i2c_attach_client(new_client))) 490 if ((err = i2c_attach_client(new_client)))
@@ -579,7 +580,7 @@ static struct fscpos_data *fscpos_update_device(struct device *dev)
579 struct i2c_client *client = to_i2c_client(dev); 580 struct i2c_client *client = to_i2c_client(dev);
580 struct fscpos_data *data = i2c_get_clientdata(client); 581 struct fscpos_data *data = i2c_get_clientdata(client);
581 582
582 down(&data->update_lock); 583 mutex_lock(&data->update_lock);
583 584
584 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { 585 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
585 int i; 586 int i;
@@ -625,7 +626,7 @@ static struct fscpos_data *fscpos_update_device(struct device *dev)
625 data->last_updated = jiffies; 626 data->last_updated = jiffies;
626 data->valid = 1; 627 data->valid = 1;
627 } 628 }
628 up(&data->update_lock); 629 mutex_unlock(&data->update_lock);
629 return data; 630 return data;
630} 631}
631 632
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c
index 9e685e3a3bc9..6606aabdb49d 100644
--- a/drivers/hwmon/gl518sm.c
+++ b/drivers/hwmon/gl518sm.c
@@ -43,6 +43,7 @@
43#include <linux/i2c.h> 43#include <linux/i2c.h>
44#include <linux/hwmon.h> 44#include <linux/hwmon.h>
45#include <linux/err.h> 45#include <linux/err.h>
46#include <linux/mutex.h>
46 47
47/* Addresses to scan */ 48/* Addresses to scan */
48static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; 49static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
@@ -120,7 +121,7 @@ struct gl518_data {
120 struct class_device *class_dev; 121 struct class_device *class_dev;
121 enum chips type; 122 enum chips type;
122 123
123 struct semaphore update_lock; 124 struct mutex update_lock;
124 char valid; /* !=0 if following fields are valid */ 125 char valid; /* !=0 if following fields are valid */
125 unsigned long last_updated; /* In jiffies */ 126 unsigned long last_updated; /* In jiffies */
126 127
@@ -212,10 +213,10 @@ static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, c
212 struct gl518_data *data = i2c_get_clientdata(client); \ 213 struct gl518_data *data = i2c_get_clientdata(client); \
213 long val = simple_strtol(buf, NULL, 10); \ 214 long val = simple_strtol(buf, NULL, 10); \
214 \ 215 \
215 down(&data->update_lock); \ 216 mutex_lock(&data->update_lock); \
216 data->value = type##_TO_REG(val); \ 217 data->value = type##_TO_REG(val); \
217 gl518_write_value(client, reg, data->value); \ 218 gl518_write_value(client, reg, data->value); \
218 up(&data->update_lock); \ 219 mutex_unlock(&data->update_lock); \
219 return count; \ 220 return count; \
220} 221}
221 222
@@ -228,12 +229,12 @@ static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, c
228 int regvalue; \ 229 int regvalue; \
229 unsigned long val = simple_strtoul(buf, NULL, 10); \ 230 unsigned long val = simple_strtoul(buf, NULL, 10); \
230 \ 231 \
231 down(&data->update_lock); \ 232 mutex_lock(&data->update_lock); \
232 regvalue = gl518_read_value(client, reg); \ 233 regvalue = gl518_read_value(client, reg); \
233 data->value = type##_TO_REG(val); \ 234 data->value = type##_TO_REG(val); \
234 regvalue = (regvalue & ~mask) | (data->value << shift); \ 235 regvalue = (regvalue & ~mask) | (data->value << shift); \
235 gl518_write_value(client, reg, regvalue); \ 236 gl518_write_value(client, reg, regvalue); \
236 up(&data->update_lock); \ 237 mutex_unlock(&data->update_lock); \
237 return count; \ 238 return count; \
238} 239}
239 240
@@ -265,7 +266,7 @@ static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, c
265 int regvalue; 266 int regvalue;
266 unsigned long val = simple_strtoul(buf, NULL, 10); 267 unsigned long val = simple_strtoul(buf, NULL, 10);
267 268
268 down(&data->update_lock); 269 mutex_lock(&data->update_lock);
269 regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); 270 regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT);
270 data->fan_min[0] = FAN_TO_REG(val, 271 data->fan_min[0] = FAN_TO_REG(val,
271 DIV_FROM_REG(data->fan_div[0])); 272 DIV_FROM_REG(data->fan_div[0]));
@@ -280,7 +281,7 @@ static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, c
280 data->beep_mask &= data->alarm_mask; 281 data->beep_mask &= data->alarm_mask;
281 gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); 282 gl518_write_value(client, GL518_REG_ALARM, data->beep_mask);
282 283
283 up(&data->update_lock); 284 mutex_unlock(&data->update_lock);
284 return count; 285 return count;
285} 286}
286 287
@@ -291,7 +292,7 @@ static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, c
291 int regvalue; 292 int regvalue;
292 unsigned long val = simple_strtoul(buf, NULL, 10); 293 unsigned long val = simple_strtoul(buf, NULL, 10);
293 294
294 down(&data->update_lock); 295 mutex_lock(&data->update_lock);
295 regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); 296 regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT);
296 data->fan_min[1] = FAN_TO_REG(val, 297 data->fan_min[1] = FAN_TO_REG(val,
297 DIV_FROM_REG(data->fan_div[1])); 298 DIV_FROM_REG(data->fan_div[1]));
@@ -306,7 +307,7 @@ static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, c
306 data->beep_mask &= data->alarm_mask; 307 data->beep_mask &= data->alarm_mask;
307 gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); 308 gl518_write_value(client, GL518_REG_ALARM, data->beep_mask);
308 309
309 up(&data->update_lock); 310 mutex_unlock(&data->update_lock);
310 return count; 311 return count;
311} 312}
312 313
@@ -407,7 +408,7 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
407 strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE); 408 strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE);
408 data->type = kind; 409 data->type = kind;
409 data->valid = 0; 410 data->valid = 0;
410 init_MUTEX(&data->update_lock); 411 mutex_init(&data->update_lock);
411 412
412 /* Tell the I2C layer a new client has arrived */ 413 /* Tell the I2C layer a new client has arrived */
413 if ((err = i2c_attach_client(new_client))) 414 if ((err = i2c_attach_client(new_client)))
@@ -525,7 +526,7 @@ static struct gl518_data *gl518_update_device(struct device *dev)
525 struct gl518_data *data = i2c_get_clientdata(client); 526 struct gl518_data *data = i2c_get_clientdata(client);
526 int val; 527 int val;
527 528
528 down(&data->update_lock); 529 mutex_lock(&data->update_lock);
529 530
530 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 531 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
531 || !data->valid) { 532 || !data->valid) {
@@ -586,7 +587,7 @@ static struct gl518_data *gl518_update_device(struct device *dev)
586 data->valid = 1; 587 data->valid = 1;
587 } 588 }
588 589
589 up(&data->update_lock); 590 mutex_unlock(&data->update_lock);
590 591
591 return data; 592 return data;
592} 593}
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c
index baee60e44b52..47b4d49f75c6 100644
--- a/drivers/hwmon/gl520sm.c
+++ b/drivers/hwmon/gl520sm.c
@@ -29,6 +29,7 @@
29#include <linux/hwmon.h> 29#include <linux/hwmon.h>
30#include <linux/hwmon-vid.h> 30#include <linux/hwmon-vid.h>
31#include <linux/err.h> 31#include <linux/err.h>
32#include <linux/mutex.h>
32 33
33/* Type of the extra sensor */ 34/* Type of the extra sensor */
34static unsigned short extra_sensor_type; 35static unsigned short extra_sensor_type;
@@ -121,7 +122,7 @@ static struct i2c_driver gl520_driver = {
121struct gl520_data { 122struct gl520_data {
122 struct i2c_client client; 123 struct i2c_client client;
123 struct class_device *class_dev; 124 struct class_device *class_dev;
124 struct semaphore update_lock; 125 struct mutex update_lock;
125 char valid; /* zero until the following fields are valid */ 126 char valid; /* zero until the following fields are valid */
126 unsigned long last_updated; /* in jiffies */ 127 unsigned long last_updated; /* in jiffies */
127 128
@@ -303,7 +304,7 @@ static ssize_t set_in_min(struct i2c_client *client, struct gl520_data *data, co
303 long v = simple_strtol(buf, NULL, 10); 304 long v = simple_strtol(buf, NULL, 10);
304 u8 r; 305 u8 r;
305 306
306 down(&data->update_lock); 307 mutex_lock(&data->update_lock);
307 308
308 if (n == 0) 309 if (n == 0)
309 r = VDD_TO_REG(v); 310 r = VDD_TO_REG(v);
@@ -317,7 +318,7 @@ static ssize_t set_in_min(struct i2c_client *client, struct gl520_data *data, co
317 else 318 else
318 gl520_write_value(client, reg, r); 319 gl520_write_value(client, reg, r);
319 320
320 up(&data->update_lock); 321 mutex_unlock(&data->update_lock);
321 return count; 322 return count;
322} 323}
323 324
@@ -331,7 +332,7 @@ static ssize_t set_in_max(struct i2c_client *client, struct gl520_data *data, co
331 else 332 else
332 r = IN_TO_REG(v); 333 r = IN_TO_REG(v);
333 334
334 down(&data->update_lock); 335 mutex_lock(&data->update_lock);
335 336
336 data->in_max[n] = r; 337 data->in_max[n] = r;
337 338
@@ -340,7 +341,7 @@ static ssize_t set_in_max(struct i2c_client *client, struct gl520_data *data, co
340 else 341 else
341 gl520_write_value(client, reg, r); 342 gl520_write_value(client, reg, r);
342 343
343 up(&data->update_lock); 344 mutex_unlock(&data->update_lock);
344 return count; 345 return count;
345} 346}
346 347
@@ -373,7 +374,7 @@ static ssize_t set_fan_min(struct i2c_client *client, struct gl520_data *data, c
373 unsigned long v = simple_strtoul(buf, NULL, 10); 374 unsigned long v = simple_strtoul(buf, NULL, 10);
374 u8 r; 375 u8 r;
375 376
376 down(&data->update_lock); 377 mutex_lock(&data->update_lock);
377 r = FAN_TO_REG(v, data->fan_div[n - 1]); 378 r = FAN_TO_REG(v, data->fan_div[n - 1]);
378 data->fan_min[n - 1] = r; 379 data->fan_min[n - 1] = r;
379 380
@@ -390,7 +391,7 @@ static ssize_t set_fan_min(struct i2c_client *client, struct gl520_data *data, c
390 data->beep_mask &= data->alarm_mask; 391 data->beep_mask &= data->alarm_mask;
391 gl520_write_value(client, GL520_REG_BEEP_MASK, data->beep_mask); 392 gl520_write_value(client, GL520_REG_BEEP_MASK, data->beep_mask);
392 393
393 up(&data->update_lock); 394 mutex_unlock(&data->update_lock);
394 return count; 395 return count;
395} 396}
396 397
@@ -409,7 +410,7 @@ static ssize_t set_fan_div(struct i2c_client *client, struct gl520_data *data, c
409 return -EINVAL; 410 return -EINVAL;
410 } 411 }
411 412
412 down(&data->update_lock); 413 mutex_lock(&data->update_lock);
413 data->fan_div[n - 1] = r; 414 data->fan_div[n - 1] = r;
414 415
415 if (n == 1) 416 if (n == 1)
@@ -417,7 +418,7 @@ static ssize_t set_fan_div(struct i2c_client *client, struct gl520_data *data, c
417 else 418 else
418 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x30) | (r << 4)); 419 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x30) | (r << 4));
419 420
420 up(&data->update_lock); 421 mutex_unlock(&data->update_lock);
421 return count; 422 return count;
422} 423}
423 424
@@ -425,10 +426,10 @@ static ssize_t set_fan_off(struct i2c_client *client, struct gl520_data *data, c
425{ 426{
426 u8 r = simple_strtoul(buf, NULL, 10)?1:0; 427 u8 r = simple_strtoul(buf, NULL, 10)?1:0;
427 428
428 down(&data->update_lock); 429 mutex_lock(&data->update_lock);
429 data->fan_off = r; 430 data->fan_off = r;
430 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x0c) | (r << 2)); 431 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x0c) | (r << 2));
431 up(&data->update_lock); 432 mutex_unlock(&data->update_lock);
432 return count; 433 return count;
433} 434}
434 435
@@ -454,10 +455,10 @@ static ssize_t set_temp_max(struct i2c_client *client, struct gl520_data *data,
454{ 455{
455 long v = simple_strtol(buf, NULL, 10); 456 long v = simple_strtol(buf, NULL, 10);
456 457
457 down(&data->update_lock); 458 mutex_lock(&data->update_lock);
458 data->temp_max[n - 1] = TEMP_TO_REG(v);; 459 data->temp_max[n - 1] = TEMP_TO_REG(v);;
459 gl520_write_value(client, reg, data->temp_max[n - 1]); 460 gl520_write_value(client, reg, data->temp_max[n - 1]);
460 up(&data->update_lock); 461 mutex_unlock(&data->update_lock);
461 return count; 462 return count;
462} 463}
463 464
@@ -465,10 +466,10 @@ static ssize_t set_temp_max_hyst(struct i2c_client *client, struct gl520_data *d
465{ 466{
466 long v = simple_strtol(buf, NULL, 10); 467 long v = simple_strtol(buf, NULL, 10);
467 468
468 down(&data->update_lock); 469 mutex_lock(&data->update_lock);
469 data->temp_max_hyst[n - 1] = TEMP_TO_REG(v); 470 data->temp_max_hyst[n - 1] = TEMP_TO_REG(v);
470 gl520_write_value(client, reg, data->temp_max_hyst[n - 1]); 471 gl520_write_value(client, reg, data->temp_max_hyst[n - 1]);
471 up(&data->update_lock); 472 mutex_unlock(&data->update_lock);
472 return count; 473 return count;
473} 474}
474 475
@@ -491,10 +492,10 @@ static ssize_t set_beep_enable(struct i2c_client *client, struct gl520_data *dat
491{ 492{
492 u8 r = simple_strtoul(buf, NULL, 10)?0:1; 493 u8 r = simple_strtoul(buf, NULL, 10)?0:1;
493 494
494 down(&data->update_lock); 495 mutex_lock(&data->update_lock);
495 data->beep_enable = !r; 496 data->beep_enable = !r;
496 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x04) | (r << 2)); 497 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x04) | (r << 2));
497 up(&data->update_lock); 498 mutex_unlock(&data->update_lock);
498 return count; 499 return count;
499} 500}
500 501
@@ -502,11 +503,11 @@ static ssize_t set_beep_mask(struct i2c_client *client, struct gl520_data *data,
502{ 503{
503 u8 r = simple_strtoul(buf, NULL, 10); 504 u8 r = simple_strtoul(buf, NULL, 10);
504 505
505 down(&data->update_lock); 506 mutex_lock(&data->update_lock);
506 r &= data->alarm_mask; 507 r &= data->alarm_mask;
507 data->beep_mask = r; 508 data->beep_mask = r;
508 gl520_write_value(client, reg, r); 509 gl520_write_value(client, reg, r);
509 up(&data->update_lock); 510 mutex_unlock(&data->update_lock);
510 return count; 511 return count;
511} 512}
512 513
@@ -561,7 +562,7 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
561 /* Fill in the remaining client fields */ 562 /* Fill in the remaining client fields */
562 strlcpy(new_client->name, "gl520sm", I2C_NAME_SIZE); 563 strlcpy(new_client->name, "gl520sm", I2C_NAME_SIZE);
563 data->valid = 0; 564 data->valid = 0;
564 init_MUTEX(&data->update_lock); 565 mutex_init(&data->update_lock);
565 566
566 /* Tell the I2C layer a new client has arrived */ 567 /* Tell the I2C layer a new client has arrived */
567 if ((err = i2c_attach_client(new_client))) 568 if ((err = i2c_attach_client(new_client)))
@@ -685,7 +686,7 @@ static struct gl520_data *gl520_update_device(struct device *dev)
685 struct gl520_data *data = i2c_get_clientdata(client); 686 struct gl520_data *data = i2c_get_clientdata(client);
686 int val; 687 int val;
687 688
688 down(&data->update_lock); 689 mutex_lock(&data->update_lock);
689 690
690 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { 691 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
691 692
@@ -750,7 +751,7 @@ static struct gl520_data *gl520_update_device(struct device *dev)
750 data->valid = 1; 751 data->valid = 1;
751 } 752 }
752 753
753 up(&data->update_lock); 754 mutex_unlock(&data->update_lock);
754 755
755 return data; 756 return data;
756} 757}
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c
index 23a9e1ea8e32..7636c1a58f9c 100644
--- a/drivers/hwmon/hdaps.c
+++ b/drivers/hwmon/hdaps.c
@@ -33,6 +33,7 @@
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/timer.h> 34#include <linux/timer.h>
35#include <linux/dmi.h> 35#include <linux/dmi.h>
36#include <linux/mutex.h>
36#include <asm/io.h> 37#include <asm/io.h>
37 38
38#define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */ 39#define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */
@@ -70,10 +71,10 @@ static u8 km_activity;
70static int rest_x; 71static int rest_x;
71static int rest_y; 72static int rest_y;
72 73
73static DECLARE_MUTEX(hdaps_sem); 74static DEFINE_MUTEX(hdaps_mutex);
74 75
75/* 76/*
76 * __get_latch - Get the value from a given port. Callers must hold hdaps_sem. 77 * __get_latch - Get the value from a given port. Callers must hold hdaps_mutex.
77 */ 78 */
78static inline u8 __get_latch(u16 port) 79static inline u8 __get_latch(u16 port)
79{ 80{
@@ -82,7 +83,7 @@ static inline u8 __get_latch(u16 port)
82 83
83/* 84/*
84 * __check_latch - Check a port latch for a given value. Returns zero if the 85 * __check_latch - Check a port latch for a given value. Returns zero if the
85 * port contains the given value. Callers must hold hdaps_sem. 86 * port contains the given value. Callers must hold hdaps_mutex.
86 */ 87 */
87static inline int __check_latch(u16 port, u8 val) 88static inline int __check_latch(u16 port, u8 val)
88{ 89{
@@ -93,7 +94,7 @@ static inline int __check_latch(u16 port, u8 val)
93 94
94/* 95/*
95 * __wait_latch - Wait up to 100us for a port latch to get a certain value, 96 * __wait_latch - Wait up to 100us for a port latch to get a certain value,
96 * returning zero if the value is obtained. Callers must hold hdaps_sem. 97 * returning zero if the value is obtained. Callers must hold hdaps_mutex.
97 */ 98 */
98static int __wait_latch(u16 port, u8 val) 99static int __wait_latch(u16 port, u8 val)
99{ 100{
@@ -110,7 +111,7 @@ static int __wait_latch(u16 port, u8 val)
110 111
111/* 112/*
112 * __device_refresh - request a refresh from the accelerometer. Does not wait 113 * __device_refresh - request a refresh from the accelerometer. Does not wait
113 * for refresh to complete. Callers must hold hdaps_sem. 114 * for refresh to complete. Callers must hold hdaps_mutex.
114 */ 115 */
115static void __device_refresh(void) 116static void __device_refresh(void)
116{ 117{
@@ -124,7 +125,7 @@ static void __device_refresh(void)
124/* 125/*
125 * __device_refresh_sync - request a synchronous refresh from the 126 * __device_refresh_sync - request a synchronous refresh from the
126 * accelerometer. We wait for the refresh to complete. Returns zero if 127 * accelerometer. We wait for the refresh to complete. Returns zero if
127 * successful and nonzero on error. Callers must hold hdaps_sem. 128 * successful and nonzero on error. Callers must hold hdaps_mutex.
128 */ 129 */
129static int __device_refresh_sync(void) 130static int __device_refresh_sync(void)
130{ 131{
@@ -134,7 +135,7 @@ static int __device_refresh_sync(void)
134 135
135/* 136/*
136 * __device_complete - indicate to the accelerometer that we are done reading 137 * __device_complete - indicate to the accelerometer that we are done reading
137 * data, and then initiate an async refresh. Callers must hold hdaps_sem. 138 * data, and then initiate an async refresh. Callers must hold hdaps_mutex.
138 */ 139 */
139static inline void __device_complete(void) 140static inline void __device_complete(void)
140{ 141{
@@ -152,7 +153,7 @@ static int hdaps_readb_one(unsigned int port, u8 *val)
152{ 153{
153 int ret; 154 int ret;
154 155
155 down(&hdaps_sem); 156 mutex_lock(&hdaps_mutex);
156 157
157 /* do a sync refresh -- we need to be sure that we read fresh data */ 158 /* do a sync refresh -- we need to be sure that we read fresh data */
158 ret = __device_refresh_sync(); 159 ret = __device_refresh_sync();
@@ -163,7 +164,7 @@ static int hdaps_readb_one(unsigned int port, u8 *val)
163 __device_complete(); 164 __device_complete();
164 165
165out: 166out:
166 up(&hdaps_sem); 167 mutex_unlock(&hdaps_mutex);
167 return ret; 168 return ret;
168} 169}
169 170
@@ -198,9 +199,9 @@ static int hdaps_read_pair(unsigned int port1, unsigned int port2,
198{ 199{
199 int ret; 200 int ret;
200 201
201 down(&hdaps_sem); 202 mutex_lock(&hdaps_mutex);
202 ret = __hdaps_read_pair(port1, port2, val1, val2); 203 ret = __hdaps_read_pair(port1, port2, val1, val2);
203 up(&hdaps_sem); 204 mutex_unlock(&hdaps_mutex);
204 205
205 return ret; 206 return ret;
206} 207}
@@ -213,7 +214,7 @@ static int hdaps_device_init(void)
213{ 214{
214 int total, ret = -ENXIO; 215 int total, ret = -ENXIO;
215 216
216 down(&hdaps_sem); 217 mutex_lock(&hdaps_mutex);
217 218
218 outb(0x13, 0x1610); 219 outb(0x13, 0x1610);
219 outb(0x01, 0x161f); 220 outb(0x01, 0x161f);
@@ -279,7 +280,7 @@ static int hdaps_device_init(void)
279 } 280 }
280 281
281out: 282out:
282 up(&hdaps_sem); 283 mutex_unlock(&hdaps_mutex);
283 return ret; 284 return ret;
284} 285}
285 286
@@ -313,7 +314,7 @@ static struct platform_driver hdaps_driver = {
313}; 314};
314 315
315/* 316/*
316 * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_sem. 317 * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_mutex.
317 */ 318 */
318static void hdaps_calibrate(void) 319static void hdaps_calibrate(void)
319{ 320{
@@ -325,7 +326,7 @@ static void hdaps_mousedev_poll(unsigned long unused)
325 int x, y; 326 int x, y;
326 327
327 /* Cannot sleep. Try nonblockingly. If we fail, try again later. */ 328 /* Cannot sleep. Try nonblockingly. If we fail, try again later. */
328 if (down_trylock(&hdaps_sem)) { 329 if (!mutex_trylock(&hdaps_mutex)) {
329 mod_timer(&hdaps_timer,jiffies + HDAPS_POLL_PERIOD); 330 mod_timer(&hdaps_timer,jiffies + HDAPS_POLL_PERIOD);
330 return; 331 return;
331 } 332 }
@@ -340,7 +341,7 @@ static void hdaps_mousedev_poll(unsigned long unused)
340 mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD); 341 mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD);
341 342
342out: 343out:
343 up(&hdaps_sem); 344 mutex_unlock(&hdaps_mutex);
344} 345}
345 346
346 347
@@ -420,9 +421,9 @@ static ssize_t hdaps_calibrate_store(struct device *dev,
420 struct device_attribute *attr, 421 struct device_attribute *attr,
421 const char *buf, size_t count) 422 const char *buf, size_t count)
422{ 423{
423 down(&hdaps_sem); 424 mutex_lock(&hdaps_mutex);
424 hdaps_calibrate(); 425 hdaps_calibrate();
425 up(&hdaps_sem); 426 mutex_unlock(&hdaps_mutex);
426 427
427 return count; 428 return count;
428} 429}
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index d7a9401600bb..122ff9cd75cb 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -41,6 +41,7 @@
41#include <linux/hwmon-sysfs.h> 41#include <linux/hwmon-sysfs.h>
42#include <linux/hwmon-vid.h> 42#include <linux/hwmon-vid.h>
43#include <linux/err.h> 43#include <linux/err.h>
44#include <linux/mutex.h>
44#include <asm/io.h> 45#include <asm/io.h>
45 46
46 47
@@ -194,10 +195,10 @@ static int DIV_TO_REG(int val)
194struct it87_data { 195struct it87_data {
195 struct i2c_client client; 196 struct i2c_client client;
196 struct class_device *class_dev; 197 struct class_device *class_dev;
197 struct semaphore lock; 198 struct mutex lock;
198 enum chips type; 199 enum chips type;
199 200
200 struct semaphore update_lock; 201 struct mutex update_lock;
201 char valid; /* !=0 if following fields are valid */ 202 char valid; /* !=0 if following fields are valid */
202 unsigned long last_updated; /* In jiffies */ 203 unsigned long last_updated; /* In jiffies */
203 204
@@ -290,11 +291,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
290 struct it87_data *data = i2c_get_clientdata(client); 291 struct it87_data *data = i2c_get_clientdata(client);
291 unsigned long val = simple_strtoul(buf, NULL, 10); 292 unsigned long val = simple_strtoul(buf, NULL, 10);
292 293
293 down(&data->update_lock); 294 mutex_lock(&data->update_lock);
294 data->in_min[nr] = IN_TO_REG(val); 295 data->in_min[nr] = IN_TO_REG(val);
295 it87_write_value(client, IT87_REG_VIN_MIN(nr), 296 it87_write_value(client, IT87_REG_VIN_MIN(nr),
296 data->in_min[nr]); 297 data->in_min[nr]);
297 up(&data->update_lock); 298 mutex_unlock(&data->update_lock);
298 return count; 299 return count;
299} 300}
300static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, 301static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
@@ -307,11 +308,11 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
307 struct it87_data *data = i2c_get_clientdata(client); 308 struct it87_data *data = i2c_get_clientdata(client);
308 unsigned long val = simple_strtoul(buf, NULL, 10); 309 unsigned long val = simple_strtoul(buf, NULL, 10);
309 310
310 down(&data->update_lock); 311 mutex_lock(&data->update_lock);
311 data->in_max[nr] = IN_TO_REG(val); 312 data->in_max[nr] = IN_TO_REG(val);
312 it87_write_value(client, IT87_REG_VIN_MAX(nr), 313 it87_write_value(client, IT87_REG_VIN_MAX(nr),
313 data->in_max[nr]); 314 data->in_max[nr]);
314 up(&data->update_lock); 315 mutex_unlock(&data->update_lock);
315 return count; 316 return count;
316} 317}
317 318
@@ -381,10 +382,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
381 struct it87_data *data = i2c_get_clientdata(client); 382 struct it87_data *data = i2c_get_clientdata(client);
382 int val = simple_strtol(buf, NULL, 10); 383 int val = simple_strtol(buf, NULL, 10);
383 384
384 down(&data->update_lock); 385 mutex_lock(&data->update_lock);
385 data->temp_high[nr] = TEMP_TO_REG(val); 386 data->temp_high[nr] = TEMP_TO_REG(val);
386 it87_write_value(client, IT87_REG_TEMP_HIGH(nr), data->temp_high[nr]); 387 it87_write_value(client, IT87_REG_TEMP_HIGH(nr), data->temp_high[nr]);
387 up(&data->update_lock); 388 mutex_unlock(&data->update_lock);
388 return count; 389 return count;
389} 390}
390static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, 391static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
@@ -397,10 +398,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
397 struct it87_data *data = i2c_get_clientdata(client); 398 struct it87_data *data = i2c_get_clientdata(client);
398 int val = simple_strtol(buf, NULL, 10); 399 int val = simple_strtol(buf, NULL, 10);
399 400
400 down(&data->update_lock); 401 mutex_lock(&data->update_lock);
401 data->temp_low[nr] = TEMP_TO_REG(val); 402 data->temp_low[nr] = TEMP_TO_REG(val);
402 it87_write_value(client, IT87_REG_TEMP_LOW(nr), data->temp_low[nr]); 403 it87_write_value(client, IT87_REG_TEMP_LOW(nr), data->temp_low[nr]);
403 up(&data->update_lock); 404 mutex_unlock(&data->update_lock);
404 return count; 405 return count;
405} 406}
406#define show_temp_offset(offset) \ 407#define show_temp_offset(offset) \
@@ -440,7 +441,7 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr,
440 struct it87_data *data = i2c_get_clientdata(client); 441 struct it87_data *data = i2c_get_clientdata(client);
441 int val = simple_strtol(buf, NULL, 10); 442 int val = simple_strtol(buf, NULL, 10);
442 443
443 down(&data->update_lock); 444 mutex_lock(&data->update_lock);
444 445
445 data->sensor &= ~(1 << nr); 446 data->sensor &= ~(1 << nr);
446 data->sensor &= ~(8 << nr); 447 data->sensor &= ~(8 << nr);
@@ -450,11 +451,11 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr,
450 else if (val == 2) 451 else if (val == 2)
451 data->sensor |= 8 << nr; 452 data->sensor |= 8 << nr;
452 else if (val != 0) { 453 else if (val != 0) {
453 up(&data->update_lock); 454 mutex_unlock(&data->update_lock);
454 return -EINVAL; 455 return -EINVAL;
455 } 456 }
456 it87_write_value(client, IT87_REG_TEMP_ENABLE, data->sensor); 457 it87_write_value(client, IT87_REG_TEMP_ENABLE, data->sensor);
457 up(&data->update_lock); 458 mutex_unlock(&data->update_lock);
458 return count; 459 return count;
459} 460}
460#define show_sensor_offset(offset) \ 461#define show_sensor_offset(offset) \
@@ -524,7 +525,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
524 int val = simple_strtol(buf, NULL, 10); 525 int val = simple_strtol(buf, NULL, 10);
525 u8 reg = it87_read_value(client, IT87_REG_FAN_DIV); 526 u8 reg = it87_read_value(client, IT87_REG_FAN_DIV);
526 527
527 down(&data->update_lock); 528 mutex_lock(&data->update_lock);
528 switch (nr) { 529 switch (nr) {
529 case 0: data->fan_div[nr] = reg & 0x07; break; 530 case 0: data->fan_div[nr] = reg & 0x07; break;
530 case 1: data->fan_div[nr] = (reg >> 3) & 0x07; break; 531 case 1: data->fan_div[nr] = (reg >> 3) & 0x07; break;
@@ -533,7 +534,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
533 534
534 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 535 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
535 it87_write_value(client, IT87_REG_FAN_MIN(nr), data->fan_min[nr]); 536 it87_write_value(client, IT87_REG_FAN_MIN(nr), data->fan_min[nr]);
536 up(&data->update_lock); 537 mutex_unlock(&data->update_lock);
537 return count; 538 return count;
538} 539}
539static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, 540static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
@@ -548,7 +549,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
548 int i, min[3]; 549 int i, min[3];
549 u8 old; 550 u8 old;
550 551
551 down(&data->update_lock); 552 mutex_lock(&data->update_lock);
552 old = it87_read_value(client, IT87_REG_FAN_DIV); 553 old = it87_read_value(client, IT87_REG_FAN_DIV);
553 554
554 for (i = 0; i < 3; i++) 555 for (i = 0; i < 3; i++)
@@ -576,7 +577,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
576 data->fan_min[i]=FAN_TO_REG(min[i], DIV_FROM_REG(data->fan_div[i])); 577 data->fan_min[i]=FAN_TO_REG(min[i], DIV_FROM_REG(data->fan_div[i]));
577 it87_write_value(client, IT87_REG_FAN_MIN(i), data->fan_min[i]); 578 it87_write_value(client, IT87_REG_FAN_MIN(i), data->fan_min[i]);
578 } 579 }
579 up(&data->update_lock); 580 mutex_unlock(&data->update_lock);
580 return count; 581 return count;
581} 582}
582static ssize_t set_pwm_enable(struct device *dev, 583static ssize_t set_pwm_enable(struct device *dev,
@@ -589,7 +590,7 @@ static ssize_t set_pwm_enable(struct device *dev,
589 struct it87_data *data = i2c_get_clientdata(client); 590 struct it87_data *data = i2c_get_clientdata(client);
590 int val = simple_strtol(buf, NULL, 10); 591 int val = simple_strtol(buf, NULL, 10);
591 592
592 down(&data->update_lock); 593 mutex_lock(&data->update_lock);
593 594
594 if (val == 0) { 595 if (val == 0) {
595 int tmp; 596 int tmp;
@@ -606,11 +607,11 @@ static ssize_t set_pwm_enable(struct device *dev,
606 /* set saved pwm value, clear FAN_CTLX PWM mode bit */ 607 /* set saved pwm value, clear FAN_CTLX PWM mode bit */
607 it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr])); 608 it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr]));
608 } else { 609 } else {
609 up(&data->update_lock); 610 mutex_unlock(&data->update_lock);
610 return -EINVAL; 611 return -EINVAL;
611 } 612 }
612 613
613 up(&data->update_lock); 614 mutex_unlock(&data->update_lock);
614 return count; 615 return count;
615} 616}
616static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, 617static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
@@ -626,11 +627,11 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
626 if (val < 0 || val > 255) 627 if (val < 0 || val > 255)
627 return -EINVAL; 628 return -EINVAL;
628 629
629 down(&data->update_lock); 630 mutex_lock(&data->update_lock);
630 data->manual_pwm_ctl[nr] = val; 631 data->manual_pwm_ctl[nr] = val;
631 if (data->fan_main_ctrl & (1 << nr)) 632 if (data->fan_main_ctrl & (1 << nr))
632 it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr])); 633 it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr]));
633 up(&data->update_lock); 634 mutex_unlock(&data->update_lock);
634 return count; 635 return count;
635} 636}
636 637
@@ -776,7 +777,7 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind)
776 777
777 new_client = &data->client; 778 new_client = &data->client;
778 if (is_isa) 779 if (is_isa)
779 init_MUTEX(&data->lock); 780 mutex_init(&data->lock);
780 i2c_set_clientdata(new_client, data); 781 i2c_set_clientdata(new_client, data);
781 new_client->addr = address; 782 new_client->addr = address;
782 new_client->adapter = adapter; 783 new_client->adapter = adapter;
@@ -823,7 +824,7 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind)
823 strlcpy(new_client->name, name, I2C_NAME_SIZE); 824 strlcpy(new_client->name, name, I2C_NAME_SIZE);
824 data->type = kind; 825 data->type = kind;
825 data->valid = 0; 826 data->valid = 0;
826 init_MUTEX(&data->update_lock); 827 mutex_init(&data->update_lock);
827 828
828 /* Tell the I2C layer a new client has arrived */ 829 /* Tell the I2C layer a new client has arrived */
829 if ((err = i2c_attach_client(new_client))) 830 if ((err = i2c_attach_client(new_client)))
@@ -950,10 +951,10 @@ static int it87_read_value(struct i2c_client *client, u8 reg)
950 951
951 int res; 952 int res;
952 if (i2c_is_isa_client(client)) { 953 if (i2c_is_isa_client(client)) {
953 down(&data->lock); 954 mutex_lock(&data->lock);
954 outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); 955 outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET);
955 res = inb_p(client->addr + IT87_DATA_REG_OFFSET); 956 res = inb_p(client->addr + IT87_DATA_REG_OFFSET);
956 up(&data->lock); 957 mutex_unlock(&data->lock);
957 return res; 958 return res;
958 } else 959 } else
959 return i2c_smbus_read_byte_data(client, reg); 960 return i2c_smbus_read_byte_data(client, reg);
@@ -969,10 +970,10 @@ static int it87_write_value(struct i2c_client *client, u8 reg, u8 value)
969 struct it87_data *data = i2c_get_clientdata(client); 970 struct it87_data *data = i2c_get_clientdata(client);
970 971
971 if (i2c_is_isa_client(client)) { 972 if (i2c_is_isa_client(client)) {
972 down(&data->lock); 973 mutex_lock(&data->lock);
973 outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); 974 outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET);
974 outb_p(value, client->addr + IT87_DATA_REG_OFFSET); 975 outb_p(value, client->addr + IT87_DATA_REG_OFFSET);
975 up(&data->lock); 976 mutex_unlock(&data->lock);
976 return 0; 977 return 0;
977 } else 978 } else
978 return i2c_smbus_write_byte_data(client, reg, value); 979 return i2c_smbus_write_byte_data(client, reg, value);
@@ -1098,7 +1099,7 @@ static struct it87_data *it87_update_device(struct device *dev)
1098 struct it87_data *data = i2c_get_clientdata(client); 1099 struct it87_data *data = i2c_get_clientdata(client);
1099 int i; 1100 int i;
1100 1101
1101 down(&data->update_lock); 1102 mutex_lock(&data->update_lock);
1102 1103
1103 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 1104 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
1104 || !data->valid) { 1105 || !data->valid) {
@@ -1160,7 +1161,7 @@ static struct it87_data *it87_update_device(struct device *dev)
1160 data->valid = 1; 1161 data->valid = 1;
1161 } 1162 }
1162 1163
1163 up(&data->update_lock); 1164 mutex_unlock(&data->update_lock);
1164 1165
1165 return data; 1166 return data;
1166} 1167}
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c
index 6b1aa7ef552e..071f0fc6adec 100644
--- a/drivers/hwmon/lm63.c
+++ b/drivers/hwmon/lm63.c
@@ -45,6 +45,7 @@
45#include <linux/hwmon-sysfs.h> 45#include <linux/hwmon-sysfs.h>
46#include <linux/hwmon.h> 46#include <linux/hwmon.h>
47#include <linux/err.h> 47#include <linux/err.h>
48#include <linux/mutex.h>
48 49
49/* 50/*
50 * Addresses to scan 51 * Addresses to scan
@@ -153,7 +154,7 @@ static struct i2c_driver lm63_driver = {
153struct lm63_data { 154struct lm63_data {
154 struct i2c_client client; 155 struct i2c_client client;
155 struct class_device *class_dev; 156 struct class_device *class_dev;
156 struct semaphore update_lock; 157 struct mutex update_lock;
157 char valid; /* zero until following fields are valid */ 158 char valid; /* zero until following fields are valid */
158 unsigned long last_updated; /* in jiffies */ 159 unsigned long last_updated; /* in jiffies */
159 160
@@ -192,13 +193,13 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *dummy,
192 struct lm63_data *data = i2c_get_clientdata(client); 193 struct lm63_data *data = i2c_get_clientdata(client);
193 unsigned long val = simple_strtoul(buf, NULL, 10); 194 unsigned long val = simple_strtoul(buf, NULL, 10);
194 195
195 down(&data->update_lock); 196 mutex_lock(&data->update_lock);
196 data->fan[1] = FAN_TO_REG(val); 197 data->fan[1] = FAN_TO_REG(val);
197 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, 198 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB,
198 data->fan[1] & 0xFF); 199 data->fan[1] & 0xFF);
199 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, 200 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB,
200 data->fan[1] >> 8); 201 data->fan[1] >> 8);
201 up(&data->update_lock); 202 mutex_unlock(&data->update_lock);
202 return count; 203 return count;
203} 204}
204 205
@@ -222,12 +223,12 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy,
222 return -EPERM; 223 return -EPERM;
223 224
224 val = simple_strtoul(buf, NULL, 10); 225 val = simple_strtoul(buf, NULL, 10);
225 down(&data->update_lock); 226 mutex_lock(&data->update_lock);
226 data->pwm1_value = val <= 0 ? 0 : 227 data->pwm1_value = val <= 0 ? 0 :
227 val >= 255 ? 2 * data->pwm1_freq : 228 val >= 255 ? 2 * data->pwm1_freq :
228 (val * data->pwm1_freq * 2 + 127) / 255; 229 (val * data->pwm1_freq * 2 + 127) / 255;
229 i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1_value); 230 i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1_value);
230 up(&data->update_lock); 231 mutex_unlock(&data->update_lock);
231 return count; 232 return count;
232} 233}
233 234
@@ -253,10 +254,10 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *dummy,
253 struct lm63_data *data = i2c_get_clientdata(client); 254 struct lm63_data *data = i2c_get_clientdata(client);
254 long val = simple_strtol(buf, NULL, 10); 255 long val = simple_strtol(buf, NULL, 10);
255 256
256 down(&data->update_lock); 257 mutex_lock(&data->update_lock);
257 data->temp8[1] = TEMP8_TO_REG(val); 258 data->temp8[1] = TEMP8_TO_REG(val);
258 i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]); 259 i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]);
259 up(&data->update_lock); 260 mutex_unlock(&data->update_lock);
260 return count; 261 return count;
261} 262}
262 263
@@ -284,13 +285,13 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
284 long val = simple_strtol(buf, NULL, 10); 285 long val = simple_strtol(buf, NULL, 10);
285 int nr = attr->index; 286 int nr = attr->index;
286 287
287 down(&data->update_lock); 288 mutex_lock(&data->update_lock);
288 data->temp11[nr] = TEMP11_TO_REG(val); 289 data->temp11[nr] = TEMP11_TO_REG(val);
289 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], 290 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2],
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
@@ -314,11 +315,11 @@ static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *
314 long val = simple_strtol(buf, NULL, 10); 315 long val = simple_strtol(buf, NULL, 10);
315 long hyst; 316 long hyst;
316 317
317 down(&data->update_lock); 318 mutex_lock(&data->update_lock);
318 hyst = TEMP8_FROM_REG(data->temp8[2]) - val; 319 hyst = TEMP8_FROM_REG(data->temp8[2]) - val;
319 i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, 320 i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST,
320 HYST_TO_REG(hyst)); 321 HYST_TO_REG(hyst));
321 up(&data->update_lock); 322 mutex_unlock(&data->update_lock);
322 return count; 323 return count;
323} 324}
324 325
@@ -427,7 +428,7 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
427 428
428 strlcpy(new_client->name, "lm63", I2C_NAME_SIZE); 429 strlcpy(new_client->name, "lm63", I2C_NAME_SIZE);
429 data->valid = 0; 430 data->valid = 0;
430 init_MUTEX(&data->update_lock); 431 mutex_init(&data->update_lock);
431 432
432 /* Tell the I2C layer a new client has arrived */ 433 /* Tell the I2C layer a new client has arrived */
433 if ((err = i2c_attach_client(new_client))) 434 if ((err = i2c_attach_client(new_client)))
@@ -530,7 +531,7 @@ static struct lm63_data *lm63_update_device(struct device *dev)
530 struct i2c_client *client = to_i2c_client(dev); 531 struct i2c_client *client = to_i2c_client(dev);
531 struct lm63_data *data = i2c_get_clientdata(client); 532 struct lm63_data *data = i2c_get_clientdata(client);
532 533
533 down(&data->update_lock); 534 mutex_lock(&data->update_lock);
534 535
535 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { 536 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
536 if (data->config & 0x04) { /* tachometer enabled */ 537 if (data->config & 0x04) { /* tachometer enabled */
@@ -582,7 +583,7 @@ static struct lm63_data *lm63_update_device(struct device *dev)
582 data->valid = 1; 583 data->valid = 1;
583 } 584 }
584 585
585 up(&data->update_lock); 586 mutex_unlock(&data->update_lock);
586 587
587 return data; 588 return data;
588} 589}
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 74ca2c8c61c3..fc25b90ec24a 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -25,6 +25,7 @@
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/hwmon.h> 26#include <linux/hwmon.h>
27#include <linux/err.h> 27#include <linux/err.h>
28#include <linux/mutex.h>
28#include "lm75.h" 29#include "lm75.h"
29 30
30 31
@@ -47,7 +48,7 @@ I2C_CLIENT_INSMOD_1(lm75);
47struct lm75_data { 48struct lm75_data {
48 struct i2c_client client; 49 struct i2c_client client;
49 struct class_device *class_dev; 50 struct class_device *class_dev;
50 struct semaphore update_lock; 51 struct mutex update_lock;
51 char valid; /* !=0 if following fields are valid */ 52 char valid; /* !=0 if following fields are valid */
52 unsigned long last_updated; /* In jiffies */ 53 unsigned long last_updated; /* In jiffies */
53 u16 temp_input; /* Register values */ 54 u16 temp_input; /* Register values */
@@ -91,10 +92,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
91 struct lm75_data *data = i2c_get_clientdata(client); \ 92 struct lm75_data *data = i2c_get_clientdata(client); \
92 int temp = simple_strtoul(buf, NULL, 10); \ 93 int temp = simple_strtoul(buf, NULL, 10); \
93 \ 94 \
94 down(&data->update_lock); \ 95 mutex_lock(&data->update_lock); \
95 data->value = LM75_TEMP_TO_REG(temp); \ 96 data->value = LM75_TEMP_TO_REG(temp); \
96 lm75_write_value(client, reg, data->value); \ 97 lm75_write_value(client, reg, data->value); \
97 up(&data->update_lock); \ 98 mutex_unlock(&data->update_lock); \
98 return count; \ 99 return count; \
99} 100}
100set(temp_max, LM75_REG_TEMP_OS); 101set(temp_max, LM75_REG_TEMP_OS);
@@ -188,7 +189,7 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
188 /* Fill in the remaining client fields and put it into the global list */ 189 /* Fill in the remaining client fields and put it into the global list */
189 strlcpy(new_client->name, name, I2C_NAME_SIZE); 190 strlcpy(new_client->name, name, I2C_NAME_SIZE);
190 data->valid = 0; 191 data->valid = 0;
191 init_MUTEX(&data->update_lock); 192 mutex_init(&data->update_lock);
192 193
193 /* Tell the I2C layer a new client has arrived */ 194 /* Tell the I2C layer a new client has arrived */
194 if ((err = i2c_attach_client(new_client))) 195 if ((err = i2c_attach_client(new_client)))
@@ -264,7 +265,7 @@ static struct lm75_data *lm75_update_device(struct device *dev)
264 struct i2c_client *client = to_i2c_client(dev); 265 struct i2c_client *client = to_i2c_client(dev);
265 struct lm75_data *data = i2c_get_clientdata(client); 266 struct lm75_data *data = i2c_get_clientdata(client);
266 267
267 down(&data->update_lock); 268 mutex_lock(&data->update_lock);
268 269
269 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 270 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
270 || !data->valid) { 271 || !data->valid) {
@@ -277,7 +278,7 @@ static struct lm75_data *lm75_update_device(struct device *dev)
277 data->valid = 1; 278 data->valid = 1;
278 } 279 }
279 280
280 up(&data->update_lock); 281 mutex_unlock(&data->update_lock);
281 282
282 return data; 283 return data;
283} 284}
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c
index df9e02aaa70a..459cc977380a 100644
--- a/drivers/hwmon/lm77.c
+++ b/drivers/hwmon/lm77.c
@@ -32,6 +32,7 @@
32#include <linux/i2c.h> 32#include <linux/i2c.h>
33#include <linux/hwmon.h> 33#include <linux/hwmon.h>
34#include <linux/err.h> 34#include <linux/err.h>
35#include <linux/mutex.h>
35 36
36/* Addresses to scan */ 37/* Addresses to scan */
37static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; 38static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END };
@@ -51,7 +52,7 @@ I2C_CLIENT_INSMOD_1(lm77);
51struct lm77_data { 52struct lm77_data {
52 struct i2c_client client; 53 struct i2c_client client;
53 struct class_device *class_dev; 54 struct class_device *class_dev;
54 struct semaphore update_lock; 55 struct mutex update_lock;
55 char valid; 56 char valid;
56 unsigned long last_updated; /* In jiffies */ 57 unsigned long last_updated; /* In jiffies */
57 int temp_input; /* Temperatures */ 58 int temp_input; /* Temperatures */
@@ -139,10 +140,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
139 struct lm77_data *data = i2c_get_clientdata(client); \ 140 struct lm77_data *data = i2c_get_clientdata(client); \
140 long val = simple_strtoul(buf, NULL, 10); \ 141 long val = simple_strtoul(buf, NULL, 10); \
141 \ 142 \
142 down(&data->update_lock); \ 143 mutex_lock(&data->update_lock); \
143 data->value = val; \ 144 data->value = val; \
144 lm77_write_value(client, reg, LM77_TEMP_TO_REG(data->value)); \ 145 lm77_write_value(client, reg, LM77_TEMP_TO_REG(data->value)); \
145 up(&data->update_lock); \ 146 mutex_unlock(&data->update_lock); \
146 return count; \ 147 return count; \
147} 148}
148 149
@@ -157,11 +158,11 @@ static ssize_t set_temp_crit_hyst(struct device *dev, struct device_attribute *a
157 struct lm77_data *data = i2c_get_clientdata(client); 158 struct lm77_data *data = i2c_get_clientdata(client);
158 unsigned long val = simple_strtoul(buf, NULL, 10); 159 unsigned long val = simple_strtoul(buf, NULL, 10);
159 160
160 down(&data->update_lock); 161 mutex_lock(&data->update_lock);
161 data->temp_hyst = data->temp_crit - val; 162 data->temp_hyst = data->temp_crit - val;
162 lm77_write_value(client, LM77_REG_TEMP_HYST, 163 lm77_write_value(client, LM77_REG_TEMP_HYST,
163 LM77_TEMP_TO_REG(data->temp_hyst)); 164 LM77_TEMP_TO_REG(data->temp_hyst));
164 up(&data->update_lock); 165 mutex_unlock(&data->update_lock);
165 return count; 166 return count;
166} 167}
167 168
@@ -173,7 +174,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
173 long val = simple_strtoul(buf, NULL, 10); 174 long val = simple_strtoul(buf, NULL, 10);
174 int oldcrithyst; 175 int oldcrithyst;
175 176
176 down(&data->update_lock); 177 mutex_lock(&data->update_lock);
177 oldcrithyst = data->temp_crit - data->temp_hyst; 178 oldcrithyst = data->temp_crit - data->temp_hyst;
178 data->temp_crit = val; 179 data->temp_crit = val;
179 data->temp_hyst = data->temp_crit - oldcrithyst; 180 data->temp_hyst = data->temp_crit - oldcrithyst;
@@ -181,7 +182,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
181 LM77_TEMP_TO_REG(data->temp_crit)); 182 LM77_TEMP_TO_REG(data->temp_crit));
182 lm77_write_value(client, LM77_REG_TEMP_HYST, 183 lm77_write_value(client, LM77_REG_TEMP_HYST,
183 LM77_TEMP_TO_REG(data->temp_hyst)); 184 LM77_TEMP_TO_REG(data->temp_hyst));
184 up(&data->update_lock); 185 mutex_unlock(&data->update_lock);
185 return count; 186 return count;
186} 187}
187 188
@@ -306,7 +307,7 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
306 /* Fill in the remaining client fields and put it into the global list */ 307 /* Fill in the remaining client fields and put it into the global list */
307 strlcpy(new_client->name, name, I2C_NAME_SIZE); 308 strlcpy(new_client->name, name, I2C_NAME_SIZE);
308 data->valid = 0; 309 data->valid = 0;
309 init_MUTEX(&data->update_lock); 310 mutex_init(&data->update_lock);
310 311
311 /* Tell the I2C layer a new client has arrived */ 312 /* Tell the I2C layer a new client has arrived */
312 if ((err = i2c_attach_client(new_client))) 313 if ((err = i2c_attach_client(new_client)))
@@ -380,7 +381,7 @@ static struct lm77_data *lm77_update_device(struct device *dev)
380 struct i2c_client *client = to_i2c_client(dev); 381 struct i2c_client *client = to_i2c_client(dev);
381 struct lm77_data *data = i2c_get_clientdata(client); 382 struct lm77_data *data = i2c_get_clientdata(client);
382 383
383 down(&data->update_lock); 384 mutex_lock(&data->update_lock);
384 385
385 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 386 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
386 || !data->valid) { 387 || !data->valid) {
@@ -406,7 +407,7 @@ static struct lm77_data *lm77_update_device(struct device *dev)
406 data->valid = 1; 407 data->valid = 1;
407 } 408 }
408 409
409 up(&data->update_lock); 410 mutex_unlock(&data->update_lock);
410 411
411 return data; 412 return data;
412} 413}
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index e404001e20da..36d1192ebe2a 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -27,6 +27,7 @@
27#include <linux/hwmon.h> 27#include <linux/hwmon.h>
28#include <linux/hwmon-vid.h> 28#include <linux/hwmon-vid.h>
29#include <linux/err.h> 29#include <linux/err.h>
30#include <linux/mutex.h>
30#include <asm/io.h> 31#include <asm/io.h>
31 32
32/* Addresses to scan */ 33/* Addresses to scan */
@@ -131,10 +132,10 @@ static inline int TEMP_FROM_REG(s8 val)
131struct lm78_data { 132struct lm78_data {
132 struct i2c_client client; 133 struct i2c_client client;
133 struct class_device *class_dev; 134 struct class_device *class_dev;
134 struct semaphore lock; 135 struct mutex lock;
135 enum chips type; 136 enum chips type;
136 137
137 struct semaphore update_lock; 138 struct mutex update_lock;
138 char valid; /* !=0 if following fields are valid */ 139 char valid; /* !=0 if following fields are valid */
139 unsigned long last_updated; /* In jiffies */ 140 unsigned long last_updated; /* In jiffies */
140 141
@@ -207,10 +208,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
207 struct lm78_data *data = i2c_get_clientdata(client); 208 struct lm78_data *data = i2c_get_clientdata(client);
208 unsigned long val = simple_strtoul(buf, NULL, 10); 209 unsigned long val = simple_strtoul(buf, NULL, 10);
209 210
210 down(&data->update_lock); 211 mutex_lock(&data->update_lock);
211 data->in_min[nr] = IN_TO_REG(val); 212 data->in_min[nr] = IN_TO_REG(val);
212 lm78_write_value(client, LM78_REG_IN_MIN(nr), data->in_min[nr]); 213 lm78_write_value(client, LM78_REG_IN_MIN(nr), data->in_min[nr]);
213 up(&data->update_lock); 214 mutex_unlock(&data->update_lock);
214 return count; 215 return count;
215} 216}
216 217
@@ -221,10 +222,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
221 struct lm78_data *data = i2c_get_clientdata(client); 222 struct lm78_data *data = i2c_get_clientdata(client);
222 unsigned long val = simple_strtoul(buf, NULL, 10); 223 unsigned long val = simple_strtoul(buf, NULL, 10);
223 224
224 down(&data->update_lock); 225 mutex_lock(&data->update_lock);
225 data->in_max[nr] = IN_TO_REG(val); 226 data->in_max[nr] = IN_TO_REG(val);
226 lm78_write_value(client, LM78_REG_IN_MAX(nr), data->in_max[nr]); 227 lm78_write_value(client, LM78_REG_IN_MAX(nr), data->in_max[nr]);
227 up(&data->update_lock); 228 mutex_unlock(&data->update_lock);
228 return count; 229 return count;
229} 230}
230 231
@@ -288,10 +289,10 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr,
288 struct lm78_data *data = i2c_get_clientdata(client); 289 struct lm78_data *data = i2c_get_clientdata(client);
289 long val = simple_strtol(buf, NULL, 10); 290 long val = simple_strtol(buf, NULL, 10);
290 291
291 down(&data->update_lock); 292 mutex_lock(&data->update_lock);
292 data->temp_over = TEMP_TO_REG(val); 293 data->temp_over = TEMP_TO_REG(val);
293 lm78_write_value(client, LM78_REG_TEMP_OVER, data->temp_over); 294 lm78_write_value(client, LM78_REG_TEMP_OVER, data->temp_over);
294 up(&data->update_lock); 295 mutex_unlock(&data->update_lock);
295 return count; 296 return count;
296} 297}
297 298
@@ -307,10 +308,10 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr,
307 struct lm78_data *data = i2c_get_clientdata(client); 308 struct lm78_data *data = i2c_get_clientdata(client);
308 long val = simple_strtol(buf, NULL, 10); 309 long val = simple_strtol(buf, NULL, 10);
309 310
310 down(&data->update_lock); 311 mutex_lock(&data->update_lock);
311 data->temp_hyst = TEMP_TO_REG(val); 312 data->temp_hyst = TEMP_TO_REG(val);
312 lm78_write_value(client, LM78_REG_TEMP_HYST, data->temp_hyst); 313 lm78_write_value(client, LM78_REG_TEMP_HYST, data->temp_hyst);
313 up(&data->update_lock); 314 mutex_unlock(&data->update_lock);
314 return count; 315 return count;
315} 316}
316 317
@@ -342,10 +343,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
342 struct lm78_data *data = i2c_get_clientdata(client); 343 struct lm78_data *data = i2c_get_clientdata(client);
343 unsigned long val = simple_strtoul(buf, NULL, 10); 344 unsigned long val = simple_strtoul(buf, NULL, 10);
344 345
345 down(&data->update_lock); 346 mutex_lock(&data->update_lock);
346 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 347 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
347 lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); 348 lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]);
348 up(&data->update_lock); 349 mutex_unlock(&data->update_lock);
349 return count; 350 return count;
350} 351}
351 352
@@ -368,7 +369,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
368 unsigned long min; 369 unsigned long min;
369 u8 reg; 370 u8 reg;
370 371
371 down(&data->update_lock); 372 mutex_lock(&data->update_lock);
372 min = FAN_FROM_REG(data->fan_min[nr], 373 min = FAN_FROM_REG(data->fan_min[nr],
373 DIV_FROM_REG(data->fan_div[nr])); 374 DIV_FROM_REG(data->fan_div[nr]));
374 375
@@ -380,7 +381,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
380 default: 381 default:
381 dev_err(&client->dev, "fan_div value %ld not " 382 dev_err(&client->dev, "fan_div value %ld not "
382 "supported. Choose one of 1, 2, 4 or 8!\n", val); 383 "supported. Choose one of 1, 2, 4 or 8!\n", val);
383 up(&data->update_lock); 384 mutex_unlock(&data->update_lock);
384 return -EINVAL; 385 return -EINVAL;
385 } 386 }
386 387
@@ -398,7 +399,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
398 data->fan_min[nr] = 399 data->fan_min[nr] =
399 FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 400 FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
400 lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); 401 lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]);
401 up(&data->update_lock); 402 mutex_unlock(&data->update_lock);
402 403
403 return count; 404 return count;
404} 405}
@@ -548,7 +549,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
548 549
549 new_client = &data->client; 550 new_client = &data->client;
550 if (is_isa) 551 if (is_isa)
551 init_MUTEX(&data->lock); 552 mutex_init(&data->lock);
552 i2c_set_clientdata(new_client, data); 553 i2c_set_clientdata(new_client, data);
553 new_client->addr = address; 554 new_client->addr = address;
554 new_client->adapter = adapter; 555 new_client->adapter = adapter;
@@ -598,7 +599,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
598 data->type = kind; 599 data->type = kind;
599 600
600 data->valid = 0; 601 data->valid = 0;
601 init_MUTEX(&data->update_lock); 602 mutex_init(&data->update_lock);
602 603
603 /* Tell the I2C layer a new client has arrived */ 604 /* Tell the I2C layer a new client has arrived */
604 if ((err = i2c_attach_client(new_client))) 605 if ((err = i2c_attach_client(new_client)))
@@ -697,10 +698,10 @@ static int lm78_read_value(struct i2c_client *client, u8 reg)
697 int res; 698 int res;
698 if (i2c_is_isa_client(client)) { 699 if (i2c_is_isa_client(client)) {
699 struct lm78_data *data = i2c_get_clientdata(client); 700 struct lm78_data *data = i2c_get_clientdata(client);
700 down(&data->lock); 701 mutex_lock(&data->lock);
701 outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); 702 outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET);
702 res = inb_p(client->addr + LM78_DATA_REG_OFFSET); 703 res = inb_p(client->addr + LM78_DATA_REG_OFFSET);
703 up(&data->lock); 704 mutex_unlock(&data->lock);
704 return res; 705 return res;
705 } else 706 } else
706 return i2c_smbus_read_byte_data(client, reg); 707 return i2c_smbus_read_byte_data(client, reg);
@@ -717,10 +718,10 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value)
717{ 718{
718 if (i2c_is_isa_client(client)) { 719 if (i2c_is_isa_client(client)) {
719 struct lm78_data *data = i2c_get_clientdata(client); 720 struct lm78_data *data = i2c_get_clientdata(client);
720 down(&data->lock); 721 mutex_lock(&data->lock);
721 outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); 722 outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET);
722 outb_p(value, client->addr + LM78_DATA_REG_OFFSET); 723 outb_p(value, client->addr + LM78_DATA_REG_OFFSET);
723 up(&data->lock); 724 mutex_unlock(&data->lock);
724 return 0; 725 return 0;
725 } else 726 } else
726 return i2c_smbus_write_byte_data(client, reg, value); 727 return i2c_smbus_write_byte_data(client, reg, value);
@@ -742,7 +743,7 @@ static struct lm78_data *lm78_update_device(struct device *dev)
742 struct lm78_data *data = i2c_get_clientdata(client); 743 struct lm78_data *data = i2c_get_clientdata(client);
743 int i; 744 int i;
744 745
745 down(&data->update_lock); 746 mutex_lock(&data->update_lock);
746 747
747 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 748 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
748 || !data->valid) { 749 || !data->valid) {
@@ -786,7 +787,7 @@ static struct lm78_data *lm78_update_device(struct device *dev)
786 data->fan_div[2] = 1; 787 data->fan_div[2] = 1;
787 } 788 }
788 789
789 up(&data->update_lock); 790 mutex_unlock(&data->update_lock);
790 791
791 return data; 792 return data;
792} 793}
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
index c9a7cdea7bd7..f72120d08c4c 100644
--- a/drivers/hwmon/lm80.c
+++ b/drivers/hwmon/lm80.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 32
32/* Addresses to scan */ 33/* Addresses to scan */
33static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 34static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c,
@@ -108,7 +109,7 @@ static inline long TEMP_FROM_REG(u16 temp)
108struct lm80_data { 109struct lm80_data {
109 struct i2c_client client; 110 struct i2c_client client;
110 struct class_device *class_dev; 111 struct class_device *class_dev;
111 struct semaphore update_lock; 112 struct mutex update_lock;
112 char valid; /* !=0 if following fields are valid */ 113 char valid; /* !=0 if following fields are valid */
113 unsigned long last_updated; /* In jiffies */ 114 unsigned long last_updated; /* In jiffies */
114 115
@@ -191,10 +192,10 @@ static ssize_t set_in_##suffix(struct device *dev, struct device_attribute *attr
191 struct lm80_data *data = i2c_get_clientdata(client); \ 192 struct lm80_data *data = i2c_get_clientdata(client); \
192 long val = simple_strtol(buf, NULL, 10); \ 193 long val = simple_strtol(buf, NULL, 10); \
193 \ 194 \
194 down(&data->update_lock);\ 195 mutex_lock(&data->update_lock);\
195 data->value = IN_TO_REG(val); \ 196 data->value = IN_TO_REG(val); \
196 lm80_write_value(client, reg, data->value); \ 197 lm80_write_value(client, reg, data->value); \
197 up(&data->update_lock);\ 198 mutex_unlock(&data->update_lock);\
198 return count; \ 199 return count; \
199} 200}
200set_in(min0, in_min[0], LM80_REG_IN_MIN(0)); 201set_in(min0, in_min[0], LM80_REG_IN_MIN(0));
@@ -241,10 +242,10 @@ static ssize_t set_fan_##suffix(struct device *dev, struct device_attribute *att
241 struct lm80_data *data = i2c_get_clientdata(client); \ 242 struct lm80_data *data = i2c_get_clientdata(client); \
242 long val = simple_strtoul(buf, NULL, 10); \ 243 long val = simple_strtoul(buf, NULL, 10); \
243 \ 244 \
244 down(&data->update_lock);\ 245 mutex_lock(&data->update_lock);\
245 data->value = FAN_TO_REG(val, DIV_FROM_REG(data->div)); \ 246 data->value = FAN_TO_REG(val, DIV_FROM_REG(data->div)); \
246 lm80_write_value(client, reg, data->value); \ 247 lm80_write_value(client, reg, data->value); \
247 up(&data->update_lock);\ 248 mutex_unlock(&data->update_lock);\
248 return count; \ 249 return count; \
249} 250}
250set_fan(min1, fan_min[0], LM80_REG_FAN_MIN(1), fan_div[0]); 251set_fan(min1, fan_min[0], LM80_REG_FAN_MIN(1), fan_div[0]);
@@ -263,7 +264,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
263 u8 reg; 264 u8 reg;
264 265
265 /* Save fan_min */ 266 /* Save fan_min */
266 down(&data->update_lock); 267 mutex_lock(&data->update_lock);
267 min = FAN_FROM_REG(data->fan_min[nr], 268 min = FAN_FROM_REG(data->fan_min[nr],
268 DIV_FROM_REG(data->fan_div[nr])); 269 DIV_FROM_REG(data->fan_div[nr]));
269 270
@@ -275,7 +276,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
275 default: 276 default:
276 dev_err(&client->dev, "fan_div value %ld not " 277 dev_err(&client->dev, "fan_div value %ld not "
277 "supported. Choose one of 1, 2, 4 or 8!\n", val); 278 "supported. Choose one of 1, 2, 4 or 8!\n", val);
278 up(&data->update_lock); 279 mutex_unlock(&data->update_lock);
279 return -EINVAL; 280 return -EINVAL;
280 } 281 }
281 282
@@ -286,7 +287,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
286 /* Restore fan_min */ 287 /* Restore fan_min */
287 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 288 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
288 lm80_write_value(client, LM80_REG_FAN_MIN(nr + 1), data->fan_min[nr]); 289 lm80_write_value(client, LM80_REG_FAN_MIN(nr + 1), data->fan_min[nr]);
289 up(&data->update_lock); 290 mutex_unlock(&data->update_lock);
290 291
291 return count; 292 return count;
292} 293}
@@ -325,10 +326,10 @@ static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *at
325 struct lm80_data *data = i2c_get_clientdata(client); \ 326 struct lm80_data *data = i2c_get_clientdata(client); \
326 long val = simple_strtoul(buf, NULL, 10); \ 327 long val = simple_strtoul(buf, NULL, 10); \
327 \ 328 \
328 down(&data->update_lock); \ 329 mutex_lock(&data->update_lock); \
329 data->value = TEMP_LIMIT_TO_REG(val); \ 330 data->value = TEMP_LIMIT_TO_REG(val); \
330 lm80_write_value(client, reg, data->value); \ 331 lm80_write_value(client, reg, data->value); \
331 up(&data->update_lock); \ 332 mutex_unlock(&data->update_lock); \
332 return count; \ 333 return count; \
333} 334}
334set_temp(hot_max, temp_hot_max, LM80_REG_TEMP_HOT_MAX); 335set_temp(hot_max, temp_hot_max, LM80_REG_TEMP_HOT_MAX);
@@ -437,7 +438,7 @@ static int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
437 /* Fill in the remaining client fields and put it into the global list */ 438 /* Fill in the remaining client fields and put it into the global list */
438 strlcpy(new_client->name, name, I2C_NAME_SIZE); 439 strlcpy(new_client->name, name, I2C_NAME_SIZE);
439 data->valid = 0; 440 data->valid = 0;
440 init_MUTEX(&data->update_lock); 441 mutex_init(&data->update_lock);
441 442
442 /* Tell the I2C layer a new client has arrived */ 443 /* Tell the I2C layer a new client has arrived */
443 if ((err = i2c_attach_client(new_client))) 444 if ((err = i2c_attach_client(new_client)))
@@ -545,7 +546,7 @@ static struct lm80_data *lm80_update_device(struct device *dev)
545 struct lm80_data *data = i2c_get_clientdata(client); 546 struct lm80_data *data = i2c_get_clientdata(client);
546 int i; 547 int i;
547 548
548 down(&data->update_lock); 549 mutex_lock(&data->update_lock);
549 550
550 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { 551 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
551 dev_dbg(&client->dev, "Starting lm80 update\n"); 552 dev_dbg(&client->dev, "Starting lm80 update\n");
@@ -585,7 +586,7 @@ static struct lm80_data *lm80_update_device(struct device *dev)
585 data->valid = 1; 586 data->valid = 1;
586 } 587 }
587 588
588 up(&data->update_lock); 589 mutex_unlock(&data->update_lock);
589 590
590 return data; 591 return data;
591} 592}
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c
index 26dfa9e216c2..aac4ec2bf694 100644
--- a/drivers/hwmon/lm83.c
+++ b/drivers/hwmon/lm83.c
@@ -35,6 +35,7 @@
35#include <linux/hwmon-sysfs.h> 35#include <linux/hwmon-sysfs.h>
36#include <linux/hwmon.h> 36#include <linux/hwmon.h>
37#include <linux/err.h> 37#include <linux/err.h>
38#include <linux/mutex.h>
38 39
39/* 40/*
40 * Addresses to scan 41 * Addresses to scan
@@ -139,7 +140,7 @@ static struct i2c_driver lm83_driver = {
139struct lm83_data { 140struct lm83_data {
140 struct i2c_client client; 141 struct i2c_client client;
141 struct class_device *class_dev; 142 struct class_device *class_dev;
142 struct semaphore update_lock; 143 struct mutex update_lock;
143 char valid; /* zero until following fields are valid */ 144 char valid; /* zero until following fields are valid */
144 unsigned long last_updated; /* in jiffies */ 145 unsigned long last_updated; /* in jiffies */
145 146
@@ -171,11 +172,11 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
171 long val = simple_strtol(buf, NULL, 10); 172 long val = simple_strtol(buf, NULL, 10);
172 int nr = attr->index; 173 int nr = attr->index;
173 174
174 down(&data->update_lock); 175 mutex_lock(&data->update_lock);
175 data->temp[nr] = TEMP_TO_REG(val); 176 data->temp[nr] = TEMP_TO_REG(val);
176 i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4], 177 i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4],
177 data->temp[nr]); 178 data->temp[nr]);
178 up(&data->update_lock); 179 mutex_unlock(&data->update_lock);
179 return count; 180 return count;
180} 181}
181 182
@@ -300,7 +301,7 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
300 /* We can fill in the remaining client fields */ 301 /* We can fill in the remaining client fields */
301 strlcpy(new_client->name, name, I2C_NAME_SIZE); 302 strlcpy(new_client->name, name, I2C_NAME_SIZE);
302 data->valid = 0; 303 data->valid = 0;
303 init_MUTEX(&data->update_lock); 304 mutex_init(&data->update_lock);
304 305
305 /* Tell the I2C layer a new client has arrived */ 306 /* Tell the I2C layer a new client has arrived */
306 if ((err = i2c_attach_client(new_client))) 307 if ((err = i2c_attach_client(new_client)))
@@ -373,7 +374,7 @@ static struct lm83_data *lm83_update_device(struct device *dev)
373 struct i2c_client *client = to_i2c_client(dev); 374 struct i2c_client *client = to_i2c_client(dev);
374 struct lm83_data *data = i2c_get_clientdata(client); 375 struct lm83_data *data = i2c_get_clientdata(client);
375 376
376 down(&data->update_lock); 377 mutex_lock(&data->update_lock);
377 378
378 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { 379 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
379 int nr; 380 int nr;
@@ -393,7 +394,7 @@ static struct lm83_data *lm83_update_device(struct device *dev)
393 data->valid = 1; 394 data->valid = 1;
394 } 395 }
395 396
396 up(&data->update_lock); 397 mutex_unlock(&data->update_lock);
397 398
398 return data; 399 return data;
399} 400}
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index 7389a0127547..095e58ac2ceb 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -31,6 +31,7 @@
31#include <linux/hwmon.h> 31#include <linux/hwmon.h>
32#include <linux/hwmon-vid.h> 32#include <linux/hwmon-vid.h>
33#include <linux/err.h> 33#include <linux/err.h>
34#include <linux/mutex.h>
34 35
35/* Addresses to scan */ 36/* Addresses to scan */
36static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; 37static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
@@ -331,10 +332,10 @@ struct lm85_autofan {
331struct lm85_data { 332struct lm85_data {
332 struct i2c_client client; 333 struct i2c_client client;
333 struct class_device *class_dev; 334 struct class_device *class_dev;
334 struct semaphore lock; 335 struct mutex lock;
335 enum chips type; 336 enum chips type;
336 337
337 struct semaphore update_lock; 338 struct mutex update_lock;
338 int valid; /* !=0 if following fields are valid */ 339 int valid; /* !=0 if following fields are valid */
339 unsigned long last_reading; /* In jiffies */ 340 unsigned long last_reading; /* In jiffies */
340 unsigned long last_config; /* In jiffies */ 341 unsigned long last_config; /* In jiffies */
@@ -407,10 +408,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
407 struct lm85_data *data = i2c_get_clientdata(client); 408 struct lm85_data *data = i2c_get_clientdata(client);
408 long val = simple_strtol(buf, NULL, 10); 409 long val = simple_strtol(buf, NULL, 10);
409 410
410 down(&data->update_lock); 411 mutex_lock(&data->update_lock);
411 data->fan_min[nr] = FAN_TO_REG(val); 412 data->fan_min[nr] = FAN_TO_REG(val);
412 lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]); 413 lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]);
413 up(&data->update_lock); 414 mutex_unlock(&data->update_lock);
414 return count; 415 return count;
415} 416}
416 417
@@ -499,10 +500,10 @@ static ssize_t set_pwm(struct device *dev, const char *buf,
499 struct lm85_data *data = i2c_get_clientdata(client); 500 struct lm85_data *data = i2c_get_clientdata(client);
500 long val = simple_strtol(buf, NULL, 10); 501 long val = simple_strtol(buf, NULL, 10);
501 502
502 down(&data->update_lock); 503 mutex_lock(&data->update_lock);
503 data->pwm[nr] = PWM_TO_REG(val); 504 data->pwm[nr] = PWM_TO_REG(val);
504 lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]); 505 lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]);
505 up(&data->update_lock); 506 mutex_unlock(&data->update_lock);
506 return count; 507 return count;
507} 508}
508static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) 509static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr)
@@ -559,10 +560,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
559 struct lm85_data *data = i2c_get_clientdata(client); 560 struct lm85_data *data = i2c_get_clientdata(client);
560 long val = simple_strtol(buf, NULL, 10); 561 long val = simple_strtol(buf, NULL, 10);
561 562
562 down(&data->update_lock); 563 mutex_lock(&data->update_lock);
563 data->in_min[nr] = INS_TO_REG(nr, val); 564 data->in_min[nr] = INS_TO_REG(nr, val);
564 lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]); 565 lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]);
565 up(&data->update_lock); 566 mutex_unlock(&data->update_lock);
566 return count; 567 return count;
567} 568}
568static ssize_t show_in_max(struct device *dev, char *buf, int nr) 569static ssize_t show_in_max(struct device *dev, char *buf, int nr)
@@ -577,10 +578,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
577 struct lm85_data *data = i2c_get_clientdata(client); 578 struct lm85_data *data = i2c_get_clientdata(client);
578 long val = simple_strtol(buf, NULL, 10); 579 long val = simple_strtol(buf, NULL, 10);
579 580
580 down(&data->update_lock); 581 mutex_lock(&data->update_lock);
581 data->in_max[nr] = INS_TO_REG(nr, val); 582 data->in_max[nr] = INS_TO_REG(nr, val);
582 lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]); 583 lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]);
583 up(&data->update_lock); 584 mutex_unlock(&data->update_lock);
584 return count; 585 return count;
585} 586}
586#define show_in_reg(offset) \ 587#define show_in_reg(offset) \
@@ -640,10 +641,10 @@ static ssize_t set_temp_min(struct device *dev, const char *buf,
640 struct lm85_data *data = i2c_get_clientdata(client); 641 struct lm85_data *data = i2c_get_clientdata(client);
641 long val = simple_strtol(buf, NULL, 10); 642 long val = simple_strtol(buf, NULL, 10);
642 643
643 down(&data->update_lock); 644 mutex_lock(&data->update_lock);
644 data->temp_min[nr] = TEMP_TO_REG(val); 645 data->temp_min[nr] = TEMP_TO_REG(val);
645 lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]); 646 lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]);
646 up(&data->update_lock); 647 mutex_unlock(&data->update_lock);
647 return count; 648 return count;
648} 649}
649static ssize_t show_temp_max(struct device *dev, char *buf, int nr) 650static ssize_t show_temp_max(struct device *dev, char *buf, int nr)
@@ -658,10 +659,10 @@ static ssize_t set_temp_max(struct device *dev, const char *buf,
658 struct lm85_data *data = i2c_get_clientdata(client); 659 struct lm85_data *data = i2c_get_clientdata(client);
659 long val = simple_strtol(buf, NULL, 10); 660 long val = simple_strtol(buf, NULL, 10);
660 661
661 down(&data->update_lock); 662 mutex_lock(&data->update_lock);
662 data->temp_max[nr] = TEMP_TO_REG(val); 663 data->temp_max[nr] = TEMP_TO_REG(val);
663 lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]); 664 lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]);
664 up(&data->update_lock); 665 mutex_unlock(&data->update_lock);
665 return count; 666 return count;
666} 667}
667#define show_temp_reg(offset) \ 668#define show_temp_reg(offset) \
@@ -713,12 +714,12 @@ static ssize_t set_pwm_auto_channels(struct device *dev, const char *buf,
713 struct lm85_data *data = i2c_get_clientdata(client); 714 struct lm85_data *data = i2c_get_clientdata(client);
714 long val = simple_strtol(buf, NULL, 10); 715 long val = simple_strtol(buf, NULL, 10);
715 716
716 down(&data->update_lock); 717 mutex_lock(&data->update_lock);
717 data->autofan[nr].config = (data->autofan[nr].config & (~0xe0)) 718 data->autofan[nr].config = (data->autofan[nr].config & (~0xe0))
718 | ZONE_TO_REG(val) ; 719 | ZONE_TO_REG(val) ;
719 lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), 720 lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr),
720 data->autofan[nr].config); 721 data->autofan[nr].config);
721 up(&data->update_lock); 722 mutex_unlock(&data->update_lock);
722 return count; 723 return count;
723} 724}
724static ssize_t show_pwm_auto_pwm_min(struct device *dev, char *buf, int nr) 725static ssize_t show_pwm_auto_pwm_min(struct device *dev, char *buf, int nr)
@@ -733,11 +734,11 @@ static ssize_t set_pwm_auto_pwm_min(struct device *dev, const char *buf,
733 struct lm85_data *data = i2c_get_clientdata(client); 734 struct lm85_data *data = i2c_get_clientdata(client);
734 long val = simple_strtol(buf, NULL, 10); 735 long val = simple_strtol(buf, NULL, 10);
735 736
736 down(&data->update_lock); 737 mutex_lock(&data->update_lock);
737 data->autofan[nr].min_pwm = PWM_TO_REG(val); 738 data->autofan[nr].min_pwm = PWM_TO_REG(val);
738 lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr), 739 lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr),
739 data->autofan[nr].min_pwm); 740 data->autofan[nr].min_pwm);
740 up(&data->update_lock); 741 mutex_unlock(&data->update_lock);
741 return count; 742 return count;
742} 743}
743static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, char *buf, int nr) 744static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, char *buf, int nr)
@@ -752,7 +753,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf,
752 struct lm85_data *data = i2c_get_clientdata(client); 753 struct lm85_data *data = i2c_get_clientdata(client);
753 long val = simple_strtol(buf, NULL, 10); 754 long val = simple_strtol(buf, NULL, 10);
754 755
755 down(&data->update_lock); 756 mutex_lock(&data->update_lock);
756 data->autofan[nr].min_off = val; 757 data->autofan[nr].min_off = val;
757 lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0] 758 lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0]
758 | data->syncpwm3 759 | data->syncpwm3
@@ -760,7 +761,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf,
760 | (data->autofan[1].min_off ? 0x40 : 0) 761 | (data->autofan[1].min_off ? 0x40 : 0)
761 | (data->autofan[2].min_off ? 0x80 : 0) 762 | (data->autofan[2].min_off ? 0x80 : 0)
762 ); 763 );
763 up(&data->update_lock); 764 mutex_unlock(&data->update_lock);
764 return count; 765 return count;
765} 766}
766static ssize_t show_pwm_auto_pwm_freq(struct device *dev, char *buf, int nr) 767static ssize_t show_pwm_auto_pwm_freq(struct device *dev, char *buf, int nr)
@@ -775,13 +776,13 @@ static ssize_t set_pwm_auto_pwm_freq(struct device *dev, const char *buf,
775 struct lm85_data *data = i2c_get_clientdata(client); 776 struct lm85_data *data = i2c_get_clientdata(client);
776 long val = simple_strtol(buf, NULL, 10); 777 long val = simple_strtol(buf, NULL, 10);
777 778
778 down(&data->update_lock); 779 mutex_lock(&data->update_lock);
779 data->autofan[nr].freq = FREQ_TO_REG(val); 780 data->autofan[nr].freq = FREQ_TO_REG(val);
780 lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), 781 lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
781 (data->zone[nr].range << 4) 782 (data->zone[nr].range << 4)
782 | data->autofan[nr].freq 783 | data->autofan[nr].freq
783 ); 784 );
784 up(&data->update_lock); 785 mutex_unlock(&data->update_lock);
785 return count; 786 return count;
786} 787}
787#define pwm_auto(offset) \ 788#define pwm_auto(offset) \
@@ -857,7 +858,7 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf,
857 int min; 858 int min;
858 long val = simple_strtol(buf, NULL, 10); 859 long val = simple_strtol(buf, NULL, 10);
859 860
860 down(&data->update_lock); 861 mutex_lock(&data->update_lock);
861 min = TEMP_FROM_REG(data->zone[nr].limit); 862 min = TEMP_FROM_REG(data->zone[nr].limit);
862 data->zone[nr].off_desired = TEMP_TO_REG(val); 863 data->zone[nr].off_desired = TEMP_TO_REG(val);
863 data->zone[nr].hyst = HYST_TO_REG(min - val); 864 data->zone[nr].hyst = HYST_TO_REG(min - val);
@@ -871,7 +872,7 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf,
871 (data->zone[2].hyst << 4) 872 (data->zone[2].hyst << 4)
872 ); 873 );
873 } 874 }
874 up(&data->update_lock); 875 mutex_unlock(&data->update_lock);
875 return count; 876 return count;
876} 877}
877static ssize_t show_temp_auto_temp_min(struct device *dev, char *buf, int nr) 878static ssize_t show_temp_auto_temp_min(struct device *dev, char *buf, int nr)
@@ -886,7 +887,7 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf,
886 struct lm85_data *data = i2c_get_clientdata(client); 887 struct lm85_data *data = i2c_get_clientdata(client);
887 long val = simple_strtol(buf, NULL, 10); 888 long val = simple_strtol(buf, NULL, 10);
888 889
889 down(&data->update_lock); 890 mutex_lock(&data->update_lock);
890 data->zone[nr].limit = TEMP_TO_REG(val); 891 data->zone[nr].limit = TEMP_TO_REG(val);
891 lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr), 892 lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr),
892 data->zone[nr].limit); 893 data->zone[nr].limit);
@@ -913,7 +914,7 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf,
913 (data->zone[2].hyst << 4) 914 (data->zone[2].hyst << 4)
914 ); 915 );
915 } 916 }
916 up(&data->update_lock); 917 mutex_unlock(&data->update_lock);
917 return count; 918 return count;
918} 919}
919static ssize_t show_temp_auto_temp_max(struct device *dev, char *buf, int nr) 920static ssize_t show_temp_auto_temp_max(struct device *dev, char *buf, int nr)
@@ -930,7 +931,7 @@ static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf,
930 int min; 931 int min;
931 long val = simple_strtol(buf, NULL, 10); 932 long val = simple_strtol(buf, NULL, 10);
932 933
933 down(&data->update_lock); 934 mutex_lock(&data->update_lock);
934 min = TEMP_FROM_REG(data->zone[nr].limit); 935 min = TEMP_FROM_REG(data->zone[nr].limit);
935 data->zone[nr].max_desired = TEMP_TO_REG(val); 936 data->zone[nr].max_desired = TEMP_TO_REG(val);
936 data->zone[nr].range = RANGE_TO_REG( 937 data->zone[nr].range = RANGE_TO_REG(
@@ -938,7 +939,7 @@ static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf,
938 lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), 939 lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
939 ((data->zone[nr].range & 0x0f) << 4) 940 ((data->zone[nr].range & 0x0f) << 4)
940 | (data->autofan[nr].freq & 0x07)); 941 | (data->autofan[nr].freq & 0x07));
941 up(&data->update_lock); 942 mutex_unlock(&data->update_lock);
942 return count; 943 return count;
943} 944}
944static ssize_t show_temp_auto_temp_crit(struct device *dev, char *buf, int nr) 945static ssize_t show_temp_auto_temp_crit(struct device *dev, char *buf, int nr)
@@ -953,11 +954,11 @@ static ssize_t set_temp_auto_temp_crit(struct device *dev, const char *buf,
953 struct lm85_data *data = i2c_get_clientdata(client); 954 struct lm85_data *data = i2c_get_clientdata(client);
954 long val = simple_strtol(buf, NULL, 10); 955 long val = simple_strtol(buf, NULL, 10);
955 956
956 down(&data->update_lock); 957 mutex_lock(&data->update_lock);
957 data->zone[nr].critical = TEMP_TO_REG(val); 958 data->zone[nr].critical = TEMP_TO_REG(val);
958 lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr), 959 lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr),
959 data->zone[nr].critical); 960 data->zone[nr].critical);
960 up(&data->update_lock); 961 mutex_unlock(&data->update_lock);
961 return count; 962 return count;
962} 963}
963#define temp_auto(offset) \ 964#define temp_auto(offset) \
@@ -1149,7 +1150,7 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
1149 /* Fill in the remaining client fields */ 1150 /* Fill in the remaining client fields */
1150 data->type = kind; 1151 data->type = kind;
1151 data->valid = 0; 1152 data->valid = 0;
1152 init_MUTEX(&data->update_lock); 1153 mutex_init(&data->update_lock);
1153 1154
1154 /* Tell the I2C layer a new client has arrived */ 1155 /* Tell the I2C layer a new client has arrived */
1155 if ((err = i2c_attach_client(new_client))) 1156 if ((err = i2c_attach_client(new_client)))
@@ -1368,7 +1369,7 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1368 struct lm85_data *data = i2c_get_clientdata(client); 1369 struct lm85_data *data = i2c_get_clientdata(client);
1369 int i; 1370 int i;
1370 1371
1371 down(&data->update_lock); 1372 mutex_lock(&data->update_lock);
1372 1373
1373 if ( !data->valid || 1374 if ( !data->valid ||
1374 time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) { 1375 time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) {
@@ -1571,7 +1572,7 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1571 1572
1572 data->valid = 1; 1573 data->valid = 1;
1573 1574
1574 up(&data->update_lock); 1575 mutex_unlock(&data->update_lock);
1575 1576
1576 return data; 1577 return data;
1577} 1578}
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c
index 6ba34c302d8d..e229daf666de 100644
--- a/drivers/hwmon/lm87.c
+++ b/drivers/hwmon/lm87.c
@@ -60,6 +60,7 @@
60#include <linux/hwmon.h> 60#include <linux/hwmon.h>
61#include <linux/hwmon-vid.h> 61#include <linux/hwmon-vid.h>
62#include <linux/err.h> 62#include <linux/err.h>
63#include <linux/mutex.h>
63 64
64/* 65/*
65 * Addresses to scan 66 * Addresses to scan
@@ -176,7 +177,7 @@ static struct i2c_driver lm87_driver = {
176struct lm87_data { 177struct lm87_data {
177 struct i2c_client client; 178 struct i2c_client client;
178 struct class_device *class_dev; 179 struct class_device *class_dev;
179 struct semaphore update_lock; 180 struct mutex update_lock;
180 char valid; /* zero until following fields are valid */ 181 char valid; /* zero until following fields are valid */
181 unsigned long last_updated; /* In jiffies */ 182 unsigned long last_updated; /* In jiffies */
182 183
@@ -253,11 +254,11 @@ static void set_in_min(struct device *dev, const char *buf, int nr)
253 struct lm87_data *data = i2c_get_clientdata(client); 254 struct lm87_data *data = i2c_get_clientdata(client);
254 long val = simple_strtol(buf, NULL, 10); 255 long val = simple_strtol(buf, NULL, 10);
255 256
256 down(&data->update_lock); 257 mutex_lock(&data->update_lock);
257 data->in_min[nr] = IN_TO_REG(val, data->in_scale[nr]); 258 data->in_min[nr] = IN_TO_REG(val, data->in_scale[nr]);
258 lm87_write_value(client, nr<6 ? LM87_REG_IN_MIN(nr) : 259 lm87_write_value(client, nr<6 ? LM87_REG_IN_MIN(nr) :
259 LM87_REG_AIN_MIN(nr-6), data->in_min[nr]); 260 LM87_REG_AIN_MIN(nr-6), data->in_min[nr]);
260 up(&data->update_lock); 261 mutex_unlock(&data->update_lock);
261} 262}
262 263
263static void set_in_max(struct device *dev, const char *buf, int nr) 264static void set_in_max(struct device *dev, const char *buf, int nr)
@@ -266,11 +267,11 @@ static void set_in_max(struct device *dev, const char *buf, int nr)
266 struct lm87_data *data = i2c_get_clientdata(client); 267 struct lm87_data *data = i2c_get_clientdata(client);
267 long val = simple_strtol(buf, NULL, 10); 268 long val = simple_strtol(buf, NULL, 10);
268 269
269 down(&data->update_lock); 270 mutex_lock(&data->update_lock);
270 data->in_max[nr] = IN_TO_REG(val, data->in_scale[nr]); 271 data->in_max[nr] = IN_TO_REG(val, data->in_scale[nr]);
271 lm87_write_value(client, nr<6 ? LM87_REG_IN_MAX(nr) : 272 lm87_write_value(client, nr<6 ? LM87_REG_IN_MAX(nr) :
272 LM87_REG_AIN_MAX(nr-6), data->in_max[nr]); 273 LM87_REG_AIN_MAX(nr-6), data->in_max[nr]);
273 up(&data->update_lock); 274 mutex_unlock(&data->update_lock);
274} 275}
275 276
276#define set_in(offset) \ 277#define set_in(offset) \
@@ -327,10 +328,10 @@ static void set_temp_low(struct device *dev, const char *buf, int nr)
327 struct lm87_data *data = i2c_get_clientdata(client); 328 struct lm87_data *data = i2c_get_clientdata(client);
328 long val = simple_strtol(buf, NULL, 10); 329 long val = simple_strtol(buf, NULL, 10);
329 330
330 down(&data->update_lock); 331 mutex_lock(&data->update_lock);
331 data->temp_low[nr] = TEMP_TO_REG(val); 332 data->temp_low[nr] = TEMP_TO_REG(val);
332 lm87_write_value(client, LM87_REG_TEMP_LOW[nr], data->temp_low[nr]); 333 lm87_write_value(client, LM87_REG_TEMP_LOW[nr], data->temp_low[nr]);
333 up(&data->update_lock); 334 mutex_unlock(&data->update_lock);
334} 335}
335 336
336static void set_temp_high(struct device *dev, const char *buf, int nr) 337static void set_temp_high(struct device *dev, const char *buf, int nr)
@@ -339,10 +340,10 @@ static void set_temp_high(struct device *dev, const char *buf, int nr)
339 struct lm87_data *data = i2c_get_clientdata(client); 340 struct lm87_data *data = i2c_get_clientdata(client);
340 long val = simple_strtol(buf, NULL, 10); 341 long val = simple_strtol(buf, NULL, 10);
341 342
342 down(&data->update_lock); 343 mutex_lock(&data->update_lock);
343 data->temp_high[nr] = TEMP_TO_REG(val); 344 data->temp_high[nr] = TEMP_TO_REG(val);
344 lm87_write_value(client, LM87_REG_TEMP_HIGH[nr], data->temp_high[nr]); 345 lm87_write_value(client, LM87_REG_TEMP_HIGH[nr], data->temp_high[nr]);
345 up(&data->update_lock); 346 mutex_unlock(&data->update_lock);
346} 347}
347 348
348#define set_temp(offset) \ 349#define set_temp(offset) \
@@ -411,11 +412,11 @@ static void set_fan_min(struct device *dev, const char *buf, int nr)
411 struct lm87_data *data = i2c_get_clientdata(client); 412 struct lm87_data *data = i2c_get_clientdata(client);
412 long val = simple_strtol(buf, NULL, 10); 413 long val = simple_strtol(buf, NULL, 10);
413 414
414 down(&data->update_lock); 415 mutex_lock(&data->update_lock);
415 data->fan_min[nr] = FAN_TO_REG(val, 416 data->fan_min[nr] = FAN_TO_REG(val,
416 FAN_DIV_FROM_REG(data->fan_div[nr])); 417 FAN_DIV_FROM_REG(data->fan_div[nr]));
417 lm87_write_value(client, LM87_REG_FAN_MIN(nr), data->fan_min[nr]); 418 lm87_write_value(client, LM87_REG_FAN_MIN(nr), data->fan_min[nr]);
418 up(&data->update_lock); 419 mutex_unlock(&data->update_lock);
419} 420}
420 421
421/* Note: we save and restore the fan minimum here, because its value is 422/* Note: we save and restore the fan minimum here, because its value is
@@ -431,7 +432,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
431 unsigned long min; 432 unsigned long min;
432 u8 reg; 433 u8 reg;
433 434
434 down(&data->update_lock); 435 mutex_lock(&data->update_lock);
435 min = FAN_FROM_REG(data->fan_min[nr], 436 min = FAN_FROM_REG(data->fan_min[nr],
436 FAN_DIV_FROM_REG(data->fan_div[nr])); 437 FAN_DIV_FROM_REG(data->fan_div[nr]));
437 438
@@ -441,7 +442,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
441 case 4: data->fan_div[nr] = 2; break; 442 case 4: data->fan_div[nr] = 2; break;
442 case 8: data->fan_div[nr] = 3; break; 443 case 8: data->fan_div[nr] = 3; break;
443 default: 444 default:
444 up(&data->update_lock); 445 mutex_unlock(&data->update_lock);
445 return -EINVAL; 446 return -EINVAL;
446 } 447 }
447 448
@@ -459,7 +460,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
459 data->fan_min[nr] = FAN_TO_REG(min, val); 460 data->fan_min[nr] = FAN_TO_REG(min, val);
460 lm87_write_value(client, LM87_REG_FAN_MIN(nr), 461 lm87_write_value(client, LM87_REG_FAN_MIN(nr),
461 data->fan_min[nr]); 462 data->fan_min[nr]);
462 up(&data->update_lock); 463 mutex_unlock(&data->update_lock);
463 464
464 return count; 465 return count;
465} 466}
@@ -522,10 +523,10 @@ static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const
522 struct lm87_data *data = i2c_get_clientdata(client); 523 struct lm87_data *data = i2c_get_clientdata(client);
523 long val = simple_strtol(buf, NULL, 10); 524 long val = simple_strtol(buf, NULL, 10);
524 525
525 down(&data->update_lock); 526 mutex_lock(&data->update_lock);
526 data->aout = AOUT_TO_REG(val); 527 data->aout = AOUT_TO_REG(val);
527 lm87_write_value(client, LM87_REG_AOUT, data->aout); 528 lm87_write_value(client, LM87_REG_AOUT, data->aout);
528 up(&data->update_lock); 529 mutex_unlock(&data->update_lock);
529 return count; 530 return count;
530} 531}
531static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); 532static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);
@@ -589,7 +590,7 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
589 /* We can fill in the remaining client fields */ 590 /* We can fill in the remaining client fields */
590 strlcpy(new_client->name, "lm87", I2C_NAME_SIZE); 591 strlcpy(new_client->name, "lm87", I2C_NAME_SIZE);
591 data->valid = 0; 592 data->valid = 0;
592 init_MUTEX(&data->update_lock); 593 mutex_init(&data->update_lock);
593 594
594 /* Tell the I2C layer a new client has arrived */ 595 /* Tell the I2C layer a new client has arrived */
595 if ((err = i2c_attach_client(new_client))) 596 if ((err = i2c_attach_client(new_client)))
@@ -744,7 +745,7 @@ static struct lm87_data *lm87_update_device(struct device *dev)
744 struct i2c_client *client = to_i2c_client(dev); 745 struct i2c_client *client = to_i2c_client(dev);
745 struct lm87_data *data = i2c_get_clientdata(client); 746 struct lm87_data *data = i2c_get_clientdata(client);
746 747
747 down(&data->update_lock); 748 mutex_lock(&data->update_lock);
748 749
749 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { 750 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
750 int i, j; 751 int i, j;
@@ -813,7 +814,7 @@ static struct lm87_data *lm87_update_device(struct device *dev)
813 data->valid = 1; 814 data->valid = 1;
814 } 815 }
815 816
816 up(&data->update_lock); 817 mutex_unlock(&data->update_lock);
817 818
818 return data; 819 return data;
819} 820}
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 = {
201struct lm90_data { 202struct 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}
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c
index b0c4cb730a7e..197f77226dc4 100644
--- a/drivers/hwmon/lm92.c
+++ b/drivers/hwmon/lm92.c
@@ -46,6 +46,7 @@
46#include <linux/i2c.h> 46#include <linux/i2c.h>
47#include <linux/hwmon.h> 47#include <linux/hwmon.h>
48#include <linux/err.h> 48#include <linux/err.h>
49#include <linux/mutex.h>
49 50
50/* The LM92 and MAX6635 have 2 two-state pins for address selection, 51/* The LM92 and MAX6635 have 2 two-state pins for address selection,
51 resulting in 4 possible addresses. */ 52 resulting in 4 possible addresses. */
@@ -96,7 +97,7 @@ static struct i2c_driver lm92_driver;
96struct lm92_data { 97struct lm92_data {
97 struct i2c_client client; 98 struct i2c_client client;
98 struct class_device *class_dev; 99 struct class_device *class_dev;
99 struct semaphore update_lock; 100 struct mutex update_lock;
100 char valid; /* zero until following fields are valid */ 101 char valid; /* zero until following fields are valid */
101 unsigned long last_updated; /* in jiffies */ 102 unsigned long last_updated; /* in jiffies */
102 103
@@ -114,7 +115,7 @@ static struct lm92_data *lm92_update_device(struct device *dev)
114 struct i2c_client *client = to_i2c_client(dev); 115 struct i2c_client *client = to_i2c_client(dev);
115 struct lm92_data *data = i2c_get_clientdata(client); 116 struct lm92_data *data = i2c_get_clientdata(client);
116 117
117 down(&data->update_lock); 118 mutex_lock(&data->update_lock);
118 119
119 if (time_after(jiffies, data->last_updated + HZ) 120 if (time_after(jiffies, data->last_updated + HZ)
120 || !data->valid) { 121 || !data->valid) {
@@ -134,7 +135,7 @@ static struct lm92_data *lm92_update_device(struct device *dev)
134 data->valid = 1; 135 data->valid = 1;
135 } 136 }
136 137
137 up(&data->update_lock); 138 mutex_unlock(&data->update_lock);
138 139
139 return data; 140 return data;
140} 141}
@@ -158,10 +159,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
158 struct lm92_data *data = i2c_get_clientdata(client); \ 159 struct lm92_data *data = i2c_get_clientdata(client); \
159 long val = simple_strtol(buf, NULL, 10); \ 160 long val = simple_strtol(buf, NULL, 10); \
160 \ 161 \
161 down(&data->update_lock); \ 162 mutex_lock(&data->update_lock); \
162 data->value = TEMP_TO_REG(val); \ 163 data->value = TEMP_TO_REG(val); \
163 i2c_smbus_write_word_data(client, reg, swab16(data->value)); \ 164 i2c_smbus_write_word_data(client, reg, swab16(data->value)); \
164 up(&data->update_lock); \ 165 mutex_unlock(&data->update_lock); \
165 return count; \ 166 return count; \
166} 167}
167set_temp(temp1_crit, LM92_REG_TEMP_CRIT); 168set_temp(temp1_crit, LM92_REG_TEMP_CRIT);
@@ -194,11 +195,11 @@ static ssize_t set_temp1_crit_hyst(struct device *dev, struct device_attribute *
194 struct lm92_data *data = i2c_get_clientdata(client); 195 struct lm92_data *data = i2c_get_clientdata(client);
195 long val = simple_strtol(buf, NULL, 10); 196 long val = simple_strtol(buf, NULL, 10);
196 197
197 down(&data->update_lock); 198 mutex_lock(&data->update_lock);
198 data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val; 199 data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val;
199 i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST, 200 i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST,
200 swab16(TEMP_TO_REG(data->temp1_hyst))); 201 swab16(TEMP_TO_REG(data->temp1_hyst)));
201 up(&data->update_lock); 202 mutex_unlock(&data->update_lock);
202 return count; 203 return count;
203} 204}
204 205
@@ -348,7 +349,7 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
348 /* Fill in the remaining client fields */ 349 /* Fill in the remaining client fields */
349 strlcpy(new_client->name, name, I2C_NAME_SIZE); 350 strlcpy(new_client->name, name, I2C_NAME_SIZE);
350 data->valid = 0; 351 data->valid = 0;
351 init_MUTEX(&data->update_lock); 352 mutex_init(&data->update_lock);
352 353
353 /* Tell the i2c subsystem a new client has arrived */ 354 /* Tell the i2c subsystem a new client has arrived */
354 if ((err = i2c_attach_client(new_client))) 355 if ((err = i2c_attach_client(new_client)))
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c
index 3abe330b22ce..b4135b5971f4 100644
--- a/drivers/hwmon/max1619.c
+++ b/drivers/hwmon/max1619.c
@@ -33,6 +33,7 @@
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <linux/hwmon.h> 34#include <linux/hwmon.h>
35#include <linux/err.h> 35#include <linux/err.h>
36#include <linux/mutex.h>
36 37
37static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, 38static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
38 0x29, 0x2a, 0x2b, 39 0x29, 0x2a, 0x2b,
@@ -104,7 +105,7 @@ static struct i2c_driver max1619_driver = {
104struct max1619_data { 105struct max1619_data {
105 struct i2c_client client; 106 struct i2c_client client;
106 struct class_device *class_dev; 107 struct class_device *class_dev;
107 struct semaphore update_lock; 108 struct mutex update_lock;
108 char valid; /* zero until following fields are valid */ 109 char valid; /* zero until following fields are valid */
109 unsigned long last_updated; /* in jiffies */ 110 unsigned long last_updated; /* in jiffies */
110 111
@@ -141,10 +142,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
141 struct max1619_data *data = i2c_get_clientdata(client); \ 142 struct max1619_data *data = i2c_get_clientdata(client); \
142 long val = simple_strtol(buf, NULL, 10); \ 143 long val = simple_strtol(buf, NULL, 10); \
143 \ 144 \
144 down(&data->update_lock); \ 145 mutex_lock(&data->update_lock); \
145 data->value = TEMP_TO_REG(val); \ 146 data->value = TEMP_TO_REG(val); \
146 i2c_smbus_write_byte_data(client, reg, data->value); \ 147 i2c_smbus_write_byte_data(client, reg, data->value); \
147 up(&data->update_lock); \ 148 mutex_unlock(&data->update_lock); \
148 return count; \ 149 return count; \
149} 150}
150 151
@@ -262,7 +263,7 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
262 /* We can fill in the remaining client fields */ 263 /* We can fill in the remaining client fields */
263 strlcpy(new_client->name, name, I2C_NAME_SIZE); 264 strlcpy(new_client->name, name, I2C_NAME_SIZE);
264 data->valid = 0; 265 data->valid = 0;
265 init_MUTEX(&data->update_lock); 266 mutex_init(&data->update_lock);
266 267
267 /* Tell the I2C layer a new client has arrived */ 268 /* Tell the I2C layer a new client has arrived */
268 if ((err = i2c_attach_client(new_client))) 269 if ((err = i2c_attach_client(new_client)))
@@ -330,7 +331,7 @@ static struct max1619_data *max1619_update_device(struct device *dev)
330 struct i2c_client *client = to_i2c_client(dev); 331 struct i2c_client *client = to_i2c_client(dev);
331 struct max1619_data *data = i2c_get_clientdata(client); 332 struct max1619_data *data = i2c_get_clientdata(client);
332 333
333 down(&data->update_lock); 334 mutex_lock(&data->update_lock);
334 335
335 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { 336 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
336 dev_dbg(&client->dev, "Updating max1619 data.\n"); 337 dev_dbg(&client->dev, "Updating max1619 data.\n");
@@ -353,7 +354,7 @@ static struct max1619_data *max1619_update_device(struct device *dev)
353 data->valid = 1; 354 data->valid = 1;
354 } 355 }
355 356
356 up(&data->update_lock); 357 mutex_unlock(&data->update_lock);
357 358
358 return data; 359 return data;
359} 360}
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c
index 2de69322f525..ae05e483a778 100644
--- a/drivers/hwmon/pc87360.c
+++ b/drivers/hwmon/pc87360.c
@@ -43,6 +43,7 @@
43#include <linux/hwmon-sysfs.h> 43#include <linux/hwmon-sysfs.h>
44#include <linux/hwmon-vid.h> 44#include <linux/hwmon-vid.h>
45#include <linux/err.h> 45#include <linux/err.h>
46#include <linux/mutex.h>
46#include <asm/io.h> 47#include <asm/io.h>
47 48
48static u8 devid; 49static u8 devid;
@@ -183,8 +184,8 @@ static inline u8 PWM_TO_REG(int val, int inv)
183struct pc87360_data { 184struct pc87360_data {
184 struct i2c_client client; 185 struct i2c_client client;
185 struct class_device *class_dev; 186 struct class_device *class_dev;
186 struct semaphore lock; 187 struct mutex lock;
187 struct semaphore update_lock; 188 struct mutex update_lock;
188 char valid; /* !=0 if following fields are valid */ 189 char valid; /* !=0 if following fields are valid */
189 unsigned long last_updated; /* In jiffies */ 190 unsigned long last_updated; /* In jiffies */
190 191
@@ -283,7 +284,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr,
283 struct pc87360_data *data = i2c_get_clientdata(client); 284 struct pc87360_data *data = i2c_get_clientdata(client);
284 long fan_min = simple_strtol(buf, NULL, 10); 285 long fan_min = simple_strtol(buf, NULL, 10);
285 286
286 down(&data->update_lock); 287 mutex_lock(&data->update_lock);
287 fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index])); 288 fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index]));
288 289
289 /* If it wouldn't fit, change clock divisor */ 290 /* If it wouldn't fit, change clock divisor */
@@ -300,7 +301,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr,
300 /* Write new divider, preserve alarm bits */ 301 /* Write new divider, preserve alarm bits */
301 pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(attr->index), 302 pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(attr->index),
302 data->fan_status[attr->index] & 0xF9); 303 data->fan_status[attr->index] & 0xF9);
303 up(&data->update_lock); 304 mutex_unlock(&data->update_lock);
304 305
305 return count; 306 return count;
306} 307}
@@ -343,12 +344,12 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, con
343 struct pc87360_data *data = i2c_get_clientdata(client); 344 struct pc87360_data *data = i2c_get_clientdata(client);
344 long val = simple_strtol(buf, NULL, 10); 345 long val = simple_strtol(buf, NULL, 10);
345 346
346 down(&data->update_lock); 347 mutex_lock(&data->update_lock);
347 data->pwm[attr->index] = PWM_TO_REG(val, 348 data->pwm[attr->index] = PWM_TO_REG(val,
348 FAN_CONFIG_INVERT(data->fan_conf, attr->index)); 349 FAN_CONFIG_INVERT(data->fan_conf, attr->index));
349 pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index), 350 pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index),
350 data->pwm[attr->index]); 351 data->pwm[attr->index]);
351 up(&data->update_lock); 352 mutex_unlock(&data->update_lock);
352 return count; 353 return count;
353} 354}
354 355
@@ -393,11 +394,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *devattr,
393 struct pc87360_data *data = i2c_get_clientdata(client); 394 struct pc87360_data *data = i2c_get_clientdata(client);
394 long val = simple_strtol(buf, NULL, 10); 395 long val = simple_strtol(buf, NULL, 10);
395 396
396 down(&data->update_lock); 397 mutex_lock(&data->update_lock);
397 data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); 398 data->in_min[attr->index] = IN_TO_REG(val, data->in_vref);
398 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MIN, 399 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MIN,
399 data->in_min[attr->index]); 400 data->in_min[attr->index]);
400 up(&data->update_lock); 401 mutex_unlock(&data->update_lock);
401 return count; 402 return count;
402} 403}
403static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf, 404static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -408,12 +409,12 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr,
408 struct pc87360_data *data = i2c_get_clientdata(client); 409 struct pc87360_data *data = i2c_get_clientdata(client);
409 long val = simple_strtol(buf, NULL, 10); 410 long val = simple_strtol(buf, NULL, 10);
410 411
411 down(&data->update_lock); 412 mutex_lock(&data->update_lock);
412 data->in_max[attr->index] = IN_TO_REG(val, 413 data->in_max[attr->index] = IN_TO_REG(val,
413 data->in_vref); 414 data->in_vref);
414 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MAX, 415 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MAX,
415 data->in_max[attr->index]); 416 data->in_max[attr->index]);
416 up(&data->update_lock); 417 mutex_unlock(&data->update_lock);
417 return count; 418 return count;
418} 419}
419 420
@@ -512,11 +513,11 @@ static ssize_t set_therm_min(struct device *dev, struct device_attribute *devatt
512 struct pc87360_data *data = i2c_get_clientdata(client); 513 struct pc87360_data *data = i2c_get_clientdata(client);
513 long val = simple_strtol(buf, NULL, 10); 514 long val = simple_strtol(buf, NULL, 10);
514 515
515 down(&data->update_lock); 516 mutex_lock(&data->update_lock);
516 data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); 517 data->in_min[attr->index] = IN_TO_REG(val, data->in_vref);
517 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MIN, 518 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MIN,
518 data->in_min[attr->index]); 519 data->in_min[attr->index]);
519 up(&data->update_lock); 520 mutex_unlock(&data->update_lock);
520 return count; 521 return count;
521} 522}
522static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf, 523static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -527,11 +528,11 @@ static ssize_t set_therm_max(struct device *dev, struct device_attribute *devatt
527 struct pc87360_data *data = i2c_get_clientdata(client); 528 struct pc87360_data *data = i2c_get_clientdata(client);
528 long val = simple_strtol(buf, NULL, 10); 529 long val = simple_strtol(buf, NULL, 10);
529 530
530 down(&data->update_lock); 531 mutex_lock(&data->update_lock);
531 data->in_max[attr->index] = IN_TO_REG(val, data->in_vref); 532 data->in_max[attr->index] = IN_TO_REG(val, data->in_vref);
532 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MAX, 533 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MAX,
533 data->in_max[attr->index]); 534 data->in_max[attr->index]);
534 up(&data->update_lock); 535 mutex_unlock(&data->update_lock);
535 return count; 536 return count;
536} 537}
537static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf, 538static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -542,11 +543,11 @@ static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devat
542 struct pc87360_data *data = i2c_get_clientdata(client); 543 struct pc87360_data *data = i2c_get_clientdata(client);
543 long val = simple_strtol(buf, NULL, 10); 544 long val = simple_strtol(buf, NULL, 10);
544 545
545 down(&data->update_lock); 546 mutex_lock(&data->update_lock);
546 data->in_crit[attr->index-11] = IN_TO_REG(val, data->in_vref); 547 data->in_crit[attr->index-11] = IN_TO_REG(val, data->in_vref);
547 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_CRIT, 548 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_CRIT,
548 data->in_crit[attr->index-11]); 549 data->in_crit[attr->index-11]);
549 up(&data->update_lock); 550 mutex_unlock(&data->update_lock);
550 return count; 551 return count;
551} 552}
552 553
@@ -654,11 +655,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *devattr
654 struct pc87360_data *data = i2c_get_clientdata(client); 655 struct pc87360_data *data = i2c_get_clientdata(client);
655 long val = simple_strtol(buf, NULL, 10); 656 long val = simple_strtol(buf, NULL, 10);
656 657
657 down(&data->update_lock); 658 mutex_lock(&data->update_lock);
658 data->temp_min[attr->index] = TEMP_TO_REG(val); 659 data->temp_min[attr->index] = TEMP_TO_REG(val);
659 pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MIN, 660 pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MIN,
660 data->temp_min[attr->index]); 661 data->temp_min[attr->index]);
661 up(&data->update_lock); 662 mutex_unlock(&data->update_lock);
662 return count; 663 return count;
663} 664}
664static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf, 665static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -669,11 +670,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr
669 struct pc87360_data *data = i2c_get_clientdata(client); 670 struct pc87360_data *data = i2c_get_clientdata(client);
670 long val = simple_strtol(buf, NULL, 10); 671 long val = simple_strtol(buf, NULL, 10);
671 672
672 down(&data->update_lock); 673 mutex_lock(&data->update_lock);
673 data->temp_max[attr->index] = TEMP_TO_REG(val); 674 data->temp_max[attr->index] = TEMP_TO_REG(val);
674 pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MAX, 675 pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MAX,
675 data->temp_max[attr->index]); 676 data->temp_max[attr->index]);
676 up(&data->update_lock); 677 mutex_unlock(&data->update_lock);
677 return count; 678 return count;
678} 679}
679static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf, 680static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -684,11 +685,11 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devatt
684 struct pc87360_data *data = i2c_get_clientdata(client); 685 struct pc87360_data *data = i2c_get_clientdata(client);
685 long val = simple_strtol(buf, NULL, 10); 686 long val = simple_strtol(buf, NULL, 10);
686 687
687 down(&data->update_lock); 688 mutex_lock(&data->update_lock);
688 data->temp_crit[attr->index] = TEMP_TO_REG(val); 689 data->temp_crit[attr->index] = TEMP_TO_REG(val);
689 pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_CRIT, 690 pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_CRIT,
690 data->temp_crit[attr->index]); 691 data->temp_crit[attr->index]);
691 up(&data->update_lock); 692 mutex_unlock(&data->update_lock);
692 return count; 693 return count;
693} 694}
694 695
@@ -845,7 +846,7 @@ static int pc87360_detect(struct i2c_adapter *adapter)
845 dev = &client->dev; 846 dev = &client->dev;
846 i2c_set_clientdata(client, data); 847 i2c_set_clientdata(client, data);
847 client->addr = address; 848 client->addr = address;
848 init_MUTEX(&data->lock); 849 mutex_init(&data->lock);
849 client->adapter = adapter; 850 client->adapter = adapter;
850 client->driver = &pc87360_driver; 851 client->driver = &pc87360_driver;
851 client->flags = 0; 852 client->flags = 0;
@@ -878,7 +879,7 @@ static int pc87360_detect(struct i2c_adapter *adapter)
878 879
879 strlcpy(client->name, name, sizeof(client->name)); 880 strlcpy(client->name, name, sizeof(client->name));
880 data->valid = 0; 881 data->valid = 0;
881 init_MUTEX(&data->update_lock); 882 mutex_init(&data->update_lock);
882 883
883 for (i = 0; i < 3; i++) { 884 for (i = 0; i < 3; i++) {
884 if (((data->address[i] = extra_isa[i])) 885 if (((data->address[i] = extra_isa[i]))
@@ -1027,11 +1028,11 @@ static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
1027{ 1028{
1028 int res; 1029 int res;
1029 1030
1030 down(&(data->lock)); 1031 mutex_lock(&(data->lock));
1031 if (bank != NO_BANK) 1032 if (bank != NO_BANK)
1032 outb_p(bank, data->address[ldi] + PC87365_REG_BANK); 1033 outb_p(bank, data->address[ldi] + PC87365_REG_BANK);
1033 res = inb_p(data->address[ldi] + reg); 1034 res = inb_p(data->address[ldi] + reg);
1034 up(&(data->lock)); 1035 mutex_unlock(&(data->lock));
1035 1036
1036 return res; 1037 return res;
1037} 1038}
@@ -1039,11 +1040,11 @@ static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
1039static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank, 1040static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank,
1040 u8 reg, u8 value) 1041 u8 reg, u8 value)
1041{ 1042{
1042 down(&(data->lock)); 1043 mutex_lock(&(data->lock));
1043 if (bank != NO_BANK) 1044 if (bank != NO_BANK)
1044 outb_p(bank, data->address[ldi] + PC87365_REG_BANK); 1045 outb_p(bank, data->address[ldi] + PC87365_REG_BANK);
1045 outb_p(value, data->address[ldi] + reg); 1046 outb_p(value, data->address[ldi] + reg);
1046 up(&(data->lock)); 1047 mutex_unlock(&(data->lock));
1047} 1048}
1048 1049
1049static void pc87360_init_client(struct i2c_client *client, int use_thermistors) 1050static void pc87360_init_client(struct i2c_client *client, int use_thermistors)
@@ -1215,7 +1216,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev)
1215 struct pc87360_data *data = i2c_get_clientdata(client); 1216 struct pc87360_data *data = i2c_get_clientdata(client);
1216 u8 i; 1217 u8 i;
1217 1218
1218 down(&data->update_lock); 1219 mutex_lock(&data->update_lock);
1219 1220
1220 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { 1221 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
1221 dev_dbg(&client->dev, "Data update\n"); 1222 dev_dbg(&client->dev, "Data update\n");
@@ -1315,7 +1316,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev)
1315 data->valid = 1; 1316 data->valid = 1;
1316 } 1317 }
1317 1318
1318 up(&data->update_lock); 1319 mutex_unlock(&data->update_lock);
1319 1320
1320 return data; 1321 return data;
1321} 1322}
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index 8be5189d9bd9..4db0dd871eee 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -60,6 +60,7 @@
60#include <linux/err.h> 60#include <linux/err.h>
61#include <linux/init.h> 61#include <linux/init.h>
62#include <linux/jiffies.h> 62#include <linux/jiffies.h>
63#include <linux/mutex.h>
63#include <asm/io.h> 64#include <asm/io.h>
64 65
65 66
@@ -167,9 +168,9 @@ static inline u8 DIV_TO_REG(int val)
167struct sis5595_data { 168struct sis5595_data {
168 struct i2c_client client; 169 struct i2c_client client;
169 struct class_device *class_dev; 170 struct class_device *class_dev;
170 struct semaphore lock; 171 struct mutex lock;
171 172
172 struct semaphore update_lock; 173 struct mutex update_lock;
173 char valid; /* !=0 if following fields are valid */ 174 char valid; /* !=0 if following fields are valid */
174 unsigned long last_updated; /* In jiffies */ 175 unsigned long last_updated; /* In jiffies */
175 char maxins; /* == 3 if temp enabled, otherwise == 4 */ 176 char maxins; /* == 3 if temp enabled, otherwise == 4 */
@@ -231,10 +232,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
231 struct sis5595_data *data = i2c_get_clientdata(client); 232 struct sis5595_data *data = i2c_get_clientdata(client);
232 unsigned long val = simple_strtoul(buf, NULL, 10); 233 unsigned long val = simple_strtoul(buf, NULL, 10);
233 234
234 down(&data->update_lock); 235 mutex_lock(&data->update_lock);
235 data->in_min[nr] = IN_TO_REG(val); 236 data->in_min[nr] = IN_TO_REG(val);
236 sis5595_write_value(client, SIS5595_REG_IN_MIN(nr), data->in_min[nr]); 237 sis5595_write_value(client, SIS5595_REG_IN_MIN(nr), data->in_min[nr]);
237 up(&data->update_lock); 238 mutex_unlock(&data->update_lock);
238 return count; 239 return count;
239} 240}
240 241
@@ -245,10 +246,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
245 struct sis5595_data *data = i2c_get_clientdata(client); 246 struct sis5595_data *data = i2c_get_clientdata(client);
246 unsigned long val = simple_strtoul(buf, NULL, 10); 247 unsigned long val = simple_strtoul(buf, NULL, 10);
247 248
248 down(&data->update_lock); 249 mutex_lock(&data->update_lock);
249 data->in_max[nr] = IN_TO_REG(val); 250 data->in_max[nr] = IN_TO_REG(val);
250 sis5595_write_value(client, SIS5595_REG_IN_MAX(nr), data->in_max[nr]); 251 sis5595_write_value(client, SIS5595_REG_IN_MAX(nr), data->in_max[nr]);
251 up(&data->update_lock); 252 mutex_unlock(&data->update_lock);
252 return count; 253 return count;
253} 254}
254 255
@@ -310,10 +311,10 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr,
310 struct sis5595_data *data = i2c_get_clientdata(client); 311 struct sis5595_data *data = i2c_get_clientdata(client);
311 long val = simple_strtol(buf, NULL, 10); 312 long val = simple_strtol(buf, NULL, 10);
312 313
313 down(&data->update_lock); 314 mutex_lock(&data->update_lock);
314 data->temp_over = TEMP_TO_REG(val); 315 data->temp_over = TEMP_TO_REG(val);
315 sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over); 316 sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over);
316 up(&data->update_lock); 317 mutex_unlock(&data->update_lock);
317 return count; 318 return count;
318} 319}
319 320
@@ -329,10 +330,10 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr,
329 struct sis5595_data *data = i2c_get_clientdata(client); 330 struct sis5595_data *data = i2c_get_clientdata(client);
330 long val = simple_strtol(buf, NULL, 10); 331 long val = simple_strtol(buf, NULL, 10);
331 332
332 down(&data->update_lock); 333 mutex_lock(&data->update_lock);
333 data->temp_hyst = TEMP_TO_REG(val); 334 data->temp_hyst = TEMP_TO_REG(val);
334 sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst); 335 sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst);
335 up(&data->update_lock); 336 mutex_unlock(&data->update_lock);
336 return count; 337 return count;
337} 338}
338 339
@@ -364,10 +365,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
364 struct sis5595_data *data = i2c_get_clientdata(client); 365 struct sis5595_data *data = i2c_get_clientdata(client);
365 unsigned long val = simple_strtoul(buf, NULL, 10); 366 unsigned long val = simple_strtoul(buf, NULL, 10);
366 367
367 down(&data->update_lock); 368 mutex_lock(&data->update_lock);
368 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 369 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
369 sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]); 370 sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]);
370 up(&data->update_lock); 371 mutex_unlock(&data->update_lock);
371 return count; 372 return count;
372} 373}
373 374
@@ -390,7 +391,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
390 unsigned long val = simple_strtoul(buf, NULL, 10); 391 unsigned long val = simple_strtoul(buf, NULL, 10);
391 int reg; 392 int reg;
392 393
393 down(&data->update_lock); 394 mutex_lock(&data->update_lock);
394 min = FAN_FROM_REG(data->fan_min[nr], 395 min = FAN_FROM_REG(data->fan_min[nr],
395 DIV_FROM_REG(data->fan_div[nr])); 396 DIV_FROM_REG(data->fan_div[nr]));
396 reg = sis5595_read_value(client, SIS5595_REG_FANDIV); 397 reg = sis5595_read_value(client, SIS5595_REG_FANDIV);
@@ -403,7 +404,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
403 default: 404 default:
404 dev_err(&client->dev, "fan_div value %ld not " 405 dev_err(&client->dev, "fan_div value %ld not "
405 "supported. Choose one of 1, 2, 4 or 8!\n", val); 406 "supported. Choose one of 1, 2, 4 or 8!\n", val);
406 up(&data->update_lock); 407 mutex_unlock(&data->update_lock);
407 return -EINVAL; 408 return -EINVAL;
408 } 409 }
409 410
@@ -419,7 +420,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
419 data->fan_min[nr] = 420 data->fan_min[nr] =
420 FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 421 FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
421 sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]); 422 sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]);
422 up(&data->update_lock); 423 mutex_unlock(&data->update_lock);
423 return count; 424 return count;
424} 425}
425 426
@@ -527,7 +528,7 @@ static int sis5595_detect(struct i2c_adapter *adapter)
527 528
528 new_client = &data->client; 529 new_client = &data->client;
529 new_client->addr = address; 530 new_client->addr = address;
530 init_MUTEX(&data->lock); 531 mutex_init(&data->lock);
531 i2c_set_clientdata(new_client, data); 532 i2c_set_clientdata(new_client, data);
532 new_client->adapter = adapter; 533 new_client->adapter = adapter;
533 new_client->driver = &sis5595_driver; 534 new_client->driver = &sis5595_driver;
@@ -548,7 +549,7 @@ static int sis5595_detect(struct i2c_adapter *adapter)
548 strlcpy(new_client->name, "sis5595", I2C_NAME_SIZE); 549 strlcpy(new_client->name, "sis5595", I2C_NAME_SIZE);
549 550
550 data->valid = 0; 551 data->valid = 0;
551 init_MUTEX(&data->update_lock); 552 mutex_init(&data->update_lock);
552 553
553 /* Tell the I2C layer a new client has arrived */ 554 /* Tell the I2C layer a new client has arrived */
554 if ((err = i2c_attach_client(new_client))) 555 if ((err = i2c_attach_client(new_client)))
@@ -635,20 +636,20 @@ static int sis5595_read_value(struct i2c_client *client, u8 reg)
635 int res; 636 int res;
636 637
637 struct sis5595_data *data = i2c_get_clientdata(client); 638 struct sis5595_data *data = i2c_get_clientdata(client);
638 down(&data->lock); 639 mutex_lock(&data->lock);
639 outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET); 640 outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET);
640 res = inb_p(client->addr + SIS5595_DATA_REG_OFFSET); 641 res = inb_p(client->addr + SIS5595_DATA_REG_OFFSET);
641 up(&data->lock); 642 mutex_unlock(&data->lock);
642 return res; 643 return res;
643} 644}
644 645
645static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value) 646static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value)
646{ 647{
647 struct sis5595_data *data = i2c_get_clientdata(client); 648 struct sis5595_data *data = i2c_get_clientdata(client);
648 down(&data->lock); 649 mutex_lock(&data->lock);
649 outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET); 650 outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET);
650 outb_p(value, client->addr + SIS5595_DATA_REG_OFFSET); 651 outb_p(value, client->addr + SIS5595_DATA_REG_OFFSET);
651 up(&data->lock); 652 mutex_unlock(&data->lock);
652 return 0; 653 return 0;
653} 654}
654 655
@@ -667,7 +668,7 @@ static struct sis5595_data *sis5595_update_device(struct device *dev)
667 struct sis5595_data *data = i2c_get_clientdata(client); 668 struct sis5595_data *data = i2c_get_clientdata(client);
668 int i; 669 int i;
669 670
670 down(&data->update_lock); 671 mutex_lock(&data->update_lock);
671 672
672 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 673 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
673 || !data->valid) { 674 || !data->valid) {
@@ -707,7 +708,7 @@ static struct sis5595_data *sis5595_update_device(struct device *dev)
707 data->valid = 1; 708 data->valid = 1;
708 } 709 }
709 710
710 up(&data->update_lock); 711 mutex_unlock(&data->update_lock);
711 712
712 return data; 713 return data;
713} 714}
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index 8663bbbe97f5..b6086186d225 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -35,6 +35,7 @@
35#include <linux/hwmon.h> 35#include <linux/hwmon.h>
36#include <linux/err.h> 36#include <linux/err.h>
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/mutex.h>
38#include <asm/io.h> 39#include <asm/io.h>
39 40
40/* Address is autodetected, there is no default value */ 41/* Address is autodetected, there is no default value */
@@ -92,9 +93,9 @@ static u8 smsc47b397_reg_temp[] = {0x25, 0x26, 0x27, 0x80};
92struct smsc47b397_data { 93struct smsc47b397_data {
93 struct i2c_client client; 94 struct i2c_client client;
94 struct class_device *class_dev; 95 struct class_device *class_dev;
95 struct semaphore lock; 96 struct mutex lock;
96 97
97 struct semaphore update_lock; 98 struct mutex update_lock;
98 unsigned long last_updated; /* in jiffies */ 99 unsigned long last_updated; /* in jiffies */
99 int valid; 100 int valid;
100 101
@@ -108,10 +109,10 @@ static int smsc47b397_read_value(struct i2c_client *client, u8 reg)
108 struct smsc47b397_data *data = i2c_get_clientdata(client); 109 struct smsc47b397_data *data = i2c_get_clientdata(client);
109 int res; 110 int res;
110 111
111 down(&data->lock); 112 mutex_lock(&data->lock);
112 outb(reg, client->addr); 113 outb(reg, client->addr);
113 res = inb_p(client->addr + 1); 114 res = inb_p(client->addr + 1);
114 up(&data->lock); 115 mutex_unlock(&data->lock);
115 return res; 116 return res;
116} 117}
117 118
@@ -121,7 +122,7 @@ static struct smsc47b397_data *smsc47b397_update_device(struct device *dev)
121 struct smsc47b397_data *data = i2c_get_clientdata(client); 122 struct smsc47b397_data *data = i2c_get_clientdata(client);
122 int i; 123 int i;
123 124
124 down(&data->update_lock); 125 mutex_lock(&data->update_lock);
125 126
126 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { 127 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
127 dev_dbg(&client->dev, "starting device update...\n"); 128 dev_dbg(&client->dev, "starting device update...\n");
@@ -144,7 +145,7 @@ static struct smsc47b397_data *smsc47b397_update_device(struct device *dev)
144 dev_dbg(&client->dev, "... device update complete\n"); 145 dev_dbg(&client->dev, "... device update complete\n");
145 } 146 }
146 147
147 up(&data->update_lock); 148 mutex_unlock(&data->update_lock);
148 149
149 return data; 150 return data;
150} 151}
@@ -254,14 +255,14 @@ static int smsc47b397_detect(struct i2c_adapter *adapter)
254 new_client = &data->client; 255 new_client = &data->client;
255 i2c_set_clientdata(new_client, data); 256 i2c_set_clientdata(new_client, data);
256 new_client->addr = address; 257 new_client->addr = address;
257 init_MUTEX(&data->lock); 258 mutex_init(&data->lock);
258 new_client->adapter = adapter; 259 new_client->adapter = adapter;
259 new_client->driver = &smsc47b397_driver; 260 new_client->driver = &smsc47b397_driver;
260 new_client->flags = 0; 261 new_client->flags = 0;
261 262
262 strlcpy(new_client->name, "smsc47b397", I2C_NAME_SIZE); 263 strlcpy(new_client->name, "smsc47b397", I2C_NAME_SIZE);
263 264
264 init_MUTEX(&data->update_lock); 265 mutex_init(&data->update_lock);
265 266
266 if ((err = i2c_attach_client(new_client))) 267 if ((err = i2c_attach_client(new_client)))
267 goto error_free; 268 goto error_free;
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index d1e3ec0fe4df..7732aec54594 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -34,6 +34,7 @@
34#include <linux/hwmon.h> 34#include <linux/hwmon.h>
35#include <linux/err.h> 35#include <linux/err.h>
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/mutex.h>
37#include <asm/io.h> 38#include <asm/io.h>
38 39
39/* Address is autodetected, there is no default value */ 40/* Address is autodetected, there is no default value */
@@ -102,9 +103,9 @@ superio_exit(void)
102struct smsc47m1_data { 103struct smsc47m1_data {
103 struct i2c_client client; 104 struct i2c_client client;
104 struct class_device *class_dev; 105 struct class_device *class_dev;
105 struct semaphore lock; 106 struct mutex lock;
106 107
107 struct semaphore update_lock; 108 struct mutex update_lock;
108 unsigned long last_updated; /* In jiffies */ 109 unsigned long last_updated; /* In jiffies */
109 110
110 u8 fan[2]; /* Register value */ 111 u8 fan[2]; /* Register value */
@@ -188,18 +189,18 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
188 struct smsc47m1_data *data = i2c_get_clientdata(client); 189 struct smsc47m1_data *data = i2c_get_clientdata(client);
189 long rpmdiv, val = simple_strtol(buf, NULL, 10); 190 long rpmdiv, val = simple_strtol(buf, NULL, 10);
190 191
191 down(&data->update_lock); 192 mutex_lock(&data->update_lock);
192 rpmdiv = val * DIV_FROM_REG(data->fan_div[nr]); 193 rpmdiv = val * DIV_FROM_REG(data->fan_div[nr]);
193 194
194 if (983040 > 192 * rpmdiv || 2 * rpmdiv > 983040) { 195 if (983040 > 192 * rpmdiv || 2 * rpmdiv > 983040) {
195 up(&data->update_lock); 196 mutex_unlock(&data->update_lock);
196 return -EINVAL; 197 return -EINVAL;
197 } 198 }
198 199
199 data->fan_preload[nr] = 192 - ((983040 + rpmdiv / 2) / rpmdiv); 200 data->fan_preload[nr] = 192 - ((983040 + rpmdiv / 2) / rpmdiv);
200 smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr), 201 smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr),
201 data->fan_preload[nr]); 202 data->fan_preload[nr]);
202 up(&data->update_lock); 203 mutex_unlock(&data->update_lock);
203 204
204 return count; 205 return count;
205} 206}
@@ -220,14 +221,14 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
220 if (new_div == old_div) /* No change */ 221 if (new_div == old_div) /* No change */
221 return count; 222 return count;
222 223
223 down(&data->update_lock); 224 mutex_lock(&data->update_lock);
224 switch (new_div) { 225 switch (new_div) {
225 case 1: data->fan_div[nr] = 0; break; 226 case 1: data->fan_div[nr] = 0; break;
226 case 2: data->fan_div[nr] = 1; break; 227 case 2: data->fan_div[nr] = 1; break;
227 case 4: data->fan_div[nr] = 2; break; 228 case 4: data->fan_div[nr] = 2; break;
228 case 8: data->fan_div[nr] = 3; break; 229 case 8: data->fan_div[nr] = 3; break;
229 default: 230 default:
230 up(&data->update_lock); 231 mutex_unlock(&data->update_lock);
231 return -EINVAL; 232 return -EINVAL;
232 } 233 }
233 234
@@ -241,7 +242,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
241 data->fan_preload[nr] = SENSORS_LIMIT(tmp, 0, 191); 242 data->fan_preload[nr] = SENSORS_LIMIT(tmp, 0, 191);
242 smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr), 243 smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr),
243 data->fan_preload[nr]); 244 data->fan_preload[nr]);
244 up(&data->update_lock); 245 mutex_unlock(&data->update_lock);
245 246
246 return count; 247 return count;
247} 248}
@@ -257,12 +258,12 @@ static ssize_t set_pwm(struct device *dev, const char *buf,
257 if (val < 0 || val > 255) 258 if (val < 0 || val > 255)
258 return -EINVAL; 259 return -EINVAL;
259 260
260 down(&data->update_lock); 261 mutex_lock(&data->update_lock);
261 data->pwm[nr] &= 0x81; /* Preserve additional bits */ 262 data->pwm[nr] &= 0x81; /* Preserve additional bits */
262 data->pwm[nr] |= PWM_TO_REG(val); 263 data->pwm[nr] |= PWM_TO_REG(val);
263 smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr), 264 smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr),
264 data->pwm[nr]); 265 data->pwm[nr]);
265 up(&data->update_lock); 266 mutex_unlock(&data->update_lock);
266 267
267 return count; 268 return count;
268} 269}
@@ -278,12 +279,12 @@ static ssize_t set_pwm_en(struct device *dev, const char *buf,
278 if (val != 0 && val != 1) 279 if (val != 0 && val != 1)
279 return -EINVAL; 280 return -EINVAL;
280 281
281 down(&data->update_lock); 282 mutex_lock(&data->update_lock);
282 data->pwm[nr] &= 0xFE; /* preserve the other bits */ 283 data->pwm[nr] &= 0xFE; /* preserve the other bits */
283 data->pwm[nr] |= !val; 284 data->pwm[nr] |= !val;
284 smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr), 285 smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr),
285 data->pwm[nr]); 286 data->pwm[nr]);
286 up(&data->update_lock); 287 mutex_unlock(&data->update_lock);
287 288
288 return count; 289 return count;
289} 290}
@@ -408,13 +409,13 @@ static int smsc47m1_detect(struct i2c_adapter *adapter)
408 new_client = &data->client; 409 new_client = &data->client;
409 i2c_set_clientdata(new_client, data); 410 i2c_set_clientdata(new_client, data);
410 new_client->addr = address; 411 new_client->addr = address;
411 init_MUTEX(&data->lock); 412 mutex_init(&data->lock);
412 new_client->adapter = adapter; 413 new_client->adapter = adapter;
413 new_client->driver = &smsc47m1_driver; 414 new_client->driver = &smsc47m1_driver;
414 new_client->flags = 0; 415 new_client->flags = 0;
415 416
416 strlcpy(new_client->name, "smsc47m1", I2C_NAME_SIZE); 417 strlcpy(new_client->name, "smsc47m1", I2C_NAME_SIZE);
417 init_MUTEX(&data->update_lock); 418 mutex_init(&data->update_lock);
418 419
419 /* If no function is properly configured, there's no point in 420 /* If no function is properly configured, there's no point in
420 actually registering the chip. */ 421 actually registering the chip. */
@@ -512,17 +513,17 @@ static int smsc47m1_read_value(struct i2c_client *client, u8 reg)
512{ 513{
513 int res; 514 int res;
514 515
515 down(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); 516 mutex_lock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
516 res = inb_p(client->addr + reg); 517 res = inb_p(client->addr + reg);
517 up(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); 518 mutex_unlock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
518 return res; 519 return res;
519} 520}
520 521
521static void smsc47m1_write_value(struct i2c_client *client, u8 reg, u8 value) 522static void smsc47m1_write_value(struct i2c_client *client, u8 reg, u8 value)
522{ 523{
523 down(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); 524 mutex_lock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
524 outb_p(value, client->addr + reg); 525 outb_p(value, client->addr + reg);
525 up(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); 526 mutex_unlock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
526} 527}
527 528
528static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, 529static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
@@ -531,7 +532,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
531 struct i2c_client *client = to_i2c_client(dev); 532 struct i2c_client *client = to_i2c_client(dev);
532 struct smsc47m1_data *data = i2c_get_clientdata(client); 533 struct smsc47m1_data *data = i2c_get_clientdata(client);
533 534
534 down(&data->update_lock); 535 mutex_lock(&data->update_lock);
535 536
536 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || init) { 537 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || init) {
537 int i; 538 int i;
@@ -558,7 +559,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
558 data->last_updated = jiffies; 559 data->last_updated = jiffies;
559 } 560 }
560 561
561 up(&data->update_lock); 562 mutex_unlock(&data->update_lock);
562 return data; 563 return data;
563} 564}
564 565
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c
index cb01848729b5..166298f1f190 100644
--- a/drivers/hwmon/via686a.c
+++ b/drivers/hwmon/via686a.c
@@ -39,6 +39,7 @@
39#include <linux/hwmon.h> 39#include <linux/hwmon.h>
40#include <linux/err.h> 40#include <linux/err.h>
41#include <linux/init.h> 41#include <linux/init.h>
42#include <linux/mutex.h>
42#include <asm/io.h> 43#include <asm/io.h>
43 44
44 45
@@ -296,7 +297,7 @@ static inline long TEMP_FROM_REG10(u16 val)
296struct via686a_data { 297struct via686a_data {
297 struct i2c_client client; 298 struct i2c_client client;
298 struct class_device *class_dev; 299 struct class_device *class_dev;
299 struct semaphore update_lock; 300 struct mutex update_lock;
300 char valid; /* !=0 if following fields are valid */ 301 char valid; /* !=0 if following fields are valid */
301 unsigned long last_updated; /* In jiffies */ 302 unsigned long last_updated; /* In jiffies */
302 303
@@ -355,11 +356,11 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
355 struct via686a_data *data = i2c_get_clientdata(client); 356 struct via686a_data *data = i2c_get_clientdata(client);
356 unsigned long val = simple_strtoul(buf, NULL, 10); 357 unsigned long val = simple_strtoul(buf, NULL, 10);
357 358
358 down(&data->update_lock); 359 mutex_lock(&data->update_lock);
359 data->in_min[nr] = IN_TO_REG(val, nr); 360 data->in_min[nr] = IN_TO_REG(val, nr);
360 via686a_write_value(client, VIA686A_REG_IN_MIN(nr), 361 via686a_write_value(client, VIA686A_REG_IN_MIN(nr),
361 data->in_min[nr]); 362 data->in_min[nr]);
362 up(&data->update_lock); 363 mutex_unlock(&data->update_lock);
363 return count; 364 return count;
364} 365}
365static ssize_t set_in_max(struct device *dev, const char *buf, 366static ssize_t set_in_max(struct device *dev, const char *buf,
@@ -368,11 +369,11 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
368 struct via686a_data *data = i2c_get_clientdata(client); 369 struct via686a_data *data = i2c_get_clientdata(client);
369 unsigned long val = simple_strtoul(buf, NULL, 10); 370 unsigned long val = simple_strtoul(buf, NULL, 10);
370 371
371 down(&data->update_lock); 372 mutex_lock(&data->update_lock);
372 data->in_max[nr] = IN_TO_REG(val, nr); 373 data->in_max[nr] = IN_TO_REG(val, nr);
373 via686a_write_value(client, VIA686A_REG_IN_MAX(nr), 374 via686a_write_value(client, VIA686A_REG_IN_MAX(nr),
374 data->in_max[nr]); 375 data->in_max[nr]);
375 up(&data->update_lock); 376 mutex_unlock(&data->update_lock);
376 return count; 377 return count;
377} 378}
378#define show_in_offset(offset) \ 379#define show_in_offset(offset) \
@@ -432,11 +433,11 @@ static ssize_t set_temp_over(struct device *dev, const char *buf,
432 struct via686a_data *data = i2c_get_clientdata(client); 433 struct via686a_data *data = i2c_get_clientdata(client);
433 int val = simple_strtol(buf, NULL, 10); 434 int val = simple_strtol(buf, NULL, 10);
434 435
435 down(&data->update_lock); 436 mutex_lock(&data->update_lock);
436 data->temp_over[nr] = TEMP_TO_REG(val); 437 data->temp_over[nr] = TEMP_TO_REG(val);
437 via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr], 438 via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr],
438 data->temp_over[nr]); 439 data->temp_over[nr]);
439 up(&data->update_lock); 440 mutex_unlock(&data->update_lock);
440 return count; 441 return count;
441} 442}
442static ssize_t set_temp_hyst(struct device *dev, const char *buf, 443static ssize_t set_temp_hyst(struct device *dev, const char *buf,
@@ -445,11 +446,11 @@ static ssize_t set_temp_hyst(struct device *dev, const char *buf,
445 struct via686a_data *data = i2c_get_clientdata(client); 446 struct via686a_data *data = i2c_get_clientdata(client);
446 int val = simple_strtol(buf, NULL, 10); 447 int val = simple_strtol(buf, NULL, 10);
447 448
448 down(&data->update_lock); 449 mutex_lock(&data->update_lock);
449 data->temp_hyst[nr] = TEMP_TO_REG(val); 450 data->temp_hyst[nr] = TEMP_TO_REG(val);
450 via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr], 451 via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr],
451 data->temp_hyst[nr]); 452 data->temp_hyst[nr]);
452 up(&data->update_lock); 453 mutex_unlock(&data->update_lock);
453 return count; 454 return count;
454} 455}
455#define show_temp_offset(offset) \ 456#define show_temp_offset(offset) \
@@ -508,10 +509,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
508 struct via686a_data *data = i2c_get_clientdata(client); 509 struct via686a_data *data = i2c_get_clientdata(client);
509 int val = simple_strtol(buf, NULL, 10); 510 int val = simple_strtol(buf, NULL, 10);
510 511
511 down(&data->update_lock); 512 mutex_lock(&data->update_lock);
512 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 513 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
513 via686a_write_value(client, VIA686A_REG_FAN_MIN(nr+1), data->fan_min[nr]); 514 via686a_write_value(client, VIA686A_REG_FAN_MIN(nr+1), data->fan_min[nr]);
514 up(&data->update_lock); 515 mutex_unlock(&data->update_lock);
515 return count; 516 return count;
516} 517}
517static ssize_t set_fan_div(struct device *dev, const char *buf, 518static ssize_t set_fan_div(struct device *dev, const char *buf,
@@ -521,12 +522,12 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
521 int val = simple_strtol(buf, NULL, 10); 522 int val = simple_strtol(buf, NULL, 10);
522 int old; 523 int old;
523 524
524 down(&data->update_lock); 525 mutex_lock(&data->update_lock);
525 old = via686a_read_value(client, VIA686A_REG_FANDIV); 526 old = via686a_read_value(client, VIA686A_REG_FANDIV);
526 data->fan_div[nr] = DIV_TO_REG(val); 527 data->fan_div[nr] = DIV_TO_REG(val);
527 old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); 528 old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4);
528 via686a_write_value(client, VIA686A_REG_FANDIV, old); 529 via686a_write_value(client, VIA686A_REG_FANDIV, old);
529 up(&data->update_lock); 530 mutex_unlock(&data->update_lock);
530 return count; 531 return count;
531} 532}
532 533
@@ -639,7 +640,7 @@ static int via686a_detect(struct i2c_adapter *adapter)
639 strlcpy(new_client->name, client_name, I2C_NAME_SIZE); 640 strlcpy(new_client->name, client_name, I2C_NAME_SIZE);
640 641
641 data->valid = 0; 642 data->valid = 0;
642 init_MUTEX(&data->update_lock); 643 mutex_init(&data->update_lock);
643 /* Tell the I2C layer a new client has arrived */ 644 /* Tell the I2C layer a new client has arrived */
644 if ((err = i2c_attach_client(new_client))) 645 if ((err = i2c_attach_client(new_client)))
645 goto exit_free; 646 goto exit_free;
@@ -733,7 +734,7 @@ static struct via686a_data *via686a_update_device(struct device *dev)
733 struct via686a_data *data = i2c_get_clientdata(client); 734 struct via686a_data *data = i2c_get_clientdata(client);
734 int i; 735 int i;
735 736
736 down(&data->update_lock); 737 mutex_lock(&data->update_lock);
737 738
738 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 739 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
739 || !data->valid) { 740 || !data->valid) {
@@ -788,7 +789,7 @@ static struct via686a_data *via686a_update_device(struct device *dev)
788 data->valid = 1; 789 data->valid = 1;
789 } 790 }
790 791
791 up(&data->update_lock); 792 mutex_unlock(&data->update_lock);
792 793
793 return data; 794 return data;
794} 795}
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
index 271e9cb9532c..686f3deb3093 100644
--- a/drivers/hwmon/vt8231.c
+++ b/drivers/hwmon/vt8231.c
@@ -35,6 +35,7 @@
35#include <linux/hwmon-sysfs.h> 35#include <linux/hwmon-sysfs.h>
36#include <linux/hwmon-vid.h> 36#include <linux/hwmon-vid.h>
37#include <linux/err.h> 37#include <linux/err.h>
38#include <linux/mutex.h>
38#include <asm/io.h> 39#include <asm/io.h>
39 40
40static int force_addr; 41static int force_addr;
@@ -148,7 +149,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
148 149
149struct vt8231_data { 150struct vt8231_data {
150 struct i2c_client client; 151 struct i2c_client client;
151 struct semaphore update_lock; 152 struct mutex update_lock;
152 struct class_device *class_dev; 153 struct class_device *class_dev;
153 char valid; /* !=0 if following fields are valid */ 154 char valid; /* !=0 if following fields are valid */
154 unsigned long last_updated; /* In jiffies */ 155 unsigned long last_updated; /* In jiffies */
@@ -223,10 +224,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
223 struct vt8231_data *data = i2c_get_clientdata(client); 224 struct vt8231_data *data = i2c_get_clientdata(client);
224 unsigned long val = simple_strtoul(buf, NULL, 10); 225 unsigned long val = simple_strtoul(buf, NULL, 10);
225 226
226 down(&data->update_lock); 227 mutex_lock(&data->update_lock);
227 data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); 228 data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255);
228 vt8231_write_value(client, regvoltmin[nr], data->in_min[nr]); 229 vt8231_write_value(client, regvoltmin[nr], data->in_min[nr]);
229 up(&data->update_lock); 230 mutex_unlock(&data->update_lock);
230 return count; 231 return count;
231} 232}
232 233
@@ -239,10 +240,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
239 struct vt8231_data *data = i2c_get_clientdata(client); 240 struct vt8231_data *data = i2c_get_clientdata(client);
240 unsigned long val = simple_strtoul(buf, NULL, 10); 241 unsigned long val = simple_strtoul(buf, NULL, 10);
241 242
242 down(&data->update_lock); 243 mutex_lock(&data->update_lock);
243 data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); 244 data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255);
244 vt8231_write_value(client, regvoltmax[nr], data->in_max[nr]); 245 vt8231_write_value(client, regvoltmax[nr], data->in_max[nr]);
245 up(&data->update_lock); 246 mutex_unlock(&data->update_lock);
246 return count; 247 return count;
247} 248}
248 249
@@ -281,11 +282,11 @@ static ssize_t set_in5_min(struct device *dev, struct device_attribute *attr,
281 struct vt8231_data *data = i2c_get_clientdata(client); 282 struct vt8231_data *data = i2c_get_clientdata(client);
282 unsigned long val = simple_strtoul(buf, NULL, 10); 283 unsigned long val = simple_strtoul(buf, NULL, 10);
283 284
284 down(&data->update_lock); 285 mutex_lock(&data->update_lock);
285 data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, 286 data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3,
286 0, 255); 287 0, 255);
287 vt8231_write_value(client, regvoltmin[5], data->in_min[5]); 288 vt8231_write_value(client, regvoltmin[5], data->in_min[5]);
288 up(&data->update_lock); 289 mutex_unlock(&data->update_lock);
289 return count; 290 return count;
290} 291}
291 292
@@ -296,11 +297,11 @@ static ssize_t set_in5_max(struct device *dev, struct device_attribute *attr,
296 struct vt8231_data *data = i2c_get_clientdata(client); 297 struct vt8231_data *data = i2c_get_clientdata(client);
297 unsigned long val = simple_strtoul(buf, NULL, 10); 298 unsigned long val = simple_strtoul(buf, NULL, 10);
298 299
299 down(&data->update_lock); 300 mutex_lock(&data->update_lock);
300 data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, 301 data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3,
301 0, 255); 302 0, 255);
302 vt8231_write_value(client, regvoltmax[5], data->in_max[5]); 303 vt8231_write_value(client, regvoltmax[5], data->in_max[5]);
303 up(&data->update_lock); 304 mutex_unlock(&data->update_lock);
304 return count; 305 return count;
305} 306}
306 307
@@ -351,10 +352,10 @@ static ssize_t set_temp0_max(struct device *dev, struct device_attribute *attr,
351 struct vt8231_data *data = i2c_get_clientdata(client); 352 struct vt8231_data *data = i2c_get_clientdata(client);
352 int val = simple_strtol(buf, NULL, 10); 353 int val = simple_strtol(buf, NULL, 10);
353 354
354 down(&data->update_lock); 355 mutex_lock(&data->update_lock);
355 data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); 356 data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255);
356 vt8231_write_value(client, regtempmax[0], data->temp_max[0]); 357 vt8231_write_value(client, regtempmax[0], data->temp_max[0]);
357 up(&data->update_lock); 358 mutex_unlock(&data->update_lock);
358 return count; 359 return count;
359} 360}
360static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, 361static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr,
@@ -364,10 +365,10 @@ static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr,
364 struct vt8231_data *data = i2c_get_clientdata(client); 365 struct vt8231_data *data = i2c_get_clientdata(client);
365 int val = simple_strtol(buf, NULL, 10); 366 int val = simple_strtol(buf, NULL, 10);
366 367
367 down(&data->update_lock); 368 mutex_lock(&data->update_lock);
368 data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); 369 data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255);
369 vt8231_write_value(client, regtempmin[0], data->temp_min[0]); 370 vt8231_write_value(client, regtempmin[0], data->temp_min[0]);
370 up(&data->update_lock); 371 mutex_unlock(&data->update_lock);
371 return count; 372 return count;
372} 373}
373 374
@@ -407,10 +408,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
407 struct vt8231_data *data = i2c_get_clientdata(client); 408 struct vt8231_data *data = i2c_get_clientdata(client);
408 int val = simple_strtol(buf, NULL, 10); 409 int val = simple_strtol(buf, NULL, 10);
409 410
410 down(&data->update_lock); 411 mutex_lock(&data->update_lock);
411 data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); 412 data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255);
412 vt8231_write_value(client, regtempmax[nr], data->temp_max[nr]); 413 vt8231_write_value(client, regtempmax[nr], data->temp_max[nr]);
413 up(&data->update_lock); 414 mutex_unlock(&data->update_lock);
414 return count; 415 return count;
415} 416}
416static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, 417static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
@@ -422,10 +423,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
422 struct vt8231_data *data = i2c_get_clientdata(client); 423 struct vt8231_data *data = i2c_get_clientdata(client);
423 int val = simple_strtol(buf, NULL, 10); 424 int val = simple_strtol(buf, NULL, 10);
424 425
425 down(&data->update_lock); 426 mutex_lock(&data->update_lock);
426 data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); 427 data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255);
427 vt8231_write_value(client, regtempmin[nr], data->temp_min[nr]); 428 vt8231_write_value(client, regtempmin[nr], data->temp_min[nr]);
428 up(&data->update_lock); 429 mutex_unlock(&data->update_lock);
429 return count; 430 return count;
430} 431}
431 432
@@ -520,10 +521,10 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
520 struct vt8231_data *data = i2c_get_clientdata(client); 521 struct vt8231_data *data = i2c_get_clientdata(client);
521 int val = simple_strtoul(buf, NULL, 10); 522 int val = simple_strtoul(buf, NULL, 10);
522 523
523 down(&data->update_lock); 524 mutex_lock(&data->update_lock);
524 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 525 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
525 vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]); 526 vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]);
526 up(&data->update_lock); 527 mutex_unlock(&data->update_lock);
527 return count; 528 return count;
528} 529}
529 530
@@ -539,7 +540,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
539 long min = FAN_FROM_REG(data->fan_min[nr], 540 long min = FAN_FROM_REG(data->fan_min[nr],
540 DIV_FROM_REG(data->fan_div[nr])); 541 DIV_FROM_REG(data->fan_div[nr]));
541 542
542 down(&data->update_lock); 543 mutex_lock(&data->update_lock);
543 switch (val) { 544 switch (val) {
544 case 1: data->fan_div[nr] = 0; break; 545 case 1: data->fan_div[nr] = 0; break;
545 case 2: data->fan_div[nr] = 1; break; 546 case 2: data->fan_div[nr] = 1; break;
@@ -548,7 +549,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
548 default: 549 default:
549 dev_err(&client->dev, "fan_div value %ld not supported." 550 dev_err(&client->dev, "fan_div value %ld not supported."
550 "Choose one of 1, 2, 4 or 8!\n", val); 551 "Choose one of 1, 2, 4 or 8!\n", val);
551 up(&data->update_lock); 552 mutex_unlock(&data->update_lock);
552 return -EINVAL; 553 return -EINVAL;
553 } 554 }
554 555
@@ -558,7 +559,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
558 559
559 old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); 560 old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4);
560 vt8231_write_value(client, VT8231_REG_FANDIV, old); 561 vt8231_write_value(client, VT8231_REG_FANDIV, old);
561 up(&data->update_lock); 562 mutex_unlock(&data->update_lock);
562 return count; 563 return count;
563} 564}
564 565
@@ -660,7 +661,7 @@ int vt8231_detect(struct i2c_adapter *adapter)
660 /* Fill in the remaining client fields and put into the global list */ 661 /* Fill in the remaining client fields and put into the global list */
661 strlcpy(client->name, "vt8231", I2C_NAME_SIZE); 662 strlcpy(client->name, "vt8231", I2C_NAME_SIZE);
662 663
663 init_MUTEX(&data->update_lock); 664 mutex_init(&data->update_lock);
664 665
665 /* Tell the I2C layer a new client has arrived */ 666 /* Tell the I2C layer a new client has arrived */
666 if ((err = i2c_attach_client(client))) 667 if ((err = i2c_attach_client(client)))
@@ -745,7 +746,7 @@ static struct vt8231_data *vt8231_update_device(struct device *dev)
745 int i; 746 int i;
746 u16 low; 747 u16 low;
747 748
748 down(&data->update_lock); 749 mutex_lock(&data->update_lock);
749 750
750 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 751 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
751 || !data->valid) { 752 || !data->valid) {
@@ -804,7 +805,7 @@ static struct vt8231_data *vt8231_update_device(struct device *dev)
804 data->valid = 1; 805 data->valid = 1;
805 } 806 }
806 807
807 up(&data->update_lock); 808 mutex_unlock(&data->update_lock);
808 809
809 return data; 810 return data;
810} 811}
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 12d79f5e4900..1affaf15beda 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -43,6 +43,7 @@
43#include <linux/i2c-isa.h> 43#include <linux/i2c-isa.h>
44#include <linux/hwmon.h> 44#include <linux/hwmon.h>
45#include <linux/err.h> 45#include <linux/err.h>
46#include <linux/mutex.h>
46#include <asm/io.h> 47#include <asm/io.h>
47#include "lm75.h" 48#include "lm75.h"
48 49
@@ -177,9 +178,9 @@ temp1_to_reg(int temp)
177struct w83627ehf_data { 178struct w83627ehf_data {
178 struct i2c_client client; 179 struct i2c_client client;
179 struct class_device *class_dev; 180 struct class_device *class_dev;
180 struct semaphore lock; 181 struct mutex lock;
181 182
182 struct semaphore update_lock; 183 struct mutex update_lock;
183 char valid; /* !=0 if following fields are valid */ 184 char valid; /* !=0 if following fields are valid */
184 unsigned long last_updated; /* In jiffies */ 185 unsigned long last_updated; /* In jiffies */
185 186
@@ -230,7 +231,7 @@ static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg)
230 struct w83627ehf_data *data = i2c_get_clientdata(client); 231 struct w83627ehf_data *data = i2c_get_clientdata(client);
231 int res, word_sized = is_word_sized(reg); 232 int res, word_sized = is_word_sized(reg);
232 233
233 down(&data->lock); 234 mutex_lock(&data->lock);
234 235
235 w83627ehf_set_bank(client, reg); 236 w83627ehf_set_bank(client, reg);
236 outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); 237 outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET);
@@ -242,7 +243,7 @@ static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg)
242 } 243 }
243 w83627ehf_reset_bank(client, reg); 244 w83627ehf_reset_bank(client, reg);
244 245
245 up(&data->lock); 246 mutex_unlock(&data->lock);
246 247
247 return res; 248 return res;
248} 249}
@@ -252,7 +253,7 @@ static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value)
252 struct w83627ehf_data *data = i2c_get_clientdata(client); 253 struct w83627ehf_data *data = i2c_get_clientdata(client);
253 int word_sized = is_word_sized(reg); 254 int word_sized = is_word_sized(reg);
254 255
255 down(&data->lock); 256 mutex_lock(&data->lock);
256 257
257 w83627ehf_set_bank(client, reg); 258 w83627ehf_set_bank(client, reg);
258 outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); 259 outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET);
@@ -264,7 +265,7 @@ static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value)
264 outb_p(value & 0xff, client->addr + DATA_REG_OFFSET); 265 outb_p(value & 0xff, client->addr + DATA_REG_OFFSET);
265 w83627ehf_reset_bank(client, reg); 266 w83627ehf_reset_bank(client, reg);
266 267
267 up(&data->lock); 268 mutex_unlock(&data->lock);
268 return 0; 269 return 0;
269} 270}
270 271
@@ -322,7 +323,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
322 struct w83627ehf_data *data = i2c_get_clientdata(client); 323 struct w83627ehf_data *data = i2c_get_clientdata(client);
323 int i; 324 int i;
324 325
325 down(&data->update_lock); 326 mutex_lock(&data->update_lock);
326 327
327 if (time_after(jiffies, data->last_updated + HZ) 328 if (time_after(jiffies, data->last_updated + HZ)
328 || !data->valid) { 329 || !data->valid) {
@@ -397,7 +398,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
397 data->valid = 1; 398 data->valid = 1;
398 } 399 }
399 400
400 up(&data->update_lock); 401 mutex_unlock(&data->update_lock);
401 return data; 402 return data;
402} 403}
403 404
@@ -434,7 +435,7 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
434 unsigned int reg; 435 unsigned int reg;
435 u8 new_div; 436 u8 new_div;
436 437
437 down(&data->update_lock); 438 mutex_lock(&data->update_lock);
438 if (!val) { 439 if (!val) {
439 /* No min limit, alarm disabled */ 440 /* No min limit, alarm disabled */
440 data->fan_min[nr] = 255; 441 data->fan_min[nr] = 255;
@@ -482,7 +483,7 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
482 } 483 }
483 w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr], 484 w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr],
484 data->fan_min[nr]); 485 data->fan_min[nr]);
485 up(&data->update_lock); 486 mutex_unlock(&data->update_lock);
486 487
487 return count; 488 return count;
488} 489}
@@ -561,11 +562,11 @@ store_temp1_##reg(struct device *dev, struct device_attribute *attr, \
561 struct w83627ehf_data *data = i2c_get_clientdata(client); \ 562 struct w83627ehf_data *data = i2c_get_clientdata(client); \
562 u32 val = simple_strtoul(buf, NULL, 10); \ 563 u32 val = simple_strtoul(buf, NULL, 10); \
563 \ 564 \
564 down(&data->update_lock); \ 565 mutex_lock(&data->update_lock); \
565 data->temp1_##reg = temp1_to_reg(val); \ 566 data->temp1_##reg = temp1_to_reg(val); \
566 w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \ 567 w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \
567 data->temp1_##reg); \ 568 data->temp1_##reg); \
568 up(&data->update_lock); \ 569 mutex_unlock(&data->update_lock); \
569 return count; \ 570 return count; \
570} 571}
571store_temp1_reg(OVER, max); 572store_temp1_reg(OVER, max);
@@ -597,11 +598,11 @@ store_##reg (struct device *dev, const char *buf, size_t count, int nr) \
597 struct w83627ehf_data *data = i2c_get_clientdata(client); \ 598 struct w83627ehf_data *data = i2c_get_clientdata(client); \
598 u32 val = simple_strtoul(buf, NULL, 10); \ 599 u32 val = simple_strtoul(buf, NULL, 10); \
599 \ 600 \
600 down(&data->update_lock); \ 601 mutex_lock(&data->update_lock); \
601 data->reg[nr] = LM75_TEMP_TO_REG(val); \ 602 data->reg[nr] = LM75_TEMP_TO_REG(val); \
602 w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \ 603 w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \
603 data->reg[nr]); \ 604 data->reg[nr]); \
604 up(&data->update_lock); \ 605 mutex_unlock(&data->update_lock); \
605 return count; \ 606 return count; \
606} 607}
607store_temp_reg(OVER, temp_max); 608store_temp_reg(OVER, temp_max);
@@ -689,14 +690,14 @@ static int w83627ehf_detect(struct i2c_adapter *adapter)
689 client = &data->client; 690 client = &data->client;
690 i2c_set_clientdata(client, data); 691 i2c_set_clientdata(client, data);
691 client->addr = address; 692 client->addr = address;
692 init_MUTEX(&data->lock); 693 mutex_init(&data->lock);
693 client->adapter = adapter; 694 client->adapter = adapter;
694 client->driver = &w83627ehf_driver; 695 client->driver = &w83627ehf_driver;
695 client->flags = 0; 696 client->flags = 0;
696 697
697 strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE); 698 strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE);
698 data->valid = 0; 699 data->valid = 0;
699 init_MUTEX(&data->update_lock); 700 mutex_init(&data->update_lock);
700 701
701 /* Tell the i2c layer a new client has arrived */ 702 /* Tell the i2c layer a new client has arrived */
702 if ((err = i2c_attach_client(client))) 703 if ((err = i2c_attach_client(client)))
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index 7ea441d4da63..3d4888c178c9 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -46,6 +46,7 @@
46#include <linux/hwmon.h> 46#include <linux/hwmon.h>
47#include <linux/hwmon-vid.h> 47#include <linux/hwmon-vid.h>
48#include <linux/err.h> 48#include <linux/err.h>
49#include <linux/mutex.h>
49#include <asm/io.h> 50#include <asm/io.h>
50#include "lm75.h" 51#include "lm75.h"
51 52
@@ -285,10 +286,10 @@ static inline u8 DIV_TO_REG(long val)
285struct w83627hf_data { 286struct w83627hf_data {
286 struct i2c_client client; 287 struct i2c_client client;
287 struct class_device *class_dev; 288 struct class_device *class_dev;
288 struct semaphore lock; 289 struct mutex lock;
289 enum chips type; 290 enum chips type;
290 291
291 struct semaphore update_lock; 292 struct mutex update_lock;
292 char valid; /* !=0 if following fields are valid */ 293 char valid; /* !=0 if following fields are valid */
293 unsigned long last_updated; /* In jiffies */ 294 unsigned long last_updated; /* In jiffies */
294 295
@@ -360,12 +361,12 @@ store_in_##reg (struct device *dev, const char *buf, size_t count, int nr) \
360 \ 361 \
361 val = simple_strtoul(buf, NULL, 10); \ 362 val = simple_strtoul(buf, NULL, 10); \
362 \ 363 \
363 down(&data->update_lock); \ 364 mutex_lock(&data->update_lock); \
364 data->in_##reg[nr] = IN_TO_REG(val); \ 365 data->in_##reg[nr] = IN_TO_REG(val); \
365 w83627hf_write_value(client, W83781D_REG_IN_##REG(nr), \ 366 w83627hf_write_value(client, W83781D_REG_IN_##REG(nr), \
366 data->in_##reg[nr]); \ 367 data->in_##reg[nr]); \
367 \ 368 \
368 up(&data->update_lock); \ 369 mutex_unlock(&data->update_lock); \
369 return count; \ 370 return count; \
370} 371}
371store_in_reg(MIN, min) 372store_in_reg(MIN, min)
@@ -451,7 +452,7 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a
451 452
452 val = simple_strtoul(buf, NULL, 10); 453 val = simple_strtoul(buf, NULL, 10);
453 454
454 down(&data->update_lock); 455 mutex_lock(&data->update_lock);
455 456
456 if ((data->vrm_ovt & 0x01) && 457 if ((data->vrm_ovt & 0x01) &&
457 (w83627thf == data->type || w83637hf == data->type)) 458 (w83627thf == data->type || w83637hf == data->type))
@@ -465,7 +466,7 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a
465 data->in_min[0] = IN_TO_REG(val); 466 data->in_min[0] = IN_TO_REG(val);
466 467
467 w83627hf_write_value(client, W83781D_REG_IN_MIN(0), data->in_min[0]); 468 w83627hf_write_value(client, W83781D_REG_IN_MIN(0), data->in_min[0]);
468 up(&data->update_lock); 469 mutex_unlock(&data->update_lock);
469 return count; 470 return count;
470} 471}
471 472
@@ -478,7 +479,7 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a
478 479
479 val = simple_strtoul(buf, NULL, 10); 480 val = simple_strtoul(buf, NULL, 10);
480 481
481 down(&data->update_lock); 482 mutex_lock(&data->update_lock);
482 483
483 if ((data->vrm_ovt & 0x01) && 484 if ((data->vrm_ovt & 0x01) &&
484 (w83627thf == data->type || w83637hf == data->type)) 485 (w83627thf == data->type || w83637hf == data->type))
@@ -492,7 +493,7 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a
492 data->in_max[0] = IN_TO_REG(val); 493 data->in_max[0] = IN_TO_REG(val);
493 494
494 w83627hf_write_value(client, W83781D_REG_IN_MAX(0), data->in_max[0]); 495 w83627hf_write_value(client, W83781D_REG_IN_MAX(0), data->in_max[0]);
495 up(&data->update_lock); 496 mutex_unlock(&data->update_lock);
496 return count; 497 return count;
497} 498}
498 499
@@ -529,13 +530,13 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
529 530
530 val = simple_strtoul(buf, NULL, 10); 531 val = simple_strtoul(buf, NULL, 10);
531 532
532 down(&data->update_lock); 533 mutex_lock(&data->update_lock);
533 data->fan_min[nr - 1] = 534 data->fan_min[nr - 1] =
534 FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); 535 FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1]));
535 w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr), 536 w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr),
536 data->fan_min[nr - 1]); 537 data->fan_min[nr - 1]);
537 538
538 up(&data->update_lock); 539 mutex_unlock(&data->update_lock);
539 return count; 540 return count;
540} 541}
541 542
@@ -597,7 +598,7 @@ store_temp_##reg (struct device *dev, const char *buf, size_t count, int nr) \
597 \ 598 \
598 val = simple_strtoul(buf, NULL, 10); \ 599 val = simple_strtoul(buf, NULL, 10); \
599 \ 600 \
600 down(&data->update_lock); \ 601 mutex_lock(&data->update_lock); \
601 \ 602 \
602 if (nr >= 2) { /* TEMP2 and TEMP3 */ \ 603 if (nr >= 2) { /* TEMP2 and TEMP3 */ \
603 data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ 604 data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \
@@ -609,7 +610,7 @@ store_temp_##reg (struct device *dev, const char *buf, size_t count, int nr) \
609 data->temp_##reg); \ 610 data->temp_##reg); \
610 } \ 611 } \
611 \ 612 \
612 up(&data->update_lock); \ 613 mutex_unlock(&data->update_lock); \
613 return count; \ 614 return count; \
614} 615}
615store_temp_reg(OVER, max); 616store_temp_reg(OVER, max);
@@ -718,7 +719,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count,
718 719
719 val = simple_strtoul(buf, NULL, 10); 720 val = simple_strtoul(buf, NULL, 10);
720 721
721 down(&data->update_lock); 722 mutex_lock(&data->update_lock);
722 723
723 if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ 724 if (update_mask == BEEP_MASK) { /* We are storing beep_mask */
724 data->beep_mask = BEEP_MASK_TO_REG(val); 725 data->beep_mask = BEEP_MASK_TO_REG(val);
@@ -736,7 +737,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count,
736 w83627hf_write_value(client, W83781D_REG_BEEP_INTS2, 737 w83627hf_write_value(client, W83781D_REG_BEEP_INTS2,
737 val2 | data->beep_enable << 7); 738 val2 | data->beep_enable << 7);
738 739
739 up(&data->update_lock); 740 mutex_unlock(&data->update_lock);
740 return count; 741 return count;
741} 742}
742 743
@@ -783,7 +784,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr)
783 u8 reg; 784 u8 reg;
784 unsigned long val = simple_strtoul(buf, NULL, 10); 785 unsigned long val = simple_strtoul(buf, NULL, 10);
785 786
786 down(&data->update_lock); 787 mutex_lock(&data->update_lock);
787 788
788 /* Save fan_min */ 789 /* Save fan_min */
789 min = FAN_FROM_REG(data->fan_min[nr], 790 min = FAN_FROM_REG(data->fan_min[nr],
@@ -805,7 +806,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr)
805 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 806 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
806 w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); 807 w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]);
807 808
808 up(&data->update_lock); 809 mutex_unlock(&data->update_lock);
809 return count; 810 return count;
810} 811}
811 812
@@ -848,7 +849,7 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr)
848 849
849 val = simple_strtoul(buf, NULL, 10); 850 val = simple_strtoul(buf, NULL, 10);
850 851
851 down(&data->update_lock); 852 mutex_lock(&data->update_lock);
852 853
853 if (data->type == w83627thf) { 854 if (data->type == w83627thf) {
854 /* bits 0-3 are reserved in 627THF */ 855 /* bits 0-3 are reserved in 627THF */
@@ -865,7 +866,7 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr)
865 data->pwm[nr - 1]); 866 data->pwm[nr - 1]);
866 } 867 }
867 868
868 up(&data->update_lock); 869 mutex_unlock(&data->update_lock);
869 return count; 870 return count;
870} 871}
871 872
@@ -907,7 +908,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr)
907 908
908 val = simple_strtoul(buf, NULL, 10); 909 val = simple_strtoul(buf, NULL, 10);
909 910
910 down(&data->update_lock); 911 mutex_lock(&data->update_lock);
911 912
912 switch (val) { 913 switch (val) {
913 case 1: /* PII/Celeron diode */ 914 case 1: /* PII/Celeron diode */
@@ -941,7 +942,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr)
941 break; 942 break;
942 } 943 }
943 944
944 up(&data->update_lock); 945 mutex_unlock(&data->update_lock);
945 return count; 946 return count;
946} 947}
947 948
@@ -1057,7 +1058,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
1057 new_client = &data->client; 1058 new_client = &data->client;
1058 i2c_set_clientdata(new_client, data); 1059 i2c_set_clientdata(new_client, data);
1059 new_client->addr = address; 1060 new_client->addr = address;
1060 init_MUTEX(&data->lock); 1061 mutex_init(&data->lock);
1061 new_client->adapter = adapter; 1062 new_client->adapter = adapter;
1062 new_client->driver = &w83627hf_driver; 1063 new_client->driver = &w83627hf_driver;
1063 new_client->flags = 0; 1064 new_client->flags = 0;
@@ -1077,7 +1078,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
1077 strlcpy(new_client->name, client_name, I2C_NAME_SIZE); 1078 strlcpy(new_client->name, client_name, I2C_NAME_SIZE);
1078 data->type = kind; 1079 data->type = kind;
1079 data->valid = 0; 1080 data->valid = 0;
1080 init_MUTEX(&data->update_lock); 1081 mutex_init(&data->update_lock);
1081 1082
1082 /* Tell the I2C layer a new client has arrived */ 1083 /* Tell the I2C layer a new client has arrived */
1083 if ((err = i2c_attach_client(new_client))) 1084 if ((err = i2c_attach_client(new_client)))
@@ -1187,7 +1188,7 @@ static int w83627hf_read_value(struct i2c_client *client, u16 reg)
1187 struct w83627hf_data *data = i2c_get_clientdata(client); 1188 struct w83627hf_data *data = i2c_get_clientdata(client);
1188 int res, word_sized; 1189 int res, word_sized;
1189 1190
1190 down(&data->lock); 1191 mutex_lock(&data->lock);
1191 word_sized = (((reg & 0xff00) == 0x100) 1192 word_sized = (((reg & 0xff00) == 0x100)
1192 || ((reg & 0xff00) == 0x200)) 1193 || ((reg & 0xff00) == 0x200))
1193 && (((reg & 0x00ff) == 0x50) 1194 && (((reg & 0x00ff) == 0x50)
@@ -1213,7 +1214,7 @@ static int w83627hf_read_value(struct i2c_client *client, u16 reg)
1213 client->addr + W83781D_ADDR_REG_OFFSET); 1214 client->addr + W83781D_ADDR_REG_OFFSET);
1214 outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); 1215 outb_p(0, client->addr + W83781D_DATA_REG_OFFSET);
1215 } 1216 }
1216 up(&data->lock); 1217 mutex_unlock(&data->lock);
1217 return res; 1218 return res;
1218} 1219}
1219 1220
@@ -1252,7 +1253,7 @@ static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value)
1252 struct w83627hf_data *data = i2c_get_clientdata(client); 1253 struct w83627hf_data *data = i2c_get_clientdata(client);
1253 int word_sized; 1254 int word_sized;
1254 1255
1255 down(&data->lock); 1256 mutex_lock(&data->lock);
1256 word_sized = (((reg & 0xff00) == 0x100) 1257 word_sized = (((reg & 0xff00) == 0x100)
1257 || ((reg & 0xff00) == 0x200)) 1258 || ((reg & 0xff00) == 0x200))
1258 && (((reg & 0x00ff) == 0x53) 1259 && (((reg & 0x00ff) == 0x53)
@@ -1277,7 +1278,7 @@ static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value)
1277 client->addr + W83781D_ADDR_REG_OFFSET); 1278 client->addr + W83781D_ADDR_REG_OFFSET);
1278 outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); 1279 outb_p(0, client->addr + W83781D_DATA_REG_OFFSET);
1279 } 1280 }
1280 up(&data->lock); 1281 mutex_unlock(&data->lock);
1281 return 0; 1282 return 0;
1282} 1283}
1283 1284
@@ -1387,7 +1388,7 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev)
1387 struct w83627hf_data *data = i2c_get_clientdata(client); 1388 struct w83627hf_data *data = i2c_get_clientdata(client);
1388 int i; 1389 int i;
1389 1390
1390 down(&data->update_lock); 1391 mutex_lock(&data->update_lock);
1391 1392
1392 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 1393 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
1393 || !data->valid) { 1394 || !data->valid) {
@@ -1470,7 +1471,7 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev)
1470 data->valid = 1; 1471 data->valid = 1;
1471 } 1472 }
1472 1473
1473 up(&data->update_lock); 1474 mutex_unlock(&data->update_lock);
1474 1475
1475 return data; 1476 return data;
1476} 1477}
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index 64c1f8af5bb2..782117817526 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -42,6 +42,7 @@
42#include <linux/hwmon.h> 42#include <linux/hwmon.h>
43#include <linux/hwmon-vid.h> 43#include <linux/hwmon-vid.h>
44#include <linux/err.h> 44#include <linux/err.h>
45#include <linux/mutex.h>
45#include <asm/io.h> 46#include <asm/io.h>
46#include "lm75.h" 47#include "lm75.h"
47 48
@@ -226,10 +227,10 @@ DIV_TO_REG(long val, enum chips type)
226struct w83781d_data { 227struct w83781d_data {
227 struct i2c_client client; 228 struct i2c_client client;
228 struct class_device *class_dev; 229 struct class_device *class_dev;
229 struct semaphore lock; 230 struct mutex lock;
230 enum chips type; 231 enum chips type;
231 232
232 struct semaphore update_lock; 233 struct mutex update_lock;
233 char valid; /* !=0 if following fields are valid */ 234 char valid; /* !=0 if following fields are valid */
234 unsigned long last_updated; /* In jiffies */ 235 unsigned long last_updated; /* In jiffies */
235 236
@@ -311,11 +312,11 @@ static ssize_t store_in_##reg (struct device *dev, const char *buf, size_t count
311 \ 312 \
312 val = simple_strtoul(buf, NULL, 10) / 10; \ 313 val = simple_strtoul(buf, NULL, 10) / 10; \
313 \ 314 \
314 down(&data->update_lock); \ 315 mutex_lock(&data->update_lock); \
315 data->in_##reg[nr] = IN_TO_REG(val); \ 316 data->in_##reg[nr] = IN_TO_REG(val); \
316 w83781d_write_value(client, W83781D_REG_IN_##REG(nr), data->in_##reg[nr]); \ 317 w83781d_write_value(client, W83781D_REG_IN_##REG(nr), data->in_##reg[nr]); \
317 \ 318 \
318 up(&data->update_lock); \ 319 mutex_unlock(&data->update_lock); \
319 return count; \ 320 return count; \
320} 321}
321store_in_reg(MIN, min); 322store_in_reg(MIN, min);
@@ -381,13 +382,13 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
381 382
382 val = simple_strtoul(buf, NULL, 10); 383 val = simple_strtoul(buf, NULL, 10);
383 384
384 down(&data->update_lock); 385 mutex_lock(&data->update_lock);
385 data->fan_min[nr - 1] = 386 data->fan_min[nr - 1] =
386 FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); 387 FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1]));
387 w83781d_write_value(client, W83781D_REG_FAN_MIN(nr), 388 w83781d_write_value(client, W83781D_REG_FAN_MIN(nr),
388 data->fan_min[nr - 1]); 389 data->fan_min[nr - 1]);
389 390
390 up(&data->update_lock); 391 mutex_unlock(&data->update_lock);
391 return count; 392 return count;
392} 393}
393 394
@@ -446,7 +447,7 @@ static ssize_t store_temp_##reg (struct device *dev, const char *buf, size_t cou
446 \ 447 \
447 val = simple_strtol(buf, NULL, 10); \ 448 val = simple_strtol(buf, NULL, 10); \
448 \ 449 \
449 down(&data->update_lock); \ 450 mutex_lock(&data->update_lock); \
450 \ 451 \
451 if (nr >= 2) { /* TEMP2 and TEMP3 */ \ 452 if (nr >= 2) { /* TEMP2 and TEMP3 */ \
452 data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ 453 data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \
@@ -458,7 +459,7 @@ static ssize_t store_temp_##reg (struct device *dev, const char *buf, size_t cou
458 data->temp_##reg); \ 459 data->temp_##reg); \
459 } \ 460 } \
460 \ 461 \
461 up(&data->update_lock); \ 462 mutex_unlock(&data->update_lock); \
462 return count; \ 463 return count; \
463} 464}
464store_temp_reg(OVER, max); 465store_temp_reg(OVER, max);
@@ -571,7 +572,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count,
571 572
572 val = simple_strtoul(buf, NULL, 10); 573 val = simple_strtoul(buf, NULL, 10);
573 574
574 down(&data->update_lock); 575 mutex_lock(&data->update_lock);
575 576
576 if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ 577 if (update_mask == BEEP_MASK) { /* We are storing beep_mask */
577 data->beep_mask = BEEP_MASK_TO_REG(val, data->type); 578 data->beep_mask = BEEP_MASK_TO_REG(val, data->type);
@@ -592,7 +593,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count,
592 w83781d_write_value(client, W83781D_REG_BEEP_INTS2, 593 w83781d_write_value(client, W83781D_REG_BEEP_INTS2,
593 val2 | data->beep_enable << 7); 594 val2 | data->beep_enable << 7);
594 595
595 up(&data->update_lock); 596 mutex_unlock(&data->update_lock);
596 return count; 597 return count;
597} 598}
598 599
@@ -637,7 +638,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr)
637 u8 reg; 638 u8 reg;
638 unsigned long val = simple_strtoul(buf, NULL, 10); 639 unsigned long val = simple_strtoul(buf, NULL, 10);
639 640
640 down(&data->update_lock); 641 mutex_lock(&data->update_lock);
641 642
642 /* Save fan_min */ 643 /* Save fan_min */
643 min = FAN_FROM_REG(data->fan_min[nr], 644 min = FAN_FROM_REG(data->fan_min[nr],
@@ -662,7 +663,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr)
662 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 663 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
663 w83781d_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); 664 w83781d_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]);
664 665
665 up(&data->update_lock); 666 mutex_unlock(&data->update_lock);
666 return count; 667 return count;
667} 668}
668 669
@@ -709,10 +710,10 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr)
709 710
710 val = simple_strtoul(buf, NULL, 10); 711 val = simple_strtoul(buf, NULL, 10);
711 712
712 down(&data->update_lock); 713 mutex_lock(&data->update_lock);
713 data->pwm[nr - 1] = PWM_TO_REG(val); 714 data->pwm[nr - 1] = PWM_TO_REG(val);
714 w83781d_write_value(client, W83781D_REG_PWM(nr), data->pwm[nr - 1]); 715 w83781d_write_value(client, W83781D_REG_PWM(nr), data->pwm[nr - 1]);
715 up(&data->update_lock); 716 mutex_unlock(&data->update_lock);
716 return count; 717 return count;
717} 718}
718 719
@@ -725,7 +726,7 @@ store_pwmenable_reg(struct device *dev, const char *buf, size_t count, int nr)
725 726
726 val = simple_strtoul(buf, NULL, 10); 727 val = simple_strtoul(buf, NULL, 10);
727 728
728 down(&data->update_lock); 729 mutex_lock(&data->update_lock);
729 730
730 switch (val) { 731 switch (val) {
731 case 0: 732 case 0:
@@ -742,11 +743,11 @@ store_pwmenable_reg(struct device *dev, const char *buf, size_t count, int nr)
742 break; 743 break;
743 744
744 default: 745 default:
745 up(&data->update_lock); 746 mutex_unlock(&data->update_lock);
746 return -EINVAL; 747 return -EINVAL;
747 } 748 }
748 749
749 up(&data->update_lock); 750 mutex_unlock(&data->update_lock);
750 return count; 751 return count;
751} 752}
752 753
@@ -808,7 +809,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr)
808 809
809 val = simple_strtoul(buf, NULL, 10); 810 val = simple_strtoul(buf, NULL, 10);
810 811
811 down(&data->update_lock); 812 mutex_lock(&data->update_lock);
812 813
813 switch (val) { 814 switch (val) {
814 case 1: /* PII/Celeron diode */ 815 case 1: /* PII/Celeron diode */
@@ -841,7 +842,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr)
841 break; 842 break;
842 } 843 }
843 844
844 up(&data->update_lock); 845 mutex_unlock(&data->update_lock);
845 return count; 846 return count;
846} 847}
847 848
@@ -1073,7 +1074,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1073 new_client = &data->client; 1074 new_client = &data->client;
1074 i2c_set_clientdata(new_client, data); 1075 i2c_set_clientdata(new_client, data);
1075 new_client->addr = address; 1076 new_client->addr = address;
1076 init_MUTEX(&data->lock); 1077 mutex_init(&data->lock);
1077 new_client->adapter = adapter; 1078 new_client->adapter = adapter;
1078 new_client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver; 1079 new_client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver;
1079 new_client->flags = 0; 1080 new_client->flags = 0;
@@ -1178,7 +1179,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1178 data->type = kind; 1179 data->type = kind;
1179 1180
1180 data->valid = 0; 1181 data->valid = 0;
1181 init_MUTEX(&data->update_lock); 1182 mutex_init(&data->update_lock);
1182 1183
1183 /* Tell the I2C layer a new client has arrived */ 1184 /* Tell the I2C layer a new client has arrived */
1184 if ((err = i2c_attach_client(new_client))) 1185 if ((err = i2c_attach_client(new_client)))
@@ -1325,7 +1326,7 @@ w83781d_read_value(struct i2c_client *client, u16 reg)
1325 int res, word_sized, bank; 1326 int res, word_sized, bank;
1326 struct i2c_client *cl; 1327 struct i2c_client *cl;
1327 1328
1328 down(&data->lock); 1329 mutex_lock(&data->lock);
1329 if (i2c_is_isa_client(client)) { 1330 if (i2c_is_isa_client(client)) {
1330 word_sized = (((reg & 0xff00) == 0x100) 1331 word_sized = (((reg & 0xff00) == 0x100)
1331 || ((reg & 0xff00) == 0x200)) 1332 || ((reg & 0xff00) == 0x200))
@@ -1383,7 +1384,7 @@ w83781d_read_value(struct i2c_client *client, u16 reg)
1383 if (bank > 2) 1384 if (bank > 2)
1384 i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0); 1385 i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0);
1385 } 1386 }
1386 up(&data->lock); 1387 mutex_unlock(&data->lock);
1387 return res; 1388 return res;
1388} 1389}
1389 1390
@@ -1394,7 +1395,7 @@ w83781d_write_value(struct i2c_client *client, u16 reg, u16 value)
1394 int word_sized, bank; 1395 int word_sized, bank;
1395 struct i2c_client *cl; 1396 struct i2c_client *cl;
1396 1397
1397 down(&data->lock); 1398 mutex_lock(&data->lock);
1398 if (i2c_is_isa_client(client)) { 1399 if (i2c_is_isa_client(client)) {
1399 word_sized = (((reg & 0xff00) == 0x100) 1400 word_sized = (((reg & 0xff00) == 0x100)
1400 || ((reg & 0xff00) == 0x200)) 1401 || ((reg & 0xff00) == 0x200))
@@ -1447,7 +1448,7 @@ w83781d_write_value(struct i2c_client *client, u16 reg, u16 value)
1447 if (bank > 2) 1448 if (bank > 2)
1448 i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0); 1449 i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0);
1449 } 1450 }
1450 up(&data->lock); 1451 mutex_unlock(&data->lock);
1451 return 0; 1452 return 0;
1452} 1453}
1453 1454
@@ -1533,7 +1534,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev)
1533 struct w83781d_data *data = i2c_get_clientdata(client); 1534 struct w83781d_data *data = i2c_get_clientdata(client);
1534 int i; 1535 int i;
1535 1536
1536 down(&data->update_lock); 1537 mutex_lock(&data->update_lock);
1537 1538
1538 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 1539 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
1539 || !data->valid) { 1540 || !data->valid) {
@@ -1641,7 +1642,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev)
1641 data->valid = 1; 1642 data->valid = 1;
1642 } 1643 }
1643 1644
1644 up(&data->update_lock); 1645 mutex_unlock(&data->update_lock);
1645 1646
1646 return data; 1647 return data;
1647} 1648}
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
index 2e86e188b27a..6865c64d8a51 100644
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -43,6 +43,7 @@
43#include <linux/hwmon.h> 43#include <linux/hwmon.h>
44#include <linux/hwmon-sysfs.h> 44#include <linux/hwmon-sysfs.h>
45#include <linux/err.h> 45#include <linux/err.h>
46#include <linux/mutex.h>
46 47
47/* Addresses to scan */ 48/* Addresses to scan */
48static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; 49static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END };
@@ -271,7 +272,7 @@ struct w83792d_data {
271 struct class_device *class_dev; 272 struct class_device *class_dev;
272 enum chips type; 273 enum chips type;
273 274
274 struct semaphore update_lock; 275 struct mutex update_lock;
275 char valid; /* !=0 if following fields are valid */ 276 char valid; /* !=0 if following fields are valid */
276 unsigned long last_updated; /* In jiffies */ 277 unsigned long last_updated; /* In jiffies */
277 278
@@ -1222,7 +1223,7 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
1222 data->type = kind; 1223 data->type = kind;
1223 1224
1224 data->valid = 0; 1225 data->valid = 0;
1225 init_MUTEX(&data->update_lock); 1226 mutex_init(&data->update_lock);
1226 1227
1227 /* Tell the I2C layer a new client has arrived */ 1228 /* Tell the I2C layer a new client has arrived */
1228 if ((err = i2c_attach_client(client))) 1229 if ((err = i2c_attach_client(client)))
@@ -1373,7 +1374,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev)
1373 int i, j; 1374 int i, j;
1374 u8 reg_array_tmp[4], pwm_array_tmp[7], reg_tmp; 1375 u8 reg_array_tmp[4], pwm_array_tmp[7], reg_tmp;
1375 1376
1376 down(&data->update_lock); 1377 mutex_lock(&data->update_lock);
1377 1378
1378 if (time_after 1379 if (time_after
1379 (jiffies - data->last_updated, (unsigned long) (HZ * 3)) 1380 (jiffies - data->last_updated, (unsigned long) (HZ * 3))
@@ -1484,7 +1485,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev)
1484 data->valid = 1; 1485 data->valid = 1;
1485 } 1486 }
1486 1487
1487 up(&data->update_lock); 1488 mutex_unlock(&data->update_lock);
1488 1489
1489#ifdef DEBUG 1490#ifdef DEBUG
1490 w83792d_print_debug(data, dev); 1491 w83792d_print_debug(data, dev);
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c
index f66c0cfdeda7..3f2bac125fb1 100644
--- a/drivers/hwmon/w83l785ts.c
+++ b/drivers/hwmon/w83l785ts.c
@@ -39,6 +39,7 @@
39#include <linux/hwmon.h> 39#include <linux/hwmon.h>
40#include <linux/hwmon-sysfs.h> 40#include <linux/hwmon-sysfs.h>
41#include <linux/err.h> 41#include <linux/err.h>
42#include <linux/mutex.h>
42 43
43/* How many retries on register read error */ 44/* How many retries on register read error */
44#define MAX_RETRIES 5 45#define MAX_RETRIES 5
@@ -107,7 +108,7 @@ static struct i2c_driver w83l785ts_driver = {
107struct w83l785ts_data { 108struct w83l785ts_data {
108 struct i2c_client client; 109 struct i2c_client client;
109 struct class_device *class_dev; 110 struct class_device *class_dev;
110 struct semaphore update_lock; 111 struct mutex update_lock;
111 char valid; /* zero until following fields are valid */ 112 char valid; /* zero until following fields are valid */
112 unsigned long last_updated; /* in jiffies */ 113 unsigned long last_updated; /* in jiffies */
113 114
@@ -221,7 +222,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
221 /* We can fill in the remaining client fields. */ 222 /* We can fill in the remaining client fields. */
222 strlcpy(new_client->name, "w83l785ts", I2C_NAME_SIZE); 223 strlcpy(new_client->name, "w83l785ts", I2C_NAME_SIZE);
223 data->valid = 0; 224 data->valid = 0;
224 init_MUTEX(&data->update_lock); 225 mutex_init(&data->update_lock);
225 226
226 /* Default values in case the first read fails (unlikely). */ 227 /* Default values in case the first read fails (unlikely). */
227 data->temp[1] = data->temp[0] = 0; 228 data->temp[1] = data->temp[0] = 0;
@@ -299,7 +300,7 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev)
299 struct i2c_client *client = to_i2c_client(dev); 300 struct i2c_client *client = to_i2c_client(dev);
300 struct w83l785ts_data *data = i2c_get_clientdata(client); 301 struct w83l785ts_data *data = i2c_get_clientdata(client);
301 302
302 down(&data->update_lock); 303 mutex_lock(&data->update_lock);
303 304
304 if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { 305 if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) {
305 dev_dbg(&client->dev, "Updating w83l785ts data.\n"); 306 dev_dbg(&client->dev, "Updating w83l785ts data.\n");
@@ -312,7 +313,7 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev)
312 data->valid = 1; 313 data->valid = 1;
313 } 314 }
314 315
315 up(&data->update_lock); 316 mutex_unlock(&data->update_lock);
316 317
317 return data; 318 return data;
318} 319}