Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/i2c-2.6

* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/i2c-2.6: (36 commits)
[PATCH] hwmon: add required idr locking
[PATCH] I2C: hwmon: Rename register parameters
[PATCH] I2C: Drop unneeded i2c-dev.h includes
[PATCH] I2C: i2c-ixp4xx: Add hwmon class
[PATCH] I2C: i2c-piix4: Add Broadcom HT-1000 support
[PATCH] I2C: i2c-amd756-s4882: Improve static mutex initialization
[PATCH] I2C: i2c-ali1535: Drop redundant mutex
[PATCH] i2c: Cleanup isp1301_omap
[PATCH] i2c: Fix i2c-ite name initialization
[PATCH] i2c: Drop the i2c-frodo bus driver
[PATCH] i2c: Optimize core_lists mutex usage
[PATCH] w83781d: Don't reset the chip by default
[PATCH] w83781d: Document the alarm and beep bits
[PATCH] w83627ehf: Refactor the sysfs interface
[PATCH] hwmon: Support the Pentium M VID code
[PATCH] hwmon: Add support for the Winbond W83687THF
[PATCH] hwmon: f71805f semaphore to mutex conversions
[PATCH] hwmon: Semaphore to mutex conversions
[PATCH] i2c: Semaphore to mutex conversions, part 3
[PATCH] i2c: Semaphore to mutex conversions, part 2
...

+1697 -1777
+4
Documentation/hwmon/w83627hf
··· 18 18 Prefix: 'w83637hf' 19 19 Addresses scanned: ISA address retrieved from Super I/O registers 20 20 Datasheet: http://www.winbond.com/PDF/sheet/w83637hf.pdf 21 + * Winbond W83687THF 22 + Prefix: 'w83687thf' 23 + Addresses scanned: ISA address retrieved from Super I/O registers 24 + Datasheet: Provided by Winbond on request 21 25 22 26 Authors: 23 27 Frodo Looijaard <frodol@dds.nl>,
+24
Documentation/hwmon/w83781d
··· 36 36 Use 'init=0' to bypass initializing the chip. 37 37 Try this if your computer crashes when you load the module. 38 38 39 + * reset int 40 + (default 0) 41 + The driver used to reset the chip on load, but does no more. Use 42 + 'reset=1' to restore the old behavior. Report if you need to do this. 43 + 39 44 force_subclients=bus,caddr,saddr,saddr 40 45 This is used to force the i2c addresses for subclients of 41 46 a certain chip. Typical usage is `force_subclients=0,0x2d,0x4a,0x4b' ··· 127 122 When an alarm goes off, you can be warned by a beeping signal through 128 123 your computer speaker. It is possible to enable all beeping globally, 129 124 or only the beeping for some alarms. 125 + 126 + Individual alarm and beep bits: 127 + 128 + 0x000001: in0 129 + 0x000002: in1 130 + 0x000004: in2 131 + 0x000008: in3 132 + 0x000010: temp1 133 + 0x000020: temp2 (+temp3 on W83781D) 134 + 0x000040: fan1 135 + 0x000080: fan2 136 + 0x000100: in4 137 + 0x000200: in5 138 + 0x000400: in6 139 + 0x000800: fan3 140 + 0x001000: chassis 141 + 0x002000: temp3 (W83782D and W83627HF only) 142 + 0x010000: in7 (W83782D and W83627HF only) 143 + 0x020000: in8 (W83782D and W83627HF only) 130 144 131 145 If an alarm triggers, it will remain triggered until the hardware register 132 146 is read at least once. This means that the cause for the alarm may
+1 -1
Documentation/i2c/busses/i2c-piix4
··· 4 4 * Intel 82371AB PIIX4 and PIIX4E 5 5 * Intel 82443MX (440MX) 6 6 Datasheet: Publicly available at the Intel website 7 - * ServerWorks OSB4, CSB5 and CSB6 southbridges 7 + * ServerWorks OSB4, CSB5, CSB6 and HT-1000 southbridges 8 8 Datasheet: Only available via NDA from ServerWorks 9 9 * Standard Microsystems (SMSC) SLC90E66 (Victory66) southbridge 10 10 Datasheet: Publicly available at the SMSC website http://www.smsc.com
+3 -2
Documentation/i2c/busses/scx200_acb
··· 6 6 ----------------- 7 7 8 8 * base: int 9 - Base addresses for the ACCESS.bus controllers 9 + Base addresses for the ACCESS.bus controllers on SCx200 and SC1100 devices 10 10 11 11 Description 12 12 ----------- 13 13 14 - Enable the use of the ACCESS.bus controllers of a SCx200 processor. 14 + Enable the use of the ACCESS.bus controller on the Geode SCx200 and 15 + SC1100 processors and the CS5535 and CS5536 Geode companion devices.
+4 -3
drivers/hwmon/Kconfig
··· 406 406 will be called w83l785ts. 407 407 408 408 config SENSORS_W83627HF 409 - tristate "Winbond W83627HF, W83627THF, W83637HF, W83697HF" 410 - depends on HWMON && I2C && EXPERIMENTAL 409 + tristate "Winbond W83627HF, W83627THF, W83637HF, W83687THF, W83697HF" 410 + depends on HWMON && I2C 411 411 select I2C_ISA 412 412 select HWMON_VID 413 413 help 414 414 If you say yes here you get support for the Winbond W836X7 series 415 - of sensor chips: the W83627HF, W83627THF, W83637HF, and the W83697HF 415 + of sensor chips: the W83627HF, W83627THF, W83637HF, W83687THF and 416 + W83697HF. 416 417 417 418 This driver can also be built as a module. If so, the module 418 419 will be called w83627hf.
+7 -6
drivers/hwmon/adm1021.c
··· 26 26 #include <linux/i2c.h> 27 27 #include <linux/hwmon.h> 28 28 #include <linux/err.h> 29 + #include <linux/mutex.h> 29 30 30 31 31 32 /* Addresses to scan */ ··· 93 92 struct class_device *class_dev; 94 93 enum chips type; 95 94 96 - struct semaphore update_lock; 95 + struct mutex update_lock; 97 96 char valid; /* !=0 if following fields are valid */ 98 97 unsigned long last_updated; /* In jiffies */ 99 98 ··· 163 162 struct adm1021_data *data = i2c_get_clientdata(client); \ 164 163 int temp = simple_strtoul(buf, NULL, 10); \ 165 164 \ 166 - down(&data->update_lock); \ 165 + mutex_lock(&data->update_lock); \ 167 166 data->value = TEMP_TO_REG(temp); \ 168 167 adm1021_write_value(client, reg, data->value); \ 169 - up(&data->update_lock); \ 168 + mutex_unlock(&data->update_lock); \ 170 169 return count; \ 171 170 } 172 171 set(temp_max, ADM1021_REG_TOS_W); ··· 276 275 strlcpy(new_client->name, type_name, I2C_NAME_SIZE); 277 276 data->type = kind; 278 277 data->valid = 0; 279 - init_MUTEX(&data->update_lock); 278 + mutex_init(&data->update_lock); 280 279 281 280 /* Tell the I2C layer a new client has arrived */ 282 281 if ((err = i2c_attach_client(new_client))) ··· 352 351 struct i2c_client *client = to_i2c_client(dev); 353 352 struct adm1021_data *data = i2c_get_clientdata(client); 354 353 355 - down(&data->update_lock); 354 + mutex_lock(&data->update_lock); 356 355 357 356 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 358 357 || !data->valid) { ··· 376 375 data->valid = 1; 377 376 } 378 377 379 - up(&data->update_lock); 378 + mutex_unlock(&data->update_lock); 380 379 381 380 return data; 382 381 }
+13 -12
drivers/hwmon/adm1025.c
··· 53 53 #include <linux/hwmon.h> 54 54 #include <linux/hwmon-vid.h> 55 55 #include <linux/err.h> 56 + #include <linux/mutex.h> 56 57 57 58 /* 58 59 * Addresses to scan ··· 134 133 struct adm1025_data { 135 134 struct i2c_client client; 136 135 struct class_device *class_dev; 137 - struct semaphore update_lock; 136 + struct mutex update_lock; 138 137 char valid; /* zero until following fields are valid */ 139 138 unsigned long last_updated; /* in jiffies */ 140 139 ··· 208 207 struct adm1025_data *data = i2c_get_clientdata(client); \ 209 208 long val = simple_strtol(buf, NULL, 10); \ 210 209 \ 211 - down(&data->update_lock); \ 210 + mutex_lock(&data->update_lock); \ 212 211 data->in_min[offset] = IN_TO_REG(val, in_scale[offset]); \ 213 212 i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(offset), \ 214 213 data->in_min[offset]); \ 215 - up(&data->update_lock); \ 214 + mutex_unlock(&data->update_lock); \ 216 215 return count; \ 217 216 } \ 218 217 static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ ··· 222 221 struct adm1025_data *data = i2c_get_clientdata(client); \ 223 222 long val = simple_strtol(buf, NULL, 10); \ 224 223 \ 225 - down(&data->update_lock); \ 224 + mutex_lock(&data->update_lock); \ 226 225 data->in_max[offset] = IN_TO_REG(val, in_scale[offset]); \ 227 226 i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(offset), \ 228 227 data->in_max[offset]); \ 229 - up(&data->update_lock); \ 228 + mutex_unlock(&data->update_lock); \ 230 229 return count; \ 231 230 } \ 232 231 static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ ··· 248 247 struct adm1025_data *data = i2c_get_clientdata(client); \ 249 248 long val = simple_strtol(buf, NULL, 10); \ 250 249 \ 251 - down(&data->update_lock); \ 250 + mutex_lock(&data->update_lock); \ 252 251 data->temp_min[offset-1] = TEMP_TO_REG(val); \ 253 252 i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(offset-1), \ 254 253 data->temp_min[offset-1]); \ 255 - up(&data->update_lock); \ 254 + mutex_unlock(&data->update_lock); \ 256 255 return count; \ 257 256 } \ 258 257 static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ ··· 262 261 struct adm1025_data *data = i2c_get_clientdata(client); \ 263 262 long val = simple_strtol(buf, NULL, 10); \ 264 263 \ 265 - down(&data->update_lock); \ 264 + mutex_lock(&data->update_lock); \ 266 265 data->temp_max[offset-1] = TEMP_TO_REG(val); \ 267 266 i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(offset-1), \ 268 267 data->temp_max[offset-1]); \ 269 - up(&data->update_lock); \ 268 + mutex_unlock(&data->update_lock); \ 270 269 return count; \ 271 270 } \ 272 271 static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ ··· 405 404 /* We can fill in the remaining client fields */ 406 405 strlcpy(new_client->name, name, I2C_NAME_SIZE); 407 406 data->valid = 0; 408 - init_MUTEX(&data->update_lock); 407 + mutex_init(&data->update_lock); 409 408 410 409 /* Tell the I2C layer a new client has arrived */ 411 410 if ((err = i2c_attach_client(new_client))) ··· 524 523 struct i2c_client *client = to_i2c_client(dev); 525 524 struct adm1025_data *data = i2c_get_clientdata(client); 526 525 527 - down(&data->update_lock); 526 + mutex_lock(&data->update_lock); 528 527 529 528 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { 530 529 int i; ··· 559 558 data->valid = 1; 560 559 } 561 560 562 - up(&data->update_lock); 561 + mutex_unlock(&data->update_lock); 563 562 564 563 return data; 565 564 }
+46 -46
drivers/hwmon/adm1026.c
··· 32 32 #include <linux/hwmon-sysfs.h> 33 33 #include <linux/hwmon-vid.h> 34 34 #include <linux/err.h> 35 + #include <linux/mutex.h> 35 36 36 37 /* Addresses to scan */ 37 38 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; ··· 261 260 struct adm1026_data { 262 261 struct i2c_client client; 263 262 struct class_device *class_dev; 264 - struct semaphore lock; 263 + struct mutex lock; 265 264 enum chips type; 266 265 267 - struct semaphore update_lock; 266 + struct mutex update_lock; 268 267 int valid; /* !=0 if following fields are valid */ 269 268 unsigned long last_reading; /* In jiffies */ 270 269 unsigned long last_config; /* In jiffies */ ··· 299 298 static int adm1026_detect(struct i2c_adapter *adapter, int address, 300 299 int kind); 301 300 static int adm1026_detach_client(struct i2c_client *client); 302 - static int adm1026_read_value(struct i2c_client *client, u8 register); 303 - static int adm1026_write_value(struct i2c_client *client, u8 register, 304 - int value); 301 + static int adm1026_read_value(struct i2c_client *client, u8 reg); 302 + static int adm1026_write_value(struct i2c_client *client, u8 reg, int value); 305 303 static void adm1026_print_gpio(struct i2c_client *client); 306 304 static void adm1026_fixup_gpio(struct i2c_client *client); 307 305 static struct adm1026_data *adm1026_update_device(struct device *dev); ··· 575 575 int i; 576 576 long value, alarms, gpio; 577 577 578 - down(&data->update_lock); 578 + mutex_lock(&data->update_lock); 579 579 if (!data->valid 580 580 || time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) { 581 581 /* Things that change quickly */ ··· 710 710 dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n"); 711 711 data->vid = (data->gpio >> 11) & 0x1f; 712 712 data->valid = 1; 713 - up(&data->update_lock); 713 + mutex_unlock(&data->update_lock); 714 714 return data; 715 715 } 716 716 ··· 739 739 struct adm1026_data *data = i2c_get_clientdata(client); 740 740 int val = simple_strtol(buf, NULL, 10); 741 741 742 - down(&data->update_lock); 742 + mutex_lock(&data->update_lock); 743 743 data->in_min[nr] = INS_TO_REG(nr, val); 744 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 746 return count; 747 747 } 748 748 static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, ··· 762 762 struct adm1026_data *data = i2c_get_clientdata(client); 763 763 int val = simple_strtol(buf, NULL, 10); 764 764 765 - down(&data->update_lock); 765 + mutex_lock(&data->update_lock); 766 766 data->in_max[nr] = INS_TO_REG(nr, val); 767 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 769 return count; 770 770 } 771 771 ··· 813 813 struct adm1026_data *data = i2c_get_clientdata(client); 814 814 int val = simple_strtol(buf, NULL, 10); 815 815 816 - down(&data->update_lock); 816 + mutex_lock(&data->update_lock); 817 817 data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET); 818 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 820 return count; 821 821 } 822 822 static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf) ··· 831 831 struct adm1026_data *data = i2c_get_clientdata(client); 832 832 int val = simple_strtol(buf, NULL, 10); 833 833 834 - down(&data->update_lock); 834 + mutex_lock(&data->update_lock); 835 835 data->in_max[16] = INS_TO_REG(16, val+NEG12_OFFSET); 836 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 838 return count; 839 839 } 840 840 ··· 874 874 struct adm1026_data *data = i2c_get_clientdata(client); 875 875 int val = simple_strtol(buf, NULL, 10); 876 876 877 - down(&data->update_lock); 877 + mutex_lock(&data->update_lock); 878 878 data->fan_min[nr] = FAN_TO_REG(val, data->fan_div[nr]); 879 879 adm1026_write_value(client, ADM1026_REG_FAN_MIN(nr), 880 880 data->fan_min[nr]); 881 - up(&data->update_lock); 881 + mutex_unlock(&data->update_lock); 882 882 return count; 883 883 } 884 884 ··· 939 939 if (new_div == 0) { 940 940 return -EINVAL; 941 941 } 942 - down(&data->update_lock); 942 + mutex_lock(&data->update_lock); 943 943 orig_div = data->fan_div[nr]; 944 944 data->fan_div[nr] = DIV_FROM_REG(new_div); 945 945 ··· 958 958 if (data->fan_div[nr] != orig_div) { 959 959 fixup_fan_min(dev,nr,orig_div); 960 960 } 961 - up(&data->update_lock); 961 + mutex_unlock(&data->update_lock); 962 962 return count; 963 963 } 964 964 ··· 1001 1001 struct adm1026_data *data = i2c_get_clientdata(client); 1002 1002 int val = simple_strtol(buf, NULL, 10); 1003 1003 1004 - down(&data->update_lock); 1004 + mutex_lock(&data->update_lock); 1005 1005 data->temp_min[nr] = TEMP_TO_REG(val); 1006 1006 adm1026_write_value(client, ADM1026_REG_TEMP_MIN[nr], 1007 1007 data->temp_min[nr]); 1008 - up(&data->update_lock); 1008 + mutex_unlock(&data->update_lock); 1009 1009 return count; 1010 1010 } 1011 1011 static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, ··· 1025 1025 struct adm1026_data *data = i2c_get_clientdata(client); 1026 1026 int val = simple_strtol(buf, NULL, 10); 1027 1027 1028 - down(&data->update_lock); 1028 + mutex_lock(&data->update_lock); 1029 1029 data->temp_max[nr] = TEMP_TO_REG(val); 1030 1030 adm1026_write_value(client, ADM1026_REG_TEMP_MAX[nr], 1031 1031 data->temp_max[nr]); 1032 - up(&data->update_lock); 1032 + mutex_unlock(&data->update_lock); 1033 1033 return count; 1034 1034 } 1035 1035 ··· 1064 1064 struct adm1026_data *data = i2c_get_clientdata(client); 1065 1065 int val = simple_strtol(buf, NULL, 10); 1066 1066 1067 - down(&data->update_lock); 1067 + mutex_lock(&data->update_lock); 1068 1068 data->temp_offset[nr] = TEMP_TO_REG(val); 1069 1069 adm1026_write_value(client, ADM1026_REG_TEMP_OFFSET[nr], 1070 1070 data->temp_offset[nr]); 1071 - up(&data->update_lock); 1071 + mutex_unlock(&data->update_lock); 1072 1072 return count; 1073 1073 } 1074 1074 ··· 1115 1115 struct adm1026_data *data = i2c_get_clientdata(client); 1116 1116 int val = simple_strtol(buf, NULL, 10); 1117 1117 1118 - down(&data->update_lock); 1118 + mutex_lock(&data->update_lock); 1119 1119 data->temp_tmin[nr] = TEMP_TO_REG(val); 1120 1120 adm1026_write_value(client, ADM1026_REG_TEMP_TMIN[nr], 1121 1121 data->temp_tmin[nr]); 1122 - up(&data->update_lock); 1122 + mutex_unlock(&data->update_lock); 1123 1123 return count; 1124 1124 } 1125 1125 ··· 1150 1150 int val = simple_strtol(buf, NULL, 10); 1151 1151 1152 1152 if ((val == 1) || (val==0)) { 1153 - down(&data->update_lock); 1153 + mutex_lock(&data->update_lock); 1154 1154 data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4); 1155 1155 adm1026_write_value(client, ADM1026_REG_CONFIG1, 1156 1156 data->config1); 1157 - up(&data->update_lock); 1157 + mutex_unlock(&data->update_lock); 1158 1158 } 1159 1159 return count; 1160 1160 } ··· 1184 1184 struct adm1026_data *data = i2c_get_clientdata(client); 1185 1185 int val = simple_strtol(buf, NULL, 10); 1186 1186 1187 - down(&data->update_lock); 1187 + mutex_lock(&data->update_lock); 1188 1188 data->temp_crit[nr] = TEMP_TO_REG(val); 1189 1189 adm1026_write_value(client, ADM1026_REG_TEMP_THERM[nr], 1190 1190 data->temp_crit[nr]); 1191 - up(&data->update_lock); 1191 + mutex_unlock(&data->update_lock); 1192 1192 return count; 1193 1193 } 1194 1194 ··· 1212 1212 struct adm1026_data *data = i2c_get_clientdata(client); 1213 1213 int val = simple_strtol(buf, NULL, 10); 1214 1214 1215 - down(&data->update_lock); 1215 + mutex_lock(&data->update_lock); 1216 1216 data->analog_out = DAC_TO_REG(val); 1217 1217 adm1026_write_value(client, ADM1026_REG_DAC, data->analog_out); 1218 - up(&data->update_lock); 1218 + mutex_unlock(&data->update_lock); 1219 1219 return count; 1220 1220 } 1221 1221 ··· 1267 1267 int val = simple_strtol(buf, NULL, 10); 1268 1268 unsigned long mask; 1269 1269 1270 - down(&data->update_lock); 1270 + mutex_lock(&data->update_lock); 1271 1271 data->alarm_mask = val & 0x7fffffff; 1272 1272 mask = data->alarm_mask 1273 1273 | (data->gpio_mask & 0x10000 ? 0x80000000 : 0); ··· 1282 1282 mask >>= 8; 1283 1283 adm1026_write_value(client, ADM1026_REG_MASK4, 1284 1284 mask & 0xff); 1285 - up(&data->update_lock); 1285 + mutex_unlock(&data->update_lock); 1286 1286 return count; 1287 1287 } 1288 1288 ··· 1303 1303 int val = simple_strtol(buf, NULL, 10); 1304 1304 long gpio; 1305 1305 1306 - down(&data->update_lock); 1306 + mutex_lock(&data->update_lock); 1307 1307 data->gpio = val & 0x1ffff; 1308 1308 gpio = data->gpio; 1309 1309 adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7,gpio & 0xff); ··· 1311 1311 adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15,gpio & 0xff); 1312 1312 gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f); 1313 1313 adm1026_write_value(client, ADM1026_REG_STATUS4,gpio & 0xff); 1314 - up(&data->update_lock); 1314 + mutex_unlock(&data->update_lock); 1315 1315 return count; 1316 1316 } 1317 1317 ··· 1331 1331 int val = simple_strtol(buf, NULL, 10); 1332 1332 long mask; 1333 1333 1334 - down(&data->update_lock); 1334 + mutex_lock(&data->update_lock); 1335 1335 data->gpio_mask = val & 0x1ffff; 1336 1336 mask = data->gpio_mask; 1337 1337 adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7,mask & 0xff); ··· 1339 1339 adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15,mask & 0xff); 1340 1340 mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f); 1341 1341 adm1026_write_value(client, ADM1026_REG_MASK1,mask & 0xff); 1342 - up(&data->update_lock); 1342 + mutex_unlock(&data->update_lock); 1343 1343 return count; 1344 1344 } 1345 1345 ··· 1359 1359 if (data->pwm1.enable == 1) { 1360 1360 int val = simple_strtol(buf, NULL, 10); 1361 1361 1362 - down(&data->update_lock); 1362 + mutex_lock(&data->update_lock); 1363 1363 data->pwm1.pwm = PWM_TO_REG(val); 1364 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 1367 return count; 1368 1368 } ··· 1378 1378 struct adm1026_data *data = i2c_get_clientdata(client); 1379 1379 int val = simple_strtol(buf, NULL, 10); 1380 1380 1381 - down(&data->update_lock); 1381 + mutex_lock(&data->update_lock); 1382 1382 data->pwm1.auto_pwm_min = SENSORS_LIMIT(val,0,255); 1383 1383 if (data->pwm1.enable == 2) { /* apply immediately */ 1384 1384 data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | 1385 1385 PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); 1386 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 1389 return count; 1390 1390 } 1391 1391 static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf) ··· 1406 1406 int old_enable; 1407 1407 1408 1408 if ((val >= 0) && (val < 3)) { 1409 - down(&data->update_lock); 1409 + mutex_lock(&data->update_lock); 1410 1410 old_enable = data->pwm1.enable; 1411 1411 data->pwm1.enable = val; 1412 1412 data->config1 = (data->config1 & ~CFG1_PWM_AFC) ··· 1424 1424 adm1026_write_value(client, ADM1026_REG_PWM, 1425 1425 data->pwm1.pwm); 1426 1426 } 1427 - up(&data->update_lock); 1427 + mutex_unlock(&data->update_lock); 1428 1428 } 1429 1429 return count; 1430 1430 } ··· 1541 1541 /* Fill in the remaining client fields */ 1542 1542 data->type = kind; 1543 1543 data->valid = 0; 1544 - init_MUTEX(&data->update_lock); 1544 + mutex_init(&data->update_lock); 1545 1545 1546 1546 /* Tell the I2C layer a new client has arrived */ 1547 1547 if ((err = i2c_attach_client(new_client)))
+25 -24
drivers/hwmon/adm1031.c
··· 28 28 #include <linux/i2c.h> 29 29 #include <linux/hwmon.h> 30 30 #include <linux/err.h> 31 + #include <linux/mutex.h> 31 32 32 33 /* Following macros takes channel parameter starting from 0 to 2 */ 33 34 #define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr)) ··· 71 70 struct adm1031_data { 72 71 struct i2c_client client; 73 72 struct class_device *class_dev; 74 - struct semaphore update_lock; 73 + struct mutex update_lock; 75 74 int chip_type; 76 75 char valid; /* !=0 if following fields are valid */ 77 76 unsigned long last_updated; /* In jiffies */ ··· 263 262 264 263 old_fan_mode = data->conf1; 265 264 266 - down(&data->update_lock); 265 + mutex_lock(&data->update_lock); 267 266 268 267 if ((ret = get_fan_auto_nearest(data, nr, val, data->conf1, &reg))) { 269 - up(&data->update_lock); 268 + mutex_unlock(&data->update_lock); 270 269 return ret; 271 270 } 272 271 if (((data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1)) & ADM1031_CONF1_AUTO_MODE) ^ ··· 289 288 } 290 289 data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1); 291 290 adm1031_write_value(client, ADM1031_REG_CONF1, data->conf1); 292 - up(&data->update_lock); 291 + mutex_unlock(&data->update_lock); 293 292 return count; 294 293 } 295 294 ··· 330 329 struct adm1031_data *data = i2c_get_clientdata(client); 331 330 int val = simple_strtol(buf, NULL, 10); 332 331 333 - down(&data->update_lock); 332 + mutex_lock(&data->update_lock); 334 333 data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]); 335 334 adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), 336 335 data->auto_temp[nr]); 337 - up(&data->update_lock); 336 + mutex_unlock(&data->update_lock); 338 337 return count; 339 338 } 340 339 static ssize_t show_auto_temp_max(struct device *dev, char *buf, int nr) ··· 350 349 struct adm1031_data *data = i2c_get_clientdata(client); 351 350 int val = simple_strtol(buf, NULL, 10); 352 351 353 - down(&data->update_lock); 352 + mutex_lock(&data->update_lock); 354 353 data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr], data->pwm[nr]); 355 354 adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), 356 355 data->temp_max[nr]); 357 - up(&data->update_lock); 356 + mutex_unlock(&data->update_lock); 358 357 return count; 359 358 } 360 359 ··· 406 405 int val = simple_strtol(buf, NULL, 10); 407 406 int reg; 408 407 409 - down(&data->update_lock); 408 + mutex_lock(&data->update_lock); 410 409 if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) && 411 410 (((val>>4) & 0xf) != 5)) { 412 411 /* In automatic mode, the only PWM accepted is 33% */ 413 - up(&data->update_lock); 412 + mutex_unlock(&data->update_lock); 414 413 return -EINVAL; 415 414 } 416 415 data->pwm[nr] = PWM_TO_REG(val); ··· 418 417 adm1031_write_value(client, ADM1031_REG_PWM, 419 418 nr ? ((data->pwm[nr] << 4) & 0xf0) | (reg & 0xf) 420 419 : (data->pwm[nr] & 0xf) | (reg & 0xf0)); 421 - up(&data->update_lock); 420 + mutex_unlock(&data->update_lock); 422 421 return count; 423 422 } 424 423 ··· 512 511 struct adm1031_data *data = i2c_get_clientdata(client); 513 512 int val = simple_strtol(buf, NULL, 10); 514 513 515 - down(&data->update_lock); 514 + mutex_lock(&data->update_lock); 516 515 if (val) { 517 516 data->fan_min[nr] = 518 517 FAN_TO_REG(val, FAN_DIV_FROM_REG(data->fan_div[nr])); ··· 520 519 data->fan_min[nr] = 0xff; 521 520 } 522 521 adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), data->fan_min[nr]); 523 - up(&data->update_lock); 522 + mutex_unlock(&data->update_lock); 524 523 return count; 525 524 } 526 525 static ssize_t ··· 541 540 if (tmp == 0xff) 542 541 return -EINVAL; 543 542 544 - down(&data->update_lock); 543 + mutex_lock(&data->update_lock); 545 544 old_div = FAN_DIV_FROM_REG(data->fan_div[nr]); 546 545 data->fan_div[nr] = (tmp & 0xC0) | (0x3f & data->fan_div[nr]); 547 546 new_min = data->fan_min[nr] * old_div / ··· 554 553 data->fan_div[nr]); 555 554 adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), 556 555 data->fan_min[nr]); 557 - up(&data->update_lock); 556 + mutex_unlock(&data->update_lock); 558 557 return count; 559 558 } 560 559 ··· 628 627 629 628 val = simple_strtol(buf, NULL, 10); 630 629 val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); 631 - down(&data->update_lock); 630 + mutex_lock(&data->update_lock); 632 631 data->temp_min[nr] = TEMP_TO_REG(val); 633 632 adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr), 634 633 data->temp_min[nr]); 635 - up(&data->update_lock); 634 + mutex_unlock(&data->update_lock); 636 635 return count; 637 636 } 638 637 static ssize_t ··· 644 643 645 644 val = simple_strtol(buf, NULL, 10); 646 645 val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); 647 - down(&data->update_lock); 646 + mutex_lock(&data->update_lock); 648 647 data->temp_max[nr] = TEMP_TO_REG(val); 649 648 adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr), 650 649 data->temp_max[nr]); 651 - up(&data->update_lock); 650 + mutex_unlock(&data->update_lock); 652 651 return count; 653 652 } 654 653 static ssize_t ··· 660 659 661 660 val = simple_strtol(buf, NULL, 10); 662 661 val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); 663 - down(&data->update_lock); 662 + mutex_lock(&data->update_lock); 664 663 data->temp_crit[nr] = TEMP_TO_REG(val); 665 664 adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr), 666 665 data->temp_crit[nr]); 667 - up(&data->update_lock); 666 + mutex_unlock(&data->update_lock); 668 667 return count; 669 668 } 670 669 ··· 779 778 780 779 strlcpy(new_client->name, name, I2C_NAME_SIZE); 781 780 data->valid = 0; 782 - init_MUTEX(&data->update_lock); 781 + mutex_init(&data->update_lock); 783 782 784 783 /* Tell the I2C layer a new client has arrived */ 785 784 if ((err = i2c_attach_client(new_client))) ··· 892 891 struct adm1031_data *data = i2c_get_clientdata(client); 893 892 int chan; 894 893 895 - down(&data->update_lock); 894 + mutex_lock(&data->update_lock); 896 895 897 896 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 898 897 || !data->valid) { ··· 966 965 data->valid = 1; 967 966 } 968 967 969 - up(&data->update_lock); 968 + mutex_unlock(&data->update_lock); 970 969 971 970 return data; 972 971 }
+15 -14
drivers/hwmon/adm9240.c
··· 49 49 #include <linux/hwmon.h> 50 50 #include <linux/hwmon-vid.h> 51 51 #include <linux/err.h> 52 + #include <linux/mutex.h> 52 53 53 54 /* Addresses to scan */ 54 55 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, ··· 151 150 enum chips type; 152 151 struct i2c_client client; 153 152 struct class_device *class_dev; 154 - struct semaphore update_lock; 153 + struct mutex update_lock; 155 154 char valid; 156 155 unsigned long last_updated_measure; 157 156 unsigned long last_updated_config; ··· 196 195 struct adm9240_data *data = i2c_get_clientdata(client); 197 196 long val = simple_strtol(buf, NULL, 10); 198 197 199 - down(&data->update_lock); 198 + mutex_lock(&data->update_lock); 200 199 data->temp_max[attr->index] = TEMP_TO_REG(val); 201 200 i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index), 202 201 data->temp_max[attr->index]); 203 - up(&data->update_lock); 202 + mutex_unlock(&data->update_lock); 204 203 return count; 205 204 } 206 205 ··· 247 246 struct adm9240_data *data = i2c_get_clientdata(client); 248 247 unsigned long val = simple_strtoul(buf, NULL, 10); 249 248 250 - down(&data->update_lock); 249 + mutex_lock(&data->update_lock); 251 250 data->in_min[attr->index] = IN_TO_REG(val, attr->index); 252 251 i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index), 253 252 data->in_min[attr->index]); 254 - up(&data->update_lock); 253 + mutex_unlock(&data->update_lock); 255 254 return count; 256 255 } 257 256 ··· 264 263 struct adm9240_data *data = i2c_get_clientdata(client); 265 264 unsigned long val = simple_strtoul(buf, NULL, 10); 266 265 267 - down(&data->update_lock); 266 + mutex_lock(&data->update_lock); 268 267 data->in_max[attr->index] = IN_TO_REG(val, attr->index); 269 268 i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index), 270 269 data->in_max[attr->index]); 271 - up(&data->update_lock); 270 + mutex_unlock(&data->update_lock); 272 271 return count; 273 272 } 274 273 ··· 351 350 int nr = attr->index; 352 351 u8 new_div; 353 352 354 - down(&data->update_lock); 353 + mutex_lock(&data->update_lock); 355 354 356 355 if (!val) { 357 356 data->fan_min[nr] = 255; ··· 391 390 i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr), 392 391 data->fan_min[nr]); 393 392 394 - up(&data->update_lock); 393 + mutex_unlock(&data->update_lock); 395 394 return count; 396 395 } 397 396 ··· 440 439 struct adm9240_data *data = i2c_get_clientdata(client); 441 440 unsigned long val = simple_strtol(buf, NULL, 10); 442 441 443 - down(&data->update_lock); 442 + mutex_lock(&data->update_lock); 444 443 data->aout = AOUT_TO_REG(val); 445 444 i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout); 446 - up(&data->update_lock); 445 + mutex_unlock(&data->update_lock); 447 446 return count; 448 447 } 449 448 static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); ··· 540 539 /* fill in the remaining client fields and attach */ 541 540 strlcpy(new_client->name, name, I2C_NAME_SIZE); 542 541 data->type = kind; 543 - init_MUTEX(&data->update_lock); 542 + mutex_init(&data->update_lock); 544 543 545 544 if ((err = i2c_attach_client(new_client))) 546 545 goto exit_free; ··· 692 691 struct adm9240_data *data = i2c_get_clientdata(client); 693 692 int i; 694 693 695 - down(&data->update_lock); 694 + mutex_lock(&data->update_lock); 696 695 697 696 /* minimum measurement cycle: 1.75 seconds */ 698 697 if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4)) ··· 772 771 data->last_updated_config = jiffies; 773 772 data->valid = 1; 774 773 } 775 - up(&data->update_lock); 774 + mutex_unlock(&data->update_lock); 776 775 return data; 777 776 } 778 777
+23 -22
drivers/hwmon/asb100.c
··· 44 44 #include <linux/err.h> 45 45 #include <linux/init.h> 46 46 #include <linux/jiffies.h> 47 + #include <linux/mutex.h> 47 48 #include "lm75.h" 48 49 49 50 /* ··· 183 182 struct asb100_data { 184 183 struct i2c_client client; 185 184 struct class_device *class_dev; 186 - struct semaphore lock; 185 + struct mutex lock; 187 186 enum chips type; 188 187 189 - struct semaphore update_lock; 188 + struct mutex update_lock; 190 189 unsigned long last_updated; /* In jiffies */ 191 190 192 191 /* array of 2 pointers to subclients */ ··· 246 245 struct asb100_data *data = i2c_get_clientdata(client); \ 247 246 unsigned long val = simple_strtoul(buf, NULL, 10); \ 248 247 \ 249 - down(&data->update_lock); \ 248 + mutex_lock(&data->update_lock); \ 250 249 data->in_##reg[nr] = IN_TO_REG(val); \ 251 250 asb100_write_value(client, ASB100_REG_IN_##REG(nr), \ 252 251 data->in_##reg[nr]); \ 253 - up(&data->update_lock); \ 252 + mutex_unlock(&data->update_lock); \ 254 253 return count; \ 255 254 } 256 255 ··· 332 331 struct asb100_data *data = i2c_get_clientdata(client); 333 332 u32 val = simple_strtoul(buf, NULL, 10); 334 333 335 - down(&data->update_lock); 334 + mutex_lock(&data->update_lock); 336 335 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 337 336 asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); 338 - up(&data->update_lock); 337 + mutex_unlock(&data->update_lock); 339 338 return count; 340 339 } 341 340 ··· 352 351 unsigned long val = simple_strtoul(buf, NULL, 10); 353 352 int reg; 354 353 355 - down(&data->update_lock); 354 + mutex_lock(&data->update_lock); 356 355 357 356 min = FAN_FROM_REG(data->fan_min[nr], 358 357 DIV_FROM_REG(data->fan_div[nr])); ··· 382 381 FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 383 382 asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); 384 383 385 - up(&data->update_lock); 384 + mutex_unlock(&data->update_lock); 386 385 387 386 return count; 388 387 } ··· 462 461 struct asb100_data *data = i2c_get_clientdata(client); \ 463 462 unsigned long val = simple_strtoul(buf, NULL, 10); \ 464 463 \ 465 - down(&data->update_lock); \ 464 + mutex_lock(&data->update_lock); \ 466 465 switch (nr) { \ 467 466 case 1: case 2: \ 468 467 data->reg[nr] = LM75_TEMP_TO_REG(val); \ ··· 473 472 } \ 474 473 asb100_write_value(client, ASB100_REG_TEMP_##REG(nr+1), \ 475 474 data->reg[nr]); \ 476 - up(&data->update_lock); \ 475 + mutex_unlock(&data->update_lock); \ 477 476 return count; \ 478 477 } 479 478 ··· 575 574 struct asb100_data *data = i2c_get_clientdata(client); 576 575 unsigned long val = simple_strtoul(buf, NULL, 10); 577 576 578 - down(&data->update_lock); 577 + mutex_lock(&data->update_lock); 579 578 data->pwm &= 0x80; /* keep the enable bit */ 580 579 data->pwm |= (0x0f & ASB100_PWM_TO_REG(val)); 581 580 asb100_write_value(client, ASB100_REG_PWM1, data->pwm); 582 - up(&data->update_lock); 581 + mutex_unlock(&data->update_lock); 583 582 return count; 584 583 } 585 584 ··· 596 595 struct asb100_data *data = i2c_get_clientdata(client); 597 596 unsigned long val = simple_strtoul(buf, NULL, 10); 598 597 599 - down(&data->update_lock); 598 + mutex_lock(&data->update_lock); 600 599 data->pwm &= 0x0f; /* keep the duty cycle bits */ 601 600 data->pwm |= (val ? 0x80 : 0x00); 602 601 asb100_write_value(client, ASB100_REG_PWM1, data->pwm); 603 - up(&data->update_lock); 602 + mutex_unlock(&data->update_lock); 604 603 return count; 605 604 } 606 605 ··· 730 729 } 731 730 732 731 new_client = &data->client; 733 - init_MUTEX(&data->lock); 732 + mutex_init(&data->lock); 734 733 i2c_set_clientdata(new_client, data); 735 734 new_client->addr = address; 736 735 new_client->adapter = adapter; ··· 790 789 data->type = kind; 791 790 792 791 data->valid = 0; 793 - init_MUTEX(&data->update_lock); 792 + mutex_init(&data->update_lock); 794 793 795 794 /* Tell the I2C layer a new client has arrived */ 796 795 if ((err = i2c_attach_client(new_client))) ··· 886 885 struct i2c_client *cl; 887 886 int res, bank; 888 887 889 - down(&data->lock); 888 + mutex_lock(&data->lock); 890 889 891 890 bank = (reg >> 8) & 0x0f; 892 891 if (bank > 2) ··· 920 919 if (bank > 2) 921 920 i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); 922 921 923 - up(&data->lock); 922 + mutex_unlock(&data->lock); 924 923 925 924 return res; 926 925 } ··· 931 930 struct i2c_client *cl; 932 931 int bank; 933 932 934 - down(&data->lock); 933 + mutex_lock(&data->lock); 935 934 936 935 bank = (reg >> 8) & 0x0f; 937 936 if (bank > 2) ··· 961 960 if (bank > 2) 962 961 i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); 963 962 964 - up(&data->lock); 963 + mutex_unlock(&data->lock); 965 964 } 966 965 967 966 static void asb100_init_client(struct i2c_client *client) ··· 985 984 struct asb100_data *data = i2c_get_clientdata(client); 986 985 int i; 987 986 988 - down(&data->update_lock); 987 + mutex_lock(&data->update_lock); 989 988 990 989 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 991 990 || !data->valid) { ··· 1043 1042 dev_dbg(&client->dev, "... device update complete\n"); 1044 1043 } 1045 1044 1046 - up(&data->update_lock); 1045 + mutex_unlock(&data->update_lock); 1047 1046 1048 1047 return data; 1049 1048 }
+5 -4
drivers/hwmon/atxp1.c
··· 26 26 #include <linux/hwmon.h> 27 27 #include <linux/hwmon-vid.h> 28 28 #include <linux/err.h> 29 + #include <linux/mutex.h> 29 30 30 31 MODULE_LICENSE("GPL"); 31 32 MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); ··· 61 60 struct atxp1_data { 62 61 struct i2c_client client; 63 62 struct class_device *class_dev; 64 - struct semaphore update_lock; 63 + struct mutex update_lock; 65 64 unsigned long last_updated; 66 65 u8 valid; 67 66 struct { ··· 81 80 client = to_i2c_client(dev); 82 81 data = i2c_get_clientdata(client); 83 82 84 - down(&data->update_lock); 83 + mutex_lock(&data->update_lock); 85 84 86 85 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { 87 86 ··· 94 93 data->valid = 1; 95 94 } 96 95 97 - up(&data->update_lock); 96 + mutex_unlock(&data->update_lock); 98 97 99 98 return(data); 100 99 } ··· 310 309 311 310 data->valid = 0; 312 311 313 - init_MUTEX(&data->update_lock); 312 + mutex_init(&data->update_lock); 314 313 315 314 err = i2c_attach_client(new_client); 316 315
+7 -6
drivers/hwmon/ds1621.c
··· 28 28 #include <linux/i2c.h> 29 29 #include <linux/hwmon.h> 30 30 #include <linux/err.h> 31 + #include <linux/mutex.h> 31 32 #include "lm75.h" 32 33 33 34 /* Addresses to scan */ ··· 73 72 struct ds1621_data { 74 73 struct i2c_client client; 75 74 struct class_device *class_dev; 76 - struct semaphore update_lock; 75 + struct mutex update_lock; 77 76 char valid; /* !=0 if following fields are valid */ 78 77 unsigned long last_updated; /* In jiffies */ 79 78 ··· 157 156 struct ds1621_data *data = ds1621_update_client(dev); \ 158 157 u16 val = LM75_TEMP_TO_REG(simple_strtoul(buf, NULL, 10)); \ 159 158 \ 160 - down(&data->update_lock); \ 159 + mutex_lock(&data->update_lock); \ 161 160 data->value = val; \ 162 161 ds1621_write_value(client, reg, data->value); \ 163 - up(&data->update_lock); \ 162 + mutex_unlock(&data->update_lock); \ 164 163 return count; \ 165 164 } 166 165 ··· 243 242 /* Fill in remaining client fields and put it into the global list */ 244 243 strlcpy(new_client->name, "ds1621", I2C_NAME_SIZE); 245 244 data->valid = 0; 246 - init_MUTEX(&data->update_lock); 245 + mutex_init(&data->update_lock); 247 246 248 247 /* Tell the I2C layer a new client has arrived */ 249 248 if ((err = i2c_attach_client(new_client))) ··· 298 297 struct ds1621_data *data = i2c_get_clientdata(client); 299 298 u8 new_conf; 300 299 301 - down(&data->update_lock); 300 + mutex_lock(&data->update_lock); 302 301 303 302 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 304 303 || !data->valid) { ··· 328 327 data->valid = 1; 329 328 } 330 329 331 - up(&data->update_lock); 330 + mutex_unlock(&data->update_lock); 332 331 333 332 return data; 334 333 }
+132 -143
drivers/hwmon/f71805f.c
··· 30 30 #include <linux/hwmon.h> 31 31 #include <linux/hwmon-sysfs.h> 32 32 #include <linux/err.h> 33 + #include <linux/mutex.h> 33 34 #include <asm/io.h> 34 35 35 36 static struct platform_device *pdev; ··· 132 131 struct f71805f_data { 133 132 unsigned short addr; 134 133 const char *name; 135 - struct semaphore lock; 134 + struct mutex lock; 136 135 struct class_device *class_dev; 137 136 138 - struct semaphore update_lock; 137 + struct mutex update_lock; 139 138 char valid; /* !=0 if following fields are valid */ 140 139 unsigned long last_updated; /* In jiffies */ 141 140 unsigned long last_limits; /* In jiffies */ ··· 225 224 { 226 225 u8 val; 227 226 228 - down(&data->lock); 227 + mutex_lock(&data->lock); 229 228 outb(reg, data->addr + ADDR_REG_OFFSET); 230 229 val = inb(data->addr + DATA_REG_OFFSET); 231 - up(&data->lock); 230 + mutex_unlock(&data->lock); 232 231 233 232 return val; 234 233 } 235 234 236 235 static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val) 237 236 { 238 - down(&data->lock); 237 + mutex_lock(&data->lock); 239 238 outb(reg, data->addr + ADDR_REG_OFFSET); 240 239 outb(val, data->addr + DATA_REG_OFFSET); 241 - up(&data->lock); 240 + mutex_unlock(&data->lock); 242 241 } 243 242 244 243 /* It is important to read the MSB first, because doing so latches the ··· 247 246 { 248 247 u16 val; 249 248 250 - down(&data->lock); 249 + mutex_lock(&data->lock); 251 250 outb(reg, data->addr + ADDR_REG_OFFSET); 252 251 val = inb(data->addr + DATA_REG_OFFSET) << 8; 253 252 outb(++reg, data->addr + ADDR_REG_OFFSET); 254 253 val |= inb(data->addr + DATA_REG_OFFSET); 255 - up(&data->lock); 254 + mutex_unlock(&data->lock); 256 255 257 256 return val; 258 257 } 259 258 260 259 static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val) 261 260 { 262 - down(&data->lock); 261 + mutex_lock(&data->lock); 263 262 outb(reg, data->addr + ADDR_REG_OFFSET); 264 263 outb(val >> 8, data->addr + DATA_REG_OFFSET); 265 264 outb(++reg, data->addr + ADDR_REG_OFFSET); 266 265 outb(val & 0xff, data->addr + DATA_REG_OFFSET); 267 - up(&data->lock); 266 + mutex_unlock(&data->lock); 268 267 } 269 268 270 269 static struct f71805f_data *f71805f_update_device(struct device *dev) ··· 272 271 struct f71805f_data *data = dev_get_drvdata(dev); 273 272 int nr; 274 273 275 - down(&data->update_lock); 274 + mutex_lock(&data->update_lock); 276 275 277 276 /* Limit registers cache is refreshed after 60 seconds */ 278 277 if (time_after(jiffies, data->last_updated + 60 * HZ) ··· 324 323 data->valid = 1; 325 324 } 326 325 327 - up(&data->update_lock); 326 + mutex_unlock(&data->update_lock); 328 327 329 328 return data; 330 329 } ··· 363 362 struct f71805f_data *data = dev_get_drvdata(dev); 364 363 long val = simple_strtol(buf, NULL, 10); 365 364 366 - down(&data->update_lock); 365 + mutex_lock(&data->update_lock); 367 366 data->in_high[0] = in0_to_reg(val); 368 367 f71805f_write8(data, F71805F_REG_IN_HIGH(0), data->in_high[0]); 369 - up(&data->update_lock); 368 + mutex_unlock(&data->update_lock); 370 369 371 370 return count; 372 371 } ··· 377 376 struct f71805f_data *data = dev_get_drvdata(dev); 378 377 long val = simple_strtol(buf, NULL, 10); 379 378 380 - down(&data->update_lock); 379 + mutex_lock(&data->update_lock); 381 380 data->in_low[0] = in0_to_reg(val); 382 381 f71805f_write8(data, F71805F_REG_IN_LOW(0), data->in_low[0]); 383 - up(&data->update_lock); 382 + mutex_unlock(&data->update_lock); 384 383 385 384 return count; 386 385 } 387 - 388 - static DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL); 389 - static DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max); 390 - static DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min); 391 386 392 387 static ssize_t show_in(struct device *dev, struct device_attribute *devattr, 393 388 char *buf) ··· 423 426 int nr = attr->index; 424 427 long val = simple_strtol(buf, NULL, 10); 425 428 426 - down(&data->update_lock); 429 + mutex_lock(&data->update_lock); 427 430 data->in_high[nr] = in_to_reg(val); 428 431 f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]); 429 - up(&data->update_lock); 432 + mutex_unlock(&data->update_lock); 430 433 431 434 return count; 432 435 } ··· 439 442 int nr = attr->index; 440 443 long val = simple_strtol(buf, NULL, 10); 441 444 442 - down(&data->update_lock); 445 + mutex_lock(&data->update_lock); 443 446 data->in_low[nr] = in_to_reg(val); 444 447 f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]); 445 - up(&data->update_lock); 448 + mutex_unlock(&data->update_lock); 446 449 447 450 return count; 448 451 } 449 - 450 - #define sysfs_in(offset) \ 451 - static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ 452 - show_in, NULL, offset); \ 453 - static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ 454 - show_in_max, set_in_max, offset); \ 455 - static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ 456 - show_in_min, set_in_min, offset) 457 - 458 - sysfs_in(1); 459 - sysfs_in(2); 460 - sysfs_in(3); 461 - sysfs_in(4); 462 - sysfs_in(5); 463 - sysfs_in(6); 464 - sysfs_in(7); 465 - sysfs_in(8); 466 452 467 453 static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, 468 454 char *buf) ··· 475 495 int nr = attr->index; 476 496 long val = simple_strtol(buf, NULL, 10); 477 497 478 - down(&data->update_lock); 498 + mutex_lock(&data->update_lock); 479 499 data->fan_low[nr] = fan_to_reg(val); 480 500 f71805f_write16(data, F71805F_REG_FAN_LOW(nr), data->fan_low[nr]); 481 - up(&data->update_lock); 501 + mutex_unlock(&data->update_lock); 482 502 483 503 return count; 484 504 } 485 - 486 - #define sysfs_fan(offset) \ 487 - static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ 488 - show_fan, NULL, offset - 1); \ 489 - static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ 490 - show_fan_min, set_fan_min, offset - 1) 491 - 492 - sysfs_fan(1); 493 - sysfs_fan(2); 494 - sysfs_fan(3); 495 505 496 506 static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, 497 507 char *buf) ··· 532 562 int nr = attr->index; 533 563 long val = simple_strtol(buf, NULL, 10); 534 564 535 - down(&data->update_lock); 565 + mutex_lock(&data->update_lock); 536 566 data->temp_high[nr] = temp_to_reg(val); 537 567 f71805f_write8(data, F71805F_REG_TEMP_HIGH(nr), data->temp_high[nr]); 538 - up(&data->update_lock); 568 + mutex_unlock(&data->update_lock); 539 569 540 570 return count; 541 571 } ··· 548 578 int nr = attr->index; 549 579 long val = simple_strtol(buf, NULL, 10); 550 580 551 - down(&data->update_lock); 581 + mutex_lock(&data->update_lock); 552 582 data->temp_hyst[nr] = temp_to_reg(val); 553 583 f71805f_write8(data, F71805F_REG_TEMP_HYST(nr), data->temp_hyst[nr]); 554 - up(&data->update_lock); 584 + mutex_unlock(&data->update_lock); 555 585 556 586 return count; 557 587 } 558 - 559 - #define sysfs_temp(offset) \ 560 - static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ 561 - show_temp, NULL, offset - 1); \ 562 - static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ 563 - show_temp_max, set_temp_max, offset - 1); \ 564 - static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ 565 - show_temp_hyst, set_temp_hyst, offset - 1); \ 566 - static SENSOR_DEVICE_ATTR(temp##offset##_type, S_IRUGO, \ 567 - show_temp_type, NULL, offset - 1) 568 - 569 - sysfs_temp(1); 570 - sysfs_temp(2); 571 - sysfs_temp(3); 572 588 573 589 static ssize_t show_alarms_in(struct device *dev, struct device_attribute 574 590 *devattr, char *buf) ··· 581 625 return sprintf(buf, "%d\n", (data->alarms[1] >> 3) & 0x07); 582 626 } 583 627 584 - static DEVICE_ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL); 585 - static DEVICE_ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL); 586 - static DEVICE_ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL); 587 - 588 628 static ssize_t show_name(struct device *dev, struct device_attribute 589 629 *devattr, char *buf) 590 630 { ··· 589 637 return sprintf(buf, "%s\n", data->name); 590 638 } 591 639 592 - static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); 640 + static struct device_attribute f71805f_dev_attr[] = { 641 + __ATTR(in0_input, S_IRUGO, show_in0, NULL), 642 + __ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max), 643 + __ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min), 644 + __ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL), 645 + __ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL), 646 + __ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL), 647 + __ATTR(name, S_IRUGO, show_name, NULL), 648 + }; 649 + 650 + static struct sensor_device_attribute f71805f_sensor_attr[] = { 651 + SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1), 652 + SENSOR_ATTR(in1_max, S_IRUGO | S_IWUSR, 653 + show_in_max, set_in_max, 1), 654 + SENSOR_ATTR(in1_min, S_IRUGO | S_IWUSR, 655 + show_in_min, set_in_min, 1), 656 + SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2), 657 + SENSOR_ATTR(in2_max, S_IRUGO | S_IWUSR, 658 + show_in_max, set_in_max, 2), 659 + SENSOR_ATTR(in2_min, S_IRUGO | S_IWUSR, 660 + show_in_min, set_in_min, 2), 661 + SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3), 662 + SENSOR_ATTR(in3_max, S_IRUGO | S_IWUSR, 663 + show_in_max, set_in_max, 3), 664 + SENSOR_ATTR(in3_min, S_IRUGO | S_IWUSR, 665 + show_in_min, set_in_min, 3), 666 + SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4), 667 + SENSOR_ATTR(in4_max, S_IRUGO | S_IWUSR, 668 + show_in_max, set_in_max, 4), 669 + SENSOR_ATTR(in4_min, S_IRUGO | S_IWUSR, 670 + show_in_min, set_in_min, 4), 671 + SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5), 672 + SENSOR_ATTR(in5_max, S_IRUGO | S_IWUSR, 673 + show_in_max, set_in_max, 5), 674 + SENSOR_ATTR(in5_min, S_IRUGO | S_IWUSR, 675 + show_in_min, set_in_min, 5), 676 + SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6), 677 + SENSOR_ATTR(in6_max, S_IRUGO | S_IWUSR, 678 + show_in_max, set_in_max, 6), 679 + SENSOR_ATTR(in6_min, S_IRUGO | S_IWUSR, 680 + show_in_min, set_in_min, 6), 681 + SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7), 682 + SENSOR_ATTR(in7_max, S_IRUGO | S_IWUSR, 683 + show_in_max, set_in_max, 7), 684 + SENSOR_ATTR(in7_min, S_IRUGO | S_IWUSR, 685 + show_in_min, set_in_min, 7), 686 + SENSOR_ATTR(in8_input, S_IRUGO, show_in, NULL, 8), 687 + SENSOR_ATTR(in8_max, S_IRUGO | S_IWUSR, 688 + show_in_max, set_in_max, 8), 689 + SENSOR_ATTR(in8_min, S_IRUGO | S_IWUSR, 690 + show_in_min, set_in_min, 8), 691 + 692 + SENSOR_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0), 693 + SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, 694 + show_temp_max, set_temp_max, 0), 695 + SENSOR_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, 696 + show_temp_hyst, set_temp_hyst, 0), 697 + SENSOR_ATTR(temp1_type, S_IRUGO, show_temp_type, NULL, 0), 698 + SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1), 699 + SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, 700 + show_temp_max, set_temp_max, 1), 701 + SENSOR_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, 702 + show_temp_hyst, set_temp_hyst, 1), 703 + SENSOR_ATTR(temp2_type, S_IRUGO, show_temp_type, NULL, 1), 704 + SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2), 705 + SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, 706 + show_temp_max, set_temp_max, 2), 707 + SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, 708 + show_temp_hyst, set_temp_hyst, 2), 709 + SENSOR_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2), 710 + }; 711 + 712 + static struct sensor_device_attribute f71805f_fan_attr[] = { 713 + SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0), 714 + SENSOR_ATTR(fan1_min, S_IRUGO | S_IWUSR, 715 + show_fan_min, set_fan_min, 0), 716 + SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1), 717 + SENSOR_ATTR(fan2_min, S_IRUGO | S_IWUSR, 718 + show_fan_min, set_fan_min, 1), 719 + SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2), 720 + SENSOR_ATTR(fan3_min, S_IRUGO | S_IWUSR, 721 + show_fan_min, set_fan_min, 2), 722 + }; 593 723 594 724 /* 595 725 * Device registration and initialization ··· 702 668 { 703 669 struct f71805f_data *data; 704 670 struct resource *res; 705 - int err; 671 + int i, err; 706 672 707 673 if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) { 708 674 err = -ENOMEM; ··· 712 678 713 679 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 714 680 data->addr = res->start; 715 - init_MUTEX(&data->lock); 681 + mutex_init(&data->lock); 716 682 data->name = "f71805f"; 717 - init_MUTEX(&data->update_lock); 683 + mutex_init(&data->update_lock); 718 684 719 685 platform_set_drvdata(pdev, data); 720 686 ··· 729 695 f71805f_init_device(data); 730 696 731 697 /* Register sysfs interface files */ 732 - device_create_file(&pdev->dev, &dev_attr_in0_input); 733 - device_create_file(&pdev->dev, &dev_attr_in0_max); 734 - device_create_file(&pdev->dev, &dev_attr_in0_min); 735 - device_create_file(&pdev->dev, &sensor_dev_attr_in1_input.dev_attr); 736 - device_create_file(&pdev->dev, &sensor_dev_attr_in2_input.dev_attr); 737 - device_create_file(&pdev->dev, &sensor_dev_attr_in3_input.dev_attr); 738 - device_create_file(&pdev->dev, &sensor_dev_attr_in4_input.dev_attr); 739 - device_create_file(&pdev->dev, &sensor_dev_attr_in5_input.dev_attr); 740 - device_create_file(&pdev->dev, &sensor_dev_attr_in6_input.dev_attr); 741 - device_create_file(&pdev->dev, &sensor_dev_attr_in7_input.dev_attr); 742 - device_create_file(&pdev->dev, &sensor_dev_attr_in8_input.dev_attr); 743 - device_create_file(&pdev->dev, &sensor_dev_attr_in1_max.dev_attr); 744 - device_create_file(&pdev->dev, &sensor_dev_attr_in2_max.dev_attr); 745 - device_create_file(&pdev->dev, &sensor_dev_attr_in3_max.dev_attr); 746 - device_create_file(&pdev->dev, &sensor_dev_attr_in4_max.dev_attr); 747 - device_create_file(&pdev->dev, &sensor_dev_attr_in5_max.dev_attr); 748 - device_create_file(&pdev->dev, &sensor_dev_attr_in6_max.dev_attr); 749 - device_create_file(&pdev->dev, &sensor_dev_attr_in7_max.dev_attr); 750 - device_create_file(&pdev->dev, &sensor_dev_attr_in8_max.dev_attr); 751 - device_create_file(&pdev->dev, &sensor_dev_attr_in1_min.dev_attr); 752 - device_create_file(&pdev->dev, &sensor_dev_attr_in2_min.dev_attr); 753 - device_create_file(&pdev->dev, &sensor_dev_attr_in3_min.dev_attr); 754 - device_create_file(&pdev->dev, &sensor_dev_attr_in4_min.dev_attr); 755 - device_create_file(&pdev->dev, &sensor_dev_attr_in5_min.dev_attr); 756 - device_create_file(&pdev->dev, &sensor_dev_attr_in6_min.dev_attr); 757 - device_create_file(&pdev->dev, &sensor_dev_attr_in7_min.dev_attr); 758 - device_create_file(&pdev->dev, &sensor_dev_attr_in8_min.dev_attr); 759 - if (data->fan_enabled & (1 << 0)) { 760 - device_create_file(&pdev->dev, 761 - &sensor_dev_attr_fan1_input.dev_attr); 762 - device_create_file(&pdev->dev, 763 - &sensor_dev_attr_fan1_min.dev_attr); 698 + for (i = 0; i < ARRAY_SIZE(f71805f_dev_attr); i++) { 699 + err = device_create_file(&pdev->dev, &f71805f_dev_attr[i]); 700 + if (err) 701 + goto exit_class; 764 702 } 765 - if (data->fan_enabled & (1 << 1)) { 766 - device_create_file(&pdev->dev, 767 - &sensor_dev_attr_fan2_input.dev_attr); 768 - device_create_file(&pdev->dev, 769 - &sensor_dev_attr_fan2_min.dev_attr); 703 + for (i = 0; i < ARRAY_SIZE(f71805f_sensor_attr); i++) { 704 + err = device_create_file(&pdev->dev, 705 + &f71805f_sensor_attr[i].dev_attr); 706 + if (err) 707 + goto exit_class; 770 708 } 771 - if (data->fan_enabled & (1 << 2)) { 772 - device_create_file(&pdev->dev, 773 - &sensor_dev_attr_fan3_input.dev_attr); 774 - device_create_file(&pdev->dev, 775 - &sensor_dev_attr_fan3_min.dev_attr); 709 + for (i = 0; i < ARRAY_SIZE(f71805f_fan_attr); i++) { 710 + if (!(data->fan_enabled & (1 << (i / 2)))) 711 + continue; 712 + err = device_create_file(&pdev->dev, 713 + &f71805f_fan_attr[i].dev_attr); 714 + if (err) 715 + goto exit_class; 776 716 } 777 - device_create_file(&pdev->dev, 778 - &sensor_dev_attr_temp1_input.dev_attr); 779 - device_create_file(&pdev->dev, 780 - &sensor_dev_attr_temp2_input.dev_attr); 781 - device_create_file(&pdev->dev, 782 - &sensor_dev_attr_temp3_input.dev_attr); 783 - device_create_file(&pdev->dev, &sensor_dev_attr_temp1_max.dev_attr); 784 - device_create_file(&pdev->dev, &sensor_dev_attr_temp2_max.dev_attr); 785 - device_create_file(&pdev->dev, &sensor_dev_attr_temp3_max.dev_attr); 786 - device_create_file(&pdev->dev, 787 - &sensor_dev_attr_temp1_max_hyst.dev_attr); 788 - device_create_file(&pdev->dev, 789 - &sensor_dev_attr_temp2_max_hyst.dev_attr); 790 - device_create_file(&pdev->dev, 791 - &sensor_dev_attr_temp3_max_hyst.dev_attr); 792 - device_create_file(&pdev->dev, &sensor_dev_attr_temp1_type.dev_attr); 793 - device_create_file(&pdev->dev, &sensor_dev_attr_temp2_type.dev_attr); 794 - device_create_file(&pdev->dev, &sensor_dev_attr_temp3_type.dev_attr); 795 - device_create_file(&pdev->dev, &dev_attr_alarms_in); 796 - device_create_file(&pdev->dev, &dev_attr_alarms_fan); 797 - device_create_file(&pdev->dev, &dev_attr_alarms_temp); 798 - device_create_file(&pdev->dev, &dev_attr_name); 799 717 800 718 return 0; 801 719 720 + exit_class: 721 + dev_err(&pdev->dev, "Sysfs interface creation failed\n"); 722 + hwmon_device_unregister(data->class_dev); 802 723 exit_free: 803 724 kfree(data); 804 725 exit:
+21 -20
drivers/hwmon/fscher.c
··· 33 33 #include <linux/i2c.h> 34 34 #include <linux/hwmon.h> 35 35 #include <linux/err.h> 36 + #include <linux/mutex.h> 36 37 37 38 /* 38 39 * Addresses to scan ··· 134 133 struct fscher_data { 135 134 struct i2c_client client; 136 135 struct class_device *class_dev; 137 - struct semaphore update_lock; 136 + struct mutex update_lock; 138 137 char valid; /* zero until following fields are valid */ 139 138 unsigned long last_updated; /* in jiffies */ 140 139 ··· 333 332 * global list */ 334 333 strlcpy(new_client->name, "fscher", I2C_NAME_SIZE); 335 334 data->valid = 0; 336 - init_MUTEX(&data->update_lock); 335 + mutex_init(&data->update_lock); 337 336 338 337 /* Tell the I2C layer a new client has arrived */ 339 338 if ((err = i2c_attach_client(new_client))) ··· 418 417 struct i2c_client *client = to_i2c_client(dev); 419 418 struct fscher_data *data = i2c_get_clientdata(client); 420 419 421 - down(&data->update_lock); 420 + mutex_lock(&data->update_lock); 422 421 423 422 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { 424 423 ··· 458 457 data->valid = 1; 459 458 } 460 459 461 - up(&data->update_lock); 460 + mutex_unlock(&data->update_lock); 462 461 463 462 return data; 464 463 } ··· 473 472 /* bits 0..1, 3..7 reserved => mask with 0x04 */ 474 473 unsigned long v = simple_strtoul(buf, NULL, 10) & 0x04; 475 474 476 - down(&data->update_lock); 475 + mutex_lock(&data->update_lock); 477 476 data->fan_status[FAN_INDEX_FROM_NUM(nr)] &= ~v; 478 477 fscher_write_value(client, reg, v); 479 - up(&data->update_lock); 478 + mutex_unlock(&data->update_lock); 480 479 return count; 481 480 } 482 481 ··· 491 490 { 492 491 unsigned long v = simple_strtoul(buf, NULL, 10); 493 492 494 - down(&data->update_lock); 493 + mutex_lock(&data->update_lock); 495 494 data->fan_min[FAN_INDEX_FROM_NUM(nr)] = v > 0xff ? 0xff : v; 496 495 fscher_write_value(client, reg, data->fan_min[FAN_INDEX_FROM_NUM(nr)]); 497 - up(&data->update_lock); 496 + mutex_unlock(&data->update_lock); 498 497 return count; 499 498 } 500 499 ··· 519 518 return -EINVAL; 520 519 } 521 520 522 - down(&data->update_lock); 521 + mutex_lock(&data->update_lock); 523 522 524 523 /* bits 2..7 reserved => mask with 0x03 */ 525 524 data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] &= ~0x03; 526 525 data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] |= v; 527 526 528 527 fscher_write_value(client, reg, data->fan_ripple[FAN_INDEX_FROM_NUM(nr)]); 529 - up(&data->update_lock); 528 + mutex_unlock(&data->update_lock); 530 529 return count; 531 530 } 532 531 ··· 553 552 /* bits 2..7 reserved, 0 read only => mask with 0x02 */ 554 553 unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02; 555 554 556 - down(&data->update_lock); 555 + mutex_lock(&data->update_lock); 557 556 data->temp_status[TEMP_INDEX_FROM_NUM(nr)] &= ~v; 558 557 fscher_write_value(client, reg, v); 559 - up(&data->update_lock); 558 + mutex_unlock(&data->update_lock); 560 559 return count; 561 560 } 562 561 ··· 610 609 /* bits 1..7 reserved => mask with 0x01 */ 611 610 unsigned long v = simple_strtoul(buf, NULL, 10) & 0x01; 612 611 613 - down(&data->update_lock); 612 + mutex_lock(&data->update_lock); 614 613 data->global_control &= ~v; 615 614 fscher_write_value(client, reg, v); 616 - up(&data->update_lock); 615 + mutex_unlock(&data->update_lock); 617 616 return count; 618 617 } 619 618 ··· 632 631 /* bits 0..3 reserved => mask with 0xf0 */ 633 632 unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; 634 633 635 - down(&data->update_lock); 634 + mutex_lock(&data->update_lock); 636 635 data->watchdog[2] &= ~0xf0; 637 636 data->watchdog[2] |= v; 638 637 fscher_write_value(client, reg, data->watchdog[2]); 639 - up(&data->update_lock); 638 + mutex_unlock(&data->update_lock); 640 639 return count; 641 640 } 642 641 ··· 652 651 /* bits 0, 2..7 reserved => mask with 0x02 */ 653 652 unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02; 654 653 655 - down(&data->update_lock); 654 + mutex_lock(&data->update_lock); 656 655 data->watchdog[1] &= ~v; 657 656 fscher_write_value(client, reg, v); 658 - up(&data->update_lock); 657 + mutex_unlock(&data->update_lock); 659 658 return count; 660 659 } 661 660 ··· 670 669 { 671 670 unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; 672 671 673 - down(&data->update_lock); 672 + mutex_lock(&data->update_lock); 674 673 data->watchdog[0] = v; 675 674 fscher_write_value(client, reg, data->watchdog[0]); 676 - up(&data->update_lock); 675 + mutex_unlock(&data->update_lock); 677 676 return count; 678 677 } 679 678
+17 -16
drivers/hwmon/fscpos.c
··· 37 37 #include <linux/init.h> 38 38 #include <linux/hwmon.h> 39 39 #include <linux/err.h> 40 + #include <linux/mutex.h> 40 41 41 42 /* 42 43 * Addresses to scan ··· 90 89 static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind); 91 90 static int fscpos_detach_client(struct i2c_client *client); 92 91 93 - static int fscpos_read_value(struct i2c_client *client, u8 register); 94 - static int fscpos_write_value(struct i2c_client *client, u8 register, u8 value); 92 + static int fscpos_read_value(struct i2c_client *client, u8 reg); 93 + static int fscpos_write_value(struct i2c_client *client, u8 reg, u8 value); 95 94 static struct fscpos_data *fscpos_update_device(struct device *dev); 96 95 static void fscpos_init_client(struct i2c_client *client); 97 96 ··· 115 114 struct fscpos_data { 116 115 struct i2c_client client; 117 116 struct class_device *class_dev; 118 - struct semaphore update_lock; 117 + struct mutex update_lock; 119 118 char valid; /* 0 until following fields are valid */ 120 119 unsigned long last_updated; /* In jiffies */ 121 120 ··· 209 208 return -EINVAL; 210 209 } 211 210 212 - down(&data->update_lock); 211 + mutex_lock(&data->update_lock); 213 212 /* bits 2..7 reserved => mask with 0x03 */ 214 213 data->fan_ripple[nr - 1] &= ~0x03; 215 214 data->fan_ripple[nr - 1] |= v; 216 215 217 216 fscpos_write_value(client, reg, data->fan_ripple[nr - 1]); 218 - up(&data->update_lock); 217 + mutex_unlock(&data->update_lock); 219 218 return count; 220 219 } 221 220 ··· 233 232 if (v < 0) v = 0; 234 233 if (v > 255) v = 255; 235 234 236 - down(&data->update_lock); 235 + mutex_lock(&data->update_lock); 237 236 data->pwm[nr - 1] = v; 238 237 fscpos_write_value(client, reg, data->pwm[nr - 1]); 239 - up(&data->update_lock); 238 + mutex_unlock(&data->update_lock); 240 239 return count; 241 240 } 242 241 ··· 279 278 /* bits 0..3 reserved => mask with 0xf0 */ 280 279 unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; 281 280 282 - down(&data->update_lock); 281 + mutex_lock(&data->update_lock); 283 282 data->wdog_control &= ~0xf0; 284 283 data->wdog_control |= v; 285 284 fscpos_write_value(client, reg, data->wdog_control); 286 - up(&data->update_lock); 285 + mutex_unlock(&data->update_lock); 287 286 return count; 288 287 } 289 288 ··· 305 304 return -EINVAL; 306 305 } 307 306 308 - down(&data->update_lock); 307 + mutex_lock(&data->update_lock); 309 308 data->wdog_state &= ~v; 310 309 fscpos_write_value(client, reg, v); 311 - up(&data->update_lock); 310 + mutex_unlock(&data->update_lock); 312 311 return count; 313 312 } 314 313 ··· 322 321 { 323 322 unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; 324 323 325 - down(&data->update_lock); 324 + mutex_lock(&data->update_lock); 326 325 data->wdog_preset = v; 327 326 fscpos_write_value(client, reg, data->wdog_preset); 328 - up(&data->update_lock); 327 + mutex_unlock(&data->update_lock); 329 328 return count; 330 329 } 331 330 ··· 484 483 strlcpy(new_client->name, "fscpos", I2C_NAME_SIZE); 485 484 486 485 data->valid = 0; 487 - init_MUTEX(&data->update_lock); 486 + mutex_init(&data->update_lock); 488 487 489 488 /* Tell the I2C layer a new client has arrived */ 490 489 if ((err = i2c_attach_client(new_client))) ··· 580 579 struct i2c_client *client = to_i2c_client(dev); 581 580 struct fscpos_data *data = i2c_get_clientdata(client); 582 581 583 - down(&data->update_lock); 582 + mutex_lock(&data->update_lock); 584 583 585 584 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { 586 585 int i; ··· 626 625 data->last_updated = jiffies; 627 626 data->valid = 1; 628 627 } 629 - up(&data->update_lock); 628 + mutex_unlock(&data->update_lock); 630 629 return data; 631 630 } 632 631
+13 -12
drivers/hwmon/gl518sm.c
··· 43 43 #include <linux/i2c.h> 44 44 #include <linux/hwmon.h> 45 45 #include <linux/err.h> 46 + #include <linux/mutex.h> 46 47 47 48 /* Addresses to scan */ 48 49 static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; ··· 121 120 struct class_device *class_dev; 122 121 enum chips type; 123 122 124 - struct semaphore update_lock; 123 + struct mutex update_lock; 125 124 char valid; /* !=0 if following fields are valid */ 126 125 unsigned long last_updated; /* In jiffies */ 127 126 ··· 213 212 struct gl518_data *data = i2c_get_clientdata(client); \ 214 213 long val = simple_strtol(buf, NULL, 10); \ 215 214 \ 216 - down(&data->update_lock); \ 215 + mutex_lock(&data->update_lock); \ 217 216 data->value = type##_TO_REG(val); \ 218 217 gl518_write_value(client, reg, data->value); \ 219 - up(&data->update_lock); \ 218 + mutex_unlock(&data->update_lock); \ 220 219 return count; \ 221 220 } 222 221 ··· 229 228 int regvalue; \ 230 229 unsigned long val = simple_strtoul(buf, NULL, 10); \ 231 230 \ 232 - down(&data->update_lock); \ 231 + mutex_lock(&data->update_lock); \ 233 232 regvalue = gl518_read_value(client, reg); \ 234 233 data->value = type##_TO_REG(val); \ 235 234 regvalue = (regvalue & ~mask) | (data->value << shift); \ 236 235 gl518_write_value(client, reg, regvalue); \ 237 - up(&data->update_lock); \ 236 + mutex_unlock(&data->update_lock); \ 238 237 return count; \ 239 238 } 240 239 ··· 266 265 int regvalue; 267 266 unsigned long val = simple_strtoul(buf, NULL, 10); 268 267 269 - down(&data->update_lock); 268 + mutex_lock(&data->update_lock); 270 269 regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); 271 270 data->fan_min[0] = FAN_TO_REG(val, 272 271 DIV_FROM_REG(data->fan_div[0])); ··· 281 280 data->beep_mask &= data->alarm_mask; 282 281 gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); 283 282 284 - up(&data->update_lock); 283 + mutex_unlock(&data->update_lock); 285 284 return count; 286 285 } 287 286 ··· 292 291 int regvalue; 293 292 unsigned long val = simple_strtoul(buf, NULL, 10); 294 293 295 - down(&data->update_lock); 294 + mutex_lock(&data->update_lock); 296 295 regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); 297 296 data->fan_min[1] = FAN_TO_REG(val, 298 297 DIV_FROM_REG(data->fan_div[1])); ··· 307 306 data->beep_mask &= data->alarm_mask; 308 307 gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); 309 308 310 - up(&data->update_lock); 309 + mutex_unlock(&data->update_lock); 311 310 return count; 312 311 } 313 312 ··· 408 407 strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE); 409 408 data->type = kind; 410 409 data->valid = 0; 411 - init_MUTEX(&data->update_lock); 410 + mutex_init(&data->update_lock); 412 411 413 412 /* Tell the I2C layer a new client has arrived */ 414 413 if ((err = i2c_attach_client(new_client))) ··· 526 525 struct gl518_data *data = i2c_get_clientdata(client); 527 526 int val; 528 527 529 - down(&data->update_lock); 528 + mutex_lock(&data->update_lock); 530 529 531 530 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 532 531 || !data->valid) { ··· 587 586 data->valid = 1; 588 587 } 589 588 590 - up(&data->update_lock); 589 + mutex_unlock(&data->update_lock); 591 590 592 591 return data; 593 592 }
+23 -22
drivers/hwmon/gl520sm.c
··· 29 29 #include <linux/hwmon.h> 30 30 #include <linux/hwmon-vid.h> 31 31 #include <linux/err.h> 32 + #include <linux/mutex.h> 32 33 33 34 /* Type of the extra sensor */ 34 35 static unsigned short extra_sensor_type; ··· 122 121 struct gl520_data { 123 122 struct i2c_client client; 124 123 struct class_device *class_dev; 125 - struct semaphore update_lock; 124 + struct mutex update_lock; 126 125 char valid; /* zero until the following fields are valid */ 127 126 unsigned long last_updated; /* in jiffies */ 128 127 ··· 304 303 long v = simple_strtol(buf, NULL, 10); 305 304 u8 r; 306 305 307 - down(&data->update_lock); 306 + mutex_lock(&data->update_lock); 308 307 309 308 if (n == 0) 310 309 r = VDD_TO_REG(v); ··· 318 317 else 319 318 gl520_write_value(client, reg, r); 320 319 321 - up(&data->update_lock); 320 + mutex_unlock(&data->update_lock); 322 321 return count; 323 322 } 324 323 ··· 332 331 else 333 332 r = IN_TO_REG(v); 334 333 335 - down(&data->update_lock); 334 + mutex_lock(&data->update_lock); 336 335 337 336 data->in_max[n] = r; 338 337 ··· 341 340 else 342 341 gl520_write_value(client, reg, r); 343 342 344 - up(&data->update_lock); 343 + mutex_unlock(&data->update_lock); 345 344 return count; 346 345 } 347 346 ··· 374 373 unsigned long v = simple_strtoul(buf, NULL, 10); 375 374 u8 r; 376 375 377 - down(&data->update_lock); 376 + mutex_lock(&data->update_lock); 378 377 r = FAN_TO_REG(v, data->fan_div[n - 1]); 379 378 data->fan_min[n - 1] = r; 380 379 ··· 391 390 data->beep_mask &= data->alarm_mask; 392 391 gl520_write_value(client, GL520_REG_BEEP_MASK, data->beep_mask); 393 392 394 - up(&data->update_lock); 393 + mutex_unlock(&data->update_lock); 395 394 return count; 396 395 } 397 396 ··· 410 409 return -EINVAL; 411 410 } 412 411 413 - down(&data->update_lock); 412 + mutex_lock(&data->update_lock); 414 413 data->fan_div[n - 1] = r; 415 414 416 415 if (n == 1) ··· 418 417 else 419 418 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x30) | (r << 4)); 420 419 421 - up(&data->update_lock); 420 + mutex_unlock(&data->update_lock); 422 421 return count; 423 422 } 424 423 ··· 426 425 { 427 426 u8 r = simple_strtoul(buf, NULL, 10)?1:0; 428 427 429 - down(&data->update_lock); 428 + mutex_lock(&data->update_lock); 430 429 data->fan_off = r; 431 430 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x0c) | (r << 2)); 432 - up(&data->update_lock); 431 + mutex_unlock(&data->update_lock); 433 432 return count; 434 433 } 435 434 ··· 455 454 { 456 455 long v = simple_strtol(buf, NULL, 10); 457 456 458 - down(&data->update_lock); 457 + mutex_lock(&data->update_lock); 459 458 data->temp_max[n - 1] = TEMP_TO_REG(v);; 460 459 gl520_write_value(client, reg, data->temp_max[n - 1]); 461 - up(&data->update_lock); 460 + mutex_unlock(&data->update_lock); 462 461 return count; 463 462 } 464 463 ··· 466 465 { 467 466 long v = simple_strtol(buf, NULL, 10); 468 467 469 - down(&data->update_lock); 468 + mutex_lock(&data->update_lock); 470 469 data->temp_max_hyst[n - 1] = TEMP_TO_REG(v); 471 470 gl520_write_value(client, reg, data->temp_max_hyst[n - 1]); 472 - up(&data->update_lock); 471 + mutex_unlock(&data->update_lock); 473 472 return count; 474 473 } 475 474 ··· 492 491 { 493 492 u8 r = simple_strtoul(buf, NULL, 10)?0:1; 494 493 495 - down(&data->update_lock); 494 + mutex_lock(&data->update_lock); 496 495 data->beep_enable = !r; 497 496 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x04) | (r << 2)); 498 - up(&data->update_lock); 497 + mutex_unlock(&data->update_lock); 499 498 return count; 500 499 } 501 500 ··· 503 502 { 504 503 u8 r = simple_strtoul(buf, NULL, 10); 505 504 506 - down(&data->update_lock); 505 + mutex_lock(&data->update_lock); 507 506 r &= data->alarm_mask; 508 507 data->beep_mask = r; 509 508 gl520_write_value(client, reg, r); 510 - up(&data->update_lock); 509 + mutex_unlock(&data->update_lock); 511 510 return count; 512 511 } 513 512 ··· 562 561 /* Fill in the remaining client fields */ 563 562 strlcpy(new_client->name, "gl520sm", I2C_NAME_SIZE); 564 563 data->valid = 0; 565 - init_MUTEX(&data->update_lock); 564 + mutex_init(&data->update_lock); 566 565 567 566 /* Tell the I2C layer a new client has arrived */ 568 567 if ((err = i2c_attach_client(new_client))) ··· 686 685 struct gl520_data *data = i2c_get_clientdata(client); 687 686 int val; 688 687 689 - down(&data->update_lock); 688 + mutex_lock(&data->update_lock); 690 689 691 690 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { 692 691 ··· 751 750 data->valid = 1; 752 751 } 753 752 754 - up(&data->update_lock); 753 + mutex_unlock(&data->update_lock); 755 754 756 755 return data; 757 756 }
+19 -18
drivers/hwmon/hdaps.c
··· 33 33 #include <linux/module.h> 34 34 #include <linux/timer.h> 35 35 #include <linux/dmi.h> 36 + #include <linux/mutex.h> 36 37 #include <asm/io.h> 37 38 38 39 #define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */ ··· 71 70 static int rest_x; 72 71 static int rest_y; 73 72 74 - static DECLARE_MUTEX(hdaps_sem); 73 + static DEFINE_MUTEX(hdaps_mutex); 75 74 76 75 /* 77 - * __get_latch - Get the value from a given port. Callers must hold hdaps_sem. 76 + * __get_latch - Get the value from a given port. Callers must hold hdaps_mutex. 78 77 */ 79 78 static inline u8 __get_latch(u16 port) 80 79 { ··· 83 82 84 83 /* 85 84 * __check_latch - Check a port latch for a given value. Returns zero if the 86 - * port contains the given value. Callers must hold hdaps_sem. 85 + * port contains the given value. Callers must hold hdaps_mutex. 87 86 */ 88 87 static inline int __check_latch(u16 port, u8 val) 89 88 { ··· 94 93 95 94 /* 96 95 * __wait_latch - Wait up to 100us for a port latch to get a certain value, 97 - * returning zero if the value is obtained. Callers must hold hdaps_sem. 96 + * returning zero if the value is obtained. Callers must hold hdaps_mutex. 98 97 */ 99 98 static int __wait_latch(u16 port, u8 val) 100 99 { ··· 111 110 112 111 /* 113 112 * __device_refresh - request a refresh from the accelerometer. Does not wait 114 - * for refresh to complete. Callers must hold hdaps_sem. 113 + * for refresh to complete. Callers must hold hdaps_mutex. 115 114 */ 116 115 static void __device_refresh(void) 117 116 { ··· 125 124 /* 126 125 * __device_refresh_sync - request a synchronous refresh from the 127 126 * accelerometer. We wait for the refresh to complete. Returns zero if 128 - * successful and nonzero on error. Callers must hold hdaps_sem. 127 + * successful and nonzero on error. Callers must hold hdaps_mutex. 129 128 */ 130 129 static int __device_refresh_sync(void) 131 130 { ··· 135 134 136 135 /* 137 136 * __device_complete - indicate to the accelerometer that we are done reading 138 - * data, and then initiate an async refresh. Callers must hold hdaps_sem. 137 + * data, and then initiate an async refresh. Callers must hold hdaps_mutex. 139 138 */ 140 139 static inline void __device_complete(void) 141 140 { ··· 153 152 { 154 153 int ret; 155 154 156 - down(&hdaps_sem); 155 + mutex_lock(&hdaps_mutex); 157 156 158 157 /* do a sync refresh -- we need to be sure that we read fresh data */ 159 158 ret = __device_refresh_sync(); ··· 164 163 __device_complete(); 165 164 166 165 out: 167 - up(&hdaps_sem); 166 + mutex_unlock(&hdaps_mutex); 168 167 return ret; 169 168 } 170 169 ··· 199 198 { 200 199 int ret; 201 200 202 - down(&hdaps_sem); 201 + mutex_lock(&hdaps_mutex); 203 202 ret = __hdaps_read_pair(port1, port2, val1, val2); 204 - up(&hdaps_sem); 203 + mutex_unlock(&hdaps_mutex); 205 204 206 205 return ret; 207 206 } ··· 214 213 { 215 214 int total, ret = -ENXIO; 216 215 217 - down(&hdaps_sem); 216 + mutex_lock(&hdaps_mutex); 218 217 219 218 outb(0x13, 0x1610); 220 219 outb(0x01, 0x161f); ··· 280 279 } 281 280 282 281 out: 283 - up(&hdaps_sem); 282 + mutex_unlock(&hdaps_mutex); 284 283 return ret; 285 284 } 286 285 ··· 314 313 }; 315 314 316 315 /* 317 - * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_sem. 316 + * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_mutex. 318 317 */ 319 318 static void hdaps_calibrate(void) 320 319 { ··· 326 325 int x, y; 327 326 328 327 /* Cannot sleep. Try nonblockingly. If we fail, try again later. */ 329 - if (down_trylock(&hdaps_sem)) { 328 + if (!mutex_trylock(&hdaps_mutex)) { 330 329 mod_timer(&hdaps_timer,jiffies + HDAPS_POLL_PERIOD); 331 330 return; 332 331 } ··· 341 340 mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD); 342 341 343 342 out: 344 - up(&hdaps_sem); 343 + mutex_unlock(&hdaps_mutex); 345 344 } 346 345 347 346 ··· 421 420 struct device_attribute *attr, 422 421 const char *buf, size_t count) 423 422 { 424 - down(&hdaps_sem); 423 + mutex_lock(&hdaps_mutex); 425 424 hdaps_calibrate(); 426 - up(&hdaps_sem); 425 + mutex_unlock(&hdaps_mutex); 427 426 428 427 return count; 429 428 }
+8 -1
drivers/hwmon/hwmon-vid.c
··· 54 54 (IMVP-II). You can find more information in the datasheet of Max1718 55 55 http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2452 56 56 57 + The 13 specification corresponds to the Intel Pentium M series. There 58 + doesn't seem to be any named specification for these. The conversion 59 + tables are detailed directly in the various Pentium M datasheets: 60 + http://www.intel.com/design/intarch/pentiumm/docs_pentiumm.htm 57 61 */ 58 62 59 63 /* vrm is the VRM/VRD document version multiplied by 10. ··· 104 100 case 17: /* Intel IMVP-II */ 105 101 return(val & 0x10 ? 975 - (val & 0xF) * 25 : 106 102 1750 - val * 50); 103 + case 13: 104 + return(1708 - (val & 0x3f) * 16); 107 105 default: /* report 0 for unknown */ 108 106 printk(KERN_INFO "hwmon-vid: requested unknown VRM version\n"); 109 107 return 0; ··· 135 129 static struct vrm_model vrm_models[] = { 136 130 {X86_VENDOR_AMD, 0x6, ANY, ANY, 90}, /* Athlon Duron etc */ 137 131 {X86_VENDOR_AMD, 0xF, ANY, ANY, 24}, /* Athlon 64, Opteron and above VRM 24 */ 138 - {X86_VENDOR_INTEL, 0x6, 0x9, ANY, 85}, /* 0.13um too */ 132 + {X86_VENDOR_INTEL, 0x6, 0x9, ANY, 13}, /* Pentium M (130 nm) */ 139 133 {X86_VENDOR_INTEL, 0x6, 0xB, ANY, 85}, /* Tualatin */ 134 + {X86_VENDOR_INTEL, 0x6, 0xD, ANY, 13}, /* Pentium M (90 nm) */ 140 135 {X86_VENDOR_INTEL, 0x6, ANY, ANY, 82}, /* any P6 */ 141 136 {X86_VENDOR_INTEL, 0x7, ANY, ANY, 0}, /* Itanium */ 142 137 {X86_VENDOR_INTEL, 0xF, 0x0, ANY, 90}, /* P4 */
+20 -6
drivers/hwmon/hwmon.c
··· 17 17 #include <linux/idr.h> 18 18 #include <linux/hwmon.h> 19 19 #include <linux/gfp.h> 20 + #include <linux/spinlock.h> 20 21 21 22 #define HWMON_ID_PREFIX "hwmon" 22 23 #define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d" ··· 25 24 static struct class *hwmon_class; 26 25 27 26 static DEFINE_IDR(hwmon_idr); 27 + static DEFINE_SPINLOCK(idr_lock); 28 28 29 29 /** 30 30 * hwmon_device_register - register w/ hwmon sysfs class ··· 39 37 struct class_device *hwmon_device_register(struct device *dev) 40 38 { 41 39 struct class_device *cdev; 42 - int id; 40 + int id, err; 43 41 44 - if (idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0) 42 + again: 43 + if (unlikely(idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0)) 45 44 return ERR_PTR(-ENOMEM); 46 45 47 - if (idr_get_new(&hwmon_idr, NULL, &id) < 0) 48 - return ERR_PTR(-ENOMEM); 46 + spin_lock(&idr_lock); 47 + err = idr_get_new(&hwmon_idr, NULL, &id); 48 + spin_unlock(&idr_lock); 49 + 50 + if (unlikely(err == -EAGAIN)) 51 + goto again; 52 + else if (unlikely(err)) 53 + return ERR_PTR(err); 49 54 50 55 id = id & MAX_ID_MASK; 51 56 cdev = class_device_create(hwmon_class, NULL, MKDEV(0,0), dev, 52 57 HWMON_ID_FORMAT, id); 53 58 54 - if (IS_ERR(cdev)) 59 + if (IS_ERR(cdev)) { 60 + spin_lock(&idr_lock); 55 61 idr_remove(&hwmon_idr, id); 62 + spin_unlock(&idr_lock); 63 + } 56 64 57 65 return cdev; 58 66 } ··· 76 64 { 77 65 int id; 78 66 79 - if (sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1) { 67 + if (likely(sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1)) { 80 68 class_device_unregister(cdev); 69 + spin_lock(&idr_lock); 81 70 idr_remove(&hwmon_idr, id); 71 + spin_unlock(&idr_lock); 82 72 } else 83 73 dev_dbg(cdev->dev, 84 74 "hwmon_device_unregister() failed: bad class ID!\n");
+33 -33
drivers/hwmon/it87.c
··· 41 41 #include <linux/hwmon-sysfs.h> 42 42 #include <linux/hwmon-vid.h> 43 43 #include <linux/err.h> 44 + #include <linux/mutex.h> 44 45 #include <asm/io.h> 45 46 46 47 ··· 195 194 struct it87_data { 196 195 struct i2c_client client; 197 196 struct class_device *class_dev; 198 - struct semaphore lock; 197 + struct mutex lock; 199 198 enum chips type; 200 199 201 - struct semaphore update_lock; 200 + struct mutex update_lock; 202 201 char valid; /* !=0 if following fields are valid */ 203 202 unsigned long last_updated; /* In jiffies */ 204 203 ··· 225 224 static int it87_detect(struct i2c_adapter *adapter, int address, int kind); 226 225 static int it87_detach_client(struct i2c_client *client); 227 226 228 - static int it87_read_value(struct i2c_client *client, u8 register); 229 - static int it87_write_value(struct i2c_client *client, u8 register, 230 - u8 value); 227 + static int it87_read_value(struct i2c_client *client, u8 reg); 228 + static int it87_write_value(struct i2c_client *client, u8 reg, u8 value); 231 229 static struct it87_data *it87_update_device(struct device *dev); 232 230 static int it87_check_pwm(struct i2c_client *client); 233 231 static void it87_init_client(struct i2c_client *client, struct it87_data *data); ··· 290 290 struct it87_data *data = i2c_get_clientdata(client); 291 291 unsigned long val = simple_strtoul(buf, NULL, 10); 292 292 293 - down(&data->update_lock); 293 + mutex_lock(&data->update_lock); 294 294 data->in_min[nr] = IN_TO_REG(val); 295 295 it87_write_value(client, IT87_REG_VIN_MIN(nr), 296 296 data->in_min[nr]); 297 - up(&data->update_lock); 297 + mutex_unlock(&data->update_lock); 298 298 return count; 299 299 } 300 300 static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, ··· 307 307 struct it87_data *data = i2c_get_clientdata(client); 308 308 unsigned long val = simple_strtoul(buf, NULL, 10); 309 309 310 - down(&data->update_lock); 310 + mutex_lock(&data->update_lock); 311 311 data->in_max[nr] = IN_TO_REG(val); 312 312 it87_write_value(client, IT87_REG_VIN_MAX(nr), 313 313 data->in_max[nr]); 314 - up(&data->update_lock); 314 + mutex_unlock(&data->update_lock); 315 315 return count; 316 316 } 317 317 ··· 381 381 struct it87_data *data = i2c_get_clientdata(client); 382 382 int val = simple_strtol(buf, NULL, 10); 383 383 384 - down(&data->update_lock); 384 + mutex_lock(&data->update_lock); 385 385 data->temp_high[nr] = TEMP_TO_REG(val); 386 386 it87_write_value(client, IT87_REG_TEMP_HIGH(nr), data->temp_high[nr]); 387 - up(&data->update_lock); 387 + mutex_unlock(&data->update_lock); 388 388 return count; 389 389 } 390 390 static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, ··· 397 397 struct it87_data *data = i2c_get_clientdata(client); 398 398 int val = simple_strtol(buf, NULL, 10); 399 399 400 - down(&data->update_lock); 400 + mutex_lock(&data->update_lock); 401 401 data->temp_low[nr] = TEMP_TO_REG(val); 402 402 it87_write_value(client, IT87_REG_TEMP_LOW(nr), data->temp_low[nr]); 403 - up(&data->update_lock); 403 + mutex_unlock(&data->update_lock); 404 404 return count; 405 405 } 406 406 #define show_temp_offset(offset) \ ··· 440 440 struct it87_data *data = i2c_get_clientdata(client); 441 441 int val = simple_strtol(buf, NULL, 10); 442 442 443 - down(&data->update_lock); 443 + mutex_lock(&data->update_lock); 444 444 445 445 data->sensor &= ~(1 << nr); 446 446 data->sensor &= ~(8 << nr); ··· 450 450 else if (val == 2) 451 451 data->sensor |= 8 << nr; 452 452 else if (val != 0) { 453 - up(&data->update_lock); 453 + mutex_unlock(&data->update_lock); 454 454 return -EINVAL; 455 455 } 456 456 it87_write_value(client, IT87_REG_TEMP_ENABLE, data->sensor); 457 - up(&data->update_lock); 457 + mutex_unlock(&data->update_lock); 458 458 return count; 459 459 } 460 460 #define show_sensor_offset(offset) \ ··· 524 524 int val = simple_strtol(buf, NULL, 10); 525 525 u8 reg = it87_read_value(client, IT87_REG_FAN_DIV); 526 526 527 - down(&data->update_lock); 527 + mutex_lock(&data->update_lock); 528 528 switch (nr) { 529 529 case 0: data->fan_div[nr] = reg & 0x07; break; 530 530 case 1: data->fan_div[nr] = (reg >> 3) & 0x07; break; ··· 533 533 534 534 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 535 535 it87_write_value(client, IT87_REG_FAN_MIN(nr), data->fan_min[nr]); 536 - up(&data->update_lock); 536 + mutex_unlock(&data->update_lock); 537 537 return count; 538 538 } 539 539 static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, ··· 548 548 int i, min[3]; 549 549 u8 old; 550 550 551 - down(&data->update_lock); 551 + mutex_lock(&data->update_lock); 552 552 old = it87_read_value(client, IT87_REG_FAN_DIV); 553 553 554 554 for (i = 0; i < 3; i++) ··· 576 576 data->fan_min[i]=FAN_TO_REG(min[i], DIV_FROM_REG(data->fan_div[i])); 577 577 it87_write_value(client, IT87_REG_FAN_MIN(i), data->fan_min[i]); 578 578 } 579 - up(&data->update_lock); 579 + mutex_unlock(&data->update_lock); 580 580 return count; 581 581 } 582 582 static ssize_t set_pwm_enable(struct device *dev, ··· 589 589 struct it87_data *data = i2c_get_clientdata(client); 590 590 int val = simple_strtol(buf, NULL, 10); 591 591 592 - down(&data->update_lock); 592 + mutex_lock(&data->update_lock); 593 593 594 594 if (val == 0) { 595 595 int tmp; ··· 606 606 /* set saved pwm value, clear FAN_CTLX PWM mode bit */ 607 607 it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr])); 608 608 } else { 609 - up(&data->update_lock); 609 + mutex_unlock(&data->update_lock); 610 610 return -EINVAL; 611 611 } 612 612 613 - up(&data->update_lock); 613 + mutex_unlock(&data->update_lock); 614 614 return count; 615 615 } 616 616 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, ··· 626 626 if (val < 0 || val > 255) 627 627 return -EINVAL; 628 628 629 - down(&data->update_lock); 629 + mutex_lock(&data->update_lock); 630 630 data->manual_pwm_ctl[nr] = val; 631 631 if (data->fan_main_ctrl & (1 << nr)) 632 632 it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr])); 633 - up(&data->update_lock); 633 + mutex_unlock(&data->update_lock); 634 634 return count; 635 635 } 636 636 ··· 776 776 777 777 new_client = &data->client; 778 778 if (is_isa) 779 - init_MUTEX(&data->lock); 779 + mutex_init(&data->lock); 780 780 i2c_set_clientdata(new_client, data); 781 781 new_client->addr = address; 782 782 new_client->adapter = adapter; ··· 823 823 strlcpy(new_client->name, name, I2C_NAME_SIZE); 824 824 data->type = kind; 825 825 data->valid = 0; 826 - init_MUTEX(&data->update_lock); 826 + mutex_init(&data->update_lock); 827 827 828 828 /* Tell the I2C layer a new client has arrived */ 829 829 if ((err = i2c_attach_client(new_client))) ··· 950 950 951 951 int res; 952 952 if (i2c_is_isa_client(client)) { 953 - down(&data->lock); 953 + mutex_lock(&data->lock); 954 954 outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); 955 955 res = inb_p(client->addr + IT87_DATA_REG_OFFSET); 956 - up(&data->lock); 956 + mutex_unlock(&data->lock); 957 957 return res; 958 958 } else 959 959 return i2c_smbus_read_byte_data(client, reg); ··· 969 969 struct it87_data *data = i2c_get_clientdata(client); 970 970 971 971 if (i2c_is_isa_client(client)) { 972 - down(&data->lock); 972 + mutex_lock(&data->lock); 973 973 outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); 974 974 outb_p(value, client->addr + IT87_DATA_REG_OFFSET); 975 - up(&data->lock); 975 + mutex_unlock(&data->lock); 976 976 return 0; 977 977 } else 978 978 return i2c_smbus_write_byte_data(client, reg, value); ··· 1098 1098 struct it87_data *data = i2c_get_clientdata(client); 1099 1099 int i; 1100 1100 1101 - down(&data->update_lock); 1101 + mutex_lock(&data->update_lock); 1102 1102 1103 1103 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 1104 1104 || !data->valid) { ··· 1160 1160 data->valid = 1; 1161 1161 } 1162 1162 1163 - up(&data->update_lock); 1163 + mutex_unlock(&data->update_lock); 1164 1164 1165 1165 return data; 1166 1166 }
+15 -14
drivers/hwmon/lm63.c
··· 45 45 #include <linux/hwmon-sysfs.h> 46 46 #include <linux/hwmon.h> 47 47 #include <linux/err.h> 48 + #include <linux/mutex.h> 48 49 49 50 /* 50 51 * Addresses to scan ··· 154 153 struct lm63_data { 155 154 struct i2c_client client; 156 155 struct class_device *class_dev; 157 - struct semaphore update_lock; 156 + struct mutex update_lock; 158 157 char valid; /* zero until following fields are valid */ 159 158 unsigned long last_updated; /* in jiffies */ 160 159 ··· 193 192 struct lm63_data *data = i2c_get_clientdata(client); 194 193 unsigned long val = simple_strtoul(buf, NULL, 10); 195 194 196 - down(&data->update_lock); 195 + mutex_lock(&data->update_lock); 197 196 data->fan[1] = FAN_TO_REG(val); 198 197 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, 199 198 data->fan[1] & 0xFF); 200 199 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, 201 200 data->fan[1] >> 8); 202 - up(&data->update_lock); 201 + mutex_unlock(&data->update_lock); 203 202 return count; 204 203 } 205 204 ··· 223 222 return -EPERM; 224 223 225 224 val = simple_strtoul(buf, NULL, 10); 226 - down(&data->update_lock); 225 + mutex_lock(&data->update_lock); 227 226 data->pwm1_value = val <= 0 ? 0 : 228 227 val >= 255 ? 2 * data->pwm1_freq : 229 228 (val * data->pwm1_freq * 2 + 127) / 255; 230 229 i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1_value); 231 - up(&data->update_lock); 230 + mutex_unlock(&data->update_lock); 232 231 return count; 233 232 } 234 233 ··· 254 253 struct lm63_data *data = i2c_get_clientdata(client); 255 254 long val = simple_strtol(buf, NULL, 10); 256 255 257 - down(&data->update_lock); 256 + mutex_lock(&data->update_lock); 258 257 data->temp8[1] = TEMP8_TO_REG(val); 259 258 i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]); 260 - up(&data->update_lock); 259 + mutex_unlock(&data->update_lock); 261 260 return count; 262 261 } 263 262 ··· 285 284 long val = simple_strtol(buf, NULL, 10); 286 285 int nr = attr->index; 287 286 288 - down(&data->update_lock); 287 + mutex_lock(&data->update_lock); 289 288 data->temp11[nr] = TEMP11_TO_REG(val); 290 289 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], 291 290 data->temp11[nr] >> 8); 292 291 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], 293 292 data->temp11[nr] & 0xff); 294 - up(&data->update_lock); 293 + mutex_unlock(&data->update_lock); 295 294 return count; 296 295 } 297 296 ··· 315 314 long val = simple_strtol(buf, NULL, 10); 316 315 long hyst; 317 316 318 - down(&data->update_lock); 317 + mutex_lock(&data->update_lock); 319 318 hyst = TEMP8_FROM_REG(data->temp8[2]) - val; 320 319 i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, 321 320 HYST_TO_REG(hyst)); 322 - up(&data->update_lock); 321 + mutex_unlock(&data->update_lock); 323 322 return count; 324 323 } 325 324 ··· 428 427 429 428 strlcpy(new_client->name, "lm63", I2C_NAME_SIZE); 430 429 data->valid = 0; 431 - init_MUTEX(&data->update_lock); 430 + mutex_init(&data->update_lock); 432 431 433 432 /* Tell the I2C layer a new client has arrived */ 434 433 if ((err = i2c_attach_client(new_client))) ··· 531 530 struct i2c_client *client = to_i2c_client(dev); 532 531 struct lm63_data *data = i2c_get_clientdata(client); 533 532 534 - down(&data->update_lock); 533 + mutex_lock(&data->update_lock); 535 534 536 535 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { 537 536 if (data->config & 0x04) { /* tachometer enabled */ ··· 583 582 data->valid = 1; 584 583 } 585 584 586 - up(&data->update_lock); 585 + mutex_unlock(&data->update_lock); 587 586 588 587 return data; 589 588 }
+7 -6
drivers/hwmon/lm75.c
··· 25 25 #include <linux/i2c.h> 26 26 #include <linux/hwmon.h> 27 27 #include <linux/err.h> 28 + #include <linux/mutex.h> 28 29 #include "lm75.h" 29 30 30 31 ··· 48 47 struct lm75_data { 49 48 struct i2c_client client; 50 49 struct class_device *class_dev; 51 - struct semaphore update_lock; 50 + struct mutex update_lock; 52 51 char valid; /* !=0 if following fields are valid */ 53 52 unsigned long last_updated; /* In jiffies */ 54 53 u16 temp_input; /* Register values */ ··· 92 91 struct lm75_data *data = i2c_get_clientdata(client); \ 93 92 int temp = simple_strtoul(buf, NULL, 10); \ 94 93 \ 95 - down(&data->update_lock); \ 94 + mutex_lock(&data->update_lock); \ 96 95 data->value = LM75_TEMP_TO_REG(temp); \ 97 96 lm75_write_value(client, reg, data->value); \ 98 - up(&data->update_lock); \ 97 + mutex_unlock(&data->update_lock); \ 99 98 return count; \ 100 99 } 101 100 set(temp_max, LM75_REG_TEMP_OS); ··· 189 188 /* Fill in the remaining client fields and put it into the global list */ 190 189 strlcpy(new_client->name, name, I2C_NAME_SIZE); 191 190 data->valid = 0; 192 - init_MUTEX(&data->update_lock); 191 + mutex_init(&data->update_lock); 193 192 194 193 /* Tell the I2C layer a new client has arrived */ 195 194 if ((err = i2c_attach_client(new_client))) ··· 265 264 struct i2c_client *client = to_i2c_client(dev); 266 265 struct lm75_data *data = i2c_get_clientdata(client); 267 266 268 - down(&data->update_lock); 267 + mutex_lock(&data->update_lock); 269 268 270 269 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 271 270 || !data->valid) { ··· 278 277 data->valid = 1; 279 278 } 280 279 281 - up(&data->update_lock); 280 + mutex_unlock(&data->update_lock); 282 281 283 282 return data; 284 283 }
+11 -10
drivers/hwmon/lm77.c
··· 32 32 #include <linux/i2c.h> 33 33 #include <linux/hwmon.h> 34 34 #include <linux/err.h> 35 + #include <linux/mutex.h> 35 36 36 37 /* Addresses to scan */ 37 38 static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; ··· 52 51 struct lm77_data { 53 52 struct i2c_client client; 54 53 struct class_device *class_dev; 55 - struct semaphore update_lock; 54 + struct mutex update_lock; 56 55 char valid; 57 56 unsigned long last_updated; /* In jiffies */ 58 57 int temp_input; /* Temperatures */ ··· 140 139 struct lm77_data *data = i2c_get_clientdata(client); \ 141 140 long val = simple_strtoul(buf, NULL, 10); \ 142 141 \ 143 - down(&data->update_lock); \ 142 + mutex_lock(&data->update_lock); \ 144 143 data->value = val; \ 145 144 lm77_write_value(client, reg, LM77_TEMP_TO_REG(data->value)); \ 146 - up(&data->update_lock); \ 145 + mutex_unlock(&data->update_lock); \ 147 146 return count; \ 148 147 } 149 148 ··· 158 157 struct lm77_data *data = i2c_get_clientdata(client); 159 158 unsigned long val = simple_strtoul(buf, NULL, 10); 160 159 161 - down(&data->update_lock); 160 + mutex_lock(&data->update_lock); 162 161 data->temp_hyst = data->temp_crit - val; 163 162 lm77_write_value(client, LM77_REG_TEMP_HYST, 164 163 LM77_TEMP_TO_REG(data->temp_hyst)); 165 - up(&data->update_lock); 164 + mutex_unlock(&data->update_lock); 166 165 return count; 167 166 } 168 167 ··· 174 173 long val = simple_strtoul(buf, NULL, 10); 175 174 int oldcrithyst; 176 175 177 - down(&data->update_lock); 176 + mutex_lock(&data->update_lock); 178 177 oldcrithyst = data->temp_crit - data->temp_hyst; 179 178 data->temp_crit = val; 180 179 data->temp_hyst = data->temp_crit - oldcrithyst; ··· 182 181 LM77_TEMP_TO_REG(data->temp_crit)); 183 182 lm77_write_value(client, LM77_REG_TEMP_HYST, 184 183 LM77_TEMP_TO_REG(data->temp_hyst)); 185 - up(&data->update_lock); 184 + mutex_unlock(&data->update_lock); 186 185 return count; 187 186 } 188 187 ··· 307 306 /* Fill in the remaining client fields and put it into the global list */ 308 307 strlcpy(new_client->name, name, I2C_NAME_SIZE); 309 308 data->valid = 0; 310 - init_MUTEX(&data->update_lock); 309 + mutex_init(&data->update_lock); 311 310 312 311 /* Tell the I2C layer a new client has arrived */ 313 312 if ((err = i2c_attach_client(new_client))) ··· 381 380 struct i2c_client *client = to_i2c_client(dev); 382 381 struct lm77_data *data = i2c_get_clientdata(client); 383 382 384 - down(&data->update_lock); 383 + mutex_lock(&data->update_lock); 385 384 386 385 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 387 386 || !data->valid) { ··· 407 406 data->valid = 1; 408 407 } 409 408 410 - up(&data->update_lock); 409 + mutex_unlock(&data->update_lock); 411 410 412 411 return data; 413 412 }
+26 -25
drivers/hwmon/lm78.c
··· 27 27 #include <linux/hwmon.h> 28 28 #include <linux/hwmon-vid.h> 29 29 #include <linux/err.h> 30 + #include <linux/mutex.h> 30 31 #include <asm/io.h> 31 32 32 33 /* Addresses to scan */ ··· 132 131 struct lm78_data { 133 132 struct i2c_client client; 134 133 struct class_device *class_dev; 135 - struct semaphore lock; 134 + struct mutex lock; 136 135 enum chips type; 137 136 138 - struct semaphore update_lock; 137 + struct mutex update_lock; 139 138 char valid; /* !=0 if following fields are valid */ 140 139 unsigned long last_updated; /* In jiffies */ 141 140 ··· 158 157 static int lm78_detect(struct i2c_adapter *adapter, int address, int kind); 159 158 static int lm78_detach_client(struct i2c_client *client); 160 159 161 - static int lm78_read_value(struct i2c_client *client, u8 register); 162 - static int lm78_write_value(struct i2c_client *client, u8 register, u8 value); 160 + static int lm78_read_value(struct i2c_client *client, u8 reg); 161 + static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value); 163 162 static struct lm78_data *lm78_update_device(struct device *dev); 164 163 static void lm78_init_client(struct i2c_client *client); 165 164 ··· 208 207 struct lm78_data *data = i2c_get_clientdata(client); 209 208 unsigned long val = simple_strtoul(buf, NULL, 10); 210 209 211 - down(&data->update_lock); 210 + mutex_lock(&data->update_lock); 212 211 data->in_min[nr] = IN_TO_REG(val); 213 212 lm78_write_value(client, LM78_REG_IN_MIN(nr), data->in_min[nr]); 214 - up(&data->update_lock); 213 + mutex_unlock(&data->update_lock); 215 214 return count; 216 215 } 217 216 ··· 222 221 struct lm78_data *data = i2c_get_clientdata(client); 223 222 unsigned long val = simple_strtoul(buf, NULL, 10); 224 223 225 - down(&data->update_lock); 224 + mutex_lock(&data->update_lock); 226 225 data->in_max[nr] = IN_TO_REG(val); 227 226 lm78_write_value(client, LM78_REG_IN_MAX(nr), data->in_max[nr]); 228 - up(&data->update_lock); 227 + mutex_unlock(&data->update_lock); 229 228 return count; 230 229 } 231 230 ··· 289 288 struct lm78_data *data = i2c_get_clientdata(client); 290 289 long val = simple_strtol(buf, NULL, 10); 291 290 292 - down(&data->update_lock); 291 + mutex_lock(&data->update_lock); 293 292 data->temp_over = TEMP_TO_REG(val); 294 293 lm78_write_value(client, LM78_REG_TEMP_OVER, data->temp_over); 295 - up(&data->update_lock); 294 + mutex_unlock(&data->update_lock); 296 295 return count; 297 296 } 298 297 ··· 308 307 struct lm78_data *data = i2c_get_clientdata(client); 309 308 long val = simple_strtol(buf, NULL, 10); 310 309 311 - down(&data->update_lock); 310 + mutex_lock(&data->update_lock); 312 311 data->temp_hyst = TEMP_TO_REG(val); 313 312 lm78_write_value(client, LM78_REG_TEMP_HYST, data->temp_hyst); 314 - up(&data->update_lock); 313 + mutex_unlock(&data->update_lock); 315 314 return count; 316 315 } 317 316 ··· 343 342 struct lm78_data *data = i2c_get_clientdata(client); 344 343 unsigned long val = simple_strtoul(buf, NULL, 10); 345 344 346 - down(&data->update_lock); 345 + mutex_lock(&data->update_lock); 347 346 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 348 347 lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); 349 - up(&data->update_lock); 348 + mutex_unlock(&data->update_lock); 350 349 return count; 351 350 } 352 351 ··· 369 368 unsigned long min; 370 369 u8 reg; 371 370 372 - down(&data->update_lock); 371 + mutex_lock(&data->update_lock); 373 372 min = FAN_FROM_REG(data->fan_min[nr], 374 373 DIV_FROM_REG(data->fan_div[nr])); 375 374 ··· 381 380 default: 382 381 dev_err(&client->dev, "fan_div value %ld not " 383 382 "supported. Choose one of 1, 2, 4 or 8!\n", val); 384 - up(&data->update_lock); 383 + mutex_unlock(&data->update_lock); 385 384 return -EINVAL; 386 385 } 387 386 ··· 399 398 data->fan_min[nr] = 400 399 FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 401 400 lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); 402 - up(&data->update_lock); 401 + mutex_unlock(&data->update_lock); 403 402 404 403 return count; 405 404 } ··· 549 548 550 549 new_client = &data->client; 551 550 if (is_isa) 552 - init_MUTEX(&data->lock); 551 + mutex_init(&data->lock); 553 552 i2c_set_clientdata(new_client, data); 554 553 new_client->addr = address; 555 554 new_client->adapter = adapter; ··· 599 598 data->type = kind; 600 599 601 600 data->valid = 0; 602 - init_MUTEX(&data->update_lock); 601 + mutex_init(&data->update_lock); 603 602 604 603 /* Tell the I2C layer a new client has arrived */ 605 604 if ((err = i2c_attach_client(new_client))) ··· 698 697 int res; 699 698 if (i2c_is_isa_client(client)) { 700 699 struct lm78_data *data = i2c_get_clientdata(client); 701 - down(&data->lock); 700 + mutex_lock(&data->lock); 702 701 outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); 703 702 res = inb_p(client->addr + LM78_DATA_REG_OFFSET); 704 - up(&data->lock); 703 + mutex_unlock(&data->lock); 705 704 return res; 706 705 } else 707 706 return i2c_smbus_read_byte_data(client, reg); ··· 718 717 { 719 718 if (i2c_is_isa_client(client)) { 720 719 struct lm78_data *data = i2c_get_clientdata(client); 721 - down(&data->lock); 720 + mutex_lock(&data->lock); 722 721 outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); 723 722 outb_p(value, client->addr + LM78_DATA_REG_OFFSET); 724 - up(&data->lock); 723 + mutex_unlock(&data->lock); 725 724 return 0; 726 725 } else 727 726 return i2c_smbus_write_byte_data(client, reg, value); ··· 743 742 struct lm78_data *data = i2c_get_clientdata(client); 744 743 int i; 745 744 746 - down(&data->update_lock); 745 + mutex_lock(&data->update_lock); 747 746 748 747 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 749 748 || !data->valid) { ··· 787 786 data->fan_div[2] = 1; 788 787 } 789 788 790 - up(&data->update_lock); 789 + mutex_unlock(&data->update_lock); 791 790 792 791 return data; 793 792 }
+14 -13
drivers/hwmon/lm80.c
··· 28 28 #include <linux/i2c.h> 29 29 #include <linux/hwmon.h> 30 30 #include <linux/err.h> 31 + #include <linux/mutex.h> 31 32 32 33 /* Addresses to scan */ 33 34 static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, ··· 109 108 struct lm80_data { 110 109 struct i2c_client client; 111 110 struct class_device *class_dev; 112 - struct semaphore update_lock; 111 + struct mutex update_lock; 113 112 char valid; /* !=0 if following fields are valid */ 114 113 unsigned long last_updated; /* In jiffies */ 115 114 ··· 192 191 struct lm80_data *data = i2c_get_clientdata(client); \ 193 192 long val = simple_strtol(buf, NULL, 10); \ 194 193 \ 195 - down(&data->update_lock);\ 194 + mutex_lock(&data->update_lock);\ 196 195 data->value = IN_TO_REG(val); \ 197 196 lm80_write_value(client, reg, data->value); \ 198 - up(&data->update_lock);\ 197 + mutex_unlock(&data->update_lock);\ 199 198 return count; \ 200 199 } 201 200 set_in(min0, in_min[0], LM80_REG_IN_MIN(0)); ··· 242 241 struct lm80_data *data = i2c_get_clientdata(client); \ 243 242 long val = simple_strtoul(buf, NULL, 10); \ 244 243 \ 245 - down(&data->update_lock);\ 244 + mutex_lock(&data->update_lock);\ 246 245 data->value = FAN_TO_REG(val, DIV_FROM_REG(data->div)); \ 247 246 lm80_write_value(client, reg, data->value); \ 248 - up(&data->update_lock);\ 247 + mutex_unlock(&data->update_lock);\ 249 248 return count; \ 250 249 } 251 250 set_fan(min1, fan_min[0], LM80_REG_FAN_MIN(1), fan_div[0]); ··· 264 263 u8 reg; 265 264 266 265 /* Save fan_min */ 267 - down(&data->update_lock); 266 + mutex_lock(&data->update_lock); 268 267 min = FAN_FROM_REG(data->fan_min[nr], 269 268 DIV_FROM_REG(data->fan_div[nr])); 270 269 ··· 276 275 default: 277 276 dev_err(&client->dev, "fan_div value %ld not " 278 277 "supported. Choose one of 1, 2, 4 or 8!\n", val); 279 - up(&data->update_lock); 278 + mutex_unlock(&data->update_lock); 280 279 return -EINVAL; 281 280 } 282 281 ··· 287 286 /* Restore fan_min */ 288 287 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 289 288 lm80_write_value(client, LM80_REG_FAN_MIN(nr + 1), data->fan_min[nr]); 290 - up(&data->update_lock); 289 + mutex_unlock(&data->update_lock); 291 290 292 291 return count; 293 292 } ··· 326 325 struct lm80_data *data = i2c_get_clientdata(client); \ 327 326 long val = simple_strtoul(buf, NULL, 10); \ 328 327 \ 329 - down(&data->update_lock); \ 328 + mutex_lock(&data->update_lock); \ 330 329 data->value = TEMP_LIMIT_TO_REG(val); \ 331 330 lm80_write_value(client, reg, data->value); \ 332 - up(&data->update_lock); \ 331 + mutex_unlock(&data->update_lock); \ 333 332 return count; \ 334 333 } 335 334 set_temp(hot_max, temp_hot_max, LM80_REG_TEMP_HOT_MAX); ··· 438 437 /* Fill in the remaining client fields and put it into the global list */ 439 438 strlcpy(new_client->name, name, I2C_NAME_SIZE); 440 439 data->valid = 0; 441 - init_MUTEX(&data->update_lock); 440 + mutex_init(&data->update_lock); 442 441 443 442 /* Tell the I2C layer a new client has arrived */ 444 443 if ((err = i2c_attach_client(new_client))) ··· 546 545 struct lm80_data *data = i2c_get_clientdata(client); 547 546 int i; 548 547 549 - down(&data->update_lock); 548 + mutex_lock(&data->update_lock); 550 549 551 550 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { 552 551 dev_dbg(&client->dev, "Starting lm80 update\n"); ··· 586 585 data->valid = 1; 587 586 } 588 587 589 - up(&data->update_lock); 588 + mutex_unlock(&data->update_lock); 590 589 591 590 return data; 592 591 }
+7 -6
drivers/hwmon/lm83.c
··· 35 35 #include <linux/hwmon-sysfs.h> 36 36 #include <linux/hwmon.h> 37 37 #include <linux/err.h> 38 + #include <linux/mutex.h> 38 39 39 40 /* 40 41 * Addresses to scan ··· 140 139 struct lm83_data { 141 140 struct i2c_client client; 142 141 struct class_device *class_dev; 143 - struct semaphore update_lock; 142 + struct mutex update_lock; 144 143 char valid; /* zero until following fields are valid */ 145 144 unsigned long last_updated; /* in jiffies */ 146 145 ··· 172 171 long val = simple_strtol(buf, NULL, 10); 173 172 int nr = attr->index; 174 173 175 - down(&data->update_lock); 174 + mutex_lock(&data->update_lock); 176 175 data->temp[nr] = TEMP_TO_REG(val); 177 176 i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4], 178 177 data->temp[nr]); 179 - up(&data->update_lock); 178 + mutex_unlock(&data->update_lock); 180 179 return count; 181 180 } 182 181 ··· 301 300 /* We can fill in the remaining client fields */ 302 301 strlcpy(new_client->name, name, I2C_NAME_SIZE); 303 302 data->valid = 0; 304 - init_MUTEX(&data->update_lock); 303 + mutex_init(&data->update_lock); 305 304 306 305 /* Tell the I2C layer a new client has arrived */ 307 306 if ((err = i2c_attach_client(new_client))) ··· 374 373 struct i2c_client *client = to_i2c_client(dev); 375 374 struct lm83_data *data = i2c_get_clientdata(client); 376 375 377 - down(&data->update_lock); 376 + mutex_lock(&data->update_lock); 378 377 379 378 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { 380 379 int nr; ··· 394 393 data->valid = 1; 395 394 } 396 395 397 - up(&data->update_lock); 396 + mutex_unlock(&data->update_lock); 398 397 399 398 return data; 400 399 }
+36 -35
drivers/hwmon/lm85.c
··· 31 31 #include <linux/hwmon.h> 32 32 #include <linux/hwmon-vid.h> 33 33 #include <linux/err.h> 34 + #include <linux/mutex.h> 34 35 35 36 /* Addresses to scan */ 36 37 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; ··· 332 331 struct lm85_data { 333 332 struct i2c_client client; 334 333 struct class_device *class_dev; 335 - struct semaphore lock; 334 + struct mutex lock; 336 335 enum chips type; 337 336 338 - struct semaphore update_lock; 337 + struct mutex update_lock; 339 338 int valid; /* !=0 if following fields are valid */ 340 339 unsigned long last_reading; /* In jiffies */ 341 340 unsigned long last_config; /* In jiffies */ ··· 374 373 int kind); 375 374 static int lm85_detach_client(struct i2c_client *client); 376 375 377 - static int lm85_read_value(struct i2c_client *client, u8 register); 378 - static int lm85_write_value(struct i2c_client *client, u8 register, int value); 376 + static int lm85_read_value(struct i2c_client *client, u8 reg); 377 + static int lm85_write_value(struct i2c_client *client, u8 reg, int value); 379 378 static struct lm85_data *lm85_update_device(struct device *dev); 380 379 static void lm85_init_client(struct i2c_client *client); 381 380 ··· 408 407 struct lm85_data *data = i2c_get_clientdata(client); 409 408 long val = simple_strtol(buf, NULL, 10); 410 409 411 - down(&data->update_lock); 410 + mutex_lock(&data->update_lock); 412 411 data->fan_min[nr] = FAN_TO_REG(val); 413 412 lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]); 414 - up(&data->update_lock); 413 + mutex_unlock(&data->update_lock); 415 414 return count; 416 415 } 417 416 ··· 500 499 struct lm85_data *data = i2c_get_clientdata(client); 501 500 long val = simple_strtol(buf, NULL, 10); 502 501 503 - down(&data->update_lock); 502 + mutex_lock(&data->update_lock); 504 503 data->pwm[nr] = PWM_TO_REG(val); 505 504 lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]); 506 - up(&data->update_lock); 505 + mutex_unlock(&data->update_lock); 507 506 return count; 508 507 } 509 508 static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) ··· 560 559 struct lm85_data *data = i2c_get_clientdata(client); 561 560 long val = simple_strtol(buf, NULL, 10); 562 561 563 - down(&data->update_lock); 562 + mutex_lock(&data->update_lock); 564 563 data->in_min[nr] = INS_TO_REG(nr, val); 565 564 lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]); 566 - up(&data->update_lock); 565 + mutex_unlock(&data->update_lock); 567 566 return count; 568 567 } 569 568 static ssize_t show_in_max(struct device *dev, char *buf, int nr) ··· 578 577 struct lm85_data *data = i2c_get_clientdata(client); 579 578 long val = simple_strtol(buf, NULL, 10); 580 579 581 - down(&data->update_lock); 580 + mutex_lock(&data->update_lock); 582 581 data->in_max[nr] = INS_TO_REG(nr, val); 583 582 lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]); 584 - up(&data->update_lock); 583 + mutex_unlock(&data->update_lock); 585 584 return count; 586 585 } 587 586 #define show_in_reg(offset) \ ··· 641 640 struct lm85_data *data = i2c_get_clientdata(client); 642 641 long val = simple_strtol(buf, NULL, 10); 643 642 644 - down(&data->update_lock); 643 + mutex_lock(&data->update_lock); 645 644 data->temp_min[nr] = TEMP_TO_REG(val); 646 645 lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]); 647 - up(&data->update_lock); 646 + mutex_unlock(&data->update_lock); 648 647 return count; 649 648 } 650 649 static ssize_t show_temp_max(struct device *dev, char *buf, int nr) ··· 659 658 struct lm85_data *data = i2c_get_clientdata(client); 660 659 long val = simple_strtol(buf, NULL, 10); 661 660 662 - down(&data->update_lock); 661 + mutex_lock(&data->update_lock); 663 662 data->temp_max[nr] = TEMP_TO_REG(val); 664 663 lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]); 665 - up(&data->update_lock); 664 + mutex_unlock(&data->update_lock); 666 665 return count; 667 666 } 668 667 #define show_temp_reg(offset) \ ··· 714 713 struct lm85_data *data = i2c_get_clientdata(client); 715 714 long val = simple_strtol(buf, NULL, 10); 716 715 717 - down(&data->update_lock); 716 + mutex_lock(&data->update_lock); 718 717 data->autofan[nr].config = (data->autofan[nr].config & (~0xe0)) 719 718 | ZONE_TO_REG(val) ; 720 719 lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), 721 720 data->autofan[nr].config); 722 - up(&data->update_lock); 721 + mutex_unlock(&data->update_lock); 723 722 return count; 724 723 } 725 724 static ssize_t show_pwm_auto_pwm_min(struct device *dev, char *buf, int nr) ··· 734 733 struct lm85_data *data = i2c_get_clientdata(client); 735 734 long val = simple_strtol(buf, NULL, 10); 736 735 737 - down(&data->update_lock); 736 + mutex_lock(&data->update_lock); 738 737 data->autofan[nr].min_pwm = PWM_TO_REG(val); 739 738 lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr), 740 739 data->autofan[nr].min_pwm); 741 - up(&data->update_lock); 740 + mutex_unlock(&data->update_lock); 742 741 return count; 743 742 } 744 743 static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, char *buf, int nr) ··· 753 752 struct lm85_data *data = i2c_get_clientdata(client); 754 753 long val = simple_strtol(buf, NULL, 10); 755 754 756 - down(&data->update_lock); 755 + mutex_lock(&data->update_lock); 757 756 data->autofan[nr].min_off = val; 758 757 lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0] 759 758 | data->syncpwm3 ··· 761 760 | (data->autofan[1].min_off ? 0x40 : 0) 762 761 | (data->autofan[2].min_off ? 0x80 : 0) 763 762 ); 764 - up(&data->update_lock); 763 + mutex_unlock(&data->update_lock); 765 764 return count; 766 765 } 767 766 static ssize_t show_pwm_auto_pwm_freq(struct device *dev, char *buf, int nr) ··· 776 775 struct lm85_data *data = i2c_get_clientdata(client); 777 776 long val = simple_strtol(buf, NULL, 10); 778 777 779 - down(&data->update_lock); 778 + mutex_lock(&data->update_lock); 780 779 data->autofan[nr].freq = FREQ_TO_REG(val); 781 780 lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), 782 781 (data->zone[nr].range << 4) 783 782 | data->autofan[nr].freq 784 783 ); 785 - up(&data->update_lock); 784 + mutex_unlock(&data->update_lock); 786 785 return count; 787 786 } 788 787 #define pwm_auto(offset) \ ··· 858 857 int min; 859 858 long val = simple_strtol(buf, NULL, 10); 860 859 861 - down(&data->update_lock); 860 + mutex_lock(&data->update_lock); 862 861 min = TEMP_FROM_REG(data->zone[nr].limit); 863 862 data->zone[nr].off_desired = TEMP_TO_REG(val); 864 863 data->zone[nr].hyst = HYST_TO_REG(min - val); ··· 872 871 (data->zone[2].hyst << 4) 873 872 ); 874 873 } 875 - up(&data->update_lock); 874 + mutex_unlock(&data->update_lock); 876 875 return count; 877 876 } 878 877 static ssize_t show_temp_auto_temp_min(struct device *dev, char *buf, int nr) ··· 887 886 struct lm85_data *data = i2c_get_clientdata(client); 888 887 long val = simple_strtol(buf, NULL, 10); 889 888 890 - down(&data->update_lock); 889 + mutex_lock(&data->update_lock); 891 890 data->zone[nr].limit = TEMP_TO_REG(val); 892 891 lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr), 893 892 data->zone[nr].limit); ··· 914 913 (data->zone[2].hyst << 4) 915 914 ); 916 915 } 917 - up(&data->update_lock); 916 + mutex_unlock(&data->update_lock); 918 917 return count; 919 918 } 920 919 static ssize_t show_temp_auto_temp_max(struct device *dev, char *buf, int nr) ··· 931 930 int min; 932 931 long val = simple_strtol(buf, NULL, 10); 933 932 934 - down(&data->update_lock); 933 + mutex_lock(&data->update_lock); 935 934 min = TEMP_FROM_REG(data->zone[nr].limit); 936 935 data->zone[nr].max_desired = TEMP_TO_REG(val); 937 936 data->zone[nr].range = RANGE_TO_REG( ··· 939 938 lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), 940 939 ((data->zone[nr].range & 0x0f) << 4) 941 940 | (data->autofan[nr].freq & 0x07)); 942 - up(&data->update_lock); 941 + mutex_unlock(&data->update_lock); 943 942 return count; 944 943 } 945 944 static ssize_t show_temp_auto_temp_crit(struct device *dev, char *buf, int nr) ··· 954 953 struct lm85_data *data = i2c_get_clientdata(client); 955 954 long val = simple_strtol(buf, NULL, 10); 956 955 957 - down(&data->update_lock); 956 + mutex_lock(&data->update_lock); 958 957 data->zone[nr].critical = TEMP_TO_REG(val); 959 958 lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr), 960 959 data->zone[nr].critical); 961 - up(&data->update_lock); 960 + mutex_unlock(&data->update_lock); 962 961 return count; 963 962 } 964 963 #define temp_auto(offset) \ ··· 1150 1149 /* Fill in the remaining client fields */ 1151 1150 data->type = kind; 1152 1151 data->valid = 0; 1153 - init_MUTEX(&data->update_lock); 1152 + mutex_init(&data->update_lock); 1154 1153 1155 1154 /* Tell the I2C layer a new client has arrived */ 1156 1155 if ((err = i2c_attach_client(new_client))) ··· 1369 1368 struct lm85_data *data = i2c_get_clientdata(client); 1370 1369 int i; 1371 1370 1372 - down(&data->update_lock); 1371 + mutex_lock(&data->update_lock); 1373 1372 1374 1373 if ( !data->valid || 1375 1374 time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) { ··· 1572 1571 1573 1572 data->valid = 1; 1574 1573 1575 - up(&data->update_lock); 1574 + mutex_unlock(&data->update_lock); 1576 1575 1577 1576 return data; 1578 1577 }
+20 -19
drivers/hwmon/lm87.c
··· 60 60 #include <linux/hwmon.h> 61 61 #include <linux/hwmon-vid.h> 62 62 #include <linux/err.h> 63 + #include <linux/mutex.h> 63 64 64 65 /* 65 66 * Addresses to scan ··· 177 176 struct lm87_data { 178 177 struct i2c_client client; 179 178 struct class_device *class_dev; 180 - struct semaphore update_lock; 179 + struct mutex update_lock; 181 180 char valid; /* zero until following fields are valid */ 182 181 unsigned long last_updated; /* In jiffies */ 183 182 ··· 254 253 struct lm87_data *data = i2c_get_clientdata(client); 255 254 long val = simple_strtol(buf, NULL, 10); 256 255 257 - down(&data->update_lock); 256 + mutex_lock(&data->update_lock); 258 257 data->in_min[nr] = IN_TO_REG(val, data->in_scale[nr]); 259 258 lm87_write_value(client, nr<6 ? LM87_REG_IN_MIN(nr) : 260 259 LM87_REG_AIN_MIN(nr-6), data->in_min[nr]); 261 - up(&data->update_lock); 260 + mutex_unlock(&data->update_lock); 262 261 } 263 262 264 263 static void set_in_max(struct device *dev, const char *buf, int nr) ··· 267 266 struct lm87_data *data = i2c_get_clientdata(client); 268 267 long val = simple_strtol(buf, NULL, 10); 269 268 270 - down(&data->update_lock); 269 + mutex_lock(&data->update_lock); 271 270 data->in_max[nr] = IN_TO_REG(val, data->in_scale[nr]); 272 271 lm87_write_value(client, nr<6 ? LM87_REG_IN_MAX(nr) : 273 272 LM87_REG_AIN_MAX(nr-6), data->in_max[nr]); 274 - up(&data->update_lock); 273 + mutex_unlock(&data->update_lock); 275 274 } 276 275 277 276 #define set_in(offset) \ ··· 328 327 struct lm87_data *data = i2c_get_clientdata(client); 329 328 long val = simple_strtol(buf, NULL, 10); 330 329 331 - down(&data->update_lock); 330 + mutex_lock(&data->update_lock); 332 331 data->temp_low[nr] = TEMP_TO_REG(val); 333 332 lm87_write_value(client, LM87_REG_TEMP_LOW[nr], data->temp_low[nr]); 334 - up(&data->update_lock); 333 + mutex_unlock(&data->update_lock); 335 334 } 336 335 337 336 static void set_temp_high(struct device *dev, const char *buf, int nr) ··· 340 339 struct lm87_data *data = i2c_get_clientdata(client); 341 340 long val = simple_strtol(buf, NULL, 10); 342 341 343 - down(&data->update_lock); 342 + mutex_lock(&data->update_lock); 344 343 data->temp_high[nr] = TEMP_TO_REG(val); 345 344 lm87_write_value(client, LM87_REG_TEMP_HIGH[nr], data->temp_high[nr]); 346 - up(&data->update_lock); 345 + mutex_unlock(&data->update_lock); 347 346 } 348 347 349 348 #define set_temp(offset) \ ··· 412 411 struct lm87_data *data = i2c_get_clientdata(client); 413 412 long val = simple_strtol(buf, NULL, 10); 414 413 415 - down(&data->update_lock); 414 + mutex_lock(&data->update_lock); 416 415 data->fan_min[nr] = FAN_TO_REG(val, 417 416 FAN_DIV_FROM_REG(data->fan_div[nr])); 418 417 lm87_write_value(client, LM87_REG_FAN_MIN(nr), data->fan_min[nr]); 419 - up(&data->update_lock); 418 + mutex_unlock(&data->update_lock); 420 419 } 421 420 422 421 /* Note: we save and restore the fan minimum here, because its value is ··· 432 431 unsigned long min; 433 432 u8 reg; 434 433 435 - down(&data->update_lock); 434 + mutex_lock(&data->update_lock); 436 435 min = FAN_FROM_REG(data->fan_min[nr], 437 436 FAN_DIV_FROM_REG(data->fan_div[nr])); 438 437 ··· 442 441 case 4: data->fan_div[nr] = 2; break; 443 442 case 8: data->fan_div[nr] = 3; break; 444 443 default: 445 - up(&data->update_lock); 444 + mutex_unlock(&data->update_lock); 446 445 return -EINVAL; 447 446 } 448 447 ··· 460 459 data->fan_min[nr] = FAN_TO_REG(min, val); 461 460 lm87_write_value(client, LM87_REG_FAN_MIN(nr), 462 461 data->fan_min[nr]); 463 - up(&data->update_lock); 462 + mutex_unlock(&data->update_lock); 464 463 465 464 return count; 466 465 } ··· 523 522 struct lm87_data *data = i2c_get_clientdata(client); 524 523 long val = simple_strtol(buf, NULL, 10); 525 524 526 - down(&data->update_lock); 525 + mutex_lock(&data->update_lock); 527 526 data->aout = AOUT_TO_REG(val); 528 527 lm87_write_value(client, LM87_REG_AOUT, data->aout); 529 - up(&data->update_lock); 528 + mutex_unlock(&data->update_lock); 530 529 return count; 531 530 } 532 531 static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); ··· 590 589 /* We can fill in the remaining client fields */ 591 590 strlcpy(new_client->name, "lm87", I2C_NAME_SIZE); 592 591 data->valid = 0; 593 - init_MUTEX(&data->update_lock); 592 + mutex_init(&data->update_lock); 594 593 595 594 /* Tell the I2C layer a new client has arrived */ 596 595 if ((err = i2c_attach_client(new_client))) ··· 745 744 struct i2c_client *client = to_i2c_client(dev); 746 745 struct lm87_data *data = i2c_get_clientdata(client); 747 746 748 - down(&data->update_lock); 747 + mutex_lock(&data->update_lock); 749 748 750 749 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { 751 750 int i, j; ··· 814 813 data->valid = 1; 815 814 } 816 815 817 - up(&data->update_lock); 816 + mutex_unlock(&data->update_lock); 818 817 819 818 return data; 820 819 }
+11 -10
drivers/hwmon/lm90.c
··· 78 78 #include <linux/hwmon-sysfs.h> 79 79 #include <linux/hwmon.h> 80 80 #include <linux/err.h> 81 + #include <linux/mutex.h> 81 82 82 83 /* 83 84 * Addresses to scan ··· 202 201 struct lm90_data { 203 202 struct i2c_client client; 204 203 struct class_device *class_dev; 205 - struct semaphore update_lock; 204 + struct mutex update_lock; 206 205 char valid; /* zero until following fields are valid */ 207 206 unsigned long last_updated; /* in jiffies */ 208 207 int kind; ··· 248 247 long val = simple_strtol(buf, NULL, 10); 249 248 int nr = attr->index; 250 249 251 - down(&data->update_lock); 250 + mutex_lock(&data->update_lock); 252 251 if (data->kind == adt7461) 253 252 data->temp8[nr] = TEMP1_TO_REG_ADT7461(val); 254 253 else 255 254 data->temp8[nr] = TEMP1_TO_REG(val); 256 255 i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]); 257 - up(&data->update_lock); 256 + mutex_unlock(&data->update_lock); 258 257 return count; 259 258 } 260 259 ··· 282 281 long val = simple_strtol(buf, NULL, 10); 283 282 int nr = attr->index; 284 283 285 - down(&data->update_lock); 284 + mutex_lock(&data->update_lock); 286 285 if (data->kind == adt7461) 287 286 data->temp11[nr] = TEMP2_TO_REG_ADT7461(val); 288 287 else ··· 291 290 data->temp11[nr] >> 8); 292 291 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], 293 292 data->temp11[nr] & 0xff); 294 - up(&data->update_lock); 293 + mutex_unlock(&data->update_lock); 295 294 return count; 296 295 } 297 296 ··· 312 311 long val = simple_strtol(buf, NULL, 10); 313 312 long hyst; 314 313 315 - down(&data->update_lock); 314 + mutex_lock(&data->update_lock); 316 315 hyst = TEMP1_FROM_REG(data->temp8[3]) - val; 317 316 i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, 318 317 HYST_TO_REG(hyst)); 319 - up(&data->update_lock); 318 + mutex_unlock(&data->update_lock); 320 319 return count; 321 320 } 322 321 ··· 559 558 strlcpy(new_client->name, name, I2C_NAME_SIZE); 560 559 data->valid = 0; 561 560 data->kind = kind; 562 - init_MUTEX(&data->update_lock); 561 + mutex_init(&data->update_lock); 563 562 564 563 /* Tell the I2C layer a new client has arrived */ 565 564 if ((err = i2c_attach_client(new_client))) ··· 647 646 struct i2c_client *client = to_i2c_client(dev); 648 647 struct lm90_data *data = i2c_get_clientdata(client); 649 648 650 - down(&data->update_lock); 649 + mutex_lock(&data->update_lock); 651 650 652 651 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { 653 652 u8 oldh, newh, l; ··· 693 692 data->valid = 1; 694 693 } 695 694 696 - up(&data->update_lock); 695 + mutex_unlock(&data->update_lock); 697 696 698 697 return data; 699 698 }
+9 -8
drivers/hwmon/lm92.c
··· 46 46 #include <linux/i2c.h> 47 47 #include <linux/hwmon.h> 48 48 #include <linux/err.h> 49 + #include <linux/mutex.h> 49 50 50 51 /* The LM92 and MAX6635 have 2 two-state pins for address selection, 51 52 resulting in 4 possible addresses. */ ··· 97 96 struct lm92_data { 98 97 struct i2c_client client; 99 98 struct class_device *class_dev; 100 - struct semaphore update_lock; 99 + struct mutex update_lock; 101 100 char valid; /* zero until following fields are valid */ 102 101 unsigned long last_updated; /* in jiffies */ 103 102 ··· 115 114 struct i2c_client *client = to_i2c_client(dev); 116 115 struct lm92_data *data = i2c_get_clientdata(client); 117 116 118 - down(&data->update_lock); 117 + mutex_lock(&data->update_lock); 119 118 120 119 if (time_after(jiffies, data->last_updated + HZ) 121 120 || !data->valid) { ··· 135 134 data->valid = 1; 136 135 } 137 136 138 - up(&data->update_lock); 137 + mutex_unlock(&data->update_lock); 139 138 140 139 return data; 141 140 } ··· 159 158 struct lm92_data *data = i2c_get_clientdata(client); \ 160 159 long val = simple_strtol(buf, NULL, 10); \ 161 160 \ 162 - down(&data->update_lock); \ 161 + mutex_lock(&data->update_lock); \ 163 162 data->value = TEMP_TO_REG(val); \ 164 163 i2c_smbus_write_word_data(client, reg, swab16(data->value)); \ 165 - up(&data->update_lock); \ 164 + mutex_unlock(&data->update_lock); \ 166 165 return count; \ 167 166 } 168 167 set_temp(temp1_crit, LM92_REG_TEMP_CRIT); ··· 195 194 struct lm92_data *data = i2c_get_clientdata(client); 196 195 long val = simple_strtol(buf, NULL, 10); 197 196 198 - down(&data->update_lock); 197 + mutex_lock(&data->update_lock); 199 198 data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val; 200 199 i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST, 201 200 swab16(TEMP_TO_REG(data->temp1_hyst))); 202 - up(&data->update_lock); 201 + mutex_unlock(&data->update_lock); 203 202 return count; 204 203 } 205 204 ··· 349 348 /* Fill in the remaining client fields */ 350 349 strlcpy(new_client->name, name, I2C_NAME_SIZE); 351 350 data->valid = 0; 352 - init_MUTEX(&data->update_lock); 351 + mutex_init(&data->update_lock); 353 352 354 353 /* Tell the i2c subsystem a new client has arrived */ 355 354 if ((err = i2c_attach_client(new_client)))
+7 -6
drivers/hwmon/max1619.c
··· 33 33 #include <linux/i2c.h> 34 34 #include <linux/hwmon.h> 35 35 #include <linux/err.h> 36 + #include <linux/mutex.h> 36 37 37 38 static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, 38 39 0x29, 0x2a, 0x2b, ··· 105 104 struct max1619_data { 106 105 struct i2c_client client; 107 106 struct class_device *class_dev; 108 - struct semaphore update_lock; 107 + struct mutex update_lock; 109 108 char valid; /* zero until following fields are valid */ 110 109 unsigned long last_updated; /* in jiffies */ 111 110 ··· 142 141 struct max1619_data *data = i2c_get_clientdata(client); \ 143 142 long val = simple_strtol(buf, NULL, 10); \ 144 143 \ 145 - down(&data->update_lock); \ 144 + mutex_lock(&data->update_lock); \ 146 145 data->value = TEMP_TO_REG(val); \ 147 146 i2c_smbus_write_byte_data(client, reg, data->value); \ 148 - up(&data->update_lock); \ 147 + mutex_unlock(&data->update_lock); \ 149 148 return count; \ 150 149 } 151 150 ··· 263 262 /* We can fill in the remaining client fields */ 264 263 strlcpy(new_client->name, name, I2C_NAME_SIZE); 265 264 data->valid = 0; 266 - init_MUTEX(&data->update_lock); 265 + mutex_init(&data->update_lock); 267 266 268 267 /* Tell the I2C layer a new client has arrived */ 269 268 if ((err = i2c_attach_client(new_client))) ··· 331 330 struct i2c_client *client = to_i2c_client(dev); 332 331 struct max1619_data *data = i2c_get_clientdata(client); 333 332 334 - down(&data->update_lock); 333 + mutex_lock(&data->update_lock); 335 334 336 335 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { 337 336 dev_dbg(&client->dev, "Updating max1619 data.\n"); ··· 354 353 data->valid = 1; 355 354 } 356 355 357 - up(&data->update_lock); 356 + mutex_unlock(&data->update_lock); 358 357 359 358 return data; 360 359 }
+232 -237
drivers/hwmon/pc87360.c
··· 43 43 #include <linux/hwmon-sysfs.h> 44 44 #include <linux/hwmon-vid.h> 45 45 #include <linux/err.h> 46 + #include <linux/mutex.h> 46 47 #include <asm/io.h> 47 48 48 49 static u8 devid; ··· 184 183 struct pc87360_data { 185 184 struct i2c_client client; 186 185 struct class_device *class_dev; 187 - struct semaphore lock; 188 - struct semaphore update_lock; 186 + struct mutex lock; 187 + struct mutex update_lock; 189 188 char valid; /* !=0 if following fields are valid */ 190 189 unsigned long last_updated; /* In jiffies */ 191 190 ··· 284 283 struct pc87360_data *data = i2c_get_clientdata(client); 285 284 long fan_min = simple_strtol(buf, NULL, 10); 286 285 287 - down(&data->update_lock); 286 + mutex_lock(&data->update_lock); 288 287 fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index])); 289 288 290 289 /* If it wouldn't fit, change clock divisor */ ··· 301 300 /* Write new divider, preserve alarm bits */ 302 301 pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(attr->index), 303 302 data->fan_status[attr->index] & 0xF9); 304 - up(&data->update_lock); 303 + mutex_unlock(&data->update_lock); 305 304 306 305 return count; 307 306 } 308 307 309 - #define show_and_set_fan(offset) \ 310 - static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ 311 - show_fan_input, NULL, offset-1); \ 312 - static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IWUSR | S_IRUGO, \ 313 - show_fan_min, set_fan_min, offset-1); \ 314 - static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ 315 - show_fan_div, NULL, offset-1); \ 316 - static SENSOR_DEVICE_ATTR(fan##offset##_status, S_IRUGO, \ 317 - show_fan_status, NULL, offset-1); 318 - show_and_set_fan(1) 319 - show_and_set_fan(2) 320 - show_and_set_fan(3) 308 + static struct sensor_device_attribute fan_input[] = { 309 + SENSOR_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0), 310 + SENSOR_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1), 311 + SENSOR_ATTR(fan3_input, S_IRUGO, show_fan_input, NULL, 2), 312 + }; 313 + static struct sensor_device_attribute fan_status[] = { 314 + SENSOR_ATTR(fan1_status, S_IRUGO, show_fan_status, NULL, 0), 315 + SENSOR_ATTR(fan2_status, S_IRUGO, show_fan_status, NULL, 1), 316 + SENSOR_ATTR(fan3_status, S_IRUGO, show_fan_status, NULL, 2), 317 + }; 318 + static struct sensor_device_attribute fan_div[] = { 319 + SENSOR_ATTR(fan1_div, S_IRUGO, show_fan_div, NULL, 0), 320 + SENSOR_ATTR(fan2_div, S_IRUGO, show_fan_div, NULL, 1), 321 + SENSOR_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2), 322 + }; 323 + static struct sensor_device_attribute fan_min[] = { 324 + SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 0), 325 + SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 1), 326 + SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 2), 327 + }; 321 328 322 329 static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf) 323 330 { ··· 344 335 struct pc87360_data *data = i2c_get_clientdata(client); 345 336 long val = simple_strtol(buf, NULL, 10); 346 337 347 - down(&data->update_lock); 338 + mutex_lock(&data->update_lock); 348 339 data->pwm[attr->index] = PWM_TO_REG(val, 349 340 FAN_CONFIG_INVERT(data->fan_conf, attr->index)); 350 341 pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index), 351 342 data->pwm[attr->index]); 352 - up(&data->update_lock); 343 + mutex_unlock(&data->update_lock); 353 344 return count; 354 345 } 355 346 356 - #define show_and_set_pwm(offset) \ 357 - static SENSOR_DEVICE_ATTR(pwm##offset, S_IWUSR | S_IRUGO, \ 358 - show_pwm, set_pwm, offset-1); 359 - show_and_set_pwm(1) 360 - show_and_set_pwm(2) 361 - show_and_set_pwm(3) 347 + static struct sensor_device_attribute pwm[] = { 348 + SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0), 349 + SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1), 350 + SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2), 351 + }; 362 352 363 353 static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf) 364 354 { ··· 394 386 struct pc87360_data *data = i2c_get_clientdata(client); 395 387 long val = simple_strtol(buf, NULL, 10); 396 388 397 - down(&data->update_lock); 389 + mutex_lock(&data->update_lock); 398 390 data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); 399 391 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MIN, 400 392 data->in_min[attr->index]); 401 - up(&data->update_lock); 393 + mutex_unlock(&data->update_lock); 402 394 return count; 403 395 } 404 396 static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf, ··· 409 401 struct pc87360_data *data = i2c_get_clientdata(client); 410 402 long val = simple_strtol(buf, NULL, 10); 411 403 412 - down(&data->update_lock); 404 + mutex_lock(&data->update_lock); 413 405 data->in_max[attr->index] = IN_TO_REG(val, 414 406 data->in_vref); 415 407 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MAX, 416 408 data->in_max[attr->index]); 417 - up(&data->update_lock); 409 + mutex_unlock(&data->update_lock); 418 410 return count; 419 411 } 420 412 421 - #define show_and_set_in(offset) \ 422 - static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ 423 - show_in_input, NULL, offset); \ 424 - static SENSOR_DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ 425 - show_in_min, set_in_min, offset); \ 426 - static SENSOR_DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \ 427 - show_in_max, set_in_max, offset); \ 428 - static SENSOR_DEVICE_ATTR(in##offset##_status, S_IRUGO, \ 429 - show_in_status, NULL, offset); 430 - show_and_set_in(0) 431 - show_and_set_in(1) 432 - show_and_set_in(2) 433 - show_and_set_in(3) 434 - show_and_set_in(4) 435 - show_and_set_in(5) 436 - show_and_set_in(6) 437 - show_and_set_in(7) 438 - show_and_set_in(8) 439 - show_and_set_in(9) 440 - show_and_set_in(10) 413 + static struct sensor_device_attribute in_input[] = { 414 + SENSOR_ATTR(in0_input, S_IRUGO, show_in_input, NULL, 0), 415 + SENSOR_ATTR(in1_input, S_IRUGO, show_in_input, NULL, 1), 416 + SENSOR_ATTR(in2_input, S_IRUGO, show_in_input, NULL, 2), 417 + SENSOR_ATTR(in3_input, S_IRUGO, show_in_input, NULL, 3), 418 + SENSOR_ATTR(in4_input, S_IRUGO, show_in_input, NULL, 4), 419 + SENSOR_ATTR(in5_input, S_IRUGO, show_in_input, NULL, 5), 420 + SENSOR_ATTR(in6_input, S_IRUGO, show_in_input, NULL, 6), 421 + SENSOR_ATTR(in7_input, S_IRUGO, show_in_input, NULL, 7), 422 + SENSOR_ATTR(in8_input, S_IRUGO, show_in_input, NULL, 8), 423 + SENSOR_ATTR(in9_input, S_IRUGO, show_in_input, NULL, 9), 424 + SENSOR_ATTR(in10_input, S_IRUGO, show_in_input, NULL, 10), 425 + }; 426 + static struct sensor_device_attribute in_status[] = { 427 + SENSOR_ATTR(in0_status, S_IRUGO, show_in_status, NULL, 0), 428 + SENSOR_ATTR(in1_status, S_IRUGO, show_in_status, NULL, 1), 429 + SENSOR_ATTR(in2_status, S_IRUGO, show_in_status, NULL, 2), 430 + SENSOR_ATTR(in3_status, S_IRUGO, show_in_status, NULL, 3), 431 + SENSOR_ATTR(in4_status, S_IRUGO, show_in_status, NULL, 4), 432 + SENSOR_ATTR(in5_status, S_IRUGO, show_in_status, NULL, 5), 433 + SENSOR_ATTR(in6_status, S_IRUGO, show_in_status, NULL, 6), 434 + SENSOR_ATTR(in7_status, S_IRUGO, show_in_status, NULL, 7), 435 + SENSOR_ATTR(in8_status, S_IRUGO, show_in_status, NULL, 8), 436 + SENSOR_ATTR(in9_status, S_IRUGO, show_in_status, NULL, 9), 437 + SENSOR_ATTR(in10_status, S_IRUGO, show_in_status, NULL, 10), 438 + }; 439 + static struct sensor_device_attribute in_min[] = { 440 + SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 0), 441 + SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 1), 442 + SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 2), 443 + SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 3), 444 + SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 4), 445 + SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 5), 446 + SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 6), 447 + SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 7), 448 + SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 8), 449 + SENSOR_ATTR(in9_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 9), 450 + SENSOR_ATTR(in10_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 10), 451 + }; 452 + static struct sensor_device_attribute in_max[] = { 453 + SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 0), 454 + SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 1), 455 + SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 2), 456 + SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 3), 457 + SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 4), 458 + SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 5), 459 + SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 6), 460 + SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 7), 461 + SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 8), 462 + SENSOR_ATTR(in9_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 9), 463 + SENSOR_ATTR(in10_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 10), 464 + }; 441 465 442 466 static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf) 443 467 { ··· 513 473 struct pc87360_data *data = i2c_get_clientdata(client); 514 474 long val = simple_strtol(buf, NULL, 10); 515 475 516 - down(&data->update_lock); 476 + mutex_lock(&data->update_lock); 517 477 data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); 518 478 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MIN, 519 479 data->in_min[attr->index]); 520 - up(&data->update_lock); 480 + mutex_unlock(&data->update_lock); 521 481 return count; 522 482 } 523 483 static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf, ··· 528 488 struct pc87360_data *data = i2c_get_clientdata(client); 529 489 long val = simple_strtol(buf, NULL, 10); 530 490 531 - down(&data->update_lock); 491 + mutex_lock(&data->update_lock); 532 492 data->in_max[attr->index] = IN_TO_REG(val, data->in_vref); 533 493 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MAX, 534 494 data->in_max[attr->index]); 535 - up(&data->update_lock); 495 + mutex_unlock(&data->update_lock); 536 496 return count; 537 497 } 538 498 static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf, ··· 543 503 struct pc87360_data *data = i2c_get_clientdata(client); 544 504 long val = simple_strtol(buf, NULL, 10); 545 505 546 - down(&data->update_lock); 506 + mutex_lock(&data->update_lock); 547 507 data->in_crit[attr->index-11] = IN_TO_REG(val, data->in_vref); 548 508 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_CRIT, 549 509 data->in_crit[attr->index-11]); 550 - up(&data->update_lock); 510 + mutex_unlock(&data->update_lock); 551 511 return count; 552 512 } 553 513 554 - #define show_and_set_therm(offset) \ 555 - static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ 556 - show_therm_input, NULL, 11+offset-4); \ 557 - static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ 558 - show_therm_min, set_therm_min, 11+offset-4); \ 559 - static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ 560 - show_therm_max, set_therm_max, 11+offset-4); \ 561 - static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ 562 - show_therm_crit, set_therm_crit, 11+offset-4); \ 563 - static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ 564 - show_therm_status, NULL, 11+offset-4); 565 - show_and_set_therm(4) 566 - show_and_set_therm(5) 567 - show_and_set_therm(6) 514 + /* the +11 term below reflects the fact that VLM units 11,12,13 are 515 + used in the chip to measure voltage across the thermistors 516 + */ 517 + static struct sensor_device_attribute therm_input[] = { 518 + SENSOR_ATTR(temp4_input, S_IRUGO, show_therm_input, NULL, 0+11), 519 + SENSOR_ATTR(temp5_input, S_IRUGO, show_therm_input, NULL, 1+11), 520 + SENSOR_ATTR(temp6_input, S_IRUGO, show_therm_input, NULL, 2+11), 521 + }; 522 + static struct sensor_device_attribute therm_status[] = { 523 + SENSOR_ATTR(temp4_status, S_IRUGO, show_therm_status, NULL, 0+11), 524 + SENSOR_ATTR(temp5_status, S_IRUGO, show_therm_status, NULL, 1+11), 525 + SENSOR_ATTR(temp6_status, S_IRUGO, show_therm_status, NULL, 2+11), 526 + }; 527 + static struct sensor_device_attribute therm_min[] = { 528 + SENSOR_ATTR(temp4_min, S_IRUGO | S_IWUSR, 529 + show_therm_min, set_therm_min, 0+11), 530 + SENSOR_ATTR(temp5_min, S_IRUGO | S_IWUSR, 531 + show_therm_min, set_therm_min, 1+11), 532 + SENSOR_ATTR(temp6_min, S_IRUGO | S_IWUSR, 533 + show_therm_min, set_therm_min, 2+11), 534 + }; 535 + static struct sensor_device_attribute therm_max[] = { 536 + SENSOR_ATTR(temp4_max, S_IRUGO | S_IWUSR, 537 + show_therm_max, set_therm_max, 0+11), 538 + SENSOR_ATTR(temp5_max, S_IRUGO | S_IWUSR, 539 + show_therm_max, set_therm_max, 1+11), 540 + SENSOR_ATTR(temp6_max, S_IRUGO | S_IWUSR, 541 + show_therm_max, set_therm_max, 2+11), 542 + }; 543 + static struct sensor_device_attribute therm_crit[] = { 544 + SENSOR_ATTR(temp4_crit, S_IRUGO | S_IWUSR, 545 + show_therm_crit, set_therm_crit, 0+11), 546 + SENSOR_ATTR(temp5_crit, S_IRUGO | S_IWUSR, 547 + show_therm_crit, set_therm_crit, 1+11), 548 + SENSOR_ATTR(temp6_crit, S_IRUGO | S_IWUSR, 549 + show_therm_crit, set_therm_crit, 2+11), 550 + }; 568 551 569 552 static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) 570 553 { ··· 655 592 struct pc87360_data *data = i2c_get_clientdata(client); 656 593 long val = simple_strtol(buf, NULL, 10); 657 594 658 - down(&data->update_lock); 595 + mutex_lock(&data->update_lock); 659 596 data->temp_min[attr->index] = TEMP_TO_REG(val); 660 597 pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MIN, 661 598 data->temp_min[attr->index]); 662 - up(&data->update_lock); 599 + mutex_unlock(&data->update_lock); 663 600 return count; 664 601 } 665 602 static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf, ··· 670 607 struct pc87360_data *data = i2c_get_clientdata(client); 671 608 long val = simple_strtol(buf, NULL, 10); 672 609 673 - down(&data->update_lock); 610 + mutex_lock(&data->update_lock); 674 611 data->temp_max[attr->index] = TEMP_TO_REG(val); 675 612 pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MAX, 676 613 data->temp_max[attr->index]); 677 - up(&data->update_lock); 614 + mutex_unlock(&data->update_lock); 678 615 return count; 679 616 } 680 617 static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf, ··· 685 622 struct pc87360_data *data = i2c_get_clientdata(client); 686 623 long val = simple_strtol(buf, NULL, 10); 687 624 688 - down(&data->update_lock); 625 + mutex_lock(&data->update_lock); 689 626 data->temp_crit[attr->index] = TEMP_TO_REG(val); 690 627 pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_CRIT, 691 628 data->temp_crit[attr->index]); 692 - up(&data->update_lock); 629 + mutex_unlock(&data->update_lock); 693 630 return count; 694 631 } 695 632 696 - #define show_and_set_temp(offset) \ 697 - static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ 698 - show_temp_input, NULL, offset-1); \ 699 - static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ 700 - show_temp_min, set_temp_min, offset-1); \ 701 - static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ 702 - show_temp_max, set_temp_max, offset-1); \ 703 - static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ 704 - show_temp_crit, set_temp_crit, offset-1); \ 705 - static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ 706 - show_temp_status, NULL, offset-1); 707 - show_and_set_temp(1) 708 - show_and_set_temp(2) 709 - show_and_set_temp(3) 633 + static struct sensor_device_attribute temp_input[] = { 634 + SENSOR_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0), 635 + SENSOR_ATTR(temp2_input, S_IRUGO, show_temp_input, NULL, 1), 636 + SENSOR_ATTR(temp3_input, S_IRUGO, show_temp_input, NULL, 2), 637 + }; 638 + static struct sensor_device_attribute temp_status[] = { 639 + SENSOR_ATTR(temp1_status, S_IRUGO, show_temp_status, NULL, 0), 640 + SENSOR_ATTR(temp2_status, S_IRUGO, show_temp_status, NULL, 1), 641 + SENSOR_ATTR(temp3_status, S_IRUGO, show_temp_status, NULL, 2), 642 + }; 643 + static struct sensor_device_attribute temp_min[] = { 644 + SENSOR_ATTR(temp1_min, S_IRUGO | S_IWUSR, 645 + show_temp_min, set_temp_min, 0), 646 + SENSOR_ATTR(temp2_min, S_IRUGO | S_IWUSR, 647 + show_temp_min, set_temp_min, 1), 648 + SENSOR_ATTR(temp3_min, S_IRUGO | S_IWUSR, 649 + show_temp_min, set_temp_min, 2), 650 + }; 651 + static struct sensor_device_attribute temp_max[] = { 652 + SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, 653 + show_temp_max, set_temp_max, 0), 654 + SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, 655 + show_temp_max, set_temp_max, 1), 656 + SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, 657 + show_temp_max, set_temp_max, 2), 658 + }; 659 + static struct sensor_device_attribute temp_crit[] = { 660 + SENSOR_ATTR(temp1_crit, S_IRUGO | S_IWUSR, 661 + show_temp_crit, set_temp_crit, 0), 662 + SENSOR_ATTR(temp2_crit, S_IRUGO | S_IWUSR, 663 + show_temp_crit, set_temp_crit, 1), 664 + SENSOR_ATTR(temp3_crit, S_IRUGO | S_IWUSR, 665 + show_temp_crit, set_temp_crit, 2), 666 + }; 710 667 711 668 static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf) 712 669 { ··· 832 749 static int pc87360_detect(struct i2c_adapter *adapter) 833 750 { 834 751 int i; 835 - struct i2c_client *new_client; 752 + struct i2c_client *client; 836 753 struct pc87360_data *data; 837 754 int err = 0; 838 755 const char *name = "pc87360"; 839 756 int use_thermistors = 0; 757 + struct device *dev; 840 758 841 759 if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL))) 842 760 return -ENOMEM; 843 761 844 - new_client = &data->client; 845 - i2c_set_clientdata(new_client, data); 846 - new_client->addr = address; 847 - init_MUTEX(&data->lock); 848 - new_client->adapter = adapter; 849 - new_client->driver = &pc87360_driver; 850 - new_client->flags = 0; 762 + client = &data->client; 763 + dev = &client->dev; 764 + i2c_set_clientdata(client, data); 765 + client->addr = address; 766 + mutex_init(&data->lock); 767 + client->adapter = adapter; 768 + client->driver = &pc87360_driver; 769 + client->flags = 0; 851 770 852 771 data->fannr = 2; 853 772 data->innr = 0; ··· 877 792 break; 878 793 } 879 794 880 - strcpy(new_client->name, name); 795 + strlcpy(client->name, name, sizeof(client->name)); 881 796 data->valid = 0; 882 - init_MUTEX(&data->update_lock); 797 + mutex_init(&data->update_lock); 883 798 884 799 for (i = 0; i < 3; i++) { 885 800 if (((data->address[i] = extra_isa[i])) 886 801 && !request_region(extra_isa[i], PC87360_EXTENT, 887 802 pc87360_driver.driver.name)) { 888 - dev_err(&new_client->dev, "Region 0x%x-0x%x already " 803 + dev_err(&client->dev, "Region 0x%x-0x%x already " 889 804 "in use!\n", extra_isa[i], 890 805 extra_isa[i]+PC87360_EXTENT-1); 891 806 for (i--; i >= 0; i--) ··· 899 814 if (data->fannr) 900 815 data->fan_conf = confreg[0] | (confreg[1] << 8); 901 816 902 - if ((err = i2c_attach_client(new_client))) 817 + if ((err = i2c_attach_client(client))) 903 818 goto ERROR2; 904 819 905 820 /* Use the correct reference voltage ··· 913 828 PC87365_REG_TEMP_CONFIG); 914 829 } 915 830 data->in_vref = (i&0x02) ? 3025 : 2966; 916 - dev_dbg(&new_client->dev, "Using %s reference voltage\n", 831 + dev_dbg(&client->dev, "Using %s reference voltage\n", 917 832 (i&0x02) ? "external" : "internal"); 918 833 919 834 data->vid_conf = confreg[3]; ··· 932 847 if (devid == 0xe9 && data->address[1]) /* PC87366 */ 933 848 use_thermistors = confreg[2] & 0x40; 934 849 935 - pc87360_init_client(new_client, use_thermistors); 850 + pc87360_init_client(client, use_thermistors); 936 851 } 937 852 938 853 /* Register sysfs hooks */ 939 - data->class_dev = hwmon_device_register(&new_client->dev); 854 + data->class_dev = hwmon_device_register(&client->dev); 940 855 if (IS_ERR(data->class_dev)) { 941 856 err = PTR_ERR(data->class_dev); 942 857 goto ERROR3; 943 858 } 944 859 945 860 if (data->innr) { 946 - device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); 947 - device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr); 948 - device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr); 949 - device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr); 950 - device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr); 951 - device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr); 952 - device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr); 953 - device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr); 954 - device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr); 955 - device_create_file(&new_client->dev, &sensor_dev_attr_in9_input.dev_attr); 956 - device_create_file(&new_client->dev, &sensor_dev_attr_in10_input.dev_attr); 957 - device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr); 958 - device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr); 959 - device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr); 960 - device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr); 961 - device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr); 962 - device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr); 963 - device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr); 964 - device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr); 965 - device_create_file(&new_client->dev, &sensor_dev_attr_in8_min.dev_attr); 966 - device_create_file(&new_client->dev, &sensor_dev_attr_in9_min.dev_attr); 967 - device_create_file(&new_client->dev, &sensor_dev_attr_in10_min.dev_attr); 968 - device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr); 969 - device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr); 970 - device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr); 971 - device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr); 972 - device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr); 973 - device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr); 974 - device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr); 975 - device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr); 976 - device_create_file(&new_client->dev, &sensor_dev_attr_in8_max.dev_attr); 977 - device_create_file(&new_client->dev, &sensor_dev_attr_in9_max.dev_attr); 978 - device_create_file(&new_client->dev, &sensor_dev_attr_in10_max.dev_attr); 979 - device_create_file(&new_client->dev, &sensor_dev_attr_in0_status.dev_attr); 980 - device_create_file(&new_client->dev, &sensor_dev_attr_in1_status.dev_attr); 981 - device_create_file(&new_client->dev, &sensor_dev_attr_in2_status.dev_attr); 982 - device_create_file(&new_client->dev, &sensor_dev_attr_in3_status.dev_attr); 983 - device_create_file(&new_client->dev, &sensor_dev_attr_in4_status.dev_attr); 984 - device_create_file(&new_client->dev, &sensor_dev_attr_in5_status.dev_attr); 985 - device_create_file(&new_client->dev, &sensor_dev_attr_in6_status.dev_attr); 986 - device_create_file(&new_client->dev, &sensor_dev_attr_in7_status.dev_attr); 987 - device_create_file(&new_client->dev, &sensor_dev_attr_in8_status.dev_attr); 988 - device_create_file(&new_client->dev, &sensor_dev_attr_in9_status.dev_attr); 989 - device_create_file(&new_client->dev, &sensor_dev_attr_in10_status.dev_attr); 990 - 991 - device_create_file(&new_client->dev, &dev_attr_cpu0_vid); 992 - device_create_file(&new_client->dev, &dev_attr_vrm); 993 - device_create_file(&new_client->dev, &dev_attr_alarms_in); 861 + for (i = 0; i < 11; i++) { 862 + device_create_file(dev, &in_input[i].dev_attr); 863 + device_create_file(dev, &in_min[i].dev_attr); 864 + device_create_file(dev, &in_max[i].dev_attr); 865 + device_create_file(dev, &in_status[i].dev_attr); 866 + } 867 + device_create_file(dev, &dev_attr_cpu0_vid); 868 + device_create_file(dev, &dev_attr_vrm); 869 + device_create_file(dev, &dev_attr_alarms_in); 994 870 } 995 871 996 872 if (data->tempnr) { 997 - device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr); 998 - device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr); 999 - device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr); 1000 - device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr); 1001 - device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr); 1002 - device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr); 1003 - device_create_file(&new_client->dev, &sensor_dev_attr_temp1_crit.dev_attr); 1004 - device_create_file(&new_client->dev, &sensor_dev_attr_temp2_crit.dev_attr); 1005 - device_create_file(&new_client->dev, &sensor_dev_attr_temp1_status.dev_attr); 1006 - device_create_file(&new_client->dev, &sensor_dev_attr_temp2_status.dev_attr); 873 + for (i = 0; i < data->tempnr; i++) { 874 + device_create_file(dev, &temp_input[i].dev_attr); 875 + device_create_file(dev, &temp_min[i].dev_attr); 876 + device_create_file(dev, &temp_max[i].dev_attr); 877 + device_create_file(dev, &temp_crit[i].dev_attr); 878 + device_create_file(dev, &temp_status[i].dev_attr); 879 + } 880 + device_create_file(dev, &dev_attr_alarms_temp); 881 + } 1007 882 1008 - device_create_file(&new_client->dev, &dev_attr_alarms_temp); 1009 - } 1010 - if (data->tempnr == 3) { 1011 - device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr); 1012 - device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr); 1013 - device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr); 1014 - device_create_file(&new_client->dev, &sensor_dev_attr_temp3_crit.dev_attr); 1015 - device_create_file(&new_client->dev, &sensor_dev_attr_temp3_status.dev_attr); 1016 - } 1017 883 if (data->innr == 14) { 1018 - device_create_file(&new_client->dev, &sensor_dev_attr_temp4_input.dev_attr); 1019 - device_create_file(&new_client->dev, &sensor_dev_attr_temp5_input.dev_attr); 1020 - device_create_file(&new_client->dev, &sensor_dev_attr_temp6_input.dev_attr); 1021 - device_create_file(&new_client->dev, &sensor_dev_attr_temp4_min.dev_attr); 1022 - device_create_file(&new_client->dev, &sensor_dev_attr_temp5_min.dev_attr); 1023 - device_create_file(&new_client->dev, &sensor_dev_attr_temp6_min.dev_attr); 1024 - device_create_file(&new_client->dev, &sensor_dev_attr_temp4_max.dev_attr); 1025 - device_create_file(&new_client->dev, &sensor_dev_attr_temp5_max.dev_attr); 1026 - device_create_file(&new_client->dev, &sensor_dev_attr_temp6_max.dev_attr); 1027 - device_create_file(&new_client->dev, &sensor_dev_attr_temp4_crit.dev_attr); 1028 - device_create_file(&new_client->dev, &sensor_dev_attr_temp5_crit.dev_attr); 1029 - device_create_file(&new_client->dev, &sensor_dev_attr_temp6_crit.dev_attr); 1030 - device_create_file(&new_client->dev, &sensor_dev_attr_temp4_status.dev_attr); 1031 - device_create_file(&new_client->dev, &sensor_dev_attr_temp5_status.dev_attr); 1032 - device_create_file(&new_client->dev, &sensor_dev_attr_temp6_status.dev_attr); 884 + for (i = 0; i < 3; i++) { 885 + device_create_file(dev, &therm_input[i].dev_attr); 886 + device_create_file(dev, &therm_min[i].dev_attr); 887 + device_create_file(dev, &therm_max[i].dev_attr); 888 + device_create_file(dev, &therm_crit[i].dev_attr); 889 + device_create_file(dev, &therm_status[i].dev_attr); 890 + } 1033 891 } 1034 892 1035 - if (data->fannr) { 1036 - if (FAN_CONFIG_MONITOR(data->fan_conf, 0)) { 1037 - device_create_file(&new_client->dev, 1038 - &sensor_dev_attr_fan1_input.dev_attr); 1039 - device_create_file(&new_client->dev, 1040 - &sensor_dev_attr_fan1_min.dev_attr); 1041 - device_create_file(&new_client->dev, 1042 - &sensor_dev_attr_fan1_div.dev_attr); 1043 - device_create_file(&new_client->dev, 1044 - &sensor_dev_attr_fan1_status.dev_attr); 893 + for (i = 0; i < data->fannr; i++) { 894 + if (FAN_CONFIG_MONITOR(data->fan_conf, i)) { 895 + device_create_file(dev, &fan_input[i].dev_attr); 896 + device_create_file(dev, &fan_min[i].dev_attr); 897 + device_create_file(dev, &fan_div[i].dev_attr); 898 + device_create_file(dev, &fan_status[i].dev_attr); 1045 899 } 1046 - 1047 - if (FAN_CONFIG_MONITOR(data->fan_conf, 1)) { 1048 - device_create_file(&new_client->dev, 1049 - &sensor_dev_attr_fan2_input.dev_attr); 1050 - device_create_file(&new_client->dev, 1051 - &sensor_dev_attr_fan2_min.dev_attr); 1052 - device_create_file(&new_client->dev, 1053 - &sensor_dev_attr_fan2_div.dev_attr); 1054 - device_create_file(&new_client->dev, 1055 - &sensor_dev_attr_fan2_status.dev_attr); 1056 - } 1057 - 1058 - if (FAN_CONFIG_CONTROL(data->fan_conf, 0)) 1059 - device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr); 1060 - if (FAN_CONFIG_CONTROL(data->fan_conf, 1)) 1061 - device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr); 1062 - } 1063 - if (data->fannr == 3) { 1064 - if (FAN_CONFIG_MONITOR(data->fan_conf, 2)) { 1065 - device_create_file(&new_client->dev, 1066 - &sensor_dev_attr_fan3_input.dev_attr); 1067 - device_create_file(&new_client->dev, 1068 - &sensor_dev_attr_fan3_min.dev_attr); 1069 - device_create_file(&new_client->dev, 1070 - &sensor_dev_attr_fan3_div.dev_attr); 1071 - device_create_file(&new_client->dev, 1072 - &sensor_dev_attr_fan3_status.dev_attr); 1073 - } 1074 - 1075 - if (FAN_CONFIG_CONTROL(data->fan_conf, 2)) 1076 - device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr); 900 + if (FAN_CONFIG_CONTROL(data->fan_conf, i)) 901 + device_create_file(dev, &pwm[i].dev_attr); 1077 902 } 1078 903 1079 904 return 0; 1080 905 1081 906 ERROR3: 1082 - i2c_detach_client(new_client); 907 + i2c_detach_client(client); 1083 908 ERROR2: 1084 909 for (i = 0; i < 3; i++) { 1085 910 if (data->address[i]) { ··· 1028 1033 { 1029 1034 int res; 1030 1035 1031 - down(&(data->lock)); 1036 + mutex_lock(&(data->lock)); 1032 1037 if (bank != NO_BANK) 1033 1038 outb_p(bank, data->address[ldi] + PC87365_REG_BANK); 1034 1039 res = inb_p(data->address[ldi] + reg); 1035 - up(&(data->lock)); 1040 + mutex_unlock(&(data->lock)); 1036 1041 1037 1042 return res; 1038 1043 } ··· 1040 1045 static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank, 1041 1046 u8 reg, u8 value) 1042 1047 { 1043 - down(&(data->lock)); 1048 + mutex_lock(&(data->lock)); 1044 1049 if (bank != NO_BANK) 1045 1050 outb_p(bank, data->address[ldi] + PC87365_REG_BANK); 1046 1051 outb_p(value, data->address[ldi] + reg); 1047 - up(&(data->lock)); 1052 + mutex_unlock(&(data->lock)); 1048 1053 } 1049 1054 1050 1055 static void pc87360_init_client(struct i2c_client *client, int use_thermistors) ··· 1066 1071 } 1067 1072 1068 1073 nr = data->innr < 11 ? data->innr : 11; 1069 - for (i=0; i<nr; i++) { 1074 + for (i = 0; i < nr; i++) { 1070 1075 if (init >= init_in[i]) { 1071 1076 /* Forcibly enable voltage channel */ 1072 1077 reg = pc87360_read_value(data, LD_IN, i, ··· 1083 1088 1084 1089 /* We can't blindly trust the Super-I/O space configuration bit, 1085 1090 most BIOS won't set it properly */ 1086 - for (i=11; i<data->innr; i++) { 1091 + for (i = 11; i < data->innr; i++) { 1087 1092 reg = pc87360_read_value(data, LD_IN, i, 1088 1093 PC87365_REG_TEMP_STATUS); 1089 1094 use_thermistors = use_thermistors || (reg & 0x01); 1090 1095 } 1091 1096 1092 1097 i = use_thermistors ? 2 : 0; 1093 - for (; i<data->tempnr; i++) { 1098 + for (; i < data->tempnr; i++) { 1094 1099 if (init >= init_temp[i]) { 1095 1100 /* Forcibly enable temperature channel */ 1096 1101 reg = pc87360_read_value(data, LD_TEMP, i, ··· 1106 1111 } 1107 1112 1108 1113 if (use_thermistors) { 1109 - for (i=11; i<data->innr; i++) { 1114 + for (i = 11; i < data->innr; i++) { 1110 1115 if (init >= init_in[i]) { 1111 1116 /* The pin may already be used by thermal 1112 1117 diodes */ ··· 1216 1221 struct pc87360_data *data = i2c_get_clientdata(client); 1217 1222 u8 i; 1218 1223 1219 - down(&data->update_lock); 1224 + mutex_lock(&data->update_lock); 1220 1225 1221 1226 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { 1222 1227 dev_dbg(&client->dev, "Data update\n"); ··· 1316 1321 data->valid = 1; 1317 1322 } 1318 1323 1319 - up(&data->update_lock); 1324 + mutex_unlock(&data->update_lock); 1320 1325 1321 1326 return data; 1322 1327 }
+26 -25
drivers/hwmon/sis5595.c
··· 60 60 #include <linux/err.h> 61 61 #include <linux/init.h> 62 62 #include <linux/jiffies.h> 63 + #include <linux/mutex.h> 63 64 #include <asm/io.h> 64 65 65 66 ··· 168 167 struct sis5595_data { 169 168 struct i2c_client client; 170 169 struct class_device *class_dev; 171 - struct semaphore lock; 170 + struct mutex lock; 172 171 173 - struct semaphore update_lock; 172 + struct mutex update_lock; 174 173 char valid; /* !=0 if following fields are valid */ 175 174 unsigned long last_updated; /* In jiffies */ 176 175 char maxins; /* == 3 if temp enabled, otherwise == 4 */ ··· 193 192 static int sis5595_detect(struct i2c_adapter *adapter); 194 193 static int sis5595_detach_client(struct i2c_client *client); 195 194 196 - static int sis5595_read_value(struct i2c_client *client, u8 register); 197 - static int sis5595_write_value(struct i2c_client *client, u8 register, u8 value); 195 + static int sis5595_read_value(struct i2c_client *client, u8 reg); 196 + static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value); 198 197 static struct sis5595_data *sis5595_update_device(struct device *dev); 199 198 static void sis5595_init_client(struct i2c_client *client); 200 199 ··· 232 231 struct sis5595_data *data = i2c_get_clientdata(client); 233 232 unsigned long val = simple_strtoul(buf, NULL, 10); 234 233 235 - down(&data->update_lock); 234 + mutex_lock(&data->update_lock); 236 235 data->in_min[nr] = IN_TO_REG(val); 237 236 sis5595_write_value(client, SIS5595_REG_IN_MIN(nr), data->in_min[nr]); 238 - up(&data->update_lock); 237 + mutex_unlock(&data->update_lock); 239 238 return count; 240 239 } 241 240 ··· 246 245 struct sis5595_data *data = i2c_get_clientdata(client); 247 246 unsigned long val = simple_strtoul(buf, NULL, 10); 248 247 249 - down(&data->update_lock); 248 + mutex_lock(&data->update_lock); 250 249 data->in_max[nr] = IN_TO_REG(val); 251 250 sis5595_write_value(client, SIS5595_REG_IN_MAX(nr), data->in_max[nr]); 252 - up(&data->update_lock); 251 + mutex_unlock(&data->update_lock); 253 252 return count; 254 253 } 255 254 ··· 311 310 struct sis5595_data *data = i2c_get_clientdata(client); 312 311 long val = simple_strtol(buf, NULL, 10); 313 312 314 - down(&data->update_lock); 313 + mutex_lock(&data->update_lock); 315 314 data->temp_over = TEMP_TO_REG(val); 316 315 sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over); 317 - up(&data->update_lock); 316 + mutex_unlock(&data->update_lock); 318 317 return count; 319 318 } 320 319 ··· 330 329 struct sis5595_data *data = i2c_get_clientdata(client); 331 330 long val = simple_strtol(buf, NULL, 10); 332 331 333 - down(&data->update_lock); 332 + mutex_lock(&data->update_lock); 334 333 data->temp_hyst = TEMP_TO_REG(val); 335 334 sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst); 336 - up(&data->update_lock); 335 + mutex_unlock(&data->update_lock); 337 336 return count; 338 337 } 339 338 ··· 365 364 struct sis5595_data *data = i2c_get_clientdata(client); 366 365 unsigned long val = simple_strtoul(buf, NULL, 10); 367 366 368 - down(&data->update_lock); 367 + mutex_lock(&data->update_lock); 369 368 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 370 369 sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]); 371 - up(&data->update_lock); 370 + mutex_unlock(&data->update_lock); 372 371 return count; 373 372 } 374 373 ··· 391 390 unsigned long val = simple_strtoul(buf, NULL, 10); 392 391 int reg; 393 392 394 - down(&data->update_lock); 393 + mutex_lock(&data->update_lock); 395 394 min = FAN_FROM_REG(data->fan_min[nr], 396 395 DIV_FROM_REG(data->fan_div[nr])); 397 396 reg = sis5595_read_value(client, SIS5595_REG_FANDIV); ··· 404 403 default: 405 404 dev_err(&client->dev, "fan_div value %ld not " 406 405 "supported. Choose one of 1, 2, 4 or 8!\n", val); 407 - up(&data->update_lock); 406 + mutex_unlock(&data->update_lock); 408 407 return -EINVAL; 409 408 } 410 409 ··· 420 419 data->fan_min[nr] = 421 420 FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 422 421 sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]); 423 - up(&data->update_lock); 422 + mutex_unlock(&data->update_lock); 424 423 return count; 425 424 } 426 425 ··· 528 527 529 528 new_client = &data->client; 530 529 new_client->addr = address; 531 - init_MUTEX(&data->lock); 530 + mutex_init(&data->lock); 532 531 i2c_set_clientdata(new_client, data); 533 532 new_client->adapter = adapter; 534 533 new_client->driver = &sis5595_driver; ··· 549 548 strlcpy(new_client->name, "sis5595", I2C_NAME_SIZE); 550 549 551 550 data->valid = 0; 552 - init_MUTEX(&data->update_lock); 551 + mutex_init(&data->update_lock); 553 552 554 553 /* Tell the I2C layer a new client has arrived */ 555 554 if ((err = i2c_attach_client(new_client))) ··· 636 635 int res; 637 636 638 637 struct sis5595_data *data = i2c_get_clientdata(client); 639 - down(&data->lock); 638 + mutex_lock(&data->lock); 640 639 outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET); 641 640 res = inb_p(client->addr + SIS5595_DATA_REG_OFFSET); 642 - up(&data->lock); 641 + mutex_unlock(&data->lock); 643 642 return res; 644 643 } 645 644 646 645 static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value) 647 646 { 648 647 struct sis5595_data *data = i2c_get_clientdata(client); 649 - down(&data->lock); 648 + mutex_lock(&data->lock); 650 649 outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET); 651 650 outb_p(value, client->addr + SIS5595_DATA_REG_OFFSET); 652 - up(&data->lock); 651 + mutex_unlock(&data->lock); 653 652 return 0; 654 653 } 655 654 ··· 668 667 struct sis5595_data *data = i2c_get_clientdata(client); 669 668 int i; 670 669 671 - down(&data->update_lock); 670 + mutex_lock(&data->update_lock); 672 671 673 672 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 674 673 || !data->valid) { ··· 708 707 data->valid = 1; 709 708 } 710 709 711 - up(&data->update_lock); 710 + mutex_unlock(&data->update_lock); 712 711 713 712 return data; 714 713 }
+9 -8
drivers/hwmon/smsc47b397.c
··· 35 35 #include <linux/hwmon.h> 36 36 #include <linux/err.h> 37 37 #include <linux/init.h> 38 + #include <linux/mutex.h> 38 39 #include <asm/io.h> 39 40 40 41 /* Address is autodetected, there is no default value */ ··· 93 92 struct smsc47b397_data { 94 93 struct i2c_client client; 95 94 struct class_device *class_dev; 96 - struct semaphore lock; 95 + struct mutex lock; 97 96 98 - struct semaphore update_lock; 97 + struct mutex update_lock; 99 98 unsigned long last_updated; /* in jiffies */ 100 99 int valid; 101 100 ··· 109 108 struct smsc47b397_data *data = i2c_get_clientdata(client); 110 109 int res; 111 110 112 - down(&data->lock); 111 + mutex_lock(&data->lock); 113 112 outb(reg, client->addr); 114 113 res = inb_p(client->addr + 1); 115 - up(&data->lock); 114 + mutex_unlock(&data->lock); 116 115 return res; 117 116 } 118 117 ··· 122 121 struct smsc47b397_data *data = i2c_get_clientdata(client); 123 122 int i; 124 123 125 - down(&data->update_lock); 124 + mutex_lock(&data->update_lock); 126 125 127 126 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { 128 127 dev_dbg(&client->dev, "starting device update...\n"); ··· 145 144 dev_dbg(&client->dev, "... device update complete\n"); 146 145 } 147 146 148 - up(&data->update_lock); 147 + mutex_unlock(&data->update_lock); 149 148 150 149 return data; 151 150 } ··· 255 254 new_client = &data->client; 256 255 i2c_set_clientdata(new_client, data); 257 256 new_client->addr = address; 258 - init_MUTEX(&data->lock); 257 + mutex_init(&data->lock); 259 258 new_client->adapter = adapter; 260 259 new_client->driver = &smsc47b397_driver; 261 260 new_client->flags = 0; 262 261 263 262 strlcpy(new_client->name, "smsc47b397", I2C_NAME_SIZE); 264 263 265 - init_MUTEX(&data->update_lock); 264 + mutex_init(&data->update_lock); 266 265 267 266 if ((err = i2c_attach_client(new_client))) 268 267 goto error_free;
+21 -20
drivers/hwmon/smsc47m1.c
··· 34 34 #include <linux/hwmon.h> 35 35 #include <linux/err.h> 36 36 #include <linux/init.h> 37 + #include <linux/mutex.h> 37 38 #include <asm/io.h> 38 39 39 40 /* Address is autodetected, there is no default value */ ··· 103 102 struct smsc47m1_data { 104 103 struct i2c_client client; 105 104 struct class_device *class_dev; 106 - struct semaphore lock; 105 + struct mutex lock; 107 106 108 - struct semaphore update_lock; 107 + struct mutex update_lock; 109 108 unsigned long last_updated; /* In jiffies */ 110 109 111 110 u8 fan[2]; /* Register value */ ··· 189 188 struct smsc47m1_data *data = i2c_get_clientdata(client); 190 189 long rpmdiv, val = simple_strtol(buf, NULL, 10); 191 190 192 - down(&data->update_lock); 191 + mutex_lock(&data->update_lock); 193 192 rpmdiv = val * DIV_FROM_REG(data->fan_div[nr]); 194 193 195 194 if (983040 > 192 * rpmdiv || 2 * rpmdiv > 983040) { 196 - up(&data->update_lock); 195 + mutex_unlock(&data->update_lock); 197 196 return -EINVAL; 198 197 } 199 198 200 199 data->fan_preload[nr] = 192 - ((983040 + rpmdiv / 2) / rpmdiv); 201 200 smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr), 202 201 data->fan_preload[nr]); 203 - up(&data->update_lock); 202 + mutex_unlock(&data->update_lock); 204 203 205 204 return count; 206 205 } ··· 221 220 if (new_div == old_div) /* No change */ 222 221 return count; 223 222 224 - down(&data->update_lock); 223 + mutex_lock(&data->update_lock); 225 224 switch (new_div) { 226 225 case 1: data->fan_div[nr] = 0; break; 227 226 case 2: data->fan_div[nr] = 1; break; 228 227 case 4: data->fan_div[nr] = 2; break; 229 228 case 8: data->fan_div[nr] = 3; break; 230 229 default: 231 - up(&data->update_lock); 230 + mutex_unlock(&data->update_lock); 232 231 return -EINVAL; 233 232 } 234 233 ··· 242 241 data->fan_preload[nr] = SENSORS_LIMIT(tmp, 0, 191); 243 242 smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr), 244 243 data->fan_preload[nr]); 245 - up(&data->update_lock); 244 + mutex_unlock(&data->update_lock); 246 245 247 246 return count; 248 247 } ··· 258 257 if (val < 0 || val > 255) 259 258 return -EINVAL; 260 259 261 - down(&data->update_lock); 260 + mutex_lock(&data->update_lock); 262 261 data->pwm[nr] &= 0x81; /* Preserve additional bits */ 263 262 data->pwm[nr] |= PWM_TO_REG(val); 264 263 smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr), 265 264 data->pwm[nr]); 266 - up(&data->update_lock); 265 + mutex_unlock(&data->update_lock); 267 266 268 267 return count; 269 268 } ··· 279 278 if (val != 0 && val != 1) 280 279 return -EINVAL; 281 280 282 - down(&data->update_lock); 281 + mutex_lock(&data->update_lock); 283 282 data->pwm[nr] &= 0xFE; /* preserve the other bits */ 284 283 data->pwm[nr] |= !val; 285 284 smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr), 286 285 data->pwm[nr]); 287 - up(&data->update_lock); 286 + mutex_unlock(&data->update_lock); 288 287 289 288 return count; 290 289 } ··· 409 408 new_client = &data->client; 410 409 i2c_set_clientdata(new_client, data); 411 410 new_client->addr = address; 412 - init_MUTEX(&data->lock); 411 + mutex_init(&data->lock); 413 412 new_client->adapter = adapter; 414 413 new_client->driver = &smsc47m1_driver; 415 414 new_client->flags = 0; 416 415 417 416 strlcpy(new_client->name, "smsc47m1", I2C_NAME_SIZE); 418 - init_MUTEX(&data->update_lock); 417 + mutex_init(&data->update_lock); 419 418 420 419 /* If no function is properly configured, there's no point in 421 420 actually registering the chip. */ ··· 513 512 { 514 513 int res; 515 514 516 - down(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); 515 + mutex_lock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); 517 516 res = inb_p(client->addr + reg); 518 - up(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); 517 + mutex_unlock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); 519 518 return res; 520 519 } 521 520 522 521 static void smsc47m1_write_value(struct i2c_client *client, u8 reg, u8 value) 523 522 { 524 - down(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); 523 + mutex_lock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); 525 524 outb_p(value, client->addr + reg); 526 - up(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); 525 + mutex_unlock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); 527 526 } 528 527 529 528 static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, ··· 532 531 struct i2c_client *client = to_i2c_client(dev); 533 532 struct smsc47m1_data *data = i2c_get_clientdata(client); 534 533 535 - down(&data->update_lock); 534 + mutex_lock(&data->update_lock); 536 535 537 536 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || init) { 538 537 int i; ··· 559 558 data->last_updated = jiffies; 560 559 } 561 560 562 - up(&data->update_lock); 561 + mutex_unlock(&data->update_lock); 563 562 return data; 564 563 } 565 564
+17 -16
drivers/hwmon/via686a.c
··· 39 39 #include <linux/hwmon.h> 40 40 #include <linux/err.h> 41 41 #include <linux/init.h> 42 + #include <linux/mutex.h> 42 43 #include <asm/io.h> 43 44 44 45 ··· 297 296 struct via686a_data { 298 297 struct i2c_client client; 299 298 struct class_device *class_dev; 300 - struct semaphore update_lock; 299 + struct mutex update_lock; 301 300 char valid; /* !=0 if following fields are valid */ 302 301 unsigned long last_updated; /* In jiffies */ 303 302 ··· 356 355 struct via686a_data *data = i2c_get_clientdata(client); 357 356 unsigned long val = simple_strtoul(buf, NULL, 10); 358 357 359 - down(&data->update_lock); 358 + mutex_lock(&data->update_lock); 360 359 data->in_min[nr] = IN_TO_REG(val, nr); 361 360 via686a_write_value(client, VIA686A_REG_IN_MIN(nr), 362 361 data->in_min[nr]); 363 - up(&data->update_lock); 362 + mutex_unlock(&data->update_lock); 364 363 return count; 365 364 } 366 365 static ssize_t set_in_max(struct device *dev, const char *buf, ··· 369 368 struct via686a_data *data = i2c_get_clientdata(client); 370 369 unsigned long val = simple_strtoul(buf, NULL, 10); 371 370 372 - down(&data->update_lock); 371 + mutex_lock(&data->update_lock); 373 372 data->in_max[nr] = IN_TO_REG(val, nr); 374 373 via686a_write_value(client, VIA686A_REG_IN_MAX(nr), 375 374 data->in_max[nr]); 376 - up(&data->update_lock); 375 + mutex_unlock(&data->update_lock); 377 376 return count; 378 377 } 379 378 #define show_in_offset(offset) \ ··· 433 432 struct via686a_data *data = i2c_get_clientdata(client); 434 433 int val = simple_strtol(buf, NULL, 10); 435 434 436 - down(&data->update_lock); 435 + mutex_lock(&data->update_lock); 437 436 data->temp_over[nr] = TEMP_TO_REG(val); 438 437 via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr], 439 438 data->temp_over[nr]); 440 - up(&data->update_lock); 439 + mutex_unlock(&data->update_lock); 441 440 return count; 442 441 } 443 442 static ssize_t set_temp_hyst(struct device *dev, const char *buf, ··· 446 445 struct via686a_data *data = i2c_get_clientdata(client); 447 446 int val = simple_strtol(buf, NULL, 10); 448 447 449 - down(&data->update_lock); 448 + mutex_lock(&data->update_lock); 450 449 data->temp_hyst[nr] = TEMP_TO_REG(val); 451 450 via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr], 452 451 data->temp_hyst[nr]); 453 - up(&data->update_lock); 452 + mutex_unlock(&data->update_lock); 454 453 return count; 455 454 } 456 455 #define show_temp_offset(offset) \ ··· 509 508 struct via686a_data *data = i2c_get_clientdata(client); 510 509 int val = simple_strtol(buf, NULL, 10); 511 510 512 - down(&data->update_lock); 511 + mutex_lock(&data->update_lock); 513 512 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 514 513 via686a_write_value(client, VIA686A_REG_FAN_MIN(nr+1), data->fan_min[nr]); 515 - up(&data->update_lock); 514 + mutex_unlock(&data->update_lock); 516 515 return count; 517 516 } 518 517 static ssize_t set_fan_div(struct device *dev, const char *buf, ··· 522 521 int val = simple_strtol(buf, NULL, 10); 523 522 int old; 524 523 525 - down(&data->update_lock); 524 + mutex_lock(&data->update_lock); 526 525 old = via686a_read_value(client, VIA686A_REG_FANDIV); 527 526 data->fan_div[nr] = DIV_TO_REG(val); 528 527 old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); 529 528 via686a_write_value(client, VIA686A_REG_FANDIV, old); 530 - up(&data->update_lock); 529 + mutex_unlock(&data->update_lock); 531 530 return count; 532 531 } 533 532 ··· 640 639 strlcpy(new_client->name, client_name, I2C_NAME_SIZE); 641 640 642 641 data->valid = 0; 643 - init_MUTEX(&data->update_lock); 642 + mutex_init(&data->update_lock); 644 643 /* Tell the I2C layer a new client has arrived */ 645 644 if ((err = i2c_attach_client(new_client))) 646 645 goto exit_free; ··· 734 733 struct via686a_data *data = i2c_get_clientdata(client); 735 734 int i; 736 735 737 - down(&data->update_lock); 736 + mutex_lock(&data->update_lock); 738 737 739 738 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 740 739 || !data->valid) { ··· 789 788 data->valid = 1; 790 789 } 791 790 792 - up(&data->update_lock); 791 + mutex_unlock(&data->update_lock); 793 792 794 793 return data; 795 794 }
+26 -25
drivers/hwmon/vt8231.c
··· 35 35 #include <linux/hwmon-sysfs.h> 36 36 #include <linux/hwmon-vid.h> 37 37 #include <linux/err.h> 38 + #include <linux/mutex.h> 38 39 #include <asm/io.h> 39 40 40 41 static int force_addr; ··· 149 148 150 149 struct vt8231_data { 151 150 struct i2c_client client; 152 - struct semaphore update_lock; 151 + struct mutex update_lock; 153 152 struct class_device *class_dev; 154 153 char valid; /* !=0 if following fields are valid */ 155 154 unsigned long last_updated; /* In jiffies */ ··· 224 223 struct vt8231_data *data = i2c_get_clientdata(client); 225 224 unsigned long val = simple_strtoul(buf, NULL, 10); 226 225 227 - down(&data->update_lock); 226 + mutex_lock(&data->update_lock); 228 227 data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); 229 228 vt8231_write_value(client, regvoltmin[nr], data->in_min[nr]); 230 - up(&data->update_lock); 229 + mutex_unlock(&data->update_lock); 231 230 return count; 232 231 } 233 232 ··· 240 239 struct vt8231_data *data = i2c_get_clientdata(client); 241 240 unsigned long val = simple_strtoul(buf, NULL, 10); 242 241 243 - down(&data->update_lock); 242 + mutex_lock(&data->update_lock); 244 243 data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); 245 244 vt8231_write_value(client, regvoltmax[nr], data->in_max[nr]); 246 - up(&data->update_lock); 245 + mutex_unlock(&data->update_lock); 247 246 return count; 248 247 } 249 248 ··· 282 281 struct vt8231_data *data = i2c_get_clientdata(client); 283 282 unsigned long val = simple_strtoul(buf, NULL, 10); 284 283 285 - down(&data->update_lock); 284 + mutex_lock(&data->update_lock); 286 285 data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, 287 286 0, 255); 288 287 vt8231_write_value(client, regvoltmin[5], data->in_min[5]); 289 - up(&data->update_lock); 288 + mutex_unlock(&data->update_lock); 290 289 return count; 291 290 } 292 291 ··· 297 296 struct vt8231_data *data = i2c_get_clientdata(client); 298 297 unsigned long val = simple_strtoul(buf, NULL, 10); 299 298 300 - down(&data->update_lock); 299 + mutex_lock(&data->update_lock); 301 300 data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, 302 301 0, 255); 303 302 vt8231_write_value(client, regvoltmax[5], data->in_max[5]); 304 - up(&data->update_lock); 303 + mutex_unlock(&data->update_lock); 305 304 return count; 306 305 } 307 306 ··· 352 351 struct vt8231_data *data = i2c_get_clientdata(client); 353 352 int val = simple_strtol(buf, NULL, 10); 354 353 355 - down(&data->update_lock); 354 + mutex_lock(&data->update_lock); 356 355 data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); 357 356 vt8231_write_value(client, regtempmax[0], data->temp_max[0]); 358 - up(&data->update_lock); 357 + mutex_unlock(&data->update_lock); 359 358 return count; 360 359 } 361 360 static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, ··· 365 364 struct vt8231_data *data = i2c_get_clientdata(client); 366 365 int val = simple_strtol(buf, NULL, 10); 367 366 368 - down(&data->update_lock); 367 + mutex_lock(&data->update_lock); 369 368 data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); 370 369 vt8231_write_value(client, regtempmin[0], data->temp_min[0]); 371 - up(&data->update_lock); 370 + mutex_unlock(&data->update_lock); 372 371 return count; 373 372 } 374 373 ··· 408 407 struct vt8231_data *data = i2c_get_clientdata(client); 409 408 int val = simple_strtol(buf, NULL, 10); 410 409 411 - down(&data->update_lock); 410 + mutex_lock(&data->update_lock); 412 411 data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); 413 412 vt8231_write_value(client, regtempmax[nr], data->temp_max[nr]); 414 - up(&data->update_lock); 413 + mutex_unlock(&data->update_lock); 415 414 return count; 416 415 } 417 416 static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, ··· 423 422 struct vt8231_data *data = i2c_get_clientdata(client); 424 423 int val = simple_strtol(buf, NULL, 10); 425 424 426 - down(&data->update_lock); 425 + mutex_lock(&data->update_lock); 427 426 data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); 428 427 vt8231_write_value(client, regtempmin[nr], data->temp_min[nr]); 429 - up(&data->update_lock); 428 + mutex_unlock(&data->update_lock); 430 429 return count; 431 430 } 432 431 ··· 521 520 struct vt8231_data *data = i2c_get_clientdata(client); 522 521 int val = simple_strtoul(buf, NULL, 10); 523 522 524 - down(&data->update_lock); 523 + mutex_lock(&data->update_lock); 525 524 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 526 525 vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]); 527 - up(&data->update_lock); 526 + mutex_unlock(&data->update_lock); 528 527 return count; 529 528 } 530 529 ··· 540 539 long min = FAN_FROM_REG(data->fan_min[nr], 541 540 DIV_FROM_REG(data->fan_div[nr])); 542 541 543 - down(&data->update_lock); 542 + mutex_lock(&data->update_lock); 544 543 switch (val) { 545 544 case 1: data->fan_div[nr] = 0; break; 546 545 case 2: data->fan_div[nr] = 1; break; ··· 549 548 default: 550 549 dev_err(&client->dev, "fan_div value %ld not supported." 551 550 "Choose one of 1, 2, 4 or 8!\n", val); 552 - up(&data->update_lock); 551 + mutex_unlock(&data->update_lock); 553 552 return -EINVAL; 554 553 } 555 554 ··· 559 558 560 559 old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); 561 560 vt8231_write_value(client, VT8231_REG_FANDIV, old); 562 - up(&data->update_lock); 561 + mutex_unlock(&data->update_lock); 563 562 return count; 564 563 } 565 564 ··· 661 660 /* Fill in the remaining client fields and put into the global list */ 662 661 strlcpy(client->name, "vt8231", I2C_NAME_SIZE); 663 662 664 - init_MUTEX(&data->update_lock); 663 + mutex_init(&data->update_lock); 665 664 666 665 /* Tell the I2C layer a new client has arrived */ 667 666 if ((err = i2c_attach_client(client))) ··· 746 745 int i; 747 746 u16 low; 748 747 749 - down(&data->update_lock); 748 + mutex_lock(&data->update_lock); 750 749 751 750 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 752 751 || !data->valid) { ··· 805 804 data->valid = 1; 806 805 } 807 806 808 - up(&data->update_lock); 807 + mutex_unlock(&data->update_lock); 809 808 810 809 return data; 811 810 }
+96 -141
drivers/hwmon/w83627ehf.c
··· 42 42 #include <linux/i2c.h> 43 43 #include <linux/i2c-isa.h> 44 44 #include <linux/hwmon.h> 45 + #include <linux/hwmon-sysfs.h> 45 46 #include <linux/err.h> 47 + #include <linux/mutex.h> 46 48 #include <asm/io.h> 47 49 #include "lm75.h" 48 50 ··· 179 177 struct w83627ehf_data { 180 178 struct i2c_client client; 181 179 struct class_device *class_dev; 182 - struct semaphore lock; 180 + struct mutex lock; 183 181 184 - struct semaphore update_lock; 182 + struct mutex update_lock; 185 183 char valid; /* !=0 if following fields are valid */ 186 184 unsigned long last_updated; /* In jiffies */ 187 185 ··· 232 230 struct w83627ehf_data *data = i2c_get_clientdata(client); 233 231 int res, word_sized = is_word_sized(reg); 234 232 235 - down(&data->lock); 233 + mutex_lock(&data->lock); 236 234 237 235 w83627ehf_set_bank(client, reg); 238 236 outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); ··· 244 242 } 245 243 w83627ehf_reset_bank(client, reg); 246 244 247 - up(&data->lock); 245 + mutex_unlock(&data->lock); 248 246 249 247 return res; 250 248 } ··· 254 252 struct w83627ehf_data *data = i2c_get_clientdata(client); 255 253 int word_sized = is_word_sized(reg); 256 254 257 - down(&data->lock); 255 + mutex_lock(&data->lock); 258 256 259 257 w83627ehf_set_bank(client, reg); 260 258 outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); ··· 266 264 outb_p(value & 0xff, client->addr + DATA_REG_OFFSET); 267 265 w83627ehf_reset_bank(client, reg); 268 266 269 - up(&data->lock); 267 + mutex_unlock(&data->lock); 270 268 return 0; 271 269 } 272 270 ··· 324 322 struct w83627ehf_data *data = i2c_get_clientdata(client); 325 323 int i; 326 324 327 - down(&data->update_lock); 325 + mutex_lock(&data->update_lock); 328 326 329 327 if (time_after(jiffies, data->last_updated + HZ) 330 328 || !data->valid) { ··· 399 397 data->valid = 1; 400 398 } 401 399 402 - up(&data->update_lock); 400 + mutex_unlock(&data->update_lock); 403 401 return data; 404 402 } 405 403 ··· 409 407 410 408 #define show_fan_reg(reg) \ 411 409 static ssize_t \ 412 - show_##reg(struct device *dev, char *buf, int nr) \ 410 + show_##reg(struct device *dev, struct device_attribute *attr, \ 411 + char *buf) \ 413 412 { \ 414 413 struct w83627ehf_data *data = w83627ehf_update_device(dev); \ 414 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ 415 + int nr = sensor_attr->index; \ 415 416 return sprintf(buf, "%d\n", \ 416 417 fan_from_reg(data->reg[nr], \ 417 418 div_from_reg(data->fan_div[nr]))); \ ··· 423 418 show_fan_reg(fan_min); 424 419 425 420 static ssize_t 426 - show_fan_div(struct device *dev, char *buf, int nr) 421 + show_fan_div(struct device *dev, struct device_attribute *attr, 422 + char *buf) 427 423 { 428 424 struct w83627ehf_data *data = w83627ehf_update_device(dev); 429 - return sprintf(buf, "%u\n", 430 - div_from_reg(data->fan_div[nr])); 425 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 426 + int nr = sensor_attr->index; 427 + return sprintf(buf, "%u\n", div_from_reg(data->fan_div[nr])); 431 428 } 432 429 433 430 static ssize_t 434 - store_fan_min(struct device *dev, const char *buf, size_t count, int nr) 431 + store_fan_min(struct device *dev, struct device_attribute *attr, 432 + const char *buf, size_t count) 435 433 { 436 434 struct i2c_client *client = to_i2c_client(dev); 437 435 struct w83627ehf_data *data = i2c_get_clientdata(client); 436 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 437 + int nr = sensor_attr->index; 438 438 unsigned int val = simple_strtoul(buf, NULL, 10); 439 439 unsigned int reg; 440 440 u8 new_div; 441 441 442 - down(&data->update_lock); 442 + mutex_lock(&data->update_lock); 443 443 if (!val) { 444 444 /* No min limit, alarm disabled */ 445 445 data->fan_min[nr] = 255; ··· 492 482 } 493 483 w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr], 494 484 data->fan_min[nr]); 495 - up(&data->update_lock); 485 + mutex_unlock(&data->update_lock); 496 486 497 487 return count; 498 488 } 499 489 500 - #define sysfs_fan_offset(offset) \ 501 - static ssize_t \ 502 - show_reg_fan_##offset(struct device *dev, struct device_attribute *attr, \ 503 - char *buf) \ 504 - { \ 505 - return show_fan(dev, buf, offset-1); \ 506 - } \ 507 - static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ 508 - show_reg_fan_##offset, NULL); 490 + static struct sensor_device_attribute sda_fan_input[] = { 491 + SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0), 492 + SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1), 493 + SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2), 494 + SENSOR_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3), 495 + SENSOR_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 4), 496 + }; 509 497 510 - #define sysfs_fan_min_offset(offset) \ 511 - static ssize_t \ 512 - show_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ 513 - char *buf) \ 514 - { \ 515 - return show_fan_min(dev, buf, offset-1); \ 516 - } \ 517 - static ssize_t \ 518 - store_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ 519 - const char *buf, size_t count) \ 520 - { \ 521 - return store_fan_min(dev, buf, count, offset-1); \ 522 - } \ 523 - static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ 524 - show_reg_fan##offset##_min, \ 525 - store_reg_fan##offset##_min); 498 + static struct sensor_device_attribute sda_fan_min[] = { 499 + SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, 500 + store_fan_min, 0), 501 + SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, 502 + store_fan_min, 1), 503 + SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, 504 + store_fan_min, 2), 505 + SENSOR_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min, 506 + store_fan_min, 3), 507 + SENSOR_ATTR(fan5_min, S_IWUSR | S_IRUGO, show_fan_min, 508 + store_fan_min, 4), 509 + }; 526 510 527 - #define sysfs_fan_div_offset(offset) \ 528 - static ssize_t \ 529 - show_reg_fan##offset##_div(struct device *dev, struct device_attribute *attr, \ 530 - char *buf) \ 531 - { \ 532 - return show_fan_div(dev, buf, offset - 1); \ 533 - } \ 534 - static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ 535 - show_reg_fan##offset##_div, NULL); 511 + static struct sensor_device_attribute sda_fan_div[] = { 512 + SENSOR_ATTR(fan1_div, S_IRUGO, show_fan_div, NULL, 0), 513 + SENSOR_ATTR(fan2_div, S_IRUGO, show_fan_div, NULL, 1), 514 + SENSOR_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2), 515 + SENSOR_ATTR(fan4_div, S_IRUGO, show_fan_div, NULL, 3), 516 + SENSOR_ATTR(fan5_div, S_IRUGO, show_fan_div, NULL, 4), 517 + }; 536 518 537 - sysfs_fan_offset(1); 538 - sysfs_fan_min_offset(1); 539 - sysfs_fan_div_offset(1); 540 - sysfs_fan_offset(2); 541 - sysfs_fan_min_offset(2); 542 - sysfs_fan_div_offset(2); 543 - sysfs_fan_offset(3); 544 - sysfs_fan_min_offset(3); 545 - sysfs_fan_div_offset(3); 546 - sysfs_fan_offset(4); 547 - sysfs_fan_min_offset(4); 548 - sysfs_fan_div_offset(4); 549 - sysfs_fan_offset(5); 550 - sysfs_fan_min_offset(5); 551 - sysfs_fan_div_offset(5); 519 + static void device_create_file_fan(struct device *dev, int i) 520 + { 521 + device_create_file(dev, &sda_fan_input[i].dev_attr); 522 + device_create_file(dev, &sda_fan_div[i].dev_attr); 523 + device_create_file(dev, &sda_fan_min[i].dev_attr); 524 + } 552 525 553 526 #define show_temp1_reg(reg) \ 554 527 static ssize_t \ ··· 554 561 struct w83627ehf_data *data = i2c_get_clientdata(client); \ 555 562 u32 val = simple_strtoul(buf, NULL, 10); \ 556 563 \ 557 - down(&data->update_lock); \ 564 + mutex_lock(&data->update_lock); \ 558 565 data->temp1_##reg = temp1_to_reg(val); \ 559 566 w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \ 560 567 data->temp1_##reg); \ 561 - up(&data->update_lock); \ 568 + mutex_unlock(&data->update_lock); \ 562 569 return count; \ 563 570 } 564 571 store_temp1_reg(OVER, max); 565 572 store_temp1_reg(HYST, max_hyst); 566 573 567 - static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL); 568 - static DEVICE_ATTR(temp1_max, S_IRUGO| S_IWUSR, 569 - show_temp1_max, store_temp1_max); 570 - static DEVICE_ATTR(temp1_max_hyst, S_IRUGO| S_IWUSR, 571 - show_temp1_max_hyst, store_temp1_max_hyst); 572 - 573 574 #define show_temp_reg(reg) \ 574 575 static ssize_t \ 575 - show_##reg (struct device *dev, char *buf, int nr) \ 576 + show_##reg(struct device *dev, struct device_attribute *attr, \ 577 + char *buf) \ 576 578 { \ 577 579 struct w83627ehf_data *data = w83627ehf_update_device(dev); \ 580 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ 581 + int nr = sensor_attr->index; \ 578 582 return sprintf(buf, "%d\n", \ 579 583 LM75_TEMP_FROM_REG(data->reg[nr])); \ 580 584 } ··· 581 591 582 592 #define store_temp_reg(REG, reg) \ 583 593 static ssize_t \ 584 - store_##reg (struct device *dev, const char *buf, size_t count, int nr) \ 594 + store_##reg(struct device *dev, struct device_attribute *attr, \ 595 + const char *buf, size_t count) \ 585 596 { \ 586 597 struct i2c_client *client = to_i2c_client(dev); \ 587 598 struct w83627ehf_data *data = i2c_get_clientdata(client); \ 599 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ 600 + int nr = sensor_attr->index; \ 588 601 u32 val = simple_strtoul(buf, NULL, 10); \ 589 602 \ 590 - down(&data->update_lock); \ 603 + mutex_lock(&data->update_lock); \ 591 604 data->reg[nr] = LM75_TEMP_TO_REG(val); \ 592 605 w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \ 593 606 data->reg[nr]); \ 594 - up(&data->update_lock); \ 607 + mutex_unlock(&data->update_lock); \ 595 608 return count; \ 596 609 } 597 610 store_temp_reg(OVER, temp_max); 598 611 store_temp_reg(HYST, temp_max_hyst); 599 612 600 - #define sysfs_temp_offset(offset) \ 601 - static ssize_t \ 602 - show_reg_temp##offset (struct device *dev, struct device_attribute *attr, \ 603 - char *buf) \ 604 - { \ 605 - return show_temp(dev, buf, offset - 2); \ 606 - } \ 607 - static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ 608 - show_reg_temp##offset, NULL); 609 - 610 - #define sysfs_temp_reg_offset(reg, offset) \ 611 - static ssize_t \ 612 - show_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ 613 - char *buf) \ 614 - { \ 615 - return show_temp_##reg(dev, buf, offset - 2); \ 616 - } \ 617 - static ssize_t \ 618 - store_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ 619 - const char *buf, size_t count) \ 620 - { \ 621 - return store_temp_##reg(dev, buf, count, offset - 2); \ 622 - } \ 623 - static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \ 624 - show_reg_temp##offset##_##reg, \ 625 - store_reg_temp##offset##_##reg); 626 - 627 - sysfs_temp_offset(2); 628 - sysfs_temp_reg_offset(max, 2); 629 - sysfs_temp_reg_offset(max_hyst, 2); 630 - sysfs_temp_offset(3); 631 - sysfs_temp_reg_offset(max, 3); 632 - sysfs_temp_reg_offset(max_hyst, 3); 613 + static struct sensor_device_attribute sda_temp[] = { 614 + SENSOR_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0), 615 + SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 0), 616 + SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 1), 617 + SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp1_max, 618 + store_temp1_max, 0), 619 + SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, show_temp_max, 620 + store_temp_max, 0), 621 + SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, show_temp_max, 622 + store_temp_max, 1), 623 + SENSOR_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1_max_hyst, 624 + store_temp1_max_hyst, 0), 625 + SENSOR_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst, 626 + store_temp_max_hyst, 0), 627 + SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst, 628 + store_temp_max_hyst, 1), 629 + }; 633 630 634 631 /* 635 632 * Driver and client management ··· 650 673 { 651 674 struct i2c_client *client; 652 675 struct w83627ehf_data *data; 676 + struct device *dev; 653 677 int i, err = 0; 654 678 655 679 if (!request_region(address + REGION_OFFSET, REGION_LENGTH, ··· 667 689 client = &data->client; 668 690 i2c_set_clientdata(client, data); 669 691 client->addr = address; 670 - init_MUTEX(&data->lock); 692 + mutex_init(&data->lock); 671 693 client->adapter = adapter; 672 694 client->driver = &w83627ehf_driver; 673 695 client->flags = 0; 696 + dev = &client->dev; 674 697 675 698 strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE); 676 699 data->valid = 0; 677 - init_MUTEX(&data->update_lock); 700 + mutex_init(&data->update_lock); 678 701 679 702 /* Tell the i2c layer a new client has arrived */ 680 703 if ((err = i2c_attach_client(client))) ··· 699 720 data->has_fan |= (1 << 4); 700 721 701 722 /* Register sysfs hooks */ 702 - data->class_dev = hwmon_device_register(&client->dev); 723 + data->class_dev = hwmon_device_register(dev); 703 724 if (IS_ERR(data->class_dev)) { 704 725 err = PTR_ERR(data->class_dev); 705 726 goto exit_detach; 706 727 } 707 728 708 - device_create_file(&client->dev, &dev_attr_fan1_input); 709 - device_create_file(&client->dev, &dev_attr_fan1_min); 710 - device_create_file(&client->dev, &dev_attr_fan1_div); 711 - device_create_file(&client->dev, &dev_attr_fan2_input); 712 - device_create_file(&client->dev, &dev_attr_fan2_min); 713 - device_create_file(&client->dev, &dev_attr_fan2_div); 714 - device_create_file(&client->dev, &dev_attr_fan3_input); 715 - device_create_file(&client->dev, &dev_attr_fan3_min); 716 - device_create_file(&client->dev, &dev_attr_fan3_div); 717 - 718 - if (data->has_fan & (1 << 3)) { 719 - device_create_file(&client->dev, &dev_attr_fan4_input); 720 - device_create_file(&client->dev, &dev_attr_fan4_min); 721 - device_create_file(&client->dev, &dev_attr_fan4_div); 729 + for (i = 0; i < 5; i++) { 730 + if (data->has_fan & (1 << i)) 731 + device_create_file_fan(dev, i); 722 732 } 723 - if (data->has_fan & (1 << 4)) { 724 - device_create_file(&client->dev, &dev_attr_fan5_input); 725 - device_create_file(&client->dev, &dev_attr_fan5_min); 726 - device_create_file(&client->dev, &dev_attr_fan5_div); 727 - } 728 - 729 - device_create_file(&client->dev, &dev_attr_temp1_input); 730 - device_create_file(&client->dev, &dev_attr_temp1_max); 731 - device_create_file(&client->dev, &dev_attr_temp1_max_hyst); 732 - device_create_file(&client->dev, &dev_attr_temp2_input); 733 - device_create_file(&client->dev, &dev_attr_temp2_max); 734 - device_create_file(&client->dev, &dev_attr_temp2_max_hyst); 735 - device_create_file(&client->dev, &dev_attr_temp3_input); 736 - device_create_file(&client->dev, &dev_attr_temp3_max); 737 - device_create_file(&client->dev, &dev_attr_temp3_max_hyst); 733 + for (i = 0; i < ARRAY_SIZE(sda_temp); i++) 734 + device_create_file(dev, &sda_temp[i].dev_attr); 738 735 739 736 return 0; 740 737
+89 -45
drivers/hwmon/w83627hf.c
··· 28 28 w83627hf 9 3 2 3 0x20 0x5ca3 no yes(LPC) 29 29 w83627thf 7 3 3 3 0x90 0x5ca3 no yes(LPC) 30 30 w83637hf 7 3 3 3 0x80 0x5ca3 no yes(LPC) 31 + w83687thf 7 3 3 3 0x90 0x5ca3 no yes(LPC) 31 32 w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC) 32 33 33 34 For other winbond chips, and for i2c support in the above chips, ··· 47 46 #include <linux/hwmon.h> 48 47 #include <linux/hwmon-vid.h> 49 48 #include <linux/err.h> 49 + #include <linux/mutex.h> 50 50 #include <asm/io.h> 51 51 #include "lm75.h" 52 52 ··· 64 62 static unsigned short address; 65 63 66 64 /* Insmod parameters */ 67 - enum chips { any_chip, w83627hf, w83627thf, w83697hf, w83637hf }; 65 + enum chips { any_chip, w83627hf, w83627thf, w83697hf, w83637hf, w83687thf }; 68 66 69 67 static int reset; 70 68 module_param(reset, bool, 0); ··· 101 99 #define W83627THF_GPIO5_EN 0x30 /* w83627thf only */ 102 100 #define W83627THF_GPIO5_IOSR 0xf3 /* w83627thf only */ 103 101 #define W83627THF_GPIO5_DR 0xf4 /* w83627thf only */ 102 + 103 + #define W83687THF_VID_EN 0x29 /* w83687thf only */ 104 + #define W83687THF_VID_CFG 0xF0 /* w83687thf only */ 105 + #define W83687THF_VID_DATA 0xF1 /* w83687thf only */ 104 106 105 107 static inline void 106 108 superio_outb(int reg, int val) ··· 144 138 #define W627THF_DEVID 0x82 145 139 #define W697_DEVID 0x60 146 140 #define W637_DEVID 0x70 141 + #define W687THF_DEVID 0x85 147 142 #define WINB_ACT_REG 0x30 148 143 #define WINB_BASE_REG 0x60 149 144 /* Constants specified below */ ··· 208 201 #define W83627HF_REG_PWM1 0x5A 209 202 #define W83627HF_REG_PWM2 0x5B 210 203 211 - #define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */ 212 - #define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */ 213 - #define W83627THF_REG_PWM3 0x11 /* 637HF too */ 204 + #define W83627THF_REG_PWM1 0x01 /* 697HF/637HF/687THF too */ 205 + #define W83627THF_REG_PWM2 0x03 /* 697HF/637HF/687THF too */ 206 + #define W83627THF_REG_PWM3 0x11 /* 637HF/687THF too */ 214 207 215 - #define W83627THF_REG_VRM_OVT_CFG 0x18 /* 637HF too */ 208 + #define W83627THF_REG_VRM_OVT_CFG 0x18 /* 637HF/687THF too */ 216 209 217 210 static const u8 regpwm_627hf[] = { W83627HF_REG_PWM1, W83627HF_REG_PWM2 }; 218 211 static const u8 regpwm[] = { W83627THF_REG_PWM1, W83627THF_REG_PWM2, ··· 292 285 struct w83627hf_data { 293 286 struct i2c_client client; 294 287 struct class_device *class_dev; 295 - struct semaphore lock; 288 + struct mutex lock; 296 289 enum chips type; 297 290 298 - struct semaphore update_lock; 291 + struct mutex update_lock; 299 292 char valid; /* !=0 if following fields are valid */ 300 293 unsigned long last_updated; /* In jiffies */ 301 294 ··· 325 318 Default = 3435. 326 319 Other Betas unimplemented */ 327 320 u8 vrm; 328 - u8 vrm_ovt; /* Register value, 627thf & 637hf only */ 321 + u8 vrm_ovt; /* Register value, 627THF/637HF/687THF only */ 329 322 }; 330 323 331 324 332 325 static int w83627hf_detect(struct i2c_adapter *adapter); 333 326 static int w83627hf_detach_client(struct i2c_client *client); 334 327 335 - static int w83627hf_read_value(struct i2c_client *client, u16 register); 336 - static int w83627hf_write_value(struct i2c_client *client, u16 register, 337 - u16 value); 328 + static int w83627hf_read_value(struct i2c_client *client, u16 reg); 329 + static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value); 338 330 static struct w83627hf_data *w83627hf_update_device(struct device *dev); 339 331 static void w83627hf_init_client(struct i2c_client *client); 340 332 ··· 366 360 \ 367 361 val = simple_strtoul(buf, NULL, 10); \ 368 362 \ 369 - down(&data->update_lock); \ 363 + mutex_lock(&data->update_lock); \ 370 364 data->in_##reg[nr] = IN_TO_REG(val); \ 371 365 w83627hf_write_value(client, W83781D_REG_IN_##REG(nr), \ 372 366 data->in_##reg[nr]); \ 373 367 \ 374 - up(&data->update_lock); \ 368 + mutex_unlock(&data->update_lock); \ 375 369 return count; \ 376 370 } 377 371 store_in_reg(MIN, min) ··· 419 413 long in0; 420 414 421 415 if ((data->vrm_ovt & 0x01) && 422 - (w83627thf == data->type || w83637hf == data->type)) 416 + (w83627thf == data->type || w83637hf == data->type 417 + || w83687thf == data->type)) 423 418 424 419 /* use VRM9 calculation */ 425 420 in0 = (long)((reg * 488 + 70000 + 50) / 100); ··· 458 451 459 452 val = simple_strtoul(buf, NULL, 10); 460 453 461 - down(&data->update_lock); 454 + mutex_lock(&data->update_lock); 462 455 463 456 if ((data->vrm_ovt & 0x01) && 464 - (w83627thf == data->type || w83637hf == data->type)) 457 + (w83627thf == data->type || w83637hf == data->type 458 + || w83687thf == data->type)) 465 459 466 460 /* use VRM9 calculation */ 467 461 data->in_min[0] = ··· 473 465 data->in_min[0] = IN_TO_REG(val); 474 466 475 467 w83627hf_write_value(client, W83781D_REG_IN_MIN(0), data->in_min[0]); 476 - up(&data->update_lock); 468 + mutex_unlock(&data->update_lock); 477 469 return count; 478 470 } 479 471 ··· 486 478 487 479 val = simple_strtoul(buf, NULL, 10); 488 480 489 - down(&data->update_lock); 481 + mutex_lock(&data->update_lock); 490 482 491 483 if ((data->vrm_ovt & 0x01) && 492 - (w83627thf == data->type || w83637hf == data->type)) 484 + (w83627thf == data->type || w83637hf == data->type 485 + || w83687thf == data->type)) 493 486 494 487 /* use VRM9 calculation */ 495 488 data->in_max[0] = ··· 501 492 data->in_max[0] = IN_TO_REG(val); 502 493 503 494 w83627hf_write_value(client, W83781D_REG_IN_MAX(0), data->in_max[0]); 504 - up(&data->update_lock); 495 + mutex_unlock(&data->update_lock); 505 496 return count; 506 497 } 507 498 ··· 538 529 539 530 val = simple_strtoul(buf, NULL, 10); 540 531 541 - down(&data->update_lock); 532 + mutex_lock(&data->update_lock); 542 533 data->fan_min[nr - 1] = 543 534 FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); 544 535 w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr), 545 536 data->fan_min[nr - 1]); 546 537 547 - up(&data->update_lock); 538 + mutex_unlock(&data->update_lock); 548 539 return count; 549 540 } 550 541 ··· 606 597 \ 607 598 val = simple_strtoul(buf, NULL, 10); \ 608 599 \ 609 - down(&data->update_lock); \ 600 + mutex_lock(&data->update_lock); \ 610 601 \ 611 602 if (nr >= 2) { /* TEMP2 and TEMP3 */ \ 612 603 data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ ··· 618 609 data->temp_##reg); \ 619 610 } \ 620 611 \ 621 - up(&data->update_lock); \ 612 + mutex_unlock(&data->update_lock); \ 622 613 return count; \ 623 614 } 624 615 store_temp_reg(OVER, max); ··· 727 718 728 719 val = simple_strtoul(buf, NULL, 10); 729 720 730 - down(&data->update_lock); 721 + mutex_lock(&data->update_lock); 731 722 732 723 if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ 733 724 data->beep_mask = BEEP_MASK_TO_REG(val); ··· 745 736 w83627hf_write_value(client, W83781D_REG_BEEP_INTS2, 746 737 val2 | data->beep_enable << 7); 747 738 748 - up(&data->update_lock); 739 + mutex_unlock(&data->update_lock); 749 740 return count; 750 741 } 751 742 ··· 792 783 u8 reg; 793 784 unsigned long val = simple_strtoul(buf, NULL, 10); 794 785 795 - down(&data->update_lock); 786 + mutex_lock(&data->update_lock); 796 787 797 788 /* Save fan_min */ 798 789 min = FAN_FROM_REG(data->fan_min[nr], ··· 814 805 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 815 806 w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); 816 807 817 - up(&data->update_lock); 808 + mutex_unlock(&data->update_lock); 818 809 return count; 819 810 } 820 811 ··· 857 848 858 849 val = simple_strtoul(buf, NULL, 10); 859 850 860 - down(&data->update_lock); 851 + mutex_lock(&data->update_lock); 861 852 862 853 if (data->type == w83627thf) { 863 854 /* bits 0-3 are reserved in 627THF */ ··· 874 865 data->pwm[nr - 1]); 875 866 } 876 867 877 - up(&data->update_lock); 868 + mutex_unlock(&data->update_lock); 878 869 return count; 879 870 } 880 871 ··· 916 907 917 908 val = simple_strtoul(buf, NULL, 10); 918 909 919 - down(&data->update_lock); 910 + mutex_lock(&data->update_lock); 920 911 921 912 switch (val) { 922 913 case 1: /* PII/Celeron diode */ ··· 950 941 break; 951 942 } 952 943 953 - up(&data->update_lock); 944 + mutex_unlock(&data->update_lock); 954 945 return count; 955 946 } 956 947 ··· 989 980 if(val != W627_DEVID && 990 981 val != W627THF_DEVID && 991 982 val != W697_DEVID && 992 - val != W637_DEVID) { 983 + val != W637_DEVID && 984 + val != W687THF_DEVID) { 993 985 superio_exit(); 994 986 return -ENODEV; 995 987 } ··· 1044 1034 kind = w83627thf; 1045 1035 else if(val == W637_DEVID) 1046 1036 kind = w83637hf; 1037 + else if (val == W687THF_DEVID) 1038 + kind = w83687thf; 1047 1039 else { 1048 1040 dev_info(&adapter->dev, 1049 1041 "Unsupported chip (dev_id=0x%02X).\n", val); ··· 1069 1057 new_client = &data->client; 1070 1058 i2c_set_clientdata(new_client, data); 1071 1059 new_client->addr = address; 1072 - init_MUTEX(&data->lock); 1060 + mutex_init(&data->lock); 1073 1061 new_client->adapter = adapter; 1074 1062 new_client->driver = &w83627hf_driver; 1075 1063 new_client->flags = 0; ··· 1083 1071 client_name = "w83697hf"; 1084 1072 } else if (kind == w83637hf) { 1085 1073 client_name = "w83637hf"; 1074 + } else if (kind == w83687thf) { 1075 + client_name = "w83687thf"; 1086 1076 } 1087 1077 1088 1078 /* Fill in the remaining client fields and put into the global list */ 1089 1079 strlcpy(new_client->name, client_name, I2C_NAME_SIZE); 1090 1080 data->type = kind; 1091 1081 data->valid = 0; 1092 - init_MUTEX(&data->update_lock); 1082 + mutex_init(&data->update_lock); 1093 1083 1094 1084 /* Tell the I2C layer a new client has arrived */ 1095 1085 if ((err = i2c_attach_client(new_client))) ··· 1120 1106 device_create_file_in(new_client, 2); 1121 1107 device_create_file_in(new_client, 3); 1122 1108 device_create_file_in(new_client, 4); 1123 - if (kind != w83627thf && kind != w83637hf) { 1109 + if (kind == w83627hf || kind == w83697hf) { 1124 1110 device_create_file_in(new_client, 5); 1125 1111 device_create_file_in(new_client, 6); 1126 1112 } ··· 1153 1139 1154 1140 device_create_file_pwm(new_client, 1); 1155 1141 device_create_file_pwm(new_client, 2); 1156 - if (kind == w83627thf || kind == w83637hf) 1142 + if (kind == w83627thf || kind == w83637hf || kind == w83687thf) 1157 1143 device_create_file_pwm(new_client, 3); 1158 1144 1159 1145 device_create_file_sensor(new_client, 1); ··· 1201 1187 struct w83627hf_data *data = i2c_get_clientdata(client); 1202 1188 int res, word_sized; 1203 1189 1204 - down(&data->lock); 1190 + mutex_lock(&data->lock); 1205 1191 word_sized = (((reg & 0xff00) == 0x100) 1206 1192 || ((reg & 0xff00) == 0x200)) 1207 1193 && (((reg & 0x00ff) == 0x50) ··· 1227 1213 client->addr + W83781D_ADDR_REG_OFFSET); 1228 1214 outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); 1229 1215 } 1230 - up(&data->lock); 1216 + mutex_unlock(&data->lock); 1231 1217 return res; 1232 1218 } 1233 1219 ··· 1261 1247 return res; 1262 1248 } 1263 1249 1250 + static int w83687thf_read_vid(struct i2c_client *client) 1251 + { 1252 + int res = 0xff; 1253 + 1254 + superio_enter(); 1255 + superio_select(W83627HF_LD_HWM); 1256 + 1257 + /* Make sure these GPIO pins are enabled */ 1258 + if (!(superio_inb(W83687THF_VID_EN) & (1 << 2))) { 1259 + dev_dbg(&client->dev, "VID disabled, no VID function\n"); 1260 + goto exit; 1261 + } 1262 + 1263 + /* Make sure the pins are configured for input */ 1264 + if (!(superio_inb(W83687THF_VID_CFG) & (1 << 4))) { 1265 + dev_dbg(&client->dev, "VID configured as output, " 1266 + "no VID function\n"); 1267 + goto exit; 1268 + } 1269 + 1270 + res = superio_inb(W83687THF_VID_DATA) & 0x3f; 1271 + 1272 + exit: 1273 + superio_exit(); 1274 + return res; 1275 + } 1276 + 1264 1277 static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value) 1265 1278 { 1266 1279 struct w83627hf_data *data = i2c_get_clientdata(client); 1267 1280 int word_sized; 1268 1281 1269 - down(&data->lock); 1282 + mutex_lock(&data->lock); 1270 1283 word_sized = (((reg & 0xff00) == 0x100) 1271 1284 || ((reg & 0xff00) == 0x200)) 1272 1285 && (((reg & 0x00ff) == 0x53) ··· 1318 1277 client->addr + W83781D_ADDR_REG_OFFSET); 1319 1278 outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); 1320 1279 } 1321 - up(&data->lock); 1280 + mutex_unlock(&data->lock); 1322 1281 return 0; 1323 1282 } 1324 1283 ··· 1365 1324 data->vid = (lo & 0x0f) | ((hi & 0x01) << 4); 1366 1325 } else if (w83627thf == data->type) { 1367 1326 data->vid = w83627thf_read_gpio5(client); 1327 + } else if (w83687thf == data->type) { 1328 + data->vid = w83687thf_read_vid(client); 1368 1329 } 1369 1330 1370 1331 /* Read VRM & OVT Config only once */ 1371 - if (w83627thf == data->type || w83637hf == data->type) { 1332 + if (w83627thf == data->type || w83637hf == data->type 1333 + || w83687thf == data->type) { 1372 1334 data->vrm_ovt = 1373 1335 w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG); 1374 1336 } ··· 1431 1387 struct w83627hf_data *data = i2c_get_clientdata(client); 1432 1388 int i; 1433 1389 1434 - down(&data->update_lock); 1390 + mutex_lock(&data->update_lock); 1435 1391 1436 1392 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 1437 1393 || !data->valid) { 1438 1394 for (i = 0; i <= 8; i++) { 1439 1395 /* skip missing sensors */ 1440 1396 if (((data->type == w83697hf) && (i == 1)) || 1441 - ((data->type == w83627thf || data->type == w83637hf) 1397 + ((data->type != w83627hf && data->type != w83697hf) 1442 1398 && (i == 5 || i == 6))) 1443 1399 continue; 1444 1400 data->in[i] = ··· 1514 1470 data->valid = 1; 1515 1471 } 1516 1472 1517 - up(&data->update_lock); 1473 + mutex_unlock(&data->update_lock); 1518 1474 1519 1475 return data; 1520 1476 }
+51 -31
drivers/hwmon/w83781d.c
··· 42 42 #include <linux/hwmon.h> 43 43 #include <linux/hwmon-vid.h> 44 44 #include <linux/err.h> 45 + #include <linux/mutex.h> 45 46 #include <asm/io.h> 46 47 #include "lm75.h" 47 48 ··· 56 55 I2C_CLIENT_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f); 57 56 I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " 58 57 "{bus, clientaddr, subclientaddr1, subclientaddr2}"); 58 + 59 + static int reset; 60 + module_param(reset, bool, 0); 61 + MODULE_PARM_DESC(reset, "Set to one to reset chip on load"); 59 62 60 63 static int init = 1; 61 64 module_param(init, bool, 0); ··· 231 226 struct w83781d_data { 232 227 struct i2c_client client; 233 228 struct class_device *class_dev; 234 - struct semaphore lock; 229 + struct mutex lock; 235 230 enum chips type; 236 231 237 - struct semaphore update_lock; 232 + struct mutex update_lock; 238 233 char valid; /* !=0 if following fields are valid */ 239 234 unsigned long last_updated; /* In jiffies */ 240 235 ··· 272 267 static int w83781d_detect(struct i2c_adapter *adapter, int address, int kind); 273 268 static int w83781d_detach_client(struct i2c_client *client); 274 269 275 - static int w83781d_read_value(struct i2c_client *client, u16 register); 276 - static int w83781d_write_value(struct i2c_client *client, u16 register, 277 - u16 value); 270 + static int w83781d_read_value(struct i2c_client *client, u16 reg); 271 + static int w83781d_write_value(struct i2c_client *client, u16 reg, u16 value); 278 272 static struct w83781d_data *w83781d_update_device(struct device *dev); 279 273 static void w83781d_init_client(struct i2c_client *client); 280 274 ··· 315 311 \ 316 312 val = simple_strtoul(buf, NULL, 10) / 10; \ 317 313 \ 318 - down(&data->update_lock); \ 314 + mutex_lock(&data->update_lock); \ 319 315 data->in_##reg[nr] = IN_TO_REG(val); \ 320 316 w83781d_write_value(client, W83781D_REG_IN_##REG(nr), data->in_##reg[nr]); \ 321 317 \ 322 - up(&data->update_lock); \ 318 + mutex_unlock(&data->update_lock); \ 323 319 return count; \ 324 320 } 325 321 store_in_reg(MIN, min); ··· 385 381 386 382 val = simple_strtoul(buf, NULL, 10); 387 383 388 - down(&data->update_lock); 384 + mutex_lock(&data->update_lock); 389 385 data->fan_min[nr - 1] = 390 386 FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); 391 387 w83781d_write_value(client, W83781D_REG_FAN_MIN(nr), 392 388 data->fan_min[nr - 1]); 393 389 394 - up(&data->update_lock); 390 + mutex_unlock(&data->update_lock); 395 391 return count; 396 392 } 397 393 ··· 450 446 \ 451 447 val = simple_strtol(buf, NULL, 10); \ 452 448 \ 453 - down(&data->update_lock); \ 449 + mutex_lock(&data->update_lock); \ 454 450 \ 455 451 if (nr >= 2) { /* TEMP2 and TEMP3 */ \ 456 452 data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ ··· 462 458 data->temp_##reg); \ 463 459 } \ 464 460 \ 465 - up(&data->update_lock); \ 461 + mutex_unlock(&data->update_lock); \ 466 462 return count; \ 467 463 } 468 464 store_temp_reg(OVER, max); ··· 575 571 576 572 val = simple_strtoul(buf, NULL, 10); 577 573 578 - down(&data->update_lock); 574 + mutex_lock(&data->update_lock); 579 575 580 576 if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ 581 577 data->beep_mask = BEEP_MASK_TO_REG(val, data->type); ··· 596 592 w83781d_write_value(client, W83781D_REG_BEEP_INTS2, 597 593 val2 | data->beep_enable << 7); 598 594 599 - up(&data->update_lock); 595 + mutex_unlock(&data->update_lock); 600 596 return count; 601 597 } 602 598 ··· 641 637 u8 reg; 642 638 unsigned long val = simple_strtoul(buf, NULL, 10); 643 639 644 - down(&data->update_lock); 640 + mutex_lock(&data->update_lock); 645 641 646 642 /* Save fan_min */ 647 643 min = FAN_FROM_REG(data->fan_min[nr], ··· 666 662 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 667 663 w83781d_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); 668 664 669 - up(&data->update_lock); 665 + mutex_unlock(&data->update_lock); 670 666 return count; 671 667 } 672 668 ··· 713 709 714 710 val = simple_strtoul(buf, NULL, 10); 715 711 716 - down(&data->update_lock); 712 + mutex_lock(&data->update_lock); 717 713 data->pwm[nr - 1] = PWM_TO_REG(val); 718 714 w83781d_write_value(client, W83781D_REG_PWM(nr), data->pwm[nr - 1]); 719 - up(&data->update_lock); 715 + mutex_unlock(&data->update_lock); 720 716 return count; 721 717 } 722 718 ··· 729 725 730 726 val = simple_strtoul(buf, NULL, 10); 731 727 732 - down(&data->update_lock); 728 + mutex_lock(&data->update_lock); 733 729 734 730 switch (val) { 735 731 case 0: ··· 746 742 break; 747 743 748 744 default: 749 - up(&data->update_lock); 745 + mutex_unlock(&data->update_lock); 750 746 return -EINVAL; 751 747 } 752 748 753 - up(&data->update_lock); 749 + mutex_unlock(&data->update_lock); 754 750 return count; 755 751 } 756 752 ··· 812 808 813 809 val = simple_strtoul(buf, NULL, 10); 814 810 815 - down(&data->update_lock); 811 + mutex_lock(&data->update_lock); 816 812 817 813 switch (val) { 818 814 case 1: /* PII/Celeron diode */ ··· 845 841 break; 846 842 } 847 843 848 - up(&data->update_lock); 844 + mutex_unlock(&data->update_lock); 849 845 return count; 850 846 } 851 847 ··· 1077 1073 new_client = &data->client; 1078 1074 i2c_set_clientdata(new_client, data); 1079 1075 new_client->addr = address; 1080 - init_MUTEX(&data->lock); 1076 + mutex_init(&data->lock); 1081 1077 new_client->adapter = adapter; 1082 1078 new_client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver; 1083 1079 new_client->flags = 0; ··· 1182 1178 data->type = kind; 1183 1179 1184 1180 data->valid = 0; 1185 - init_MUTEX(&data->update_lock); 1181 + mutex_init(&data->update_lock); 1186 1182 1187 1183 /* Tell the I2C layer a new client has arrived */ 1188 1184 if ((err = i2c_attach_client(new_client))) ··· 1329 1325 int res, word_sized, bank; 1330 1326 struct i2c_client *cl; 1331 1327 1332 - down(&data->lock); 1328 + mutex_lock(&data->lock); 1333 1329 if (i2c_is_isa_client(client)) { 1334 1330 word_sized = (((reg & 0xff00) == 0x100) 1335 1331 || ((reg & 0xff00) == 0x200)) ··· 1387 1383 if (bank > 2) 1388 1384 i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0); 1389 1385 } 1390 - up(&data->lock); 1386 + mutex_unlock(&data->lock); 1391 1387 return res; 1392 1388 } 1393 1389 ··· 1398 1394 int word_sized, bank; 1399 1395 struct i2c_client *cl; 1400 1396 1401 - down(&data->lock); 1397 + mutex_lock(&data->lock); 1402 1398 if (i2c_is_isa_client(client)) { 1403 1399 word_sized = (((reg & 0xff00) == 0x100) 1404 1400 || ((reg & 0xff00) == 0x200)) ··· 1451 1447 if (bank > 2) 1452 1448 i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0); 1453 1449 } 1454 - up(&data->lock); 1450 + mutex_unlock(&data->lock); 1455 1451 return 0; 1456 1452 } 1457 1453 ··· 1463 1459 int type = data->type; 1464 1460 u8 tmp; 1465 1461 1466 - if (init && type != as99127f) { /* this resets registers we don't have 1462 + if (reset && type != as99127f) { /* this resets registers we don't have 1467 1463 documentation for on the as99127f */ 1464 + /* Resetting the chip has been the default for a long time, 1465 + but it causes the BIOS initializations (fan clock dividers, 1466 + thermal sensor types...) to be lost, so it is now optional. 1467 + It might even go away if nobody reports it as being useful, 1468 + as I see very little reason why this would be needed at 1469 + all. */ 1470 + dev_info(&client->dev, "If reset=1 solved a problem you were " 1471 + "having, please report!\n"); 1472 + 1468 1473 /* save these registers */ 1469 1474 i = w83781d_read_value(client, W83781D_REG_BEEP_CONFIG); 1470 1475 p = w83781d_read_value(client, W83781D_REG_PWMCLK12); ··· 1488 1475 Individual beep_mask should be reset to off but for some reason 1489 1476 disabling this bit helps some people not get beeped */ 1490 1477 w83781d_write_value(client, W83781D_REG_BEEP_INTS2, 0); 1478 + } 1479 + 1480 + /* Disable power-on abnormal beep, as advised by the datasheet. 1481 + Already done if reset=1. */ 1482 + if (init && !reset && type != as99127f) { 1483 + i = w83781d_read_value(client, W83781D_REG_BEEP_CONFIG); 1484 + w83781d_write_value(client, W83781D_REG_BEEP_CONFIG, i | 0x80); 1491 1485 } 1492 1486 1493 1487 data->vrm = vid_which_vrm(); ··· 1553 1533 struct w83781d_data *data = i2c_get_clientdata(client); 1554 1534 int i; 1555 1535 1556 - down(&data->update_lock); 1536 + mutex_lock(&data->update_lock); 1557 1537 1558 1538 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 1559 1539 || !data->valid) { ··· 1661 1641 data->valid = 1; 1662 1642 } 1663 1643 1664 - up(&data->update_lock); 1644 + mutex_unlock(&data->update_lock); 1665 1645 1666 1646 return data; 1667 1647 }
+229 -289
drivers/hwmon/w83792d.c
··· 43 43 #include <linux/hwmon.h> 44 44 #include <linux/hwmon-sysfs.h> 45 45 #include <linux/err.h> 46 + #include <linux/mutex.h> 46 47 47 48 /* Addresses to scan */ 48 49 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; ··· 272 271 struct class_device *class_dev; 273 272 enum chips type; 274 273 275 - struct semaphore update_lock; 274 + struct mutex update_lock; 276 275 char valid; /* !=0 if following fields are valid */ 277 276 unsigned long last_updated; /* In jiffies */ 278 277 ··· 383 382 store_in_reg(MIN, min); 384 383 store_in_reg(MAX, max); 385 384 386 - #define sysfs_in_reg(offset) \ 387 - static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in, \ 388 - NULL, offset); \ 389 - static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ 390 - show_in_min, store_in_min, offset); \ 391 - static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ 392 - show_in_max, store_in_max, offset); 385 + static struct sensor_device_attribute sda_in_input[] = { 386 + SENSOR_ATTR(in0_input, S_IRUGO, show_in, NULL, 0), 387 + SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1), 388 + SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2), 389 + SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3), 390 + SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4), 391 + SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5), 392 + SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6), 393 + SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7), 394 + SENSOR_ATTR(in8_input, S_IRUGO, show_in, NULL, 8), 395 + }; 396 + static struct sensor_device_attribute sda_in_min[] = { 397 + SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 0), 398 + SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 1), 399 + SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 2), 400 + SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 3), 401 + SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 4), 402 + SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 5), 403 + SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 6), 404 + SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 7), 405 + SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 8), 406 + }; 407 + static struct sensor_device_attribute sda_in_max[] = { 408 + SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 0), 409 + SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 1), 410 + SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 2), 411 + SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 3), 412 + SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 4), 413 + SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 5), 414 + SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 6), 415 + SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 7), 416 + SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 8), 417 + }; 393 418 394 - sysfs_in_reg(0); 395 - sysfs_in_reg(1); 396 - sysfs_in_reg(2); 397 - sysfs_in_reg(3); 398 - sysfs_in_reg(4); 399 - sysfs_in_reg(5); 400 - sysfs_in_reg(6); 401 - sysfs_in_reg(7); 402 - sysfs_in_reg(8); 403 - 404 - #define device_create_file_in(client, offset) \ 405 - do { \ 406 - device_create_file(&client->dev, &sensor_dev_attr_in##offset##_input.dev_attr); \ 407 - device_create_file(&client->dev, &sensor_dev_attr_in##offset##_max.dev_attr); \ 408 - device_create_file(&client->dev, &sensor_dev_attr_in##offset##_min.dev_attr); \ 409 - } while (0) 410 419 411 420 #define show_fan_reg(reg) \ 412 421 static ssize_t show_##reg (struct device *dev, struct device_attribute *attr, \ ··· 497 486 return count; 498 487 } 499 488 500 - #define sysfs_fan(offset) \ 501 - static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL, \ 502 - offset); \ 503 - static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ 504 - show_fan_div, store_fan_div, offset); \ 505 - static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ 506 - show_fan_min, store_fan_min, offset); 507 - 508 - sysfs_fan(1); 509 - sysfs_fan(2); 510 - sysfs_fan(3); 511 - sysfs_fan(4); 512 - sysfs_fan(5); 513 - sysfs_fan(6); 514 - sysfs_fan(7); 515 - 516 - #define device_create_file_fan(client, offset) \ 517 - do { \ 518 - device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_input.dev_attr); \ 519 - device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_div.dev_attr); \ 520 - device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_min.dev_attr); \ 521 - } while (0) 489 + static struct sensor_device_attribute sda_fan_input[] = { 490 + SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 1), 491 + SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 2), 492 + SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 3), 493 + SENSOR_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 4), 494 + SENSOR_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 5), 495 + SENSOR_ATTR(fan6_input, S_IRUGO, show_fan, NULL, 6), 496 + SENSOR_ATTR(fan7_input, S_IRUGO, show_fan, NULL, 7), 497 + }; 498 + static struct sensor_device_attribute sda_fan_min[] = { 499 + SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 1), 500 + SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 2), 501 + SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 3), 502 + SENSOR_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 4), 503 + SENSOR_ATTR(fan5_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 5), 504 + SENSOR_ATTR(fan6_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 6), 505 + SENSOR_ATTR(fan7_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 7), 506 + }; 507 + static struct sensor_device_attribute sda_fan_div[] = { 508 + SENSOR_ATTR(fan1_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 1), 509 + SENSOR_ATTR(fan2_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 2), 510 + SENSOR_ATTR(fan3_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 3), 511 + SENSOR_ATTR(fan4_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 4), 512 + SENSOR_ATTR(fan5_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 5), 513 + SENSOR_ATTR(fan6_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 6), 514 + SENSOR_ATTR(fan7_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 7), 515 + }; 522 516 523 517 524 518 /* read/write the temperature1, includes measured value and limits */ ··· 554 538 555 539 return count; 556 540 } 557 - 558 - 559 - static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0); 560 - static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp1, 561 - store_temp1, 1); 562 - static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1, 563 - store_temp1, 2); 564 - 565 - #define device_create_file_temp1(client) \ 566 - do { \ 567 - device_create_file(&client->dev, &sensor_dev_attr_temp1_input.dev_attr); \ 568 - device_create_file(&client->dev, &sensor_dev_attr_temp1_max.dev_attr); \ 569 - device_create_file(&client->dev, &sensor_dev_attr_temp1_max_hyst.dev_attr); \ 570 - } while (0) 571 - 572 541 573 542 /* read/write the temperature2-3, includes measured value and limits */ 574 543 ··· 591 590 return count; 592 591 } 593 592 594 - #define sysfs_temp23(name,idx) \ 595 - static SENSOR_DEVICE_ATTR_2(name##_input, S_IRUGO, show_temp23, NULL, \ 596 - idx, 0); \ 597 - static SENSOR_DEVICE_ATTR_2(name##_max, S_IRUGO | S_IWUSR, \ 598 - show_temp23, store_temp23, idx, 2); \ 599 - static SENSOR_DEVICE_ATTR_2(name##_max_hyst, S_IRUGO | S_IWUSR, \ 600 - show_temp23, store_temp23, idx, 4); 593 + static struct sensor_device_attribute_2 sda_temp_input[] = { 594 + SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp1, NULL, 0, 0), 595 + SENSOR_ATTR_2(temp2_input, S_IRUGO, show_temp23, NULL, 0, 0), 596 + SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp23, NULL, 1, 0), 597 + }; 601 598 602 - sysfs_temp23(temp2,0) 603 - sysfs_temp23(temp3,1) 599 + static struct sensor_device_attribute_2 sda_temp_max[] = { 600 + SENSOR_ATTR_2(temp1_max, S_IRUGO | S_IWUSR, show_temp1, store_temp1, 0, 1), 601 + SENSOR_ATTR_2(temp2_max, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 0, 2), 602 + SENSOR_ATTR_2(temp3_max, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 1, 2), 603 + }; 604 604 605 - #define device_create_file_temp_add(client, offset) \ 606 - do { \ 607 - device_create_file(&client->dev, &sensor_dev_attr_temp##offset##_input.dev_attr); \ 608 - device_create_file(&client->dev, &sensor_dev_attr_temp##offset##_max.dev_attr); \ 609 - device_create_file(&client->dev, \ 610 - &sensor_dev_attr_temp##offset##_max_hyst.dev_attr); \ 611 - } while (0) 612 - 605 + static struct sensor_device_attribute_2 sda_temp_max_hyst[] = { 606 + SENSOR_ATTR_2(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1, store_temp1, 0, 2), 607 + SENSOR_ATTR_2(temp2_max_hyst, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 0, 4), 608 + SENSOR_ATTR_2(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 1, 4), 609 + }; 613 610 614 611 /* get reatime status of all sensors items: voltage, temp, fan */ 615 612 static ssize_t ··· 619 620 620 621 static 621 622 DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); 622 - #define device_create_file_alarms(client) \ 623 - device_create_file(&client->dev, &dev_attr_alarms); 624 - 625 - 626 623 627 624 static ssize_t 628 625 show_pwm(struct device *dev, struct device_attribute *attr, ··· 706 711 return count; 707 712 } 708 713 709 - #define sysfs_pwm(offset) \ 710 - static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ 711 - show_pwm, store_pwm, offset); \ 712 - static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ 713 - show_pwmenable, store_pwmenable, offset); \ 714 - 715 - sysfs_pwm(1); 716 - sysfs_pwm(2); 717 - sysfs_pwm(3); 718 - 719 - 720 - #define device_create_file_pwm(client, offset) \ 721 - do { \ 722 - device_create_file(&client->dev, &sensor_dev_attr_pwm##offset.dev_attr); \ 723 - } while (0) 724 - 725 - #define device_create_file_pwmenable(client, offset) \ 726 - do { \ 727 - device_create_file(&client->dev, &sensor_dev_attr_pwm##offset##_enable.dev_attr); \ 728 - } while (0) 714 + static struct sensor_device_attribute sda_pwm[] = { 715 + SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 1), 716 + SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 2), 717 + SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 3), 718 + }; 719 + static struct sensor_device_attribute sda_pwm_enable[] = { 720 + SENSOR_ATTR(pwm1_enable, S_IWUSR | S_IRUGO, 721 + show_pwmenable, store_pwmenable, 1), 722 + SENSOR_ATTR(pwm2_enable, S_IWUSR | S_IRUGO, 723 + show_pwmenable, store_pwmenable, 2), 724 + SENSOR_ATTR(pwm3_enable, S_IWUSR | S_IRUGO, 725 + show_pwmenable, store_pwmenable, 3), 726 + }; 729 727 730 728 731 729 static ssize_t ··· 752 764 return count; 753 765 } 754 766 755 - #define sysfs_pwm_mode(offset) \ 756 - static SENSOR_DEVICE_ATTR(pwm##offset##_mode, S_IRUGO | S_IWUSR, \ 757 - show_pwm_mode, store_pwm_mode, offset); 758 - 759 - sysfs_pwm_mode(1); 760 - sysfs_pwm_mode(2); 761 - sysfs_pwm_mode(3); 762 - 763 - #define device_create_file_pwm_mode(client, offset) \ 764 - do { \ 765 - device_create_file(&client->dev, &sensor_dev_attr_pwm##offset##_mode.dev_attr); \ 766 - } while (0) 767 + static struct sensor_device_attribute sda_pwm_mode[] = { 768 + SENSOR_ATTR(pwm1_mode, S_IWUSR | S_IRUGO, 769 + show_pwm_mode, store_pwm_mode, 1), 770 + SENSOR_ATTR(pwm2_mode, S_IWUSR | S_IRUGO, 771 + show_pwm_mode, store_pwm_mode, 2), 772 + SENSOR_ATTR(pwm3_mode, S_IWUSR | S_IRUGO, 773 + show_pwm_mode, store_pwm_mode, 3), 774 + }; 767 775 768 776 769 777 static ssize_t ··· 771 787 } 772 788 773 789 static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL); 774 - 775 - #define device_create_file_chassis(client) \ 776 - do { \ 777 - device_create_file(&client->dev, &dev_attr_chassis); \ 778 - } while (0) 779 - 780 790 781 791 static ssize_t 782 792 show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf) ··· 801 823 802 824 static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR, 803 825 show_chassis_clear, store_chassis_clear); 804 - 805 - #define device_create_file_chassis_clear(client) \ 806 - do { \ 807 - device_create_file(&client->dev, &dev_attr_chassis_clear); \ 808 - } while (0) 809 - 810 - 811 826 812 827 /* For Smart Fan I / Thermal Cruise */ 813 828 static ssize_t ··· 835 864 return count; 836 865 } 837 866 838 - #define sysfs_thermal_cruise(offset) \ 839 - static SENSOR_DEVICE_ATTR(thermal_cruise##offset, S_IRUGO | S_IWUSR, \ 840 - show_thermal_cruise, store_thermal_cruise, offset); 841 - 842 - sysfs_thermal_cruise(1); 843 - sysfs_thermal_cruise(2); 844 - sysfs_thermal_cruise(3); 845 - 846 - #define device_create_file_thermal_cruise(client, offset) \ 847 - do { \ 848 - device_create_file(&client->dev, \ 849 - &sensor_dev_attr_thermal_cruise##offset.dev_attr); \ 850 - } while (0) 851 - 867 + static struct sensor_device_attribute sda_thermal_cruise[] = { 868 + SENSOR_ATTR(thermal_cruise1, S_IWUSR | S_IRUGO, 869 + show_thermal_cruise, store_thermal_cruise, 1), 870 + SENSOR_ATTR(thermal_cruise2, S_IWUSR | S_IRUGO, 871 + show_thermal_cruise, store_thermal_cruise, 2), 872 + SENSOR_ATTR(thermal_cruise3, S_IWUSR | S_IRUGO, 873 + show_thermal_cruise, store_thermal_cruise, 3), 874 + }; 852 875 853 876 /* For Smart Fan I/Thermal Cruise and Smart Fan II */ 854 877 static ssize_t ··· 881 916 return count; 882 917 } 883 918 884 - #define sysfs_tolerance(offset) \ 885 - static SENSOR_DEVICE_ATTR(tolerance##offset, S_IRUGO | S_IWUSR, \ 886 - show_tolerance, store_tolerance, offset); 887 - 888 - sysfs_tolerance(1); 889 - sysfs_tolerance(2); 890 - sysfs_tolerance(3); 891 - 892 - #define device_create_file_tolerance(client, offset) \ 893 - do { \ 894 - device_create_file(&client->dev, &sensor_dev_attr_tolerance##offset.dev_attr); \ 895 - } while (0) 896 - 919 + static struct sensor_device_attribute sda_tolerance[] = { 920 + SENSOR_ATTR(tolerance1, S_IWUSR | S_IRUGO, 921 + show_tolerance, store_tolerance, 1), 922 + SENSOR_ATTR(tolerance2, S_IWUSR | S_IRUGO, 923 + show_tolerance, store_tolerance, 2), 924 + SENSOR_ATTR(tolerance3, S_IWUSR | S_IRUGO, 925 + show_tolerance, store_tolerance, 3), 926 + }; 897 927 898 928 /* For Smart Fan II */ 899 929 static ssize_t ··· 924 964 return count; 925 965 } 926 966 927 - #define sysfs_sf2_point(offset, index) \ 928 - static SENSOR_DEVICE_ATTR_2(sf2_point##offset##_fan##index, S_IRUGO | S_IWUSR, \ 929 - show_sf2_point, store_sf2_point, offset, index); 967 + static struct sensor_device_attribute_2 sda_sf2_point[] = { 968 + SENSOR_ATTR_2(sf2_point1_fan1, S_IRUGO | S_IWUSR, 969 + show_sf2_point, store_sf2_point, 1, 1), 970 + SENSOR_ATTR_2(sf2_point2_fan1, S_IRUGO | S_IWUSR, 971 + show_sf2_point, store_sf2_point, 2, 1), 972 + SENSOR_ATTR_2(sf2_point3_fan1, S_IRUGO | S_IWUSR, 973 + show_sf2_point, store_sf2_point, 3, 1), 974 + SENSOR_ATTR_2(sf2_point4_fan1, S_IRUGO | S_IWUSR, 975 + show_sf2_point, store_sf2_point, 4, 1), 930 976 931 - sysfs_sf2_point(1, 1); /* Fan1 */ 932 - sysfs_sf2_point(2, 1); /* Fan1 */ 933 - sysfs_sf2_point(3, 1); /* Fan1 */ 934 - sysfs_sf2_point(4, 1); /* Fan1 */ 935 - sysfs_sf2_point(1, 2); /* Fan2 */ 936 - sysfs_sf2_point(2, 2); /* Fan2 */ 937 - sysfs_sf2_point(3, 2); /* Fan2 */ 938 - sysfs_sf2_point(4, 2); /* Fan2 */ 939 - sysfs_sf2_point(1, 3); /* Fan3 */ 940 - sysfs_sf2_point(2, 3); /* Fan3 */ 941 - sysfs_sf2_point(3, 3); /* Fan3 */ 942 - sysfs_sf2_point(4, 3); /* Fan3 */ 977 + SENSOR_ATTR_2(sf2_point1_fan2, S_IRUGO | S_IWUSR, 978 + show_sf2_point, store_sf2_point, 1, 2), 979 + SENSOR_ATTR_2(sf2_point2_fan2, S_IRUGO | S_IWUSR, 980 + show_sf2_point, store_sf2_point, 2, 2), 981 + SENSOR_ATTR_2(sf2_point3_fan2, S_IRUGO | S_IWUSR, 982 + show_sf2_point, store_sf2_point, 3, 2), 983 + SENSOR_ATTR_2(sf2_point4_fan2, S_IRUGO | S_IWUSR, 984 + show_sf2_point, store_sf2_point, 4, 2), 943 985 944 - #define device_create_file_sf2_point(client, offset, index) \ 945 - do { \ 946 - device_create_file(&client->dev, \ 947 - &sensor_dev_attr_sf2_point##offset##_fan##index.dev_attr); \ 948 - } while (0) 986 + SENSOR_ATTR_2(sf2_point1_fan3, S_IRUGO | S_IWUSR, 987 + show_sf2_point, store_sf2_point, 1, 3), 988 + SENSOR_ATTR_2(sf2_point2_fan3, S_IRUGO | S_IWUSR, 989 + show_sf2_point, store_sf2_point, 2, 3), 990 + SENSOR_ATTR_2(sf2_point3_fan3, S_IRUGO | S_IWUSR, 991 + show_sf2_point, store_sf2_point, 3, 3), 992 + SENSOR_ATTR_2(sf2_point4_fan3, S_IRUGO | S_IWUSR, 993 + show_sf2_point, store_sf2_point, 4, 3), 994 + }; 949 995 950 996 951 997 static ssize_t ··· 992 1026 return count; 993 1027 } 994 1028 995 - #define sysfs_sf2_level(offset, index) \ 996 - static SENSOR_DEVICE_ATTR_2(sf2_level##offset##_fan##index, S_IRUGO | S_IWUSR, \ 997 - show_sf2_level, store_sf2_level, offset, index); 1029 + static struct sensor_device_attribute_2 sda_sf2_level[] = { 1030 + SENSOR_ATTR_2(sf2_level1_fan1, S_IRUGO | S_IWUSR, 1031 + show_sf2_level, store_sf2_level, 1, 1), 1032 + SENSOR_ATTR_2(sf2_level2_fan1, S_IRUGO | S_IWUSR, 1033 + show_sf2_level, store_sf2_level, 2, 1), 1034 + SENSOR_ATTR_2(sf2_level3_fan1, S_IRUGO | S_IWUSR, 1035 + show_sf2_level, store_sf2_level, 3, 1), 998 1036 999 - sysfs_sf2_level(1, 1); /* Fan1 */ 1000 - sysfs_sf2_level(2, 1); /* Fan1 */ 1001 - sysfs_sf2_level(3, 1); /* Fan1 */ 1002 - sysfs_sf2_level(1, 2); /* Fan2 */ 1003 - sysfs_sf2_level(2, 2); /* Fan2 */ 1004 - sysfs_sf2_level(3, 2); /* Fan2 */ 1005 - sysfs_sf2_level(1, 3); /* Fan3 */ 1006 - sysfs_sf2_level(2, 3); /* Fan3 */ 1007 - sysfs_sf2_level(3, 3); /* Fan3 */ 1037 + SENSOR_ATTR_2(sf2_level1_fan2, S_IRUGO | S_IWUSR, 1038 + show_sf2_level, store_sf2_level, 1, 2), 1039 + SENSOR_ATTR_2(sf2_level2_fan2, S_IRUGO | S_IWUSR, 1040 + show_sf2_level, store_sf2_level, 2, 2), 1041 + SENSOR_ATTR_2(sf2_level3_fan2, S_IRUGO | S_IWUSR, 1042 + show_sf2_level, store_sf2_level, 3, 2), 1008 1043 1009 - #define device_create_file_sf2_level(client, offset, index) \ 1010 - do { \ 1011 - device_create_file(&client->dev, \ 1012 - &sensor_dev_attr_sf2_level##offset##_fan##index.dev_attr); \ 1013 - } while (0) 1014 - 1044 + SENSOR_ATTR_2(sf2_level1_fan3, S_IRUGO | S_IWUSR, 1045 + show_sf2_level, store_sf2_level, 1, 3), 1046 + SENSOR_ATTR_2(sf2_level2_fan3, S_IRUGO | S_IWUSR, 1047 + show_sf2_level, store_sf2_level, 2, 3), 1048 + SENSOR_ATTR_2(sf2_level3_fan3, S_IRUGO | S_IWUSR, 1049 + show_sf2_level, store_sf2_level, 3, 3), 1050 + }; 1015 1051 1016 1052 /* This function is called when: 1017 1053 * w83792d_driver is inserted (when this module is loaded), for each ··· 1115 1147 return err; 1116 1148 } 1117 1149 1150 + static void device_create_file_fan(struct device *dev, int i) 1151 + { 1152 + device_create_file(dev, &sda_fan_input[i].dev_attr); 1153 + device_create_file(dev, &sda_fan_div[i].dev_attr); 1154 + device_create_file(dev, &sda_fan_min[i].dev_attr); 1155 + } 1118 1156 1119 1157 static int 1120 1158 w83792d_detect(struct i2c_adapter *adapter, int address, int kind) 1121 1159 { 1122 1160 int i = 0, val1 = 0, val2; 1123 - struct i2c_client *new_client; 1161 + struct i2c_client *client; 1162 + struct device *dev; 1124 1163 struct w83792d_data *data; 1125 1164 int err = 0; 1126 1165 const char *client_name = ""; ··· 1145 1170 goto ERROR0; 1146 1171 } 1147 1172 1148 - new_client = &data->client; 1149 - i2c_set_clientdata(new_client, data); 1150 - new_client->addr = address; 1151 - new_client->adapter = adapter; 1152 - new_client->driver = &w83792d_driver; 1153 - new_client->flags = 0; 1173 + client = &data->client; 1174 + dev = &client->dev; 1175 + i2c_set_clientdata(client, data); 1176 + client->addr = address; 1177 + client->adapter = adapter; 1178 + client->driver = &w83792d_driver; 1179 + client->flags = 0; 1154 1180 1155 1181 /* Now, we do the remaining detection. */ 1156 1182 ··· 1160 1184 force_*=... parameter, and the Winbond will be reset to the right 1161 1185 bank. */ 1162 1186 if (kind < 0) { 1163 - if (w83792d_read_value(new_client, W83792D_REG_CONFIG) & 0x80) { 1164 - dev_warn(&new_client->dev, "Detection failed at step " 1165 - "3\n"); 1187 + if (w83792d_read_value(client, W83792D_REG_CONFIG) & 0x80) { 1188 + dev_warn(dev, "Detection failed at step 3\n"); 1166 1189 goto ERROR1; 1167 1190 } 1168 - val1 = w83792d_read_value(new_client, W83792D_REG_BANK); 1169 - val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN); 1191 + val1 = w83792d_read_value(client, W83792D_REG_BANK); 1192 + val2 = w83792d_read_value(client, W83792D_REG_CHIPMAN); 1170 1193 /* Check for Winbond ID if in bank 0 */ 1171 1194 if (!(val1 & 0x07)) { /* is Bank0 */ 1172 1195 if (((!(val1 & 0x80)) && (val2 != 0xa3)) || ··· 1175 1200 } 1176 1201 /* If Winbond chip, address of chip and W83792D_REG_I2C_ADDR 1177 1202 should match */ 1178 - if (w83792d_read_value(new_client, 1203 + if (w83792d_read_value(client, 1179 1204 W83792D_REG_I2C_ADDR) != address) { 1180 - dev_warn(&new_client->dev, "Detection failed " 1181 - "at step 5\n"); 1205 + dev_warn(dev, "Detection failed at step 5\n"); 1182 1206 goto ERROR1; 1183 1207 } 1184 1208 } 1185 1209 1186 1210 /* We have either had a force parameter, or we have already detected the 1187 1211 Winbond. Put it now into bank 0 and Vendor ID High Byte */ 1188 - w83792d_write_value(new_client, 1212 + w83792d_write_value(client, 1189 1213 W83792D_REG_BANK, 1190 - (w83792d_read_value(new_client, 1214 + (w83792d_read_value(client, 1191 1215 W83792D_REG_BANK) & 0x78) | 0x80); 1192 1216 1193 1217 /* Determine the chip type. */ 1194 1218 if (kind <= 0) { 1195 1219 /* get vendor ID */ 1196 - val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN); 1220 + val2 = w83792d_read_value(client, W83792D_REG_CHIPMAN); 1197 1221 if (val2 != 0x5c) { /* the vendor is NOT Winbond */ 1198 1222 goto ERROR1; 1199 1223 } 1200 - val1 = w83792d_read_value(new_client, W83792D_REG_WCHIPID); 1224 + val1 = w83792d_read_value(client, W83792D_REG_WCHIPID); 1201 1225 if (val1 == 0x7a) { 1202 1226 kind = w83792d; 1203 1227 } else { 1204 1228 if (kind == 0) 1205 - dev_warn(&new_client->dev, 1229 + dev_warn(dev, 1206 1230 "w83792d: Ignoring 'force' parameter for" 1207 1231 " unknown chip at adapter %d, address" 1208 1232 " 0x%02x\n", i2c_adapter_id(adapter), ··· 1213 1239 if (kind == w83792d) { 1214 1240 client_name = "w83792d"; 1215 1241 } else { 1216 - dev_err(&new_client->dev, "w83792d: Internal error: unknown" 1242 + dev_err(dev, "w83792d: Internal error: unknown" 1217 1243 " kind (%d)?!?", kind); 1218 1244 goto ERROR1; 1219 1245 } 1220 1246 1221 1247 /* Fill in the remaining client fields and put into the global list */ 1222 - strlcpy(new_client->name, client_name, I2C_NAME_SIZE); 1248 + strlcpy(client->name, client_name, I2C_NAME_SIZE); 1223 1249 data->type = kind; 1224 1250 1225 1251 data->valid = 0; 1226 - init_MUTEX(&data->update_lock); 1252 + mutex_init(&data->update_lock); 1227 1253 1228 1254 /* Tell the I2C layer a new client has arrived */ 1229 - if ((err = i2c_attach_client(new_client))) 1255 + if ((err = i2c_attach_client(client))) 1230 1256 goto ERROR1; 1231 1257 1232 1258 if ((err = w83792d_detect_subclients(adapter, address, 1233 - kind, new_client))) 1259 + kind, client))) 1234 1260 goto ERROR2; 1235 1261 1236 1262 /* Initialize the chip */ 1237 - w83792d_init_client(new_client); 1263 + w83792d_init_client(client); 1238 1264 1239 1265 /* A few vars need to be filled upon startup */ 1240 1266 for (i = 0; i < 7; i++) { 1241 - data->fan_min[i] = w83792d_read_value(new_client, 1267 + data->fan_min[i] = w83792d_read_value(client, 1242 1268 W83792D_REG_FAN_MIN[i]); 1243 1269 } 1244 1270 1245 1271 /* Register sysfs hooks */ 1246 - data->class_dev = hwmon_device_register(&new_client->dev); 1272 + data->class_dev = hwmon_device_register(dev); 1247 1273 if (IS_ERR(data->class_dev)) { 1248 1274 err = PTR_ERR(data->class_dev); 1249 1275 goto ERROR3; 1250 1276 } 1251 - device_create_file_in(new_client, 0); 1252 - device_create_file_in(new_client, 1); 1253 - device_create_file_in(new_client, 2); 1254 - device_create_file_in(new_client, 3); 1255 - device_create_file_in(new_client, 4); 1256 - device_create_file_in(new_client, 5); 1257 - device_create_file_in(new_client, 6); 1258 - device_create_file_in(new_client, 7); 1259 - device_create_file_in(new_client, 8); 1260 - 1261 - device_create_file_fan(new_client, 1); 1262 - device_create_file_fan(new_client, 2); 1263 - device_create_file_fan(new_client, 3); 1277 + for (i = 0; i < 9; i++) { 1278 + device_create_file(dev, &sda_in_input[i].dev_attr); 1279 + device_create_file(dev, &sda_in_max[i].dev_attr); 1280 + device_create_file(dev, &sda_in_min[i].dev_attr); 1281 + } 1282 + for (i = 0; i < 3; i++) 1283 + device_create_file_fan(dev, i); 1264 1284 1265 1285 /* Read GPIO enable register to check if pins for fan 4,5 are used as 1266 1286 GPIO */ 1267 - val1 = w83792d_read_value(new_client, W83792D_REG_GPIO_EN); 1287 + val1 = w83792d_read_value(client, W83792D_REG_GPIO_EN); 1268 1288 if (!(val1 & 0x40)) 1269 - device_create_file_fan(new_client, 4); 1289 + device_create_file_fan(dev, 3); 1270 1290 if (!(val1 & 0x20)) 1271 - device_create_file_fan(new_client, 5); 1291 + device_create_file_fan(dev, 4); 1272 1292 1273 - val1 = w83792d_read_value(new_client, W83792D_REG_PIN); 1293 + val1 = w83792d_read_value(client, W83792D_REG_PIN); 1274 1294 if (val1 & 0x40) 1275 - device_create_file_fan(new_client, 6); 1295 + device_create_file_fan(dev, 5); 1276 1296 if (val1 & 0x04) 1277 - device_create_file_fan(new_client, 7); 1297 + device_create_file_fan(dev, 6); 1278 1298 1279 - device_create_file_temp1(new_client); /* Temp1 */ 1280 - device_create_file_temp_add(new_client, 2); /* Temp2 */ 1281 - device_create_file_temp_add(new_client, 3); /* Temp3 */ 1299 + for (i = 0; i < 3; i++) { 1300 + device_create_file(dev, &sda_temp_input[i].dev_attr); 1301 + device_create_file(dev, &sda_temp_max[i].dev_attr); 1302 + device_create_file(dev, &sda_temp_max_hyst[i].dev_attr); 1303 + device_create_file(dev, &sda_thermal_cruise[i].dev_attr); 1304 + device_create_file(dev, &sda_tolerance[i].dev_attr); 1305 + } 1282 1306 1283 - device_create_file_alarms(new_client); 1307 + for (i = 0; i < ARRAY_SIZE(sda_pwm); i++) { 1308 + device_create_file(dev, &sda_pwm[i].dev_attr); 1309 + device_create_file(dev, &sda_pwm_enable[i].dev_attr); 1310 + device_create_file(dev, &sda_pwm_mode[i].dev_attr); 1311 + } 1284 1312 1285 - device_create_file_pwm(new_client, 1); 1286 - device_create_file_pwm(new_client, 2); 1287 - device_create_file_pwm(new_client, 3); 1313 + device_create_file(dev, &dev_attr_alarms); 1314 + device_create_file(dev, &dev_attr_chassis); 1315 + device_create_file(dev, &dev_attr_chassis_clear); 1288 1316 1289 - device_create_file_pwmenable(new_client, 1); 1290 - device_create_file_pwmenable(new_client, 2); 1291 - device_create_file_pwmenable(new_client, 3); 1317 + for (i = 0; i < ARRAY_SIZE(sda_sf2_point); i++) 1318 + device_create_file(dev, &sda_sf2_point[i].dev_attr); 1292 1319 1293 - device_create_file_pwm_mode(new_client, 1); 1294 - device_create_file_pwm_mode(new_client, 2); 1295 - device_create_file_pwm_mode(new_client, 3); 1296 - 1297 - device_create_file_chassis(new_client); 1298 - device_create_file_chassis_clear(new_client); 1299 - 1300 - device_create_file_thermal_cruise(new_client, 1); 1301 - device_create_file_thermal_cruise(new_client, 2); 1302 - device_create_file_thermal_cruise(new_client, 3); 1303 - 1304 - device_create_file_tolerance(new_client, 1); 1305 - device_create_file_tolerance(new_client, 2); 1306 - device_create_file_tolerance(new_client, 3); 1307 - 1308 - device_create_file_sf2_point(new_client, 1, 1); /* Fan1 */ 1309 - device_create_file_sf2_point(new_client, 2, 1); /* Fan1 */ 1310 - device_create_file_sf2_point(new_client, 3, 1); /* Fan1 */ 1311 - device_create_file_sf2_point(new_client, 4, 1); /* Fan1 */ 1312 - device_create_file_sf2_point(new_client, 1, 2); /* Fan2 */ 1313 - device_create_file_sf2_point(new_client, 2, 2); /* Fan2 */ 1314 - device_create_file_sf2_point(new_client, 3, 2); /* Fan2 */ 1315 - device_create_file_sf2_point(new_client, 4, 2); /* Fan2 */ 1316 - device_create_file_sf2_point(new_client, 1, 3); /* Fan3 */ 1317 - device_create_file_sf2_point(new_client, 2, 3); /* Fan3 */ 1318 - device_create_file_sf2_point(new_client, 3, 3); /* Fan3 */ 1319 - device_create_file_sf2_point(new_client, 4, 3); /* Fan3 */ 1320 - 1321 - device_create_file_sf2_level(new_client, 1, 1); /* Fan1 */ 1322 - device_create_file_sf2_level(new_client, 2, 1); /* Fan1 */ 1323 - device_create_file_sf2_level(new_client, 3, 1); /* Fan1 */ 1324 - device_create_file_sf2_level(new_client, 1, 2); /* Fan2 */ 1325 - device_create_file_sf2_level(new_client, 2, 2); /* Fan2 */ 1326 - device_create_file_sf2_level(new_client, 3, 2); /* Fan2 */ 1327 - device_create_file_sf2_level(new_client, 1, 3); /* Fan3 */ 1328 - device_create_file_sf2_level(new_client, 2, 3); /* Fan3 */ 1329 - device_create_file_sf2_level(new_client, 3, 3); /* Fan3 */ 1320 + for (i = 0; i < ARRAY_SIZE(sda_sf2_level); i++) 1321 + device_create_file(dev, &sda_sf2_level[i].dev_attr); 1330 1322 1331 1323 return 0; 1332 1324 ··· 1306 1366 kfree(data->lm75[1]); 1307 1367 } 1308 1368 ERROR2: 1309 - i2c_detach_client(new_client); 1369 + i2c_detach_client(client); 1310 1370 ERROR1: 1311 1371 kfree(data); 1312 1372 ERROR0: ··· 1374 1434 int i, j; 1375 1435 u8 reg_array_tmp[4], pwm_array_tmp[7], reg_tmp; 1376 1436 1377 - down(&data->update_lock); 1437 + mutex_lock(&data->update_lock); 1378 1438 1379 1439 if (time_after 1380 1440 (jiffies - data->last_updated, (unsigned long) (HZ * 3)) ··· 1485 1545 data->valid = 1; 1486 1546 } 1487 1547 1488 - up(&data->update_lock); 1548 + mutex_unlock(&data->update_lock); 1489 1549 1490 1550 #ifdef DEBUG 1491 1551 w83792d_print_debug(data, dev);
+5 -4
drivers/hwmon/w83l785ts.c
··· 39 39 #include <linux/hwmon.h> 40 40 #include <linux/hwmon-sysfs.h> 41 41 #include <linux/err.h> 42 + #include <linux/mutex.h> 42 43 43 44 /* How many retries on register read error */ 44 45 #define MAX_RETRIES 5 ··· 108 107 struct w83l785ts_data { 109 108 struct i2c_client client; 110 109 struct class_device *class_dev; 111 - struct semaphore update_lock; 110 + struct mutex update_lock; 112 111 char valid; /* zero until following fields are valid */ 113 112 unsigned long last_updated; /* in jiffies */ 114 113 ··· 222 221 /* We can fill in the remaining client fields. */ 223 222 strlcpy(new_client->name, "w83l785ts", I2C_NAME_SIZE); 224 223 data->valid = 0; 225 - init_MUTEX(&data->update_lock); 224 + mutex_init(&data->update_lock); 226 225 227 226 /* Default values in case the first read fails (unlikely). */ 228 227 data->temp[1] = data->temp[0] = 0; ··· 300 299 struct i2c_client *client = to_i2c_client(dev); 301 300 struct w83l785ts_data *data = i2c_get_clientdata(client); 302 301 303 - down(&data->update_lock); 302 + mutex_lock(&data->update_lock); 304 303 305 304 if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { 306 305 dev_dbg(&client->dev, "Updating w83l785ts data.\n"); ··· 313 312 data->valid = 1; 314 313 } 315 314 316 - up(&data->update_lock); 315 + mutex_unlock(&data->update_lock); 317 316 318 317 return data; 319 318 }
+7 -4
drivers/i2c/busses/Kconfig
··· 168 168 help 169 169 If you say yes to this option, support will be included for the Intel 170 170 PIIX4 family of mainboard I2C interfaces. Specifically, the following 171 - versions of the chipset are supported: 171 + versions of the chipset are supported (note that Serverworks is part 172 + of Broadcom): 172 173 Intel PIIX4 173 174 Intel 440MX 174 175 Serverworks OSB4 175 176 Serverworks CSB5 176 177 Serverworks CSB6 178 + Serverworks HT-1000 177 179 SMSC Victory66 178 180 179 181 This driver can also be built as a module. If so, the module ··· 391 389 also be specified with a module parameter. 392 390 393 391 config SCx200_ACB 394 - tristate "NatSemi SCx200 ACCESS.bus" 395 - depends on I2C && PCI 392 + tristate "Geode ACCESS.bus support" 393 + depends on X86_32 && I2C && PCI 396 394 help 397 - Enable the use of the ACCESS.bus controllers of a SCx200 processor. 395 + Enable the use of the ACCESS.bus controllers on the Geode SCx200 and 396 + SC1100 processors and the CS5535 and CS5536 Geode companion devices. 398 397 399 398 If you don't know what to do here, say N. 400 399
-4
drivers/i2c/busses/i2c-ali1535.c
··· 63 63 #include <linux/i2c.h> 64 64 #include <linux/init.h> 65 65 #include <asm/io.h> 66 - #include <asm/semaphore.h> 67 66 68 67 69 68 /* ALI1535 SMBus address offsets */ ··· 135 136 136 137 static struct pci_driver ali1535_driver; 137 138 static unsigned short ali1535_smba; 138 - static DECLARE_MUTEX(i2c_ali1535_sem); 139 139 140 140 /* Detect whether a ALI1535 can be found, and initialize it, where necessary. 141 141 Note the differences between kernels with the old PCI BIOS interface and ··· 343 345 int timeout; 344 346 s32 result = 0; 345 347 346 - down(&i2c_ali1535_sem); 347 348 /* make sure SMBus is idle */ 348 349 temp = inb_p(SMBHSTSTS); 349 350 for (timeout = 0; ··· 457 460 break; 458 461 } 459 462 EXIT: 460 - up(&i2c_ali1535_sem); 461 463 return result; 462 464 } 463 465
+6 -7
drivers/i2c/busses/i2c-amd756-s4882.c
··· 38 38 #include <linux/slab.h> 39 39 #include <linux/init.h> 40 40 #include <linux/i2c.h> 41 + #include <linux/mutex.h> 41 42 42 43 extern struct i2c_adapter amd756_smbus; 43 44 ··· 46 45 static struct i2c_algorithm *s4882_algo; 47 46 48 47 /* Wrapper access functions for multiplexed SMBus */ 49 - static struct semaphore amd756_lock; 48 + static DEFINE_MUTEX(amd756_lock); 50 49 51 50 static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr, 52 51 unsigned short flags, char read_write, ··· 60 59 || addr == 0x18) 61 60 return -1; 62 61 63 - down(&amd756_lock); 62 + mutex_lock(&amd756_lock); 64 63 65 64 error = amd756_smbus.algo->smbus_xfer(adap, addr, flags, read_write, 66 65 command, size, data); 67 66 68 - up(&amd756_lock); 67 + mutex_unlock(&amd756_lock); 69 68 70 69 return error; 71 70 } ··· 88 87 if (addr != 0x4c && (addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30) 89 88 return -1; 90 89 91 - down(&amd756_lock); 90 + mutex_lock(&amd756_lock); 92 91 93 92 if (last_channels != channels) { 94 93 union i2c_smbus_data mplxdata; ··· 106 105 command, size, data); 107 106 108 107 UNLOCK: 109 - up(&amd756_lock); 108 + mutex_unlock(&amd756_lock); 110 109 return error; 111 110 } 112 111 ··· 167 166 } 168 167 169 168 printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n"); 170 - init_MUTEX(&amd756_lock); 171 - 172 169 /* Define the 5 virtual adapters and algorithms structures */ 173 170 if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter), 174 171 GFP_KERNEL))) {
-85
drivers/i2c/busses/i2c-frodo.c
··· 1 - 2 - /* 3 - * linux/drivers/i2c/i2c-frodo.c 4 - * 5 - * Author: Abraham van der Merwe <abraham@2d3d.co.za> 6 - * 7 - * An I2C adapter driver for the 2d3D, Inc. StrongARM SA-1110 8 - * Development board (Frodo). 9 - * 10 - * This source code is free software; you can redistribute it and/or 11 - * modify it under the terms of the GNU General Public License 12 - * version 2 as published by the Free Software Foundation. 13 - */ 14 - 15 - #include <linux/module.h> 16 - #include <linux/kernel.h> 17 - #include <linux/init.h> 18 - #include <linux/delay.h> 19 - #include <linux/i2c.h> 20 - #include <linux/i2c-algo-bit.h> 21 - #include <asm/hardware.h> 22 - 23 - 24 - static void frodo_setsda (void *data,int state) 25 - { 26 - if (state) 27 - FRODO_CPLD_I2C |= FRODO_I2C_SDA_OUT; 28 - else 29 - FRODO_CPLD_I2C &= ~FRODO_I2C_SDA_OUT; 30 - } 31 - 32 - static void frodo_setscl (void *data,int state) 33 - { 34 - if (state) 35 - FRODO_CPLD_I2C |= FRODO_I2C_SCL_OUT; 36 - else 37 - FRODO_CPLD_I2C &= ~FRODO_I2C_SCL_OUT; 38 - } 39 - 40 - static int frodo_getsda (void *data) 41 - { 42 - return ((FRODO_CPLD_I2C & FRODO_I2C_SDA_IN) != 0); 43 - } 44 - 45 - static int frodo_getscl (void *data) 46 - { 47 - return ((FRODO_CPLD_I2C & FRODO_I2C_SCL_IN) != 0); 48 - } 49 - 50 - static struct i2c_algo_bit_data bit_frodo_data = { 51 - .setsda = frodo_setsda, 52 - .setscl = frodo_setscl, 53 - .getsda = frodo_getsda, 54 - .getscl = frodo_getscl, 55 - .udelay = 80, 56 - .mdelay = 80, 57 - .timeout = HZ 58 - }; 59 - 60 - static struct i2c_adapter frodo_ops = { 61 - .owner = THIS_MODULE, 62 - .id = I2C_HW_B_FRODO, 63 - .algo_data = &bit_frodo_data, 64 - .dev = { 65 - .name = "Frodo adapter driver", 66 - }, 67 - }; 68 - 69 - static int __init i2c_frodo_init (void) 70 - { 71 - return i2c_bit_add_bus(&frodo_ops); 72 - } 73 - 74 - static void __exit i2c_frodo_exit (void) 75 - { 76 - i2c_bit_del_bus(&frodo_ops); 77 - } 78 - 79 - MODULE_AUTHOR ("Abraham van der Merwe <abraham@2d3d.co.za>"); 80 - MODULE_DESCRIPTION ("I2C-Bus adapter routines for Frodo"); 81 - MODULE_LICENSE ("GPL"); 82 - 83 - module_init (i2c_frodo_init); 84 - module_exit (i2c_frodo_exit); 85 -
+1 -1
drivers/i2c/busses/i2c-isa.c
··· 125 125 126 126 static int __init i2c_isa_init(void) 127 127 { 128 - init_MUTEX(&isa_adapter.clist_lock); 128 + mutex_init(&isa_adapter.clist_lock); 129 129 INIT_LIST_HEAD(&isa_adapter.clients); 130 130 131 131 isa_adapter.nr = ANY_I2C_ISA_BUS;
+1 -3
drivers/i2c/busses/i2c-ite.c
··· 200 200 .owner = THIS_MODULE, 201 201 .id = I2C_HW_I_IIC, 202 202 .algo_data = &iic_ite_data, 203 - .dev = { 204 - .name = "ITE IIC adapter", 205 - }, 203 + .name = "ITE IIC adapter", 206 204 }; 207 205 208 206 /* Called when the module is loaded. This function starts the
+1
drivers/i2c/busses/i2c-ixp4xx.c
··· 126 126 drv_data->algo_data.timeout = 100; 127 127 128 128 drv_data->adapter.id = I2C_HW_B_IXP4XX; 129 + drv_data->adapter.class = I2C_CLASS_HWMON; 129 130 strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name, 130 131 I2C_NAME_SIZE); 131 132 drv_data->adapter.algo_data = &drv_data->algo_data;
+3 -1
drivers/i2c/busses/i2c-piix4.c
··· 22 22 /* 23 23 Supports: 24 24 Intel PIIX4, 440MX 25 - Serverworks OSB4, CSB5, CSB6 25 + Serverworks OSB4, CSB5, CSB6, HT-1000 26 26 SMSC Victory66 27 27 28 28 Note: we assume there can only be one device, with one SMBus interface. ··· 418 418 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5), 419 419 .driver_data = 0 }, 420 420 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6), 421 + .driver_data = 0 }, 422 + { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000SB), 421 423 .driver_data = 0 }, 422 424 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3), 423 425 .driver_data = 3 },
+1 -1
drivers/i2c/busses/i2c-pxa.c
··· 647 647 } 648 648 649 649 /* 650 - * We are protected by the adapter bus semaphore. 650 + * We are protected by the adapter bus mutex. 651 651 */ 652 652 static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num) 653 653 {
+141 -146
drivers/i2c/busses/scx200_acb.c
··· 1 - /* linux/drivers/i2c/scx200_acb.c 2 - 1 + /* 3 2 Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com> 4 3 5 4 National Semiconductor SCx200 ACCESS.bus support 6 - 5 + Also supports the AMD CS5535 and AMD CS5536 6 + 7 7 Based on i2c-keywest.c which is: 8 8 Copyright (c) 2001 Benjamin Herrenschmidt <benh@kernel.crashing.org> 9 9 Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.com> 10 - 10 + 11 11 This program is free software; you can redistribute it and/or 12 12 modify it under the terms of the GNU General Public License as 13 13 published by the Free Software Foundation; either version 2 of the 14 14 License, or (at your option) any later version. 15 - 15 + 16 16 This program is distributed in the hope that it will be useful, 17 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 19 General Public License for more details. 20 - 20 + 21 21 You should have received a copy of the GNU General Public License 22 22 along with this program; if not, write to the Free Software 23 23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 - 25 24 */ 26 25 27 26 #include <linux/module.h> ··· 31 32 #include <linux/smp_lock.h> 32 33 #include <linux/pci.h> 33 34 #include <linux/delay.h> 35 + #include <linux/mutex.h> 34 36 #include <asm/io.h> 37 + #include <asm/msr.h> 35 38 36 39 #include <linux/scx200.h> 37 40 ··· 48 47 module_param_array(base, int, NULL, 0); 49 48 MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers"); 50 49 51 - #ifdef DEBUG 52 - #define DBG(x...) printk(KERN_DEBUG NAME ": " x) 53 - #else 54 - #define DBG(x...) 55 - #endif 56 - 57 - /* The hardware supports interrupt driven mode too, but I haven't 58 - implemented that. */ 59 - #define POLLED_MODE 1 60 - #define POLL_TIMEOUT (HZ) 50 + #define POLL_TIMEOUT (HZ/5) 61 51 62 52 enum scx200_acb_state { 63 53 state_idle, ··· 71 79 }; 72 80 73 81 /* Physical interface */ 74 - struct scx200_acb_iface 75 - { 82 + struct scx200_acb_iface { 76 83 struct scx200_acb_iface *next; 77 84 struct i2c_adapter adapter; 78 85 unsigned base; 79 - struct semaphore sem; 86 + struct mutex mutex; 80 87 81 88 /* State machine data */ 82 89 enum scx200_acb_state state; ··· 91 100 #define ACBSDA (iface->base + 0) 92 101 #define ACBST (iface->base + 1) 93 102 #define ACBST_SDAST 0x40 /* SDA Status */ 94 - #define ACBST_BER 0x20 103 + #define ACBST_BER 0x20 95 104 #define ACBST_NEGACK 0x10 /* Negative Acknowledge */ 96 105 #define ACBST_STASTR 0x08 /* Stall After Start */ 97 106 #define ACBST_MASTER 0x02 ··· 100 109 #define ACBCTL1 (iface->base + 3) 101 110 #define ACBCTL1_STASTRE 0x80 102 111 #define ACBCTL1_NMINTE 0x40 103 - #define ACBCTL1_ACK 0x10 104 - #define ACBCTL1_STOP 0x02 105 - #define ACBCTL1_START 0x01 112 + #define ACBCTL1_ACK 0x10 113 + #define ACBCTL1_STOP 0x02 114 + #define ACBCTL1_START 0x01 106 115 #define ACBADDR (iface->base + 4) 107 116 #define ACBCTL2 (iface->base + 5) 108 117 #define ACBCTL2_ENABLE 0x01 ··· 113 122 { 114 123 const char *errmsg; 115 124 116 - DBG("state %s, status = 0x%02x\n", 117 - scx200_acb_state_name[iface->state], status); 125 + dev_dbg(&iface->adapter.dev, "state %s, status = 0x%02x\n", 126 + scx200_acb_state_name[iface->state], status); 118 127 119 128 if (status & ACBST_BER) { 120 129 errmsg = "bus error"; ··· 124 133 errmsg = "not master"; 125 134 goto error; 126 135 } 127 - if (status & ACBST_NEGACK) 128 - goto negack; 136 + if (status & ACBST_NEGACK) { 137 + dev_dbg(&iface->adapter.dev, "negative ack in state %s\n", 138 + scx200_acb_state_name[iface->state]); 139 + 140 + iface->state = state_idle; 141 + iface->result = -ENXIO; 142 + 143 + outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); 144 + outb(ACBST_STASTR | ACBST_NEGACK, ACBST); 145 + return; 146 + } 129 147 130 148 switch (iface->state) { 131 149 case state_idle: ··· 160 160 case state_repeat_start: 161 161 outb(inb(ACBCTL1) | ACBCTL1_START, ACBCTL1); 162 162 /* fallthrough */ 163 - 163 + 164 164 case state_quick: 165 165 if (iface->address_byte & 1) { 166 - if (iface->len == 1) 166 + if (iface->len == 1) 167 167 outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1); 168 168 else 169 169 outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1); ··· 202 202 outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); 203 203 break; 204 204 } 205 - 205 + 206 206 outb(*iface->ptr++, ACBSDA); 207 207 --iface->len; 208 - 208 + 209 209 break; 210 210 } 211 211 212 - return; 213 - 214 - negack: 215 - DBG("negative acknowledge in state %s\n", 216 - scx200_acb_state_name[iface->state]); 217 - 218 - iface->state = state_idle; 219 - iface->result = -ENXIO; 220 - 221 - outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); 222 - outb(ACBST_STASTR | ACBST_NEGACK, ACBST); 223 212 return; 224 213 225 214 error: ··· 220 231 iface->needs_reset = 1; 221 232 } 222 233 223 - static void scx200_acb_timeout(struct scx200_acb_iface *iface) 224 - { 225 - dev_err(&iface->adapter.dev, "timeout in state %s\n", 226 - scx200_acb_state_name[iface->state]); 227 - 228 - iface->state = state_idle; 229 - iface->result = -EIO; 230 - iface->needs_reset = 1; 231 - } 232 - 233 - #ifdef POLLED_MODE 234 234 static void scx200_acb_poll(struct scx200_acb_iface *iface) 235 235 { 236 - u8 status = 0; 236 + u8 status; 237 237 unsigned long timeout; 238 238 239 239 timeout = jiffies + POLL_TIMEOUT; ··· 232 254 scx200_acb_machine(iface, status); 233 255 return; 234 256 } 235 - msleep(10); 257 + yield(); 236 258 } 237 259 238 - scx200_acb_timeout(iface); 260 + dev_err(&iface->adapter.dev, "timeout in state %s\n", 261 + scx200_acb_state_name[iface->state]); 262 + 263 + iface->state = state_idle; 264 + iface->result = -EIO; 265 + iface->needs_reset = 1; 239 266 } 240 - #endif /* POLLED_MODE */ 241 267 242 268 static void scx200_acb_reset(struct scx200_acb_iface *iface) 243 269 { 244 270 /* Disable the ACCESS.bus device and Configure the SCL 245 - frequency: 16 clock cycles */ 271 + frequency: 16 clock cycles */ 246 272 outb(0x70, ACBCTL2); 247 273 /* Polling mode */ 248 274 outb(0, ACBCTL1); ··· 265 283 } 266 284 267 285 static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter, 268 - u16 address, unsigned short flags, 269 - char rw, u8 command, int size, 270 - union i2c_smbus_data *data) 286 + u16 address, unsigned short flags, 287 + char rw, u8 command, int size, 288 + union i2c_smbus_data *data) 271 289 { 272 290 struct scx200_acb_iface *iface = i2c_get_adapdata(adapter); 273 291 int len; ··· 277 295 278 296 switch (size) { 279 297 case I2C_SMBUS_QUICK: 280 - len = 0; 281 - buffer = NULL; 282 - break; 298 + len = 0; 299 + buffer = NULL; 300 + break; 301 + 283 302 case I2C_SMBUS_BYTE: 284 - if (rw == I2C_SMBUS_READ) { 285 - len = 1; 286 - buffer = &data->byte; 287 - } else { 288 - len = 1; 289 - buffer = &command; 290 - } 291 - break; 303 + len = 1; 304 + buffer = rw ? &data->byte : &command; 305 + break; 306 + 292 307 case I2C_SMBUS_BYTE_DATA: 293 - len = 1; 294 - buffer = &data->byte; 295 - break; 308 + len = 1; 309 + buffer = &data->byte; 310 + break; 311 + 296 312 case I2C_SMBUS_WORD_DATA: 297 313 len = 2; 298 - cur_word = cpu_to_le16(data->word); 299 - buffer = (u8 *)&cur_word; 314 + cur_word = cpu_to_le16(data->word); 315 + buffer = (u8 *)&cur_word; 300 316 break; 317 + 301 318 case I2C_SMBUS_BLOCK_DATA: 302 - len = data->block[0]; 303 - buffer = &data->block[1]; 319 + len = data->block[0]; 320 + buffer = &data->block[1]; 304 321 break; 322 + 305 323 default: 306 - return -EINVAL; 307 - } 308 - 309 - DBG("size=%d, address=0x%x, command=0x%x, len=%d, read=%d\n", 310 - size, address, command, len, rw == I2C_SMBUS_READ); 311 - 312 - if (!len && rw == I2C_SMBUS_READ) { 313 - dev_warn(&adapter->dev, "zero length read\n"); 314 324 return -EINVAL; 315 325 } 316 326 317 - if (len && !buffer) { 318 - dev_warn(&adapter->dev, "nonzero length but no buffer\n"); 319 - return -EFAULT; 327 + dev_dbg(&adapter->dev, 328 + "size=%d, address=0x%x, command=0x%x, len=%d, read=%d\n", 329 + size, address, command, len, rw); 330 + 331 + if (!len && rw == I2C_SMBUS_READ) { 332 + dev_dbg(&adapter->dev, "zero length read\n"); 333 + return -EINVAL; 320 334 } 321 335 322 - down(&iface->sem); 336 + mutex_lock(&iface->mutex); 323 337 324 - iface->address_byte = address<<1; 325 - if (rw == I2C_SMBUS_READ) 326 - iface->address_byte |= 1; 338 + iface->address_byte = (address << 1) | rw; 327 339 iface->command = command; 328 340 iface->ptr = buffer; 329 341 iface->len = len; ··· 331 355 else 332 356 iface->state = state_address; 333 357 334 - #ifdef POLLED_MODE 335 358 while (iface->state != state_idle) 336 359 scx200_acb_poll(iface); 337 - #else /* POLLED_MODE */ 338 - #error Interrupt driven mode not implemented 339 - #endif /* POLLED_MODE */ 340 360 341 361 if (iface->needs_reset) 342 362 scx200_acb_reset(iface); 343 363 344 364 rc = iface->result; 345 365 346 - up(&iface->sem); 366 + mutex_unlock(&iface->mutex); 347 367 348 368 if (rc == 0 && size == I2C_SMBUS_WORD_DATA && rw == I2C_SMBUS_READ) 349 - data->word = le16_to_cpu(cur_word); 369 + data->word = le16_to_cpu(cur_word); 350 370 351 371 #ifdef DEBUG 352 - DBG(": transfer done, result: %d", rc); 372 + dev_dbg(&adapter->dev, "transfer done, result: %d", rc); 353 373 if (buffer) { 354 374 int i; 355 375 printk(" data:"); ··· 372 400 }; 373 401 374 402 static struct scx200_acb_iface *scx200_acb_list; 403 + static DECLARE_MUTEX(scx200_acb_list_mutex); 375 404 376 405 static int scx200_acb_probe(struct scx200_acb_iface *iface) 377 406 { 378 407 u8 val; 379 408 380 409 /* Disable the ACCESS.bus device and Configure the SCL 381 - frequency: 16 clock cycles */ 410 + frequency: 16 clock cycles */ 382 411 outb(0x70, ACBCTL2); 383 412 384 413 if (inb(ACBCTL2) != 0x70) { 385 - DBG("ACBCTL2 readback failed\n"); 414 + pr_debug(NAME ": ACBCTL2 readback failed\n"); 386 415 return -ENXIO; 387 416 } 388 417 ··· 391 418 392 419 val = inb(ACBCTL1); 393 420 if (val) { 394 - DBG("disabled, but ACBCTL1=0x%02x\n", val); 421 + pr_debug(NAME ": disabled, but ACBCTL1=0x%02x\n", 422 + val); 395 423 return -ENXIO; 396 424 } 397 425 ··· 402 428 403 429 val = inb(ACBCTL1); 404 430 if ((val & ACBCTL1_NMINTE) != ACBCTL1_NMINTE) { 405 - DBG("enabled, but NMINTE won't be set, ACBCTL1=0x%02x\n", val); 431 + pr_debug(NAME ": enabled, but NMINTE won't be set, " 432 + "ACBCTL1=0x%02x\n", val); 406 433 return -ENXIO; 407 434 } 408 435 409 436 return 0; 410 437 } 411 438 412 - static int __init scx200_acb_create(int base, int index) 439 + static int __init scx200_acb_create(const char *text, int base, int index) 413 440 { 414 441 struct scx200_acb_iface *iface; 415 442 struct i2c_adapter *adapter; 416 - int rc = 0; 443 + int rc; 417 444 char description[64]; 418 445 419 446 iface = kzalloc(sizeof(*iface), GFP_KERNEL); ··· 426 451 427 452 adapter = &iface->adapter; 428 453 i2c_set_adapdata(adapter, iface); 429 - snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index); 454 + snprintf(adapter->name, I2C_NAME_SIZE, "%s ACB%d", text, index); 430 455 adapter->owner = THIS_MODULE; 431 456 adapter->id = I2C_HW_SMBUS_SCX200; 432 457 adapter->algo = &scx200_acb_algorithm; 433 458 adapter->class = I2C_CLASS_HWMON; 434 459 435 - init_MUTEX(&iface->sem); 460 + mutex_init(&iface->mutex); 436 461 437 - snprintf(description, sizeof(description), "NatSemi SCx200 ACCESS.bus [%s]", adapter->name); 462 + snprintf(description, sizeof(description), "%s ACCESS.bus [%s]", 463 + text, adapter->name); 464 + 438 465 if (request_region(base, 8, description) == 0) { 439 - dev_err(&adapter->dev, "can't allocate io 0x%x-0x%x\n", 466 + printk(KERN_ERR NAME ": can't allocate io 0x%x-0x%x\n", 440 467 base, base + 8-1); 441 468 rc = -EBUSY; 442 - goto errout; 469 + goto errout_free; 443 470 } 444 471 iface->base = base; 445 472 446 473 rc = scx200_acb_probe(iface); 447 474 if (rc) { 448 - dev_warn(&adapter->dev, "probe failed\n"); 449 - goto errout; 475 + printk(KERN_WARNING NAME ": probe failed\n"); 476 + goto errout_release; 450 477 } 451 478 452 479 scx200_acb_reset(iface); 453 480 454 481 if (i2c_add_adapter(adapter) < 0) { 455 - dev_err(&adapter->dev, "failed to register\n"); 482 + printk(KERN_ERR NAME ": failed to register\n"); 456 483 rc = -ENODEV; 457 - goto errout; 484 + goto errout_release; 458 485 } 459 486 460 - lock_kernel(); 487 + down(&scx200_acb_list_mutex); 461 488 iface->next = scx200_acb_list; 462 489 scx200_acb_list = iface; 463 - unlock_kernel(); 490 + up(&scx200_acb_list_mutex); 464 491 465 492 return 0; 466 493 494 + errout_release: 495 + release_region(iface->base, 8); 496 + errout_free: 497 + kfree(iface); 467 498 errout: 468 - if (iface) { 469 - if (iface->base) 470 - release_region(iface->base, 8); 471 - kfree(iface); 472 - } 473 499 return rc; 474 500 } 475 501 ··· 480 504 { }, 481 505 }; 482 506 507 + static struct pci_device_id divil_pci[] = { 508 + { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, 509 + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, 510 + { } /* NULL entry */ 511 + }; 512 + 513 + #define MSR_LBAR_SMB 0x5140000B 514 + 515 + static int scx200_add_cs553x(void) 516 + { 517 + u32 low, hi; 518 + u32 smb_base; 519 + 520 + /* Grab & reserve the SMB I/O range */ 521 + rdmsr(MSR_LBAR_SMB, low, hi); 522 + 523 + /* Check the IO mask and whether SMB is enabled */ 524 + if (hi != 0x0000F001) { 525 + printk(KERN_WARNING NAME ": SMBus not enabled\n"); 526 + return -ENODEV; 527 + } 528 + 529 + /* SMBus IO size is 8 bytes */ 530 + smb_base = low & 0x0000FFF8; 531 + 532 + return scx200_acb_create("CS5535", smb_base, 0); 533 + } 534 + 483 535 static int __init scx200_acb_init(void) 484 536 { 485 537 int i; 486 - int rc; 538 + int rc = -ENODEV; 487 539 488 540 pr_debug(NAME ": NatSemi SCx200 ACCESS.bus Driver\n"); 489 541 490 542 /* Verify that this really is a SCx200 processor */ 491 - if (pci_dev_present(scx200) == 0) 492 - return -ENODEV; 543 + if (pci_dev_present(scx200)) { 544 + for (i = 0; i < MAX_DEVICES; ++i) { 545 + if (base[i] > 0) 546 + rc = scx200_acb_create("SCx200", base[i], i); 547 + } 548 + } else if (pci_dev_present(divil_pci)) 549 + rc = scx200_add_cs553x(); 493 550 494 - rc = -ENXIO; 495 - for (i = 0; i < MAX_DEVICES; ++i) { 496 - if (base[i] > 0) 497 - rc = scx200_acb_create(base[i], i); 498 - } 499 - if (scx200_acb_list) 500 - return 0; 501 551 return rc; 502 552 } 503 553 504 554 static void __exit scx200_acb_cleanup(void) 505 555 { 506 556 struct scx200_acb_iface *iface; 507 - lock_kernel(); 557 + 558 + down(&scx200_acb_list_mutex); 508 559 while ((iface = scx200_acb_list) != NULL) { 509 560 scx200_acb_list = iface->next; 510 - unlock_kernel(); 561 + up(&scx200_acb_list_mutex); 511 562 512 563 i2c_del_adapter(&iface->adapter); 513 564 release_region(iface->base, 8); 514 565 kfree(iface); 515 - lock_kernel(); 566 + down(&scx200_acb_list_mutex); 516 567 } 517 - unlock_kernel(); 568 + up(&scx200_acb_list_mutex); 518 569 } 519 570 520 571 module_init(scx200_acb_init); 521 572 module_exit(scx200_acb_cleanup); 522 - 523 - /* 524 - Local variables: 525 - compile-command: "make -k -C ../.. SUBDIRS=drivers/i2c modules" 526 - c-basic-offset: 8 527 - End: 528 - */ 529 -
+6 -5
drivers/i2c/chips/ds1374.c
··· 26 26 #include <linux/i2c.h> 27 27 #include <linux/rtc.h> 28 28 #include <linux/bcd.h> 29 + #include <linux/mutex.h> 29 30 30 31 #define DS1374_REG_TOD0 0x00 31 32 #define DS1374_REG_TOD1 0x01 ··· 42 41 43 42 #define DS1374_DRV_NAME "ds1374" 44 43 45 - static DECLARE_MUTEX(ds1374_mutex); 44 + static DEFINE_MUTEX(ds1374_mutex); 46 45 47 46 static struct i2c_driver ds1374_driver; 48 47 static struct i2c_client *save_client; ··· 115 114 ulong t1, t2; 116 115 int limit = 10; /* arbitrary retry limit */ 117 116 118 - down(&ds1374_mutex); 117 + mutex_lock(&ds1374_mutex); 119 118 120 119 /* 121 120 * Since the reads are being performed one byte at a time using ··· 128 127 t2 = ds1374_read_rtc(); 129 128 } while (t1 != t2 && limit--); 130 129 131 - up(&ds1374_mutex); 130 + mutex_unlock(&ds1374_mutex); 132 131 133 132 if (t1 != t2) { 134 133 dev_warn(&save_client->dev, ··· 146 145 147 146 t1 = *(ulong *) arg; 148 147 149 - down(&ds1374_mutex); 148 + mutex_lock(&ds1374_mutex); 150 149 151 150 /* 152 151 * Since the writes are being performed one byte at a time using ··· 159 158 t2 = ds1374_read_rtc(); 160 159 } while (t1 != t2 && limit--); 161 160 162 - up(&ds1374_mutex); 161 + mutex_unlock(&ds1374_mutex); 163 162 164 163 if (t1 != t2) 165 164 dev_warn(&save_client->dev,
+5 -4
drivers/i2c/chips/eeprom.c
··· 33 33 #include <linux/sched.h> 34 34 #include <linux/jiffies.h> 35 35 #include <linux/i2c.h> 36 + #include <linux/mutex.h> 36 37 37 38 /* Addresses to scan */ 38 39 static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54, ··· 55 54 /* Each client has this additional data */ 56 55 struct eeprom_data { 57 56 struct i2c_client client; 58 - struct semaphore update_lock; 57 + struct mutex update_lock; 59 58 u8 valid; /* bitfield, bit!=0 if slice is valid */ 60 59 unsigned long last_updated[8]; /* In jiffies, 8 slices */ 61 60 u8 data[EEPROM_SIZE]; /* Register values */ ··· 82 81 struct eeprom_data *data = i2c_get_clientdata(client); 83 82 int i, j; 84 83 85 - down(&data->update_lock); 84 + mutex_lock(&data->update_lock); 86 85 87 86 if (!(data->valid & (1 << slice)) || 88 87 time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { ··· 108 107 data->valid |= (1 << slice); 109 108 } 110 109 exit: 111 - up(&data->update_lock); 110 + mutex_unlock(&data->update_lock); 112 111 } 113 112 114 113 static ssize_t eeprom_read(struct kobject *kobj, char *buf, loff_t off, size_t count) ··· 188 187 /* Fill in the remaining client fields */ 189 188 strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE); 190 189 data->valid = 0; 191 - init_MUTEX(&data->update_lock); 190 + mutex_init(&data->update_lock); 192 191 data->nature = UNKNOWN; 193 192 194 193 /* Tell the I2C layer a new client has arrived */
-2
drivers/i2c/chips/isp1301_omap.c
··· 1635 1635 .driver = { 1636 1636 .name = "isp1301_omap", 1637 1637 }, 1638 - .id = 1301, /* FIXME "official", i2c-ids.h */ 1639 - .class = I2C_CLASS_HWMON, 1640 1638 .attach_adapter = isp1301_scan_bus, 1641 1639 .detach_client = isp1301_detach_client, 1642 1640 };
+6 -5
drivers/i2c/chips/m41t00.c
··· 24 24 #include <linux/i2c.h> 25 25 #include <linux/rtc.h> 26 26 #include <linux/bcd.h> 27 + #include <linux/mutex.h> 27 28 28 29 #include <asm/time.h> 29 30 #include <asm/rtc.h> 30 31 31 32 #define M41T00_DRV_NAME "m41t00" 32 33 33 - static DECLARE_MUTEX(m41t00_mutex); 34 + static DEFINE_MUTEX(m41t00_mutex); 34 35 35 36 static struct i2c_driver m41t00_driver; 36 37 static struct i2c_client *save_client; ··· 55 54 sec = min = hour = day = mon = year = 0; 56 55 sec1 = min1 = hour1 = day1 = mon1 = year1 = 0; 57 56 58 - down(&m41t00_mutex); 57 + mutex_lock(&m41t00_mutex); 59 58 do { 60 59 if (((sec = i2c_smbus_read_byte_data(save_client, 0)) >= 0) 61 60 && ((min = i2c_smbus_read_byte_data(save_client, 1)) ··· 81 80 mon1 = mon; 82 81 year1 = year; 83 82 } while (--limit > 0); 84 - up(&m41t00_mutex); 83 + mutex_unlock(&m41t00_mutex); 85 84 86 85 if (limit == 0) { 87 86 dev_warn(&save_client->dev, ··· 126 125 BIN_TO_BCD(tm.tm_mday); 127 126 BIN_TO_BCD(tm.tm_year); 128 127 129 - down(&m41t00_mutex); 128 + mutex_lock(&m41t00_mutex); 130 129 if ((i2c_smbus_write_byte_data(save_client, 0, tm.tm_sec & 0x7f) < 0) 131 130 || (i2c_smbus_write_byte_data(save_client, 1, tm.tm_min & 0x7f) 132 131 < 0) ··· 141 140 142 141 dev_warn(&save_client->dev,"m41t00: can't write to rtc chip\n"); 143 142 144 - up(&m41t00_mutex); 143 + mutex_unlock(&m41t00_mutex); 145 144 return; 146 145 } 147 146
+5 -5
drivers/i2c/chips/max6875.c
··· 31 31 #include <linux/module.h> 32 32 #include <linux/slab.h> 33 33 #include <linux/i2c.h> 34 - #include <asm/semaphore.h> 34 + #include <linux/mutex.h> 35 35 36 36 /* Do not scan - the MAX6875 access method will write to some EEPROM chips */ 37 37 static unsigned short normal_i2c[] = {I2C_CLIENT_END}; ··· 54 54 /* Each client has this additional data */ 55 55 struct max6875_data { 56 56 struct i2c_client client; 57 - struct semaphore update_lock; 57 + struct mutex update_lock; 58 58 59 59 u32 valid; 60 60 u8 data[USER_EEPROM_SIZE]; ··· 83 83 if (slice >= USER_EEPROM_SLICES) 84 84 return; 85 85 86 - down(&data->update_lock); 86 + mutex_lock(&data->update_lock); 87 87 88 88 buf = &data->data[slice << SLICE_BITS]; 89 89 ··· 122 122 data->valid |= (1 << slice); 123 123 } 124 124 exit_up: 125 - up(&data->update_lock); 125 + mutex_unlock(&data->update_lock); 126 126 } 127 127 128 128 static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, ··· 196 196 real_client->driver = &max6875_driver; 197 197 real_client->flags = 0; 198 198 strlcpy(real_client->name, "max6875", I2C_NAME_SIZE); 199 - init_MUTEX(&data->update_lock); 199 + mutex_init(&data->update_lock); 200 200 201 201 /* Init fake client data */ 202 202 /* set the client data to the i2c_client so that it will get freed */
+7 -6
drivers/i2c/chips/pcf8591.c
··· 24 24 #include <linux/init.h> 25 25 #include <linux/slab.h> 26 26 #include <linux/i2c.h> 27 + #include <linux/mutex.h> 27 28 28 29 /* Addresses to scan */ 29 30 static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, ··· 75 74 76 75 struct pcf8591_data { 77 76 struct i2c_client client; 78 - struct semaphore update_lock; 77 + struct mutex update_lock; 79 78 80 79 u8 control; 81 80 u8 aout; ··· 145 144 struct pcf8591_data *data = i2c_get_clientdata(client); 146 145 unsigned long val = simple_strtoul(buf, NULL, 10); 147 146 148 - down(&data->update_lock); 147 + mutex_lock(&data->update_lock); 149 148 if (val) 150 149 data->control |= PCF8591_CONTROL_AOEF; 151 150 else 152 151 data->control &= ~PCF8591_CONTROL_AOEF; 153 152 i2c_smbus_write_byte(client, data->control); 154 - up(&data->update_lock); 153 + mutex_unlock(&data->update_lock); 155 154 return count; 156 155 } 157 156 ··· 201 200 /* Fill in the remaining client fields and put it into the global 202 201 list */ 203 202 strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE); 204 - init_MUTEX(&data->update_lock); 203 + mutex_init(&data->update_lock); 205 204 206 205 /* Tell the I2C layer a new client has arrived */ 207 206 if ((err = i2c_attach_client(new_client))) ··· 266 265 struct i2c_client *client = to_i2c_client(dev); 267 266 struct pcf8591_data *data = i2c_get_clientdata(client); 268 267 269 - down(&data->update_lock); 268 + mutex_lock(&data->update_lock); 270 269 271 270 if ((data->control & PCF8591_CONTROL_AICH_MASK) != channel) { 272 271 data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK) ··· 279 278 } 280 279 value = i2c_smbus_read_byte(client); 281 280 282 - up(&data->update_lock); 281 + mutex_unlock(&data->update_lock); 283 282 284 283 if ((channel == 2 && input_mode == 2) || 285 284 (channel != 3 && (input_mode == 1 || input_mode == 3)))
+23 -22
drivers/i2c/chips/tps65010.c
··· 32 32 #include <linux/suspend.h> 33 33 #include <linux/debugfs.h> 34 34 #include <linux/seq_file.h> 35 + #include <linux/mutex.h> 35 36 36 37 #include <asm/irq.h> 37 38 #include <asm/mach-types.h> ··· 82 81 83 82 struct tps65010 { 84 83 struct i2c_client client; 85 - struct semaphore lock; 84 + struct mutex lock; 86 85 int irq; 87 86 struct work_struct work; 88 87 struct dentry *file; ··· 219 218 seq_printf(s, "driver %s\nversion %s\nchip %s\n\n", 220 219 DRIVER_NAME, DRIVER_VERSION, chip); 221 220 222 - down(&tps->lock); 221 + mutex_lock(&tps->lock); 223 222 224 223 /* FIXME how can we tell whether a battery is present? 225 224 * likely involves a charge gauging chip (like BQ26501). ··· 301 300 (v2 & (1 << (4 + i))) ? "rising" : "falling"); 302 301 } 303 302 304 - up(&tps->lock); 303 + mutex_unlock(&tps->lock); 305 304 return 0; 306 305 } 307 306 ··· 417 416 { 418 417 struct tps65010 *tps = _tps; 419 418 420 - down(&tps->lock); 419 + mutex_lock(&tps->lock); 421 420 422 421 tps65010_interrupt(tps); 423 422 ··· 445 444 if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags)) 446 445 enable_irq(tps->irq); 447 446 448 - up(&tps->lock); 447 + mutex_unlock(&tps->lock); 449 448 } 450 449 451 450 static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs) ··· 506 505 if (!tps) 507 506 return 0; 508 507 509 - init_MUTEX(&tps->lock); 508 + mutex_init(&tps->lock); 510 509 INIT_WORK(&tps->work, tps65010_work, tps); 511 510 tps->irq = -1; 512 511 tps->client.addr = address; ··· 696 695 if ((gpio < GPIO1) || (gpio > GPIO4)) 697 696 return -EINVAL; 698 697 699 - down(&the_tps->lock); 698 + mutex_lock(&the_tps->lock); 700 699 701 700 defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO); 702 701 ··· 721 720 gpio, value ? "high" : "low", 722 721 i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO)); 723 722 724 - up(&the_tps->lock); 723 + mutex_unlock(&the_tps->lock); 725 724 return status; 726 725 } 727 726 EXPORT_SYMBOL(tps65010_set_gpio_out_value); ··· 746 745 led = LED2; 747 746 } 748 747 749 - down(&the_tps->lock); 748 + mutex_lock(&the_tps->lock); 750 749 751 750 pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led, 752 751 i2c_smbus_read_byte_data(&the_tps->client, ··· 772 771 default: 773 772 printk(KERN_ERR "%s: Wrong mode parameter for set_led()\n", 774 773 DRIVER_NAME); 775 - up(&the_tps->lock); 774 + mutex_unlock(&the_tps->lock); 776 775 return -EINVAL; 777 776 } 778 777 ··· 782 781 if (status != 0) { 783 782 printk(KERN_ERR "%s: Failed to write led%i_on register\n", 784 783 DRIVER_NAME, led); 785 - up(&the_tps->lock); 784 + mutex_unlock(&the_tps->lock); 786 785 return status; 787 786 } 788 787 ··· 795 794 if (status != 0) { 796 795 printk(KERN_ERR "%s: Failed to write led%i_per register\n", 797 796 DRIVER_NAME, led); 798 - up(&the_tps->lock); 797 + mutex_unlock(&the_tps->lock); 799 798 return status; 800 799 } 801 800 ··· 803 802 i2c_smbus_read_byte_data(&the_tps->client, 804 803 TPS_LED1_PER + offs)); 805 804 806 - up(&the_tps->lock); 805 + mutex_unlock(&the_tps->lock); 807 806 808 807 return status; 809 808 } ··· 821 820 if (!the_tps) 822 821 return -ENODEV; 823 822 824 - down(&the_tps->lock); 823 + mutex_lock(&the_tps->lock); 825 824 826 825 vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2); 827 826 vdcdc2 &= ~(1 << 1); ··· 832 831 833 832 pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off"); 834 833 835 - up(&the_tps->lock); 834 + mutex_unlock(&the_tps->lock); 836 835 return status; 837 836 } 838 837 EXPORT_SYMBOL(tps65010_set_vib); ··· 849 848 if (!the_tps) 850 849 return -ENODEV; 851 850 852 - down(&the_tps->lock); 851 + mutex_lock(&the_tps->lock); 853 852 854 853 pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME, 855 854 mode ? "enable" : "disable", ··· 877 876 pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, 878 877 i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); 879 878 880 - up(&the_tps->lock); 879 + mutex_unlock(&the_tps->lock); 881 880 882 881 return status; 883 882 } ··· 895 894 if (!the_tps) 896 895 return -ENODEV; 897 896 898 - down(&the_tps->lock); 897 + mutex_lock(&the_tps->lock); 899 898 900 899 pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, 901 900 i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); ··· 910 909 pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, 911 910 i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); 912 911 913 - up(&the_tps->lock); 912 + mutex_unlock(&the_tps->lock); 914 913 915 914 return status; 916 915 } ··· 932 931 if (!the_tps || the_tps->por) 933 932 return -ENODEV; 934 933 935 - down(&the_tps->lock); 934 + mutex_lock(&the_tps->lock); 936 935 937 936 pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n", 938 937 DRIVER_NAME, ··· 960 959 if (status != 0) { 961 960 printk(KERN_ERR "%s: Failed to write chconfig register\n", 962 961 DRIVER_NAME); 963 - up(&the_tps->lock); 962 + mutex_unlock(&the_tps->lock); 964 963 return status; 965 964 } 966 965 ··· 978 977 pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, 979 978 i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); 980 979 981 - up(&the_tps->lock); 980 + mutex_unlock(&the_tps->lock); 982 981 983 982 return status; 984 983 }
+39 -42
drivers/i2c/i2c-core.c
··· 31 31 #include <linux/idr.h> 32 32 #include <linux/seq_file.h> 33 33 #include <linux/platform_device.h> 34 + #include <linux/mutex.h> 34 35 #include <asm/uaccess.h> 35 36 36 37 37 38 static LIST_HEAD(adapters); 38 39 static LIST_HEAD(drivers); 39 - static DECLARE_MUTEX(core_lists); 40 + static DEFINE_MUTEX(core_lists); 40 41 static DEFINE_IDR(i2c_adapter_idr); 41 42 42 43 /* match always succeeds, as we want the probe() to tell if we really accept this match */ ··· 154 153 struct list_head *item; 155 154 struct i2c_driver *driver; 156 155 157 - down(&core_lists); 156 + mutex_lock(&core_lists); 158 157 159 158 if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) { 160 159 res = -ENOMEM; ··· 169 168 } 170 169 171 170 adap->nr = id & MAX_ID_MASK; 172 - init_MUTEX(&adap->bus_lock); 173 - init_MUTEX(&adap->clist_lock); 171 + mutex_init(&adap->bus_lock); 172 + mutex_init(&adap->clist_lock); 174 173 list_add_tail(&adap->list,&adapters); 175 174 INIT_LIST_HEAD(&adap->clients); 176 175 ··· 204 203 } 205 204 206 205 out_unlock: 207 - up(&core_lists); 206 + mutex_unlock(&core_lists); 208 207 return res; 209 208 } 210 209 ··· 217 216 struct i2c_client *client; 218 217 int res = 0; 219 218 220 - down(&core_lists); 219 + mutex_lock(&core_lists); 221 220 222 221 /* First make sure that this adapter was ever added */ 223 222 list_for_each_entry(adap_from_list, &adapters, list) { ··· 273 272 dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); 274 273 275 274 out_unlock: 276 - up(&core_lists); 275 + mutex_unlock(&core_lists); 277 276 return res; 278 277 } 279 278 ··· 288 287 { 289 288 struct list_head *item; 290 289 struct i2c_adapter *adapter; 291 - int res = 0; 292 - 293 - down(&core_lists); 290 + int res; 294 291 295 292 /* add the driver to the list of i2c drivers in the driver core */ 296 293 driver->driver.owner = owner; ··· 296 297 297 298 res = driver_register(&driver->driver); 298 299 if (res) 299 - goto out_unlock; 300 + return res; 300 301 302 + mutex_lock(&core_lists); 303 + 301 304 list_add_tail(&driver->list,&drivers); 302 305 pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name); 303 306 ··· 311 310 } 312 311 } 313 312 314 - out_unlock: 315 - up(&core_lists); 316 - return res; 313 + mutex_unlock(&core_lists); 314 + return 0; 317 315 } 318 316 EXPORT_SYMBOL(i2c_register_driver); 319 317 ··· 324 324 325 325 int res = 0; 326 326 327 - down(&core_lists); 327 + mutex_lock(&core_lists); 328 328 329 329 /* Have a look at each adapter, if clients of this driver are still 330 330 * attached. If so, detach them to be able to kill the driver ··· 363 363 pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); 364 364 365 365 out_unlock: 366 - up(&core_lists); 366 + mutex_unlock(&core_lists); 367 367 return 0; 368 368 } 369 369 ··· 384 384 { 385 385 int rval; 386 386 387 - down(&adapter->clist_lock); 387 + mutex_lock(&adapter->clist_lock); 388 388 rval = __i2c_check_addr(adapter, addr); 389 - up(&adapter->clist_lock); 389 + mutex_unlock(&adapter->clist_lock); 390 390 391 391 return rval; 392 392 } ··· 395 395 { 396 396 struct i2c_adapter *adapter = client->adapter; 397 397 398 - down(&adapter->clist_lock); 398 + mutex_lock(&adapter->clist_lock); 399 399 if (__i2c_check_addr(client->adapter, client->addr)) { 400 - up(&adapter->clist_lock); 400 + mutex_unlock(&adapter->clist_lock); 401 401 return -EBUSY; 402 402 } 403 403 list_add_tail(&client->list,&adapter->clients); 404 - up(&adapter->clist_lock); 404 + mutex_unlock(&adapter->clist_lock); 405 405 406 406 if (adapter->client_register) { 407 407 if (adapter->client_register(client)) { ··· 450 450 } 451 451 } 452 452 453 - down(&adapter->clist_lock); 453 + mutex_lock(&adapter->clist_lock); 454 454 list_del(&client->list); 455 455 init_completion(&client->released); 456 456 device_remove_file(&client->dev, &dev_attr_client_name); 457 457 device_unregister(&client->dev); 458 - up(&adapter->clist_lock); 458 + mutex_unlock(&adapter->clist_lock); 459 459 wait_for_completion(&client->released); 460 460 461 461 out: ··· 513 513 struct list_head *item; 514 514 struct i2c_client *client; 515 515 516 - down(&adap->clist_lock); 516 + mutex_lock(&adap->clist_lock); 517 517 list_for_each(item,&adap->clients) { 518 518 client = list_entry(item, struct i2c_client, list); 519 519 if (!try_module_get(client->driver->driver.owner)) 520 520 continue; 521 521 if (NULL != client->driver->command) { 522 - up(&adap->clist_lock); 522 + mutex_unlock(&adap->clist_lock); 523 523 client->driver->command(client,cmd,arg); 524 - down(&adap->clist_lock); 524 + mutex_lock(&adap->clist_lock); 525 525 } 526 526 module_put(client->driver->driver.owner); 527 527 } 528 - up(&adap->clist_lock); 528 + mutex_unlock(&adap->clist_lock); 529 529 } 530 530 531 531 static int __init i2c_init(void) ··· 569 569 } 570 570 #endif 571 571 572 - down(&adap->bus_lock); 572 + mutex_lock(&adap->bus_lock); 573 573 ret = adap->algo->master_xfer(adap,msgs,num); 574 - up(&adap->bus_lock); 574 + mutex_unlock(&adap->bus_lock); 575 575 576 576 return ret; 577 577 } else { ··· 779 779 { 780 780 struct i2c_adapter *adapter; 781 781 782 - down(&core_lists); 782 + mutex_lock(&core_lists); 783 783 adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); 784 784 if (adapter && !try_module_get(adapter->owner)) 785 785 adapter = NULL; 786 786 787 - up(&core_lists); 787 + mutex_unlock(&core_lists); 788 788 return adapter; 789 789 } 790 790 ··· 919 919 u8 length, u8 *values) 920 920 { 921 921 union i2c_smbus_data data; 922 - int i; 922 + 923 923 if (length > I2C_SMBUS_BLOCK_MAX) 924 924 length = I2C_SMBUS_BLOCK_MAX; 925 - for (i = 1; i <= length; i++) 926 - data.block[i] = values[i-1]; 927 925 data.block[0] = length; 926 + memcpy(&data.block[1], values, length); 928 927 return i2c_smbus_xfer(client->adapter,client->addr,client->flags, 929 928 I2C_SMBUS_WRITE,command, 930 929 I2C_SMBUS_BLOCK_DATA,&data); ··· 933 934 s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values) 934 935 { 935 936 union i2c_smbus_data data; 936 - int i; 937 + 937 938 if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, 938 939 I2C_SMBUS_READ,command, 939 940 I2C_SMBUS_I2C_BLOCK_DATA,&data)) 940 941 return -1; 941 - else { 942 - for (i = 1; i <= data.block[0]; i++) 943 - values[i-1] = data.block[i]; 944 - return data.block[0]; 945 - } 942 + 943 + memcpy(values, &data.block[1], data.block[0]); 944 + return data.block[0]; 946 945 } 947 946 948 947 s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command, ··· 1115 1118 flags &= I2C_M_TEN | I2C_CLIENT_PEC; 1116 1119 1117 1120 if (adapter->algo->smbus_xfer) { 1118 - down(&adapter->bus_lock); 1121 + mutex_lock(&adapter->bus_lock); 1119 1122 res = adapter->algo->smbus_xfer(adapter,addr,flags,read_write, 1120 1123 command,size,data); 1121 - up(&adapter->bus_lock); 1124 + mutex_unlock(&adapter->bus_lock); 1122 1125 } else 1123 1126 res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, 1124 1127 command,size,data);
-1
drivers/media/video/adv7170.c
··· 53 53 MODULE_LICENSE("GPL"); 54 54 55 55 #include <linux/i2c.h> 56 - #include <linux/i2c-dev.h> 57 56 58 57 #define I2C_NAME(x) (x)->name 59 58
-1
drivers/media/video/adv7175.c
··· 49 49 MODULE_LICENSE("GPL"); 50 50 51 51 #include <linux/i2c.h> 52 - #include <linux/i2c-dev.h> 53 52 54 53 #define I2C_NAME(s) (s)->name 55 54
-1
drivers/media/video/bt819.c
··· 53 53 MODULE_LICENSE("GPL"); 54 54 55 55 #include <linux/i2c.h> 56 - #include <linux/i2c-dev.h> 57 56 58 57 #define I2C_NAME(s) (s)->name 59 58
-1
drivers/media/video/bt856.c
··· 53 53 MODULE_LICENSE("GPL"); 54 54 55 55 #include <linux/i2c.h> 56 - #include <linux/i2c-dev.h> 57 56 58 57 #define I2C_NAME(s) (s)->name 59 58
-1
drivers/media/video/saa7110.c
··· 39 39 MODULE_LICENSE("GPL"); 40 40 41 41 #include <linux/i2c.h> 42 - #include <linux/i2c-dev.h> 43 42 44 43 #define I2C_NAME(s) (s)->name 45 44
-1
drivers/media/video/saa7111.c
··· 52 52 MODULE_LICENSE("GPL"); 53 53 54 54 #include <linux/i2c.h> 55 - #include <linux/i2c-dev.h> 56 55 57 56 #define I2C_NAME(s) (s)->name 58 57
-1
drivers/media/video/saa7114.c
··· 55 55 MODULE_LICENSE("GPL"); 56 56 57 57 #include <linux/i2c.h> 58 - #include <linux/i2c-dev.h> 59 58 60 59 #define I2C_NAME(x) (x)->name 61 60
-1
drivers/media/video/saa711x.c
··· 45 45 MODULE_LICENSE("GPL"); 46 46 47 47 #include <linux/i2c.h> 48 - #include <linux/i2c-dev.h> 49 48 50 49 #define I2C_NAME(s) (s)->name 51 50
-1
drivers/media/video/saa7185.c
··· 49 49 MODULE_LICENSE("GPL"); 50 50 51 51 #include <linux/i2c.h> 52 - #include <linux/i2c-dev.h> 53 52 54 53 #define I2C_NAME(s) (s)->name 55 54
-1
drivers/media/video/vpx3220.c
··· 30 30 #include <asm/uaccess.h> 31 31 32 32 #include <linux/i2c.h> 33 - #include <linux/i2c-dev.h> 34 33 35 34 #define I2C_NAME(x) (x)->name 36 35
+14 -10
include/linux/hwmon-sysfs.h
··· 27 27 #define to_sensor_dev_attr(_dev_attr) \ 28 28 container_of(_dev_attr, struct sensor_device_attribute, dev_attr) 29 29 30 - #define SENSOR_DEVICE_ATTR(_name,_mode,_show,_store,_index) \ 31 - struct sensor_device_attribute sensor_dev_attr_##_name = { \ 32 - .dev_attr = __ATTR(_name,_mode,_show,_store), \ 33 - .index = _index, \ 34 - } 30 + #define SENSOR_ATTR(_name, _mode, _show, _store, _index) \ 31 + { .dev_attr = __ATTR(_name, _mode, _show, _store), \ 32 + .index = _index } 33 + 34 + #define SENSOR_DEVICE_ATTR(_name, _mode, _show, _store, _index) \ 35 + struct sensor_device_attribute sensor_dev_attr_##_name \ 36 + = SENSOR_ATTR(_name, _mode, _show, _store, _index) 35 37 36 38 struct sensor_device_attribute_2 { 37 39 struct device_attribute dev_attr; ··· 43 41 #define to_sensor_dev_attr_2(_dev_attr) \ 44 42 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr) 45 43 44 + #define SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index) \ 45 + { .dev_attr = __ATTR(_name, _mode, _show, _store), \ 46 + .index = _index, \ 47 + .nr = _nr } 48 + 46 49 #define SENSOR_DEVICE_ATTR_2(_name,_mode,_show,_store,_nr,_index) \ 47 - struct sensor_device_attribute_2 sensor_dev_attr_##_name = { \ 48 - .dev_attr = __ATTR(_name,_mode,_show,_store), \ 49 - .index = _index, \ 50 - .nr = _nr, \ 51 - } 50 + struct sensor_device_attribute_2 sensor_dev_attr_##_name \ 51 + = SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index) 52 52 53 53 #endif /* _LINUX_HWMON_SYSFS_H */
-1
include/linux/i2c-id.h
··· 172 172 #define I2C_HW_B_RIVA 0x010010 /* Riva based graphics cards */ 173 173 #define I2C_HW_B_IOC 0x010011 /* IOC bit-wiggling */ 174 174 #define I2C_HW_B_TSUNA 0x010012 /* DEC Tsunami chipset */ 175 - #define I2C_HW_B_FRODO 0x010013 /* 2d3D SA-1110 Development Board */ 176 175 #define I2C_HW_B_OMAHA 0x010014 /* Omaha I2C interface (ARM) */ 177 176 #define I2C_HW_B_GUIDE 0x010015 /* Guide bit-basher */ 178 177 #define I2C_HW_B_IXP2000 0x010016 /* GPIO on IXP2000 systems */
+3 -3
include/linux/i2c.h
··· 32 32 #include <linux/mod_devicetable.h> 33 33 #include <linux/device.h> /* for struct device */ 34 34 #include <linux/sched.h> /* for completion */ 35 - #include <asm/semaphore.h> 35 + #include <linux/mutex.h> 36 36 37 37 /* --- For i2c-isa ---------------------------------------------------- */ 38 38 ··· 225 225 int (*client_unregister)(struct i2c_client *); 226 226 227 227 /* data fields that are valid for all devices */ 228 - struct semaphore bus_lock; 229 - struct semaphore clist_lock; 228 + struct mutex bus_lock; 229 + struct mutex clist_lock; 230 230 231 231 int timeout; 232 232 int retries;
+1
include/linux/pci_ids.h
··· 1371 1371 #define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200 1372 1372 #define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201 1373 1373 #define PCI_DEVICE_ID_SERVERWORKS_CSB6 0x0203 1374 + #define PCI_DEVICE_ID_SERVERWORKS_HT1000SB 0x0205 1374 1375 #define PCI_DEVICE_ID_SERVERWORKS_OSB4IDE 0x0211 1375 1376 #define PCI_DEVICE_ID_SERVERWORKS_CSB5IDE 0x0212 1376 1377 #define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE 0x0213
-2
sound/oss/dmasound/dmasound_awacs.c
··· 88 88 #include <linux/pmu.h> 89 89 #endif 90 90 91 - #include <linux/i2c-dev.h> 92 - 93 91 #include <asm/uaccess.h> 94 92 #include <asm/prom.h> 95 93 #include <asm/machdep.h>
-1
sound/ppc/daca.c
··· 22 22 #include <sound/driver.h> 23 23 #include <linux/init.h> 24 24 #include <linux/i2c.h> 25 - #include <linux/i2c-dev.h> 26 25 #include <linux/kmod.h> 27 26 #include <linux/slab.h> 28 27 #include <sound/core.h>
-1
sound/ppc/keywest.c
··· 23 23 #include <linux/init.h> 24 24 #include <linux/i2c.h> 25 25 #include <linux/delay.h> 26 - #include <linux/i2c-dev.h> 27 26 #include <linux/slab.h> 28 27 #include <sound/core.h> 29 28 #include "pmac.h"
-1
sound/ppc/toonie.c
··· 22 22 #include <linux/init.h> 23 23 #include <linux/delay.h> 24 24 #include <linux/i2c.h> 25 - #include <linux/i2c-dev.h> 26 25 #include <linux/kmod.h> 27 26 #include <linux/slab.h> 28 27 #include <linux/interrupt.h>
-1
sound/ppc/tumbler.c
··· 28 28 #include <linux/init.h> 29 29 #include <linux/delay.h> 30 30 #include <linux/i2c.h> 31 - #include <linux/i2c-dev.h> 32 31 #include <linux/kmod.h> 33 32 #include <linux/slab.h> 34 33 #include <linux/interrupt.h>