diff options
Diffstat (limited to 'drivers/hwmon/adm1026.c')
-rw-r--r-- | drivers/hwmon/adm1026.c | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index fefe6e74fd02..6d4f8b8d358e 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 */ |
37 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 38 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
@@ -260,10 +261,10 @@ struct pwm_data { | |||
260 | struct adm1026_data { | 261 | struct 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 */ |
@@ -298,9 +299,8 @@ static int adm1026_attach_adapter(struct i2c_adapter *adapter); | |||
298 | static int adm1026_detect(struct i2c_adapter *adapter, int address, | 299 | static int adm1026_detect(struct i2c_adapter *adapter, int address, |
299 | int kind); | 300 | int kind); |
300 | static int adm1026_detach_client(struct i2c_client *client); | 301 | static int adm1026_detach_client(struct i2c_client *client); |
301 | static int adm1026_read_value(struct i2c_client *client, u8 register); | 302 | static int adm1026_read_value(struct i2c_client *client, u8 reg); |
302 | static int adm1026_write_value(struct i2c_client *client, u8 register, | 303 | static int adm1026_write_value(struct i2c_client *client, u8 reg, int value); |
303 | int value); | ||
304 | static void adm1026_print_gpio(struct i2c_client *client); | 304 | static void adm1026_print_gpio(struct i2c_client *client); |
305 | static void adm1026_fixup_gpio(struct i2c_client *client); | 305 | static void adm1026_fixup_gpio(struct i2c_client *client); |
306 | static struct adm1026_data *adm1026_update_device(struct device *dev); | 306 | static struct adm1026_data *adm1026_update_device(struct device *dev); |
@@ -575,7 +575,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
575 | int i; | 575 | int i; |
576 | long value, alarms, gpio; | 576 | long value, alarms, gpio; |
577 | 577 | ||
578 | down(&data->update_lock); | 578 | mutex_lock(&data->update_lock); |
579 | if (!data->valid | 579 | if (!data->valid |
580 | || time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) { | 580 | || time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) { |
581 | /* Things that change quickly */ | 581 | /* Things that change quickly */ |
@@ -710,7 +710,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
710 | dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n"); | 710 | dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n"); |
711 | data->vid = (data->gpio >> 11) & 0x1f; | 711 | data->vid = (data->gpio >> 11) & 0x1f; |
712 | data->valid = 1; | 712 | data->valid = 1; |
713 | up(&data->update_lock); | 713 | mutex_unlock(&data->update_lock); |
714 | return data; | 714 | return data; |
715 | } | 715 | } |
716 | 716 | ||
@@ -739,10 +739,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | |||
739 | struct adm1026_data *data = i2c_get_clientdata(client); | 739 | struct adm1026_data *data = i2c_get_clientdata(client); |
740 | int val = simple_strtol(buf, NULL, 10); | 740 | int val = simple_strtol(buf, NULL, 10); |
741 | 741 | ||
742 | down(&data->update_lock); | 742 | mutex_lock(&data->update_lock); |
743 | data->in_min[nr] = INS_TO_REG(nr, val); | 743 | data->in_min[nr] = INS_TO_REG(nr, val); |
744 | adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]); | 744 | adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]); |
745 | up(&data->update_lock); | 745 | mutex_unlock(&data->update_lock); |
746 | return count; | 746 | return count; |
747 | } | 747 | } |
748 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, | 748 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, |
@@ -762,10 +762,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | |||
762 | struct adm1026_data *data = i2c_get_clientdata(client); | 762 | struct adm1026_data *data = i2c_get_clientdata(client); |
763 | int val = simple_strtol(buf, NULL, 10); | 763 | int val = simple_strtol(buf, NULL, 10); |
764 | 764 | ||
765 | down(&data->update_lock); | 765 | mutex_lock(&data->update_lock); |
766 | data->in_max[nr] = INS_TO_REG(nr, val); | 766 | data->in_max[nr] = INS_TO_REG(nr, val); |
767 | adm1026_write_value(client, ADM1026_REG_IN_MAX[nr], data->in_max[nr]); | 767 | adm1026_write_value(client, ADM1026_REG_IN_MAX[nr], data->in_max[nr]); |
768 | up(&data->update_lock); | 768 | mutex_unlock(&data->update_lock); |
769 | return count; | 769 | return count; |
770 | } | 770 | } |
771 | 771 | ||
@@ -813,10 +813,10 @@ static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr, c | |||
813 | struct adm1026_data *data = i2c_get_clientdata(client); | 813 | struct adm1026_data *data = i2c_get_clientdata(client); |
814 | int val = simple_strtol(buf, NULL, 10); | 814 | int val = simple_strtol(buf, NULL, 10); |
815 | 815 | ||
816 | down(&data->update_lock); | 816 | mutex_lock(&data->update_lock); |
817 | data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET); | 817 | 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]); | 818 | adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]); |
819 | up(&data->update_lock); | 819 | mutex_unlock(&data->update_lock); |
820 | return count; | 820 | return count; |
821 | } | 821 | } |
822 | static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf) | 822 | static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf) |
@@ -831,10 +831,10 @@ static ssize_t set_in16_max(struct device *dev, struct device_attribute *attr, c | |||
831 | struct adm1026_data *data = i2c_get_clientdata(client); | 831 | struct adm1026_data *data = i2c_get_clientdata(client); |
832 | int val = simple_strtol(buf, NULL, 10); | 832 | int val = simple_strtol(buf, NULL, 10); |
833 | 833 | ||
834 | down(&data->update_lock); | 834 | mutex_lock(&data->update_lock); |
835 | data->in_max[16] = INS_TO_REG(16, val+NEG12_OFFSET); | 835 | 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]); | 836 | adm1026_write_value(client, ADM1026_REG_IN_MAX[16], data->in_max[16]); |
837 | up(&data->update_lock); | 837 | mutex_unlock(&data->update_lock); |
838 | return count; | 838 | return count; |
839 | } | 839 | } |
840 | 840 | ||
@@ -874,11 +874,11 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
874 | struct adm1026_data *data = i2c_get_clientdata(client); | 874 | struct adm1026_data *data = i2c_get_clientdata(client); |
875 | int val = simple_strtol(buf, NULL, 10); | 875 | int val = simple_strtol(buf, NULL, 10); |
876 | 876 | ||
877 | down(&data->update_lock); | 877 | mutex_lock(&data->update_lock); |
878 | data->fan_min[nr] = FAN_TO_REG(val, data->fan_div[nr]); | 878 | data->fan_min[nr] = FAN_TO_REG(val, data->fan_div[nr]); |
879 | adm1026_write_value(client, ADM1026_REG_FAN_MIN(nr), | 879 | adm1026_write_value(client, ADM1026_REG_FAN_MIN(nr), |
880 | data->fan_min[nr]); | 880 | data->fan_min[nr]); |
881 | up(&data->update_lock); | 881 | mutex_unlock(&data->update_lock); |
882 | return count; | 882 | return count; |
883 | } | 883 | } |
884 | 884 | ||
@@ -939,7 +939,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
939 | if (new_div == 0) { | 939 | if (new_div == 0) { |
940 | return -EINVAL; | 940 | return -EINVAL; |
941 | } | 941 | } |
942 | down(&data->update_lock); | 942 | mutex_lock(&data->update_lock); |
943 | orig_div = data->fan_div[nr]; | 943 | orig_div = data->fan_div[nr]; |
944 | data->fan_div[nr] = DIV_FROM_REG(new_div); | 944 | data->fan_div[nr] = DIV_FROM_REG(new_div); |
945 | 945 | ||
@@ -958,7 +958,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
958 | if (data->fan_div[nr] != orig_div) { | 958 | if (data->fan_div[nr] != orig_div) { |
959 | fixup_fan_min(dev,nr,orig_div); | 959 | fixup_fan_min(dev,nr,orig_div); |
960 | } | 960 | } |
961 | up(&data->update_lock); | 961 | mutex_unlock(&data->update_lock); |
962 | return count; | 962 | return count; |
963 | } | 963 | } |
964 | 964 | ||
@@ -1001,11 +1001,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
1001 | struct adm1026_data *data = i2c_get_clientdata(client); | 1001 | struct adm1026_data *data = i2c_get_clientdata(client); |
1002 | int val = simple_strtol(buf, NULL, 10); | 1002 | int val = simple_strtol(buf, NULL, 10); |
1003 | 1003 | ||
1004 | down(&data->update_lock); | 1004 | mutex_lock(&data->update_lock); |
1005 | data->temp_min[nr] = TEMP_TO_REG(val); | 1005 | data->temp_min[nr] = TEMP_TO_REG(val); |
1006 | adm1026_write_value(client, ADM1026_REG_TEMP_MIN[nr], | 1006 | adm1026_write_value(client, ADM1026_REG_TEMP_MIN[nr], |
1007 | data->temp_min[nr]); | 1007 | data->temp_min[nr]); |
1008 | up(&data->update_lock); | 1008 | mutex_unlock(&data->update_lock); |
1009 | return count; | 1009 | return count; |
1010 | } | 1010 | } |
1011 | static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, | 1011 | static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, |
@@ -1025,11 +1025,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
1025 | struct adm1026_data *data = i2c_get_clientdata(client); | 1025 | struct adm1026_data *data = i2c_get_clientdata(client); |
1026 | int val = simple_strtol(buf, NULL, 10); | 1026 | int val = simple_strtol(buf, NULL, 10); |
1027 | 1027 | ||
1028 | down(&data->update_lock); | 1028 | mutex_lock(&data->update_lock); |
1029 | data->temp_max[nr] = TEMP_TO_REG(val); | 1029 | data->temp_max[nr] = TEMP_TO_REG(val); |
1030 | adm1026_write_value(client, ADM1026_REG_TEMP_MAX[nr], | 1030 | adm1026_write_value(client, ADM1026_REG_TEMP_MAX[nr], |
1031 | data->temp_max[nr]); | 1031 | data->temp_max[nr]); |
1032 | up(&data->update_lock); | 1032 | mutex_unlock(&data->update_lock); |
1033 | return count; | 1033 | return count; |
1034 | } | 1034 | } |
1035 | 1035 | ||
@@ -1064,11 +1064,11 @@ static ssize_t set_temp_offset(struct device *dev, | |||
1064 | struct adm1026_data *data = i2c_get_clientdata(client); | 1064 | struct adm1026_data *data = i2c_get_clientdata(client); |
1065 | int val = simple_strtol(buf, NULL, 10); | 1065 | int val = simple_strtol(buf, NULL, 10); |
1066 | 1066 | ||
1067 | down(&data->update_lock); | 1067 | mutex_lock(&data->update_lock); |
1068 | data->temp_offset[nr] = TEMP_TO_REG(val); | 1068 | data->temp_offset[nr] = TEMP_TO_REG(val); |
1069 | adm1026_write_value(client, ADM1026_REG_TEMP_OFFSET[nr], | 1069 | adm1026_write_value(client, ADM1026_REG_TEMP_OFFSET[nr], |
1070 | data->temp_offset[nr]); | 1070 | data->temp_offset[nr]); |
1071 | up(&data->update_lock); | 1071 | mutex_unlock(&data->update_lock); |
1072 | return count; | 1072 | return count; |
1073 | } | 1073 | } |
1074 | 1074 | ||
@@ -1115,11 +1115,11 @@ static ssize_t set_temp_auto_point1_temp(struct device *dev, | |||
1115 | struct adm1026_data *data = i2c_get_clientdata(client); | 1115 | struct adm1026_data *data = i2c_get_clientdata(client); |
1116 | int val = simple_strtol(buf, NULL, 10); | 1116 | int val = simple_strtol(buf, NULL, 10); |
1117 | 1117 | ||
1118 | down(&data->update_lock); | 1118 | mutex_lock(&data->update_lock); |
1119 | data->temp_tmin[nr] = TEMP_TO_REG(val); | 1119 | data->temp_tmin[nr] = TEMP_TO_REG(val); |
1120 | adm1026_write_value(client, ADM1026_REG_TEMP_TMIN[nr], | 1120 | adm1026_write_value(client, ADM1026_REG_TEMP_TMIN[nr], |
1121 | data->temp_tmin[nr]); | 1121 | data->temp_tmin[nr]); |
1122 | up(&data->update_lock); | 1122 | mutex_unlock(&data->update_lock); |
1123 | return count; | 1123 | return count; |
1124 | } | 1124 | } |
1125 | 1125 | ||
@@ -1150,11 +1150,11 @@ static ssize_t set_temp_crit_enable(struct device *dev, | |||
1150 | int val = simple_strtol(buf, NULL, 10); | 1150 | int val = simple_strtol(buf, NULL, 10); |
1151 | 1151 | ||
1152 | if ((val == 1) || (val==0)) { | 1152 | if ((val == 1) || (val==0)) { |
1153 | down(&data->update_lock); | 1153 | mutex_lock(&data->update_lock); |
1154 | data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4); | 1154 | data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4); |
1155 | adm1026_write_value(client, ADM1026_REG_CONFIG1, | 1155 | adm1026_write_value(client, ADM1026_REG_CONFIG1, |
1156 | data->config1); | 1156 | data->config1); |
1157 | up(&data->update_lock); | 1157 | mutex_unlock(&data->update_lock); |
1158 | } | 1158 | } |
1159 | return count; | 1159 | return count; |
1160 | } | 1160 | } |
@@ -1184,11 +1184,11 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, | |||
1184 | struct adm1026_data *data = i2c_get_clientdata(client); | 1184 | struct adm1026_data *data = i2c_get_clientdata(client); |
1185 | int val = simple_strtol(buf, NULL, 10); | 1185 | int val = simple_strtol(buf, NULL, 10); |
1186 | 1186 | ||
1187 | down(&data->update_lock); | 1187 | mutex_lock(&data->update_lock); |
1188 | data->temp_crit[nr] = TEMP_TO_REG(val); | 1188 | data->temp_crit[nr] = TEMP_TO_REG(val); |
1189 | adm1026_write_value(client, ADM1026_REG_TEMP_THERM[nr], | 1189 | adm1026_write_value(client, ADM1026_REG_TEMP_THERM[nr], |
1190 | data->temp_crit[nr]); | 1190 | data->temp_crit[nr]); |
1191 | up(&data->update_lock); | 1191 | mutex_unlock(&data->update_lock); |
1192 | return count; | 1192 | return count; |
1193 | } | 1193 | } |
1194 | 1194 | ||
@@ -1212,10 +1212,10 @@ static ssize_t set_analog_out_reg(struct device *dev, struct device_attribute *a | |||
1212 | struct adm1026_data *data = i2c_get_clientdata(client); | 1212 | struct adm1026_data *data = i2c_get_clientdata(client); |
1213 | int val = simple_strtol(buf, NULL, 10); | 1213 | int val = simple_strtol(buf, NULL, 10); |
1214 | 1214 | ||
1215 | down(&data->update_lock); | 1215 | mutex_lock(&data->update_lock); |
1216 | data->analog_out = DAC_TO_REG(val); | 1216 | data->analog_out = DAC_TO_REG(val); |
1217 | adm1026_write_value(client, ADM1026_REG_DAC, data->analog_out); | 1217 | adm1026_write_value(client, ADM1026_REG_DAC, data->analog_out); |
1218 | up(&data->update_lock); | 1218 | mutex_unlock(&data->update_lock); |
1219 | return count; | 1219 | return count; |
1220 | } | 1220 | } |
1221 | 1221 | ||
@@ -1267,7 +1267,7 @@ static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr, | |||
1267 | int val = simple_strtol(buf, NULL, 10); | 1267 | int val = simple_strtol(buf, NULL, 10); |
1268 | unsigned long mask; | 1268 | unsigned long mask; |
1269 | 1269 | ||
1270 | down(&data->update_lock); | 1270 | mutex_lock(&data->update_lock); |
1271 | data->alarm_mask = val & 0x7fffffff; | 1271 | data->alarm_mask = val & 0x7fffffff; |
1272 | mask = data->alarm_mask | 1272 | mask = data->alarm_mask |
1273 | | (data->gpio_mask & 0x10000 ? 0x80000000 : 0); | 1273 | | (data->gpio_mask & 0x10000 ? 0x80000000 : 0); |
@@ -1282,7 +1282,7 @@ static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr, | |||
1282 | mask >>= 8; | 1282 | mask >>= 8; |
1283 | adm1026_write_value(client, ADM1026_REG_MASK4, | 1283 | adm1026_write_value(client, ADM1026_REG_MASK4, |
1284 | mask & 0xff); | 1284 | mask & 0xff); |
1285 | up(&data->update_lock); | 1285 | mutex_unlock(&data->update_lock); |
1286 | return count; | 1286 | return count; |
1287 | } | 1287 | } |
1288 | 1288 | ||
@@ -1303,7 +1303,7 @@ static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const | |||
1303 | int val = simple_strtol(buf, NULL, 10); | 1303 | int val = simple_strtol(buf, NULL, 10); |
1304 | long gpio; | 1304 | long gpio; |
1305 | 1305 | ||
1306 | down(&data->update_lock); | 1306 | mutex_lock(&data->update_lock); |
1307 | data->gpio = val & 0x1ffff; | 1307 | data->gpio = val & 0x1ffff; |
1308 | gpio = data->gpio; | 1308 | gpio = data->gpio; |
1309 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7,gpio & 0xff); | 1309 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7,gpio & 0xff); |
@@ -1311,7 +1311,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); | 1311 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15,gpio & 0xff); |
1312 | gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f); | 1312 | gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f); |
1313 | adm1026_write_value(client, ADM1026_REG_STATUS4,gpio & 0xff); | 1313 | adm1026_write_value(client, ADM1026_REG_STATUS4,gpio & 0xff); |
1314 | up(&data->update_lock); | 1314 | mutex_unlock(&data->update_lock); |
1315 | return count; | 1315 | return count; |
1316 | } | 1316 | } |
1317 | 1317 | ||
@@ -1331,7 +1331,7 @@ static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr, | |||
1331 | int val = simple_strtol(buf, NULL, 10); | 1331 | int val = simple_strtol(buf, NULL, 10); |
1332 | long mask; | 1332 | long mask; |
1333 | 1333 | ||
1334 | down(&data->update_lock); | 1334 | mutex_lock(&data->update_lock); |
1335 | data->gpio_mask = val & 0x1ffff; | 1335 | data->gpio_mask = val & 0x1ffff; |
1336 | mask = data->gpio_mask; | 1336 | mask = data->gpio_mask; |
1337 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7,mask & 0xff); | 1337 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7,mask & 0xff); |
@@ -1339,7 +1339,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); | 1339 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15,mask & 0xff); |
1340 | mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f); | 1340 | mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f); |
1341 | adm1026_write_value(client, ADM1026_REG_MASK1,mask & 0xff); | 1341 | adm1026_write_value(client, ADM1026_REG_MASK1,mask & 0xff); |
1342 | up(&data->update_lock); | 1342 | mutex_unlock(&data->update_lock); |
1343 | return count; | 1343 | return count; |
1344 | } | 1344 | } |
1345 | 1345 | ||
@@ -1359,10 +1359,10 @@ static ssize_t set_pwm_reg(struct device *dev, struct device_attribute *attr, co | |||
1359 | if (data->pwm1.enable == 1) { | 1359 | if (data->pwm1.enable == 1) { |
1360 | int val = simple_strtol(buf, NULL, 10); | 1360 | int val = simple_strtol(buf, NULL, 10); |
1361 | 1361 | ||
1362 | down(&data->update_lock); | 1362 | mutex_lock(&data->update_lock); |
1363 | data->pwm1.pwm = PWM_TO_REG(val); | 1363 | data->pwm1.pwm = PWM_TO_REG(val); |
1364 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); | 1364 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); |
1365 | up(&data->update_lock); | 1365 | mutex_unlock(&data->update_lock); |
1366 | } | 1366 | } |
1367 | return count; | 1367 | return count; |
1368 | } | 1368 | } |
@@ -1378,14 +1378,14 @@ static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *att | |||
1378 | struct adm1026_data *data = i2c_get_clientdata(client); | 1378 | struct adm1026_data *data = i2c_get_clientdata(client); |
1379 | int val = simple_strtol(buf, NULL, 10); | 1379 | int val = simple_strtol(buf, NULL, 10); |
1380 | 1380 | ||
1381 | down(&data->update_lock); | 1381 | mutex_lock(&data->update_lock); |
1382 | data->pwm1.auto_pwm_min = SENSORS_LIMIT(val,0,255); | 1382 | data->pwm1.auto_pwm_min = SENSORS_LIMIT(val,0,255); |
1383 | if (data->pwm1.enable == 2) { /* apply immediately */ | 1383 | if (data->pwm1.enable == 2) { /* apply immediately */ |
1384 | data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | | 1384 | data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | |
1385 | PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); | 1385 | PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); |
1386 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); | 1386 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); |
1387 | } | 1387 | } |
1388 | up(&data->update_lock); | 1388 | mutex_unlock(&data->update_lock); |
1389 | return count; | 1389 | return count; |
1390 | } | 1390 | } |
1391 | static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf) | 1391 | static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf) |
@@ -1406,7 +1406,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
1406 | int old_enable; | 1406 | int old_enable; |
1407 | 1407 | ||
1408 | if ((val >= 0) && (val < 3)) { | 1408 | if ((val >= 0) && (val < 3)) { |
1409 | down(&data->update_lock); | 1409 | mutex_lock(&data->update_lock); |
1410 | old_enable = data->pwm1.enable; | 1410 | old_enable = data->pwm1.enable; |
1411 | data->pwm1.enable = val; | 1411 | data->pwm1.enable = val; |
1412 | data->config1 = (data->config1 & ~CFG1_PWM_AFC) | 1412 | data->config1 = (data->config1 & ~CFG1_PWM_AFC) |
@@ -1424,7 +1424,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
1424 | adm1026_write_value(client, ADM1026_REG_PWM, | 1424 | adm1026_write_value(client, ADM1026_REG_PWM, |
1425 | data->pwm1.pwm); | 1425 | data->pwm1.pwm); |
1426 | } | 1426 | } |
1427 | up(&data->update_lock); | 1427 | mutex_unlock(&data->update_lock); |
1428 | } | 1428 | } |
1429 | return count; | 1429 | return count; |
1430 | } | 1430 | } |
@@ -1541,7 +1541,7 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1541 | /* Fill in the remaining client fields */ | 1541 | /* Fill in the remaining client fields */ |
1542 | data->type = kind; | 1542 | data->type = kind; |
1543 | data->valid = 0; | 1543 | data->valid = 0; |
1544 | init_MUTEX(&data->update_lock); | 1544 | mutex_init(&data->update_lock); |
1545 | 1545 | ||
1546 | /* Tell the I2C layer a new client has arrived */ | 1546 | /* Tell the I2C layer a new client has arrived */ |
1547 | if ((err = i2c_attach_client(new_client))) | 1547 | if ((err = i2c_attach_client(new_client))) |