diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-23 18:51:32 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-23 18:51:32 -0500 |
commit | b6585dedac232ca79fe978d97a95fdaa6da24f66 (patch) | |
tree | 4d2d78300bb9bcfb40cb35450f78dd3af82c78d3 | |
parent | a3ea9b584ed2acdeae817f0dc91a5880e0828a05 (diff) | |
parent | ded2b66615613093eeb83b81499bc270de8fc499 (diff) |
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
...
81 files changed, 1706 insertions, 1786 deletions
diff --git a/Documentation/hwmon/w83627hf b/Documentation/hwmon/w83627hf index bbeaba680443..792231921241 100644 --- a/Documentation/hwmon/w83627hf +++ b/Documentation/hwmon/w83627hf | |||
@@ -18,6 +18,10 @@ Supported chips: | |||
18 | Prefix: 'w83637hf' | 18 | Prefix: 'w83637hf' |
19 | Addresses scanned: ISA address retrieved from Super I/O registers | 19 | Addresses scanned: ISA address retrieved from Super I/O registers |
20 | Datasheet: http://www.winbond.com/PDF/sheet/w83637hf.pdf | 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 | Authors: | 26 | Authors: |
23 | Frodo Looijaard <frodol@dds.nl>, | 27 | Frodo Looijaard <frodol@dds.nl>, |
diff --git a/Documentation/hwmon/w83781d b/Documentation/hwmon/w83781d index e5459333ba68..b1e9f80098ee 100644 --- a/Documentation/hwmon/w83781d +++ b/Documentation/hwmon/w83781d | |||
@@ -36,6 +36,11 @@ Module parameters | |||
36 | Use 'init=0' to bypass initializing the chip. | 36 | Use 'init=0' to bypass initializing the chip. |
37 | Try this if your computer crashes when you load the module. | 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 | force_subclients=bus,caddr,saddr,saddr | 44 | force_subclients=bus,caddr,saddr,saddr |
40 | This is used to force the i2c addresses for subclients of | 45 | This is used to force the i2c addresses for subclients of |
41 | a certain chip. Typical usage is `force_subclients=0,0x2d,0x4a,0x4b' | 46 | a certain chip. Typical usage is `force_subclients=0,0x2d,0x4a,0x4b' |
@@ -123,6 +128,25 @@ When an alarm goes off, you can be warned by a beeping signal through | |||
123 | your computer speaker. It is possible to enable all beeping globally, | 128 | your computer speaker. It is possible to enable all beeping globally, |
124 | or only the beeping for some alarms. | 129 | or only the beeping for some alarms. |
125 | 130 | ||
131 | Individual alarm and beep bits: | ||
132 | |||
133 | 0x000001: in0 | ||
134 | 0x000002: in1 | ||
135 | 0x000004: in2 | ||
136 | 0x000008: in3 | ||
137 | 0x000010: temp1 | ||
138 | 0x000020: temp2 (+temp3 on W83781D) | ||
139 | 0x000040: fan1 | ||
140 | 0x000080: fan2 | ||
141 | 0x000100: in4 | ||
142 | 0x000200: in5 | ||
143 | 0x000400: in6 | ||
144 | 0x000800: fan3 | ||
145 | 0x001000: chassis | ||
146 | 0x002000: temp3 (W83782D and W83627HF only) | ||
147 | 0x010000: in7 (W83782D and W83627HF only) | ||
148 | 0x020000: in8 (W83782D and W83627HF only) | ||
149 | |||
126 | If an alarm triggers, it will remain triggered until the hardware register | 150 | If an alarm triggers, it will remain triggered until the hardware register |
127 | is read at least once. This means that the cause for the alarm may | 151 | is read at least once. This means that the cause for the alarm may |
128 | already have disappeared! Note that in the current implementation, all | 152 | already have disappeared! Note that in the current implementation, all |
diff --git a/Documentation/i2c/busses/i2c-piix4 b/Documentation/i2c/busses/i2c-piix4 index 856b4b8b962c..a1c8f581afed 100644 --- a/Documentation/i2c/busses/i2c-piix4 +++ b/Documentation/i2c/busses/i2c-piix4 | |||
@@ -4,7 +4,7 @@ Supported adapters: | |||
4 | * Intel 82371AB PIIX4 and PIIX4E | 4 | * Intel 82371AB PIIX4 and PIIX4E |
5 | * Intel 82443MX (440MX) | 5 | * Intel 82443MX (440MX) |
6 | Datasheet: Publicly available at the Intel website | 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 | Datasheet: Only available via NDA from ServerWorks | 8 | Datasheet: Only available via NDA from ServerWorks |
9 | * Standard Microsystems (SMSC) SLC90E66 (Victory66) southbridge | 9 | * Standard Microsystems (SMSC) SLC90E66 (Victory66) southbridge |
10 | Datasheet: Publicly available at the SMSC website http://www.smsc.com | 10 | Datasheet: Publicly available at the SMSC website http://www.smsc.com |
diff --git a/Documentation/i2c/busses/scx200_acb b/Documentation/i2c/busses/scx200_acb index 08c8cd1df60c..f50e69981ec6 100644 --- a/Documentation/i2c/busses/scx200_acb +++ b/Documentation/i2c/busses/scx200_acb | |||
@@ -6,9 +6,10 @@ Module Parameters | |||
6 | ----------------- | 6 | ----------------- |
7 | 7 | ||
8 | * base: int | 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 | Description | 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. | ||
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 7230d4e08196..99cdc612d2c6 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -406,13 +406,14 @@ config SENSORS_W83L785TS | |||
406 | will be called w83l785ts. | 406 | will be called w83l785ts. |
407 | 407 | ||
408 | config SENSORS_W83627HF | 408 | config SENSORS_W83627HF |
409 | tristate "Winbond W83627HF, W83627THF, W83637HF, W83697HF" | 409 | tristate "Winbond W83627HF, W83627THF, W83637HF, W83687THF, W83697HF" |
410 | depends on HWMON && I2C && EXPERIMENTAL | 410 | depends on HWMON && I2C |
411 | select I2C_ISA | 411 | select I2C_ISA |
412 | select HWMON_VID | 412 | select HWMON_VID |
413 | help | 413 | help |
414 | If you say yes here you get support for the Winbond W836X7 series | 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 | This driver can also be built as a module. If so, the module | 418 | This driver can also be built as a module. If so, the module |
418 | will be called w83627hf. | 419 | will be called w83627hf. |
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index 665612729cb9..2b6e74dd4a82 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
27 | #include <linux/hwmon.h> | 27 | #include <linux/hwmon.h> |
28 | #include <linux/err.h> | 28 | #include <linux/err.h> |
29 | #include <linux/mutex.h> | ||
29 | 30 | ||
30 | 31 | ||
31 | /* Addresses to scan */ | 32 | /* Addresses to scan */ |
@@ -92,7 +93,7 @@ struct adm1021_data { | |||
92 | struct class_device *class_dev; | 93 | struct class_device *class_dev; |
93 | enum chips type; | 94 | enum chips type; |
94 | 95 | ||
95 | struct semaphore update_lock; | 96 | struct mutex update_lock; |
96 | char valid; /* !=0 if following fields are valid */ | 97 | char valid; /* !=0 if following fields are valid */ |
97 | unsigned long last_updated; /* In jiffies */ | 98 | unsigned long last_updated; /* In jiffies */ |
98 | 99 | ||
@@ -162,10 +163,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co | |||
162 | struct adm1021_data *data = i2c_get_clientdata(client); \ | 163 | struct adm1021_data *data = i2c_get_clientdata(client); \ |
163 | int temp = simple_strtoul(buf, NULL, 10); \ | 164 | int temp = simple_strtoul(buf, NULL, 10); \ |
164 | \ | 165 | \ |
165 | down(&data->update_lock); \ | 166 | mutex_lock(&data->update_lock); \ |
166 | data->value = TEMP_TO_REG(temp); \ | 167 | data->value = TEMP_TO_REG(temp); \ |
167 | adm1021_write_value(client, reg, data->value); \ | 168 | adm1021_write_value(client, reg, data->value); \ |
168 | up(&data->update_lock); \ | 169 | mutex_unlock(&data->update_lock); \ |
169 | return count; \ | 170 | return count; \ |
170 | } | 171 | } |
171 | set(temp_max, ADM1021_REG_TOS_W); | 172 | set(temp_max, ADM1021_REG_TOS_W); |
@@ -275,7 +276,7 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) | |||
275 | strlcpy(new_client->name, type_name, I2C_NAME_SIZE); | 276 | strlcpy(new_client->name, type_name, I2C_NAME_SIZE); |
276 | data->type = kind; | 277 | data->type = kind; |
277 | data->valid = 0; | 278 | data->valid = 0; |
278 | init_MUTEX(&data->update_lock); | 279 | mutex_init(&data->update_lock); |
279 | 280 | ||
280 | /* Tell the I2C layer a new client has arrived */ | 281 | /* Tell the I2C layer a new client has arrived */ |
281 | if ((err = i2c_attach_client(new_client))) | 282 | if ((err = i2c_attach_client(new_client))) |
@@ -351,7 +352,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev) | |||
351 | struct i2c_client *client = to_i2c_client(dev); | 352 | struct i2c_client *client = to_i2c_client(dev); |
352 | struct adm1021_data *data = i2c_get_clientdata(client); | 353 | struct adm1021_data *data = i2c_get_clientdata(client); |
353 | 354 | ||
354 | down(&data->update_lock); | 355 | mutex_lock(&data->update_lock); |
355 | 356 | ||
356 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 357 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
357 | || !data->valid) { | 358 | || !data->valid) { |
@@ -375,7 +376,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev) | |||
375 | data->valid = 1; | 376 | data->valid = 1; |
376 | } | 377 | } |
377 | 378 | ||
378 | up(&data->update_lock); | 379 | mutex_unlock(&data->update_lock); |
379 | 380 | ||
380 | return data; | 381 | return data; |
381 | } | 382 | } |
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index 9331c56d2ba6..a4c859c9fbf8 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c | |||
@@ -53,6 +53,7 @@ | |||
53 | #include <linux/hwmon.h> | 53 | #include <linux/hwmon.h> |
54 | #include <linux/hwmon-vid.h> | 54 | #include <linux/hwmon-vid.h> |
55 | #include <linux/err.h> | 55 | #include <linux/err.h> |
56 | #include <linux/mutex.h> | ||
56 | 57 | ||
57 | /* | 58 | /* |
58 | * Addresses to scan | 59 | * Addresses to scan |
@@ -133,7 +134,7 @@ static struct i2c_driver adm1025_driver = { | |||
133 | struct adm1025_data { | 134 | struct adm1025_data { |
134 | struct i2c_client client; | 135 | struct i2c_client client; |
135 | struct class_device *class_dev; | 136 | struct class_device *class_dev; |
136 | struct semaphore update_lock; | 137 | struct mutex update_lock; |
137 | char valid; /* zero until following fields are valid */ | 138 | char valid; /* zero until following fields are valid */ |
138 | unsigned long last_updated; /* in jiffies */ | 139 | unsigned long last_updated; /* in jiffies */ |
139 | 140 | ||
@@ -207,11 +208,11 @@ static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute | |||
207 | struct adm1025_data *data = i2c_get_clientdata(client); \ | 208 | struct adm1025_data *data = i2c_get_clientdata(client); \ |
208 | long val = simple_strtol(buf, NULL, 10); \ | 209 | long val = simple_strtol(buf, NULL, 10); \ |
209 | \ | 210 | \ |
210 | down(&data->update_lock); \ | 211 | mutex_lock(&data->update_lock); \ |
211 | data->in_min[offset] = IN_TO_REG(val, in_scale[offset]); \ | 212 | data->in_min[offset] = IN_TO_REG(val, in_scale[offset]); \ |
212 | i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(offset), \ | 213 | i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(offset), \ |
213 | data->in_min[offset]); \ | 214 | data->in_min[offset]); \ |
214 | up(&data->update_lock); \ | 215 | mutex_unlock(&data->update_lock); \ |
215 | return count; \ | 216 | return count; \ |
216 | } \ | 217 | } \ |
217 | static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ | 218 | static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ |
@@ -221,11 +222,11 @@ static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute | |||
221 | struct adm1025_data *data = i2c_get_clientdata(client); \ | 222 | struct adm1025_data *data = i2c_get_clientdata(client); \ |
222 | long val = simple_strtol(buf, NULL, 10); \ | 223 | long val = simple_strtol(buf, NULL, 10); \ |
223 | \ | 224 | \ |
224 | down(&data->update_lock); \ | 225 | mutex_lock(&data->update_lock); \ |
225 | data->in_max[offset] = IN_TO_REG(val, in_scale[offset]); \ | 226 | data->in_max[offset] = IN_TO_REG(val, in_scale[offset]); \ |
226 | i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(offset), \ | 227 | i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(offset), \ |
227 | data->in_max[offset]); \ | 228 | data->in_max[offset]); \ |
228 | up(&data->update_lock); \ | 229 | mutex_unlock(&data->update_lock); \ |
229 | return count; \ | 230 | return count; \ |
230 | } \ | 231 | } \ |
231 | static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ | 232 | static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ |
@@ -247,11 +248,11 @@ static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribut | |||
247 | struct adm1025_data *data = i2c_get_clientdata(client); \ | 248 | struct adm1025_data *data = i2c_get_clientdata(client); \ |
248 | long val = simple_strtol(buf, NULL, 10); \ | 249 | long val = simple_strtol(buf, NULL, 10); \ |
249 | \ | 250 | \ |
250 | down(&data->update_lock); \ | 251 | mutex_lock(&data->update_lock); \ |
251 | data->temp_min[offset-1] = TEMP_TO_REG(val); \ | 252 | data->temp_min[offset-1] = TEMP_TO_REG(val); \ |
252 | i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(offset-1), \ | 253 | i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(offset-1), \ |
253 | data->temp_min[offset-1]); \ | 254 | data->temp_min[offset-1]); \ |
254 | up(&data->update_lock); \ | 255 | mutex_unlock(&data->update_lock); \ |
255 | return count; \ | 256 | return count; \ |
256 | } \ | 257 | } \ |
257 | static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ | 258 | static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ |
@@ -261,11 +262,11 @@ static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribut | |||
261 | struct adm1025_data *data = i2c_get_clientdata(client); \ | 262 | struct adm1025_data *data = i2c_get_clientdata(client); \ |
262 | long val = simple_strtol(buf, NULL, 10); \ | 263 | long val = simple_strtol(buf, NULL, 10); \ |
263 | \ | 264 | \ |
264 | down(&data->update_lock); \ | 265 | mutex_lock(&data->update_lock); \ |
265 | data->temp_max[offset-1] = TEMP_TO_REG(val); \ | 266 | data->temp_max[offset-1] = TEMP_TO_REG(val); \ |
266 | i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(offset-1), \ | 267 | i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(offset-1), \ |
267 | data->temp_max[offset-1]); \ | 268 | data->temp_max[offset-1]); \ |
268 | up(&data->update_lock); \ | 269 | mutex_unlock(&data->update_lock); \ |
269 | return count; \ | 270 | return count; \ |
270 | } \ | 271 | } \ |
271 | static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ | 272 | static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ |
@@ -404,7 +405,7 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) | |||
404 | /* We can fill in the remaining client fields */ | 405 | /* We can fill in the remaining client fields */ |
405 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 406 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
406 | data->valid = 0; | 407 | data->valid = 0; |
407 | init_MUTEX(&data->update_lock); | 408 | mutex_init(&data->update_lock); |
408 | 409 | ||
409 | /* Tell the I2C layer a new client has arrived */ | 410 | /* Tell the I2C layer a new client has arrived */ |
410 | if ((err = i2c_attach_client(new_client))) | 411 | if ((err = i2c_attach_client(new_client))) |
@@ -523,7 +524,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev) | |||
523 | struct i2c_client *client = to_i2c_client(dev); | 524 | struct i2c_client *client = to_i2c_client(dev); |
524 | struct adm1025_data *data = i2c_get_clientdata(client); | 525 | struct adm1025_data *data = i2c_get_clientdata(client); |
525 | 526 | ||
526 | down(&data->update_lock); | 527 | mutex_lock(&data->update_lock); |
527 | 528 | ||
528 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 529 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
529 | int i; | 530 | int i; |
@@ -558,7 +559,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev) | |||
558 | data->valid = 1; | 559 | data->valid = 1; |
559 | } | 560 | } |
560 | 561 | ||
561 | up(&data->update_lock); | 562 | mutex_unlock(&data->update_lock); |
562 | 563 | ||
563 | return data; | 564 | return data; |
564 | } | 565 | } |
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index fefe6e74fd02..6d4f8b8d358e 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/hwmon-sysfs.h> | 32 | #include <linux/hwmon-sysfs.h> |
33 | #include <linux/hwmon-vid.h> | 33 | #include <linux/hwmon-vid.h> |
34 | #include <linux/err.h> | 34 | #include <linux/err.h> |
35 | #include <linux/mutex.h> | ||
35 | 36 | ||
36 | /* Addresses to scan */ | 37 | /* Addresses to scan */ |
37 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 38 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
@@ -260,10 +261,10 @@ struct pwm_data { | |||
260 | struct adm1026_data { | 261 | struct adm1026_data { |
261 | struct i2c_client client; | 262 | struct i2c_client client; |
262 | struct class_device *class_dev; | 263 | struct class_device *class_dev; |
263 | struct semaphore lock; | 264 | struct mutex lock; |
264 | enum chips type; | 265 | enum chips type; |
265 | 266 | ||
266 | struct semaphore update_lock; | 267 | struct mutex update_lock; |
267 | int valid; /* !=0 if following fields are valid */ | 268 | int valid; /* !=0 if following fields are valid */ |
268 | unsigned long last_reading; /* In jiffies */ | 269 | unsigned long last_reading; /* In jiffies */ |
269 | unsigned long last_config; /* In jiffies */ | 270 | unsigned long last_config; /* In jiffies */ |
@@ -298,9 +299,8 @@ static int adm1026_attach_adapter(struct i2c_adapter *adapter); | |||
298 | static int adm1026_detect(struct i2c_adapter *adapter, int address, | 299 | static int adm1026_detect(struct i2c_adapter *adapter, int address, |
299 | int kind); | 300 | int kind); |
300 | static int adm1026_detach_client(struct i2c_client *client); | 301 | static int adm1026_detach_client(struct i2c_client *client); |
301 | static int adm1026_read_value(struct i2c_client *client, u8 register); | 302 | static int adm1026_read_value(struct i2c_client *client, u8 reg); |
302 | static int adm1026_write_value(struct i2c_client *client, u8 register, | 303 | static int adm1026_write_value(struct i2c_client *client, u8 reg, int value); |
303 | int value); | ||
304 | static void adm1026_print_gpio(struct i2c_client *client); | 304 | static void adm1026_print_gpio(struct i2c_client *client); |
305 | static void adm1026_fixup_gpio(struct i2c_client *client); | 305 | static void adm1026_fixup_gpio(struct i2c_client *client); |
306 | static struct adm1026_data *adm1026_update_device(struct device *dev); | 306 | static struct adm1026_data *adm1026_update_device(struct device *dev); |
@@ -575,7 +575,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
575 | int i; | 575 | int i; |
576 | long value, alarms, gpio; | 576 | long value, alarms, gpio; |
577 | 577 | ||
578 | down(&data->update_lock); | 578 | mutex_lock(&data->update_lock); |
579 | if (!data->valid | 579 | if (!data->valid |
580 | || time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) { | 580 | || time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) { |
581 | /* Things that change quickly */ | 581 | /* Things that change quickly */ |
@@ -710,7 +710,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
710 | dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n"); | 710 | dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n"); |
711 | data->vid = (data->gpio >> 11) & 0x1f; | 711 | data->vid = (data->gpio >> 11) & 0x1f; |
712 | data->valid = 1; | 712 | data->valid = 1; |
713 | up(&data->update_lock); | 713 | mutex_unlock(&data->update_lock); |
714 | return data; | 714 | return data; |
715 | } | 715 | } |
716 | 716 | ||
@@ -739,10 +739,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | |||
739 | struct adm1026_data *data = i2c_get_clientdata(client); | 739 | struct adm1026_data *data = i2c_get_clientdata(client); |
740 | int val = simple_strtol(buf, NULL, 10); | 740 | int val = simple_strtol(buf, NULL, 10); |
741 | 741 | ||
742 | down(&data->update_lock); | 742 | mutex_lock(&data->update_lock); |
743 | data->in_min[nr] = INS_TO_REG(nr, val); | 743 | data->in_min[nr] = INS_TO_REG(nr, val); |
744 | adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]); | 744 | adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]); |
745 | up(&data->update_lock); | 745 | mutex_unlock(&data->update_lock); |
746 | return count; | 746 | return count; |
747 | } | 747 | } |
748 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, | 748 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, |
@@ -762,10 +762,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | |||
762 | struct adm1026_data *data = i2c_get_clientdata(client); | 762 | struct adm1026_data *data = i2c_get_clientdata(client); |
763 | int val = simple_strtol(buf, NULL, 10); | 763 | int val = simple_strtol(buf, NULL, 10); |
764 | 764 | ||
765 | down(&data->update_lock); | 765 | mutex_lock(&data->update_lock); |
766 | data->in_max[nr] = INS_TO_REG(nr, val); | 766 | data->in_max[nr] = INS_TO_REG(nr, val); |
767 | adm1026_write_value(client, ADM1026_REG_IN_MAX[nr], data->in_max[nr]); | 767 | adm1026_write_value(client, ADM1026_REG_IN_MAX[nr], data->in_max[nr]); |
768 | up(&data->update_lock); | 768 | mutex_unlock(&data->update_lock); |
769 | return count; | 769 | return count; |
770 | } | 770 | } |
771 | 771 | ||
@@ -813,10 +813,10 @@ static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr, c | |||
813 | struct adm1026_data *data = i2c_get_clientdata(client); | 813 | struct adm1026_data *data = i2c_get_clientdata(client); |
814 | int val = simple_strtol(buf, NULL, 10); | 814 | int val = simple_strtol(buf, NULL, 10); |
815 | 815 | ||
816 | down(&data->update_lock); | 816 | mutex_lock(&data->update_lock); |
817 | data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET); | 817 | data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET); |
818 | adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]); | 818 | adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]); |
819 | up(&data->update_lock); | 819 | mutex_unlock(&data->update_lock); |
820 | return count; | 820 | return count; |
821 | } | 821 | } |
822 | static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf) | 822 | static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf) |
@@ -831,10 +831,10 @@ static ssize_t set_in16_max(struct device *dev, struct device_attribute *attr, c | |||
831 | struct adm1026_data *data = i2c_get_clientdata(client); | 831 | struct adm1026_data *data = i2c_get_clientdata(client); |
832 | int val = simple_strtol(buf, NULL, 10); | 832 | int val = simple_strtol(buf, NULL, 10); |
833 | 833 | ||
834 | down(&data->update_lock); | 834 | mutex_lock(&data->update_lock); |
835 | data->in_max[16] = INS_TO_REG(16, val+NEG12_OFFSET); | 835 | data->in_max[16] = INS_TO_REG(16, val+NEG12_OFFSET); |
836 | adm1026_write_value(client, ADM1026_REG_IN_MAX[16], data->in_max[16]); | 836 | adm1026_write_value(client, ADM1026_REG_IN_MAX[16], data->in_max[16]); |
837 | up(&data->update_lock); | 837 | mutex_unlock(&data->update_lock); |
838 | return count; | 838 | return count; |
839 | } | 839 | } |
840 | 840 | ||
@@ -874,11 +874,11 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
874 | struct adm1026_data *data = i2c_get_clientdata(client); | 874 | struct adm1026_data *data = i2c_get_clientdata(client); |
875 | int val = simple_strtol(buf, NULL, 10); | 875 | int val = simple_strtol(buf, NULL, 10); |
876 | 876 | ||
877 | down(&data->update_lock); | 877 | mutex_lock(&data->update_lock); |
878 | data->fan_min[nr] = FAN_TO_REG(val, data->fan_div[nr]); | 878 | data->fan_min[nr] = FAN_TO_REG(val, data->fan_div[nr]); |
879 | adm1026_write_value(client, ADM1026_REG_FAN_MIN(nr), | 879 | adm1026_write_value(client, ADM1026_REG_FAN_MIN(nr), |
880 | data->fan_min[nr]); | 880 | data->fan_min[nr]); |
881 | up(&data->update_lock); | 881 | mutex_unlock(&data->update_lock); |
882 | return count; | 882 | return count; |
883 | } | 883 | } |
884 | 884 | ||
@@ -939,7 +939,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
939 | if (new_div == 0) { | 939 | if (new_div == 0) { |
940 | return -EINVAL; | 940 | return -EINVAL; |
941 | } | 941 | } |
942 | down(&data->update_lock); | 942 | mutex_lock(&data->update_lock); |
943 | orig_div = data->fan_div[nr]; | 943 | orig_div = data->fan_div[nr]; |
944 | data->fan_div[nr] = DIV_FROM_REG(new_div); | 944 | data->fan_div[nr] = DIV_FROM_REG(new_div); |
945 | 945 | ||
@@ -958,7 +958,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
958 | if (data->fan_div[nr] != orig_div) { | 958 | if (data->fan_div[nr] != orig_div) { |
959 | fixup_fan_min(dev,nr,orig_div); | 959 | fixup_fan_min(dev,nr,orig_div); |
960 | } | 960 | } |
961 | up(&data->update_lock); | 961 | mutex_unlock(&data->update_lock); |
962 | return count; | 962 | return count; |
963 | } | 963 | } |
964 | 964 | ||
@@ -1001,11 +1001,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
1001 | struct adm1026_data *data = i2c_get_clientdata(client); | 1001 | struct adm1026_data *data = i2c_get_clientdata(client); |
1002 | int val = simple_strtol(buf, NULL, 10); | 1002 | int val = simple_strtol(buf, NULL, 10); |
1003 | 1003 | ||
1004 | down(&data->update_lock); | 1004 | mutex_lock(&data->update_lock); |
1005 | data->temp_min[nr] = TEMP_TO_REG(val); | 1005 | data->temp_min[nr] = TEMP_TO_REG(val); |
1006 | adm1026_write_value(client, ADM1026_REG_TEMP_MIN[nr], | 1006 | adm1026_write_value(client, ADM1026_REG_TEMP_MIN[nr], |
1007 | data->temp_min[nr]); | 1007 | data->temp_min[nr]); |
1008 | up(&data->update_lock); | 1008 | mutex_unlock(&data->update_lock); |
1009 | return count; | 1009 | return count; |
1010 | } | 1010 | } |
1011 | static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, | 1011 | static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, |
@@ -1025,11 +1025,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
1025 | struct adm1026_data *data = i2c_get_clientdata(client); | 1025 | struct adm1026_data *data = i2c_get_clientdata(client); |
1026 | int val = simple_strtol(buf, NULL, 10); | 1026 | int val = simple_strtol(buf, NULL, 10); |
1027 | 1027 | ||
1028 | down(&data->update_lock); | 1028 | mutex_lock(&data->update_lock); |
1029 | data->temp_max[nr] = TEMP_TO_REG(val); | 1029 | data->temp_max[nr] = TEMP_TO_REG(val); |
1030 | adm1026_write_value(client, ADM1026_REG_TEMP_MAX[nr], | 1030 | adm1026_write_value(client, ADM1026_REG_TEMP_MAX[nr], |
1031 | data->temp_max[nr]); | 1031 | data->temp_max[nr]); |
1032 | up(&data->update_lock); | 1032 | mutex_unlock(&data->update_lock); |
1033 | return count; | 1033 | return count; |
1034 | } | 1034 | } |
1035 | 1035 | ||
@@ -1064,11 +1064,11 @@ static ssize_t set_temp_offset(struct device *dev, | |||
1064 | struct adm1026_data *data = i2c_get_clientdata(client); | 1064 | struct adm1026_data *data = i2c_get_clientdata(client); |
1065 | int val = simple_strtol(buf, NULL, 10); | 1065 | int val = simple_strtol(buf, NULL, 10); |
1066 | 1066 | ||
1067 | down(&data->update_lock); | 1067 | mutex_lock(&data->update_lock); |
1068 | data->temp_offset[nr] = TEMP_TO_REG(val); | 1068 | data->temp_offset[nr] = TEMP_TO_REG(val); |
1069 | adm1026_write_value(client, ADM1026_REG_TEMP_OFFSET[nr], | 1069 | adm1026_write_value(client, ADM1026_REG_TEMP_OFFSET[nr], |
1070 | data->temp_offset[nr]); | 1070 | data->temp_offset[nr]); |
1071 | up(&data->update_lock); | 1071 | mutex_unlock(&data->update_lock); |
1072 | return count; | 1072 | return count; |
1073 | } | 1073 | } |
1074 | 1074 | ||
@@ -1115,11 +1115,11 @@ static ssize_t set_temp_auto_point1_temp(struct device *dev, | |||
1115 | struct adm1026_data *data = i2c_get_clientdata(client); | 1115 | struct adm1026_data *data = i2c_get_clientdata(client); |
1116 | int val = simple_strtol(buf, NULL, 10); | 1116 | int val = simple_strtol(buf, NULL, 10); |
1117 | 1117 | ||
1118 | down(&data->update_lock); | 1118 | mutex_lock(&data->update_lock); |
1119 | data->temp_tmin[nr] = TEMP_TO_REG(val); | 1119 | data->temp_tmin[nr] = TEMP_TO_REG(val); |
1120 | adm1026_write_value(client, ADM1026_REG_TEMP_TMIN[nr], | 1120 | adm1026_write_value(client, ADM1026_REG_TEMP_TMIN[nr], |
1121 | data->temp_tmin[nr]); | 1121 | data->temp_tmin[nr]); |
1122 | up(&data->update_lock); | 1122 | mutex_unlock(&data->update_lock); |
1123 | return count; | 1123 | return count; |
1124 | } | 1124 | } |
1125 | 1125 | ||
@@ -1150,11 +1150,11 @@ static ssize_t set_temp_crit_enable(struct device *dev, | |||
1150 | int val = simple_strtol(buf, NULL, 10); | 1150 | int val = simple_strtol(buf, NULL, 10); |
1151 | 1151 | ||
1152 | if ((val == 1) || (val==0)) { | 1152 | if ((val == 1) || (val==0)) { |
1153 | down(&data->update_lock); | 1153 | mutex_lock(&data->update_lock); |
1154 | data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4); | 1154 | data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4); |
1155 | adm1026_write_value(client, ADM1026_REG_CONFIG1, | 1155 | adm1026_write_value(client, ADM1026_REG_CONFIG1, |
1156 | data->config1); | 1156 | data->config1); |
1157 | up(&data->update_lock); | 1157 | mutex_unlock(&data->update_lock); |
1158 | } | 1158 | } |
1159 | return count; | 1159 | return count; |
1160 | } | 1160 | } |
@@ -1184,11 +1184,11 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, | |||
1184 | struct adm1026_data *data = i2c_get_clientdata(client); | 1184 | struct adm1026_data *data = i2c_get_clientdata(client); |
1185 | int val = simple_strtol(buf, NULL, 10); | 1185 | int val = simple_strtol(buf, NULL, 10); |
1186 | 1186 | ||
1187 | down(&data->update_lock); | 1187 | mutex_lock(&data->update_lock); |
1188 | data->temp_crit[nr] = TEMP_TO_REG(val); | 1188 | data->temp_crit[nr] = TEMP_TO_REG(val); |
1189 | adm1026_write_value(client, ADM1026_REG_TEMP_THERM[nr], | 1189 | adm1026_write_value(client, ADM1026_REG_TEMP_THERM[nr], |
1190 | data->temp_crit[nr]); | 1190 | data->temp_crit[nr]); |
1191 | up(&data->update_lock); | 1191 | mutex_unlock(&data->update_lock); |
1192 | return count; | 1192 | return count; |
1193 | } | 1193 | } |
1194 | 1194 | ||
@@ -1212,10 +1212,10 @@ static ssize_t set_analog_out_reg(struct device *dev, struct device_attribute *a | |||
1212 | struct adm1026_data *data = i2c_get_clientdata(client); | 1212 | struct adm1026_data *data = i2c_get_clientdata(client); |
1213 | int val = simple_strtol(buf, NULL, 10); | 1213 | int val = simple_strtol(buf, NULL, 10); |
1214 | 1214 | ||
1215 | down(&data->update_lock); | 1215 | mutex_lock(&data->update_lock); |
1216 | data->analog_out = DAC_TO_REG(val); | 1216 | data->analog_out = DAC_TO_REG(val); |
1217 | adm1026_write_value(client, ADM1026_REG_DAC, data->analog_out); | 1217 | adm1026_write_value(client, ADM1026_REG_DAC, data->analog_out); |
1218 | up(&data->update_lock); | 1218 | mutex_unlock(&data->update_lock); |
1219 | return count; | 1219 | return count; |
1220 | } | 1220 | } |
1221 | 1221 | ||
@@ -1267,7 +1267,7 @@ static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr, | |||
1267 | int val = simple_strtol(buf, NULL, 10); | 1267 | int val = simple_strtol(buf, NULL, 10); |
1268 | unsigned long mask; | 1268 | unsigned long mask; |
1269 | 1269 | ||
1270 | down(&data->update_lock); | 1270 | mutex_lock(&data->update_lock); |
1271 | data->alarm_mask = val & 0x7fffffff; | 1271 | data->alarm_mask = val & 0x7fffffff; |
1272 | mask = data->alarm_mask | 1272 | mask = data->alarm_mask |
1273 | | (data->gpio_mask & 0x10000 ? 0x80000000 : 0); | 1273 | | (data->gpio_mask & 0x10000 ? 0x80000000 : 0); |
@@ -1282,7 +1282,7 @@ static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr, | |||
1282 | mask >>= 8; | 1282 | mask >>= 8; |
1283 | adm1026_write_value(client, ADM1026_REG_MASK4, | 1283 | adm1026_write_value(client, ADM1026_REG_MASK4, |
1284 | mask & 0xff); | 1284 | mask & 0xff); |
1285 | up(&data->update_lock); | 1285 | mutex_unlock(&data->update_lock); |
1286 | return count; | 1286 | return count; |
1287 | } | 1287 | } |
1288 | 1288 | ||
@@ -1303,7 +1303,7 @@ static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const | |||
1303 | int val = simple_strtol(buf, NULL, 10); | 1303 | int val = simple_strtol(buf, NULL, 10); |
1304 | long gpio; | 1304 | long gpio; |
1305 | 1305 | ||
1306 | down(&data->update_lock); | 1306 | mutex_lock(&data->update_lock); |
1307 | data->gpio = val & 0x1ffff; | 1307 | data->gpio = val & 0x1ffff; |
1308 | gpio = data->gpio; | 1308 | gpio = data->gpio; |
1309 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7,gpio & 0xff); | 1309 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7,gpio & 0xff); |
@@ -1311,7 +1311,7 @@ static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const | |||
1311 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15,gpio & 0xff); | 1311 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15,gpio & 0xff); |
1312 | gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f); | 1312 | gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f); |
1313 | adm1026_write_value(client, ADM1026_REG_STATUS4,gpio & 0xff); | 1313 | adm1026_write_value(client, ADM1026_REG_STATUS4,gpio & 0xff); |
1314 | up(&data->update_lock); | 1314 | mutex_unlock(&data->update_lock); |
1315 | return count; | 1315 | return count; |
1316 | } | 1316 | } |
1317 | 1317 | ||
@@ -1331,7 +1331,7 @@ static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr, | |||
1331 | int val = simple_strtol(buf, NULL, 10); | 1331 | int val = simple_strtol(buf, NULL, 10); |
1332 | long mask; | 1332 | long mask; |
1333 | 1333 | ||
1334 | down(&data->update_lock); | 1334 | mutex_lock(&data->update_lock); |
1335 | data->gpio_mask = val & 0x1ffff; | 1335 | data->gpio_mask = val & 0x1ffff; |
1336 | mask = data->gpio_mask; | 1336 | mask = data->gpio_mask; |
1337 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7,mask & 0xff); | 1337 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7,mask & 0xff); |
@@ -1339,7 +1339,7 @@ static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr, | |||
1339 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15,mask & 0xff); | 1339 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15,mask & 0xff); |
1340 | mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f); | 1340 | mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f); |
1341 | adm1026_write_value(client, ADM1026_REG_MASK1,mask & 0xff); | 1341 | adm1026_write_value(client, ADM1026_REG_MASK1,mask & 0xff); |
1342 | up(&data->update_lock); | 1342 | mutex_unlock(&data->update_lock); |
1343 | return count; | 1343 | return count; |
1344 | } | 1344 | } |
1345 | 1345 | ||
@@ -1359,10 +1359,10 @@ static ssize_t set_pwm_reg(struct device *dev, struct device_attribute *attr, co | |||
1359 | if (data->pwm1.enable == 1) { | 1359 | if (data->pwm1.enable == 1) { |
1360 | int val = simple_strtol(buf, NULL, 10); | 1360 | int val = simple_strtol(buf, NULL, 10); |
1361 | 1361 | ||
1362 | down(&data->update_lock); | 1362 | mutex_lock(&data->update_lock); |
1363 | data->pwm1.pwm = PWM_TO_REG(val); | 1363 | data->pwm1.pwm = PWM_TO_REG(val); |
1364 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); | 1364 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); |
1365 | up(&data->update_lock); | 1365 | mutex_unlock(&data->update_lock); |
1366 | } | 1366 | } |
1367 | return count; | 1367 | return count; |
1368 | } | 1368 | } |
@@ -1378,14 +1378,14 @@ static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *att | |||
1378 | struct adm1026_data *data = i2c_get_clientdata(client); | 1378 | struct adm1026_data *data = i2c_get_clientdata(client); |
1379 | int val = simple_strtol(buf, NULL, 10); | 1379 | int val = simple_strtol(buf, NULL, 10); |
1380 | 1380 | ||
1381 | down(&data->update_lock); | 1381 | mutex_lock(&data->update_lock); |
1382 | data->pwm1.auto_pwm_min = SENSORS_LIMIT(val,0,255); | 1382 | data->pwm1.auto_pwm_min = SENSORS_LIMIT(val,0,255); |
1383 | if (data->pwm1.enable == 2) { /* apply immediately */ | 1383 | if (data->pwm1.enable == 2) { /* apply immediately */ |
1384 | data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | | 1384 | data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | |
1385 | PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); | 1385 | PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); |
1386 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); | 1386 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); |
1387 | } | 1387 | } |
1388 | up(&data->update_lock); | 1388 | mutex_unlock(&data->update_lock); |
1389 | return count; | 1389 | return count; |
1390 | } | 1390 | } |
1391 | static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf) | 1391 | static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf) |
@@ -1406,7 +1406,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
1406 | int old_enable; | 1406 | int old_enable; |
1407 | 1407 | ||
1408 | if ((val >= 0) && (val < 3)) { | 1408 | if ((val >= 0) && (val < 3)) { |
1409 | down(&data->update_lock); | 1409 | mutex_lock(&data->update_lock); |
1410 | old_enable = data->pwm1.enable; | 1410 | old_enable = data->pwm1.enable; |
1411 | data->pwm1.enable = val; | 1411 | data->pwm1.enable = val; |
1412 | data->config1 = (data->config1 & ~CFG1_PWM_AFC) | 1412 | data->config1 = (data->config1 & ~CFG1_PWM_AFC) |
@@ -1424,7 +1424,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
1424 | adm1026_write_value(client, ADM1026_REG_PWM, | 1424 | adm1026_write_value(client, ADM1026_REG_PWM, |
1425 | data->pwm1.pwm); | 1425 | data->pwm1.pwm); |
1426 | } | 1426 | } |
1427 | up(&data->update_lock); | 1427 | mutex_unlock(&data->update_lock); |
1428 | } | 1428 | } |
1429 | return count; | 1429 | return count; |
1430 | } | 1430 | } |
@@ -1541,7 +1541,7 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1541 | /* Fill in the remaining client fields */ | 1541 | /* Fill in the remaining client fields */ |
1542 | data->type = kind; | 1542 | data->type = kind; |
1543 | data->valid = 0; | 1543 | data->valid = 0; |
1544 | init_MUTEX(&data->update_lock); | 1544 | mutex_init(&data->update_lock); |
1545 | 1545 | ||
1546 | /* Tell the I2C layer a new client has arrived */ | 1546 | /* Tell the I2C layer a new client has arrived */ |
1547 | if ((err = i2c_attach_client(new_client))) | 1547 | if ((err = i2c_attach_client(new_client))) |
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index d06397966081..3bf2da621aed 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/hwmon.h> | 29 | #include <linux/hwmon.h> |
30 | #include <linux/err.h> | 30 | #include <linux/err.h> |
31 | #include <linux/mutex.h> | ||
31 | 32 | ||
32 | /* Following macros takes channel parameter starting from 0 to 2 */ | 33 | /* Following macros takes channel parameter starting from 0 to 2 */ |
33 | #define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr)) | 34 | #define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr)) |
@@ -70,7 +71,7 @@ typedef u8 auto_chan_table_t[8][2]; | |||
70 | struct adm1031_data { | 71 | struct adm1031_data { |
71 | struct i2c_client client; | 72 | struct i2c_client client; |
72 | struct class_device *class_dev; | 73 | struct class_device *class_dev; |
73 | struct semaphore update_lock; | 74 | struct mutex update_lock; |
74 | int chip_type; | 75 | int chip_type; |
75 | char valid; /* !=0 if following fields are valid */ | 76 | char valid; /* !=0 if following fields are valid */ |
76 | unsigned long last_updated; /* In jiffies */ | 77 | unsigned long last_updated; /* In jiffies */ |
@@ -262,10 +263,10 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr) | |||
262 | 263 | ||
263 | old_fan_mode = data->conf1; | 264 | old_fan_mode = data->conf1; |
264 | 265 | ||
265 | down(&data->update_lock); | 266 | mutex_lock(&data->update_lock); |
266 | 267 | ||
267 | if ((ret = get_fan_auto_nearest(data, nr, val, data->conf1, ®))) { | 268 | if ((ret = get_fan_auto_nearest(data, nr, val, data->conf1, ®))) { |
268 | up(&data->update_lock); | 269 | mutex_unlock(&data->update_lock); |
269 | return ret; | 270 | return ret; |
270 | } | 271 | } |
271 | if (((data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1)) & ADM1031_CONF1_AUTO_MODE) ^ | 272 | if (((data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1)) & ADM1031_CONF1_AUTO_MODE) ^ |
@@ -288,7 +289,7 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr) | |||
288 | } | 289 | } |
289 | data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1); | 290 | data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1); |
290 | adm1031_write_value(client, ADM1031_REG_CONF1, data->conf1); | 291 | adm1031_write_value(client, ADM1031_REG_CONF1, data->conf1); |
291 | up(&data->update_lock); | 292 | mutex_unlock(&data->update_lock); |
292 | return count; | 293 | return count; |
293 | } | 294 | } |
294 | 295 | ||
@@ -329,11 +330,11 @@ set_auto_temp_min(struct device *dev, const char *buf, size_t count, int nr) | |||
329 | struct adm1031_data *data = i2c_get_clientdata(client); | 330 | struct adm1031_data *data = i2c_get_clientdata(client); |
330 | int val = simple_strtol(buf, NULL, 10); | 331 | int val = simple_strtol(buf, NULL, 10); |
331 | 332 | ||
332 | down(&data->update_lock); | 333 | mutex_lock(&data->update_lock); |
333 | data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]); | 334 | data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]); |
334 | adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), | 335 | adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), |
335 | data->auto_temp[nr]); | 336 | data->auto_temp[nr]); |
336 | up(&data->update_lock); | 337 | mutex_unlock(&data->update_lock); |
337 | return count; | 338 | return count; |
338 | } | 339 | } |
339 | static ssize_t show_auto_temp_max(struct device *dev, char *buf, int nr) | 340 | static ssize_t show_auto_temp_max(struct device *dev, char *buf, int nr) |
@@ -349,11 +350,11 @@ set_auto_temp_max(struct device *dev, const char *buf, size_t count, int nr) | |||
349 | struct adm1031_data *data = i2c_get_clientdata(client); | 350 | struct adm1031_data *data = i2c_get_clientdata(client); |
350 | int val = simple_strtol(buf, NULL, 10); | 351 | int val = simple_strtol(buf, NULL, 10); |
351 | 352 | ||
352 | down(&data->update_lock); | 353 | mutex_lock(&data->update_lock); |
353 | data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr], data->pwm[nr]); | 354 | data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr], data->pwm[nr]); |
354 | adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), | 355 | adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), |
355 | data->temp_max[nr]); | 356 | data->temp_max[nr]); |
356 | up(&data->update_lock); | 357 | mutex_unlock(&data->update_lock); |
357 | return count; | 358 | return count; |
358 | } | 359 | } |
359 | 360 | ||
@@ -405,11 +406,11 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr) | |||
405 | int val = simple_strtol(buf, NULL, 10); | 406 | int val = simple_strtol(buf, NULL, 10); |
406 | int reg; | 407 | int reg; |
407 | 408 | ||
408 | down(&data->update_lock); | 409 | mutex_lock(&data->update_lock); |
409 | if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) && | 410 | if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) && |
410 | (((val>>4) & 0xf) != 5)) { | 411 | (((val>>4) & 0xf) != 5)) { |
411 | /* In automatic mode, the only PWM accepted is 33% */ | 412 | /* In automatic mode, the only PWM accepted is 33% */ |
412 | up(&data->update_lock); | 413 | mutex_unlock(&data->update_lock); |
413 | return -EINVAL; | 414 | return -EINVAL; |
414 | } | 415 | } |
415 | data->pwm[nr] = PWM_TO_REG(val); | 416 | data->pwm[nr] = PWM_TO_REG(val); |
@@ -417,7 +418,7 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr) | |||
417 | adm1031_write_value(client, ADM1031_REG_PWM, | 418 | adm1031_write_value(client, ADM1031_REG_PWM, |
418 | nr ? ((data->pwm[nr] << 4) & 0xf0) | (reg & 0xf) | 419 | nr ? ((data->pwm[nr] << 4) & 0xf0) | (reg & 0xf) |
419 | : (data->pwm[nr] & 0xf) | (reg & 0xf0)); | 420 | : (data->pwm[nr] & 0xf) | (reg & 0xf0)); |
420 | up(&data->update_lock); | 421 | mutex_unlock(&data->update_lock); |
421 | return count; | 422 | return count; |
422 | } | 423 | } |
423 | 424 | ||
@@ -511,7 +512,7 @@ set_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
511 | struct adm1031_data *data = i2c_get_clientdata(client); | 512 | struct adm1031_data *data = i2c_get_clientdata(client); |
512 | int val = simple_strtol(buf, NULL, 10); | 513 | int val = simple_strtol(buf, NULL, 10); |
513 | 514 | ||
514 | down(&data->update_lock); | 515 | mutex_lock(&data->update_lock); |
515 | if (val) { | 516 | if (val) { |
516 | data->fan_min[nr] = | 517 | data->fan_min[nr] = |
517 | FAN_TO_REG(val, FAN_DIV_FROM_REG(data->fan_div[nr])); | 518 | FAN_TO_REG(val, FAN_DIV_FROM_REG(data->fan_div[nr])); |
@@ -519,7 +520,7 @@ set_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
519 | data->fan_min[nr] = 0xff; | 520 | data->fan_min[nr] = 0xff; |
520 | } | 521 | } |
521 | adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), data->fan_min[nr]); | 522 | adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), data->fan_min[nr]); |
522 | up(&data->update_lock); | 523 | mutex_unlock(&data->update_lock); |
523 | return count; | 524 | return count; |
524 | } | 525 | } |
525 | static ssize_t | 526 | static ssize_t |
@@ -540,7 +541,7 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr) | |||
540 | if (tmp == 0xff) | 541 | if (tmp == 0xff) |
541 | return -EINVAL; | 542 | return -EINVAL; |
542 | 543 | ||
543 | down(&data->update_lock); | 544 | mutex_lock(&data->update_lock); |
544 | old_div = FAN_DIV_FROM_REG(data->fan_div[nr]); | 545 | old_div = FAN_DIV_FROM_REG(data->fan_div[nr]); |
545 | data->fan_div[nr] = (tmp & 0xC0) | (0x3f & data->fan_div[nr]); | 546 | data->fan_div[nr] = (tmp & 0xC0) | (0x3f & data->fan_div[nr]); |
546 | new_min = data->fan_min[nr] * old_div / | 547 | new_min = data->fan_min[nr] * old_div / |
@@ -553,7 +554,7 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr) | |||
553 | data->fan_div[nr]); | 554 | data->fan_div[nr]); |
554 | adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), | 555 | adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), |
555 | data->fan_min[nr]); | 556 | data->fan_min[nr]); |
556 | up(&data->update_lock); | 557 | mutex_unlock(&data->update_lock); |
557 | return count; | 558 | return count; |
558 | } | 559 | } |
559 | 560 | ||
@@ -627,11 +628,11 @@ set_temp_min(struct device *dev, const char *buf, size_t count, int nr) | |||
627 | 628 | ||
628 | val = simple_strtol(buf, NULL, 10); | 629 | val = simple_strtol(buf, NULL, 10); |
629 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); | 630 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); |
630 | down(&data->update_lock); | 631 | mutex_lock(&data->update_lock); |
631 | data->temp_min[nr] = TEMP_TO_REG(val); | 632 | data->temp_min[nr] = TEMP_TO_REG(val); |
632 | adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr), | 633 | adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr), |
633 | data->temp_min[nr]); | 634 | data->temp_min[nr]); |
634 | up(&data->update_lock); | 635 | mutex_unlock(&data->update_lock); |
635 | return count; | 636 | return count; |
636 | } | 637 | } |
637 | static ssize_t | 638 | static ssize_t |
@@ -643,11 +644,11 @@ set_temp_max(struct device *dev, const char *buf, size_t count, int nr) | |||
643 | 644 | ||
644 | val = simple_strtol(buf, NULL, 10); | 645 | val = simple_strtol(buf, NULL, 10); |
645 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); | 646 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); |
646 | down(&data->update_lock); | 647 | mutex_lock(&data->update_lock); |
647 | data->temp_max[nr] = TEMP_TO_REG(val); | 648 | data->temp_max[nr] = TEMP_TO_REG(val); |
648 | adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr), | 649 | adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr), |
649 | data->temp_max[nr]); | 650 | data->temp_max[nr]); |
650 | up(&data->update_lock); | 651 | mutex_unlock(&data->update_lock); |
651 | return count; | 652 | return count; |
652 | } | 653 | } |
653 | static ssize_t | 654 | static ssize_t |
@@ -659,11 +660,11 @@ set_temp_crit(struct device *dev, const char *buf, size_t count, int nr) | |||
659 | 660 | ||
660 | val = simple_strtol(buf, NULL, 10); | 661 | val = simple_strtol(buf, NULL, 10); |
661 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); | 662 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); |
662 | down(&data->update_lock); | 663 | mutex_lock(&data->update_lock); |
663 | data->temp_crit[nr] = TEMP_TO_REG(val); | 664 | data->temp_crit[nr] = TEMP_TO_REG(val); |
664 | adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr), | 665 | adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr), |
665 | data->temp_crit[nr]); | 666 | data->temp_crit[nr]); |
666 | up(&data->update_lock); | 667 | mutex_unlock(&data->update_lock); |
667 | return count; | 668 | return count; |
668 | } | 669 | } |
669 | 670 | ||
@@ -778,7 +779,7 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) | |||
778 | 779 | ||
779 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 780 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
780 | data->valid = 0; | 781 | data->valid = 0; |
781 | init_MUTEX(&data->update_lock); | 782 | mutex_init(&data->update_lock); |
782 | 783 | ||
783 | /* Tell the I2C layer a new client has arrived */ | 784 | /* Tell the I2C layer a new client has arrived */ |
784 | if ((err = i2c_attach_client(new_client))) | 785 | if ((err = i2c_attach_client(new_client))) |
@@ -891,7 +892,7 @@ static struct adm1031_data *adm1031_update_device(struct device *dev) | |||
891 | struct adm1031_data *data = i2c_get_clientdata(client); | 892 | struct adm1031_data *data = i2c_get_clientdata(client); |
892 | int chan; | 893 | int chan; |
893 | 894 | ||
894 | down(&data->update_lock); | 895 | mutex_lock(&data->update_lock); |
895 | 896 | ||
896 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 897 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
897 | || !data->valid) { | 898 | || !data->valid) { |
@@ -965,7 +966,7 @@ static struct adm1031_data *adm1031_update_device(struct device *dev) | |||
965 | data->valid = 1; | 966 | data->valid = 1; |
966 | } | 967 | } |
967 | 968 | ||
968 | up(&data->update_lock); | 969 | mutex_unlock(&data->update_lock); |
969 | 970 | ||
970 | return data; | 971 | return data; |
971 | } | 972 | } |
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index 5ddc22fea4a3..43f6991b588c 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include <linux/hwmon.h> | 49 | #include <linux/hwmon.h> |
50 | #include <linux/hwmon-vid.h> | 50 | #include <linux/hwmon-vid.h> |
51 | #include <linux/err.h> | 51 | #include <linux/err.h> |
52 | #include <linux/mutex.h> | ||
52 | 53 | ||
53 | /* Addresses to scan */ | 54 | /* Addresses to scan */ |
54 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, | 55 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, |
@@ -150,7 +151,7 @@ struct adm9240_data { | |||
150 | enum chips type; | 151 | enum chips type; |
151 | struct i2c_client client; | 152 | struct i2c_client client; |
152 | struct class_device *class_dev; | 153 | struct class_device *class_dev; |
153 | struct semaphore update_lock; | 154 | struct mutex update_lock; |
154 | char valid; | 155 | char valid; |
155 | unsigned long last_updated_measure; | 156 | unsigned long last_updated_measure; |
156 | unsigned long last_updated_config; | 157 | unsigned long last_updated_config; |
@@ -195,11 +196,11 @@ static ssize_t set_max(struct device *dev, struct device_attribute *devattr, | |||
195 | struct adm9240_data *data = i2c_get_clientdata(client); | 196 | struct adm9240_data *data = i2c_get_clientdata(client); |
196 | long val = simple_strtol(buf, NULL, 10); | 197 | long val = simple_strtol(buf, NULL, 10); |
197 | 198 | ||
198 | down(&data->update_lock); | 199 | mutex_lock(&data->update_lock); |
199 | data->temp_max[attr->index] = TEMP_TO_REG(val); | 200 | data->temp_max[attr->index] = TEMP_TO_REG(val); |
200 | i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index), | 201 | i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index), |
201 | data->temp_max[attr->index]); | 202 | data->temp_max[attr->index]); |
202 | up(&data->update_lock); | 203 | mutex_unlock(&data->update_lock); |
203 | return count; | 204 | return count; |
204 | } | 205 | } |
205 | 206 | ||
@@ -246,11 +247,11 @@ static ssize_t set_in_min(struct device *dev, | |||
246 | struct adm9240_data *data = i2c_get_clientdata(client); | 247 | struct adm9240_data *data = i2c_get_clientdata(client); |
247 | unsigned long val = simple_strtoul(buf, NULL, 10); | 248 | unsigned long val = simple_strtoul(buf, NULL, 10); |
248 | 249 | ||
249 | down(&data->update_lock); | 250 | mutex_lock(&data->update_lock); |
250 | data->in_min[attr->index] = IN_TO_REG(val, attr->index); | 251 | data->in_min[attr->index] = IN_TO_REG(val, attr->index); |
251 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index), | 252 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index), |
252 | data->in_min[attr->index]); | 253 | data->in_min[attr->index]); |
253 | up(&data->update_lock); | 254 | mutex_unlock(&data->update_lock); |
254 | return count; | 255 | return count; |
255 | } | 256 | } |
256 | 257 | ||
@@ -263,11 +264,11 @@ static ssize_t set_in_max(struct device *dev, | |||
263 | struct adm9240_data *data = i2c_get_clientdata(client); | 264 | struct adm9240_data *data = i2c_get_clientdata(client); |
264 | unsigned long val = simple_strtoul(buf, NULL, 10); | 265 | unsigned long val = simple_strtoul(buf, NULL, 10); |
265 | 266 | ||
266 | down(&data->update_lock); | 267 | mutex_lock(&data->update_lock); |
267 | data->in_max[attr->index] = IN_TO_REG(val, attr->index); | 268 | data->in_max[attr->index] = IN_TO_REG(val, attr->index); |
268 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index), | 269 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index), |
269 | data->in_max[attr->index]); | 270 | data->in_max[attr->index]); |
270 | up(&data->update_lock); | 271 | mutex_unlock(&data->update_lock); |
271 | return count; | 272 | return count; |
272 | } | 273 | } |
273 | 274 | ||
@@ -350,7 +351,7 @@ static ssize_t set_fan_min(struct device *dev, | |||
350 | int nr = attr->index; | 351 | int nr = attr->index; |
351 | u8 new_div; | 352 | u8 new_div; |
352 | 353 | ||
353 | down(&data->update_lock); | 354 | mutex_lock(&data->update_lock); |
354 | 355 | ||
355 | if (!val) { | 356 | if (!val) { |
356 | data->fan_min[nr] = 255; | 357 | data->fan_min[nr] = 255; |
@@ -390,7 +391,7 @@ static ssize_t set_fan_min(struct device *dev, | |||
390 | i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr), | 391 | i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr), |
391 | data->fan_min[nr]); | 392 | data->fan_min[nr]); |
392 | 393 | ||
393 | up(&data->update_lock); | 394 | mutex_unlock(&data->update_lock); |
394 | return count; | 395 | return count; |
395 | } | 396 | } |
396 | 397 | ||
@@ -439,10 +440,10 @@ static ssize_t set_aout(struct device *dev, | |||
439 | struct adm9240_data *data = i2c_get_clientdata(client); | 440 | struct adm9240_data *data = i2c_get_clientdata(client); |
440 | unsigned long val = simple_strtol(buf, NULL, 10); | 441 | unsigned long val = simple_strtol(buf, NULL, 10); |
441 | 442 | ||
442 | down(&data->update_lock); | 443 | mutex_lock(&data->update_lock); |
443 | data->aout = AOUT_TO_REG(val); | 444 | data->aout = AOUT_TO_REG(val); |
444 | i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout); | 445 | i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout); |
445 | up(&data->update_lock); | 446 | mutex_unlock(&data->update_lock); |
446 | return count; | 447 | return count; |
447 | } | 448 | } |
448 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); | 449 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); |
@@ -539,7 +540,7 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
539 | /* fill in the remaining client fields and attach */ | 540 | /* fill in the remaining client fields and attach */ |
540 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 541 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
541 | data->type = kind; | 542 | data->type = kind; |
542 | init_MUTEX(&data->update_lock); | 543 | mutex_init(&data->update_lock); |
543 | 544 | ||
544 | if ((err = i2c_attach_client(new_client))) | 545 | if ((err = i2c_attach_client(new_client))) |
545 | goto exit_free; | 546 | goto exit_free; |
@@ -691,7 +692,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) | |||
691 | struct adm9240_data *data = i2c_get_clientdata(client); | 692 | struct adm9240_data *data = i2c_get_clientdata(client); |
692 | int i; | 693 | int i; |
693 | 694 | ||
694 | down(&data->update_lock); | 695 | mutex_lock(&data->update_lock); |
695 | 696 | ||
696 | /* minimum measurement cycle: 1.75 seconds */ | 697 | /* minimum measurement cycle: 1.75 seconds */ |
697 | if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4)) | 698 | if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4)) |
@@ -771,7 +772,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) | |||
771 | data->last_updated_config = jiffies; | 772 | data->last_updated_config = jiffies; |
772 | data->valid = 1; | 773 | data->valid = 1; |
773 | } | 774 | } |
774 | up(&data->update_lock); | 775 | mutex_unlock(&data->update_lock); |
775 | return data; | 776 | return data; |
776 | } | 777 | } |
777 | 778 | ||
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index ae9de63cf2e0..65b2709f750c 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/err.h> | 44 | #include <linux/err.h> |
45 | #include <linux/init.h> | 45 | #include <linux/init.h> |
46 | #include <linux/jiffies.h> | 46 | #include <linux/jiffies.h> |
47 | #include <linux/mutex.h> | ||
47 | #include "lm75.h" | 48 | #include "lm75.h" |
48 | 49 | ||
49 | /* | 50 | /* |
@@ -182,10 +183,10 @@ static u8 DIV_TO_REG(long val) | |||
182 | struct asb100_data { | 183 | struct asb100_data { |
183 | struct i2c_client client; | 184 | struct i2c_client client; |
184 | struct class_device *class_dev; | 185 | struct class_device *class_dev; |
185 | struct semaphore lock; | 186 | struct mutex lock; |
186 | enum chips type; | 187 | enum chips type; |
187 | 188 | ||
188 | struct semaphore update_lock; | 189 | struct mutex update_lock; |
189 | unsigned long last_updated; /* In jiffies */ | 190 | unsigned long last_updated; /* In jiffies */ |
190 | 191 | ||
191 | /* array of 2 pointers to subclients */ | 192 | /* array of 2 pointers to subclients */ |
@@ -245,11 +246,11 @@ static ssize_t set_in_##reg(struct device *dev, const char *buf, \ | |||
245 | struct asb100_data *data = i2c_get_clientdata(client); \ | 246 | struct asb100_data *data = i2c_get_clientdata(client); \ |
246 | unsigned long val = simple_strtoul(buf, NULL, 10); \ | 247 | unsigned long val = simple_strtoul(buf, NULL, 10); \ |
247 | \ | 248 | \ |
248 | down(&data->update_lock); \ | 249 | mutex_lock(&data->update_lock); \ |
249 | data->in_##reg[nr] = IN_TO_REG(val); \ | 250 | data->in_##reg[nr] = IN_TO_REG(val); \ |
250 | asb100_write_value(client, ASB100_REG_IN_##REG(nr), \ | 251 | asb100_write_value(client, ASB100_REG_IN_##REG(nr), \ |
251 | data->in_##reg[nr]); \ | 252 | data->in_##reg[nr]); \ |
252 | up(&data->update_lock); \ | 253 | mutex_unlock(&data->update_lock); \ |
253 | return count; \ | 254 | return count; \ |
254 | } | 255 | } |
255 | 256 | ||
@@ -331,10 +332,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
331 | struct asb100_data *data = i2c_get_clientdata(client); | 332 | struct asb100_data *data = i2c_get_clientdata(client); |
332 | u32 val = simple_strtoul(buf, NULL, 10); | 333 | u32 val = simple_strtoul(buf, NULL, 10); |
333 | 334 | ||
334 | down(&data->update_lock); | 335 | mutex_lock(&data->update_lock); |
335 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 336 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
336 | asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); | 337 | asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); |
337 | up(&data->update_lock); | 338 | mutex_unlock(&data->update_lock); |
338 | return count; | 339 | return count; |
339 | } | 340 | } |
340 | 341 | ||
@@ -351,7 +352,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
351 | unsigned long val = simple_strtoul(buf, NULL, 10); | 352 | unsigned long val = simple_strtoul(buf, NULL, 10); |
352 | int reg; | 353 | int reg; |
353 | 354 | ||
354 | down(&data->update_lock); | 355 | mutex_lock(&data->update_lock); |
355 | 356 | ||
356 | min = FAN_FROM_REG(data->fan_min[nr], | 357 | min = FAN_FROM_REG(data->fan_min[nr], |
357 | DIV_FROM_REG(data->fan_div[nr])); | 358 | DIV_FROM_REG(data->fan_div[nr])); |
@@ -381,7 +382,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
381 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 382 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
382 | asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); | 383 | asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); |
383 | 384 | ||
384 | up(&data->update_lock); | 385 | mutex_unlock(&data->update_lock); |
385 | 386 | ||
386 | return count; | 387 | return count; |
387 | } | 388 | } |
@@ -461,7 +462,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \ | |||
461 | struct asb100_data *data = i2c_get_clientdata(client); \ | 462 | struct asb100_data *data = i2c_get_clientdata(client); \ |
462 | unsigned long val = simple_strtoul(buf, NULL, 10); \ | 463 | unsigned long val = simple_strtoul(buf, NULL, 10); \ |
463 | \ | 464 | \ |
464 | down(&data->update_lock); \ | 465 | mutex_lock(&data->update_lock); \ |
465 | switch (nr) { \ | 466 | switch (nr) { \ |
466 | case 1: case 2: \ | 467 | case 1: case 2: \ |
467 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ | 468 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ |
@@ -472,7 +473,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \ | |||
472 | } \ | 473 | } \ |
473 | asb100_write_value(client, ASB100_REG_TEMP_##REG(nr+1), \ | 474 | asb100_write_value(client, ASB100_REG_TEMP_##REG(nr+1), \ |
474 | data->reg[nr]); \ | 475 | data->reg[nr]); \ |
475 | up(&data->update_lock); \ | 476 | mutex_unlock(&data->update_lock); \ |
476 | return count; \ | 477 | return count; \ |
477 | } | 478 | } |
478 | 479 | ||
@@ -574,11 +575,11 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const | |||
574 | struct asb100_data *data = i2c_get_clientdata(client); | 575 | struct asb100_data *data = i2c_get_clientdata(client); |
575 | unsigned long val = simple_strtoul(buf, NULL, 10); | 576 | unsigned long val = simple_strtoul(buf, NULL, 10); |
576 | 577 | ||
577 | down(&data->update_lock); | 578 | mutex_lock(&data->update_lock); |
578 | data->pwm &= 0x80; /* keep the enable bit */ | 579 | data->pwm &= 0x80; /* keep the enable bit */ |
579 | data->pwm |= (0x0f & ASB100_PWM_TO_REG(val)); | 580 | data->pwm |= (0x0f & ASB100_PWM_TO_REG(val)); |
580 | asb100_write_value(client, ASB100_REG_PWM1, data->pwm); | 581 | asb100_write_value(client, ASB100_REG_PWM1, data->pwm); |
581 | up(&data->update_lock); | 582 | mutex_unlock(&data->update_lock); |
582 | return count; | 583 | return count; |
583 | } | 584 | } |
584 | 585 | ||
@@ -595,11 +596,11 @@ static ssize_t set_pwm_enable1(struct device *dev, struct device_attribute *attr | |||
595 | struct asb100_data *data = i2c_get_clientdata(client); | 596 | struct asb100_data *data = i2c_get_clientdata(client); |
596 | unsigned long val = simple_strtoul(buf, NULL, 10); | 597 | unsigned long val = simple_strtoul(buf, NULL, 10); |
597 | 598 | ||
598 | down(&data->update_lock); | 599 | mutex_lock(&data->update_lock); |
599 | data->pwm &= 0x0f; /* keep the duty cycle bits */ | 600 | data->pwm &= 0x0f; /* keep the duty cycle bits */ |
600 | data->pwm |= (val ? 0x80 : 0x00); | 601 | data->pwm |= (val ? 0x80 : 0x00); |
601 | asb100_write_value(client, ASB100_REG_PWM1, data->pwm); | 602 | asb100_write_value(client, ASB100_REG_PWM1, data->pwm); |
602 | up(&data->update_lock); | 603 | mutex_unlock(&data->update_lock); |
603 | return count; | 604 | return count; |
604 | } | 605 | } |
605 | 606 | ||
@@ -729,7 +730,7 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
729 | } | 730 | } |
730 | 731 | ||
731 | new_client = &data->client; | 732 | new_client = &data->client; |
732 | init_MUTEX(&data->lock); | 733 | mutex_init(&data->lock); |
733 | i2c_set_clientdata(new_client, data); | 734 | i2c_set_clientdata(new_client, data); |
734 | new_client->addr = address; | 735 | new_client->addr = address; |
735 | new_client->adapter = adapter; | 736 | new_client->adapter = adapter; |
@@ -789,7 +790,7 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
789 | data->type = kind; | 790 | data->type = kind; |
790 | 791 | ||
791 | data->valid = 0; | 792 | data->valid = 0; |
792 | init_MUTEX(&data->update_lock); | 793 | mutex_init(&data->update_lock); |
793 | 794 | ||
794 | /* Tell the I2C layer a new client has arrived */ | 795 | /* Tell the I2C layer a new client has arrived */ |
795 | if ((err = i2c_attach_client(new_client))) | 796 | if ((err = i2c_attach_client(new_client))) |
@@ -885,7 +886,7 @@ static int asb100_read_value(struct i2c_client *client, u16 reg) | |||
885 | struct i2c_client *cl; | 886 | struct i2c_client *cl; |
886 | int res, bank; | 887 | int res, bank; |
887 | 888 | ||
888 | down(&data->lock); | 889 | mutex_lock(&data->lock); |
889 | 890 | ||
890 | bank = (reg >> 8) & 0x0f; | 891 | bank = (reg >> 8) & 0x0f; |
891 | if (bank > 2) | 892 | if (bank > 2) |
@@ -919,7 +920,7 @@ static int asb100_read_value(struct i2c_client *client, u16 reg) | |||
919 | if (bank > 2) | 920 | if (bank > 2) |
920 | i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); | 921 | i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); |
921 | 922 | ||
922 | up(&data->lock); | 923 | mutex_unlock(&data->lock); |
923 | 924 | ||
924 | return res; | 925 | return res; |
925 | } | 926 | } |
@@ -930,7 +931,7 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
930 | struct i2c_client *cl; | 931 | struct i2c_client *cl; |
931 | int bank; | 932 | int bank; |
932 | 933 | ||
933 | down(&data->lock); | 934 | mutex_lock(&data->lock); |
934 | 935 | ||
935 | bank = (reg >> 8) & 0x0f; | 936 | bank = (reg >> 8) & 0x0f; |
936 | if (bank > 2) | 937 | if (bank > 2) |
@@ -960,7 +961,7 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
960 | if (bank > 2) | 961 | if (bank > 2) |
961 | i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); | 962 | i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); |
962 | 963 | ||
963 | up(&data->lock); | 964 | mutex_unlock(&data->lock); |
964 | } | 965 | } |
965 | 966 | ||
966 | static void asb100_init_client(struct i2c_client *client) | 967 | static void asb100_init_client(struct i2c_client *client) |
@@ -984,7 +985,7 @@ static struct asb100_data *asb100_update_device(struct device *dev) | |||
984 | struct asb100_data *data = i2c_get_clientdata(client); | 985 | struct asb100_data *data = i2c_get_clientdata(client); |
985 | int i; | 986 | int i; |
986 | 987 | ||
987 | down(&data->update_lock); | 988 | mutex_lock(&data->update_lock); |
988 | 989 | ||
989 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 990 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
990 | || !data->valid) { | 991 | || !data->valid) { |
@@ -1042,7 +1043,7 @@ static struct asb100_data *asb100_update_device(struct device *dev) | |||
1042 | dev_dbg(&client->dev, "... device update complete\n"); | 1043 | dev_dbg(&client->dev, "... device update complete\n"); |
1043 | } | 1044 | } |
1044 | 1045 | ||
1045 | up(&data->update_lock); | 1046 | mutex_unlock(&data->update_lock); |
1046 | 1047 | ||
1047 | return data; | 1048 | return data; |
1048 | } | 1049 | } |
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index b0c490073c8e..728a1e8b9190 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/hwmon.h> | 26 | #include <linux/hwmon.h> |
27 | #include <linux/hwmon-vid.h> | 27 | #include <linux/hwmon-vid.h> |
28 | #include <linux/err.h> | 28 | #include <linux/err.h> |
29 | #include <linux/mutex.h> | ||
29 | 30 | ||
30 | MODULE_LICENSE("GPL"); | 31 | MODULE_LICENSE("GPL"); |
31 | MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); | 32 | MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); |
@@ -60,7 +61,7 @@ static struct i2c_driver atxp1_driver = { | |||
60 | struct atxp1_data { | 61 | struct atxp1_data { |
61 | struct i2c_client client; | 62 | struct i2c_client client; |
62 | struct class_device *class_dev; | 63 | struct class_device *class_dev; |
63 | struct semaphore update_lock; | 64 | struct mutex update_lock; |
64 | unsigned long last_updated; | 65 | unsigned long last_updated; |
65 | u8 valid; | 66 | u8 valid; |
66 | struct { | 67 | struct { |
@@ -80,7 +81,7 @@ static struct atxp1_data * atxp1_update_device(struct device *dev) | |||
80 | client = to_i2c_client(dev); | 81 | client = to_i2c_client(dev); |
81 | data = i2c_get_clientdata(client); | 82 | data = i2c_get_clientdata(client); |
82 | 83 | ||
83 | down(&data->update_lock); | 84 | mutex_lock(&data->update_lock); |
84 | 85 | ||
85 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | 86 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
86 | 87 | ||
@@ -93,7 +94,7 @@ static struct atxp1_data * atxp1_update_device(struct device *dev) | |||
93 | data->valid = 1; | 94 | data->valid = 1; |
94 | } | 95 | } |
95 | 96 | ||
96 | up(&data->update_lock); | 97 | mutex_unlock(&data->update_lock); |
97 | 98 | ||
98 | return(data); | 99 | return(data); |
99 | } | 100 | } |
@@ -309,7 +310,7 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) | |||
309 | 310 | ||
310 | data->valid = 0; | 311 | data->valid = 0; |
311 | 312 | ||
312 | init_MUTEX(&data->update_lock); | 313 | mutex_init(&data->update_lock); |
313 | 314 | ||
314 | err = i2c_attach_client(new_client); | 315 | err = i2c_attach_client(new_client); |
315 | 316 | ||
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 203f9c7abb20..478eb4bb8570 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/hwmon.h> | 29 | #include <linux/hwmon.h> |
30 | #include <linux/err.h> | 30 | #include <linux/err.h> |
31 | #include <linux/mutex.h> | ||
31 | #include "lm75.h" | 32 | #include "lm75.h" |
32 | 33 | ||
33 | /* Addresses to scan */ | 34 | /* Addresses to scan */ |
@@ -72,7 +73,7 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low") | |||
72 | struct ds1621_data { | 73 | struct ds1621_data { |
73 | struct i2c_client client; | 74 | struct i2c_client client; |
74 | struct class_device *class_dev; | 75 | struct class_device *class_dev; |
75 | struct semaphore update_lock; | 76 | struct mutex update_lock; |
76 | char valid; /* !=0 if following fields are valid */ | 77 | char valid; /* !=0 if following fields are valid */ |
77 | unsigned long last_updated; /* In jiffies */ | 78 | unsigned long last_updated; /* In jiffies */ |
78 | 79 | ||
@@ -156,10 +157,10 @@ static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *at | |||
156 | struct ds1621_data *data = ds1621_update_client(dev); \ | 157 | struct ds1621_data *data = ds1621_update_client(dev); \ |
157 | u16 val = LM75_TEMP_TO_REG(simple_strtoul(buf, NULL, 10)); \ | 158 | u16 val = LM75_TEMP_TO_REG(simple_strtoul(buf, NULL, 10)); \ |
158 | \ | 159 | \ |
159 | down(&data->update_lock); \ | 160 | mutex_lock(&data->update_lock); \ |
160 | data->value = val; \ | 161 | data->value = val; \ |
161 | ds1621_write_value(client, reg, data->value); \ | 162 | ds1621_write_value(client, reg, data->value); \ |
162 | up(&data->update_lock); \ | 163 | mutex_unlock(&data->update_lock); \ |
163 | return count; \ | 164 | return count; \ |
164 | } | 165 | } |
165 | 166 | ||
@@ -242,7 +243,7 @@ static int ds1621_detect(struct i2c_adapter *adapter, int address, | |||
242 | /* Fill in remaining client fields and put it into the global list */ | 243 | /* Fill in remaining client fields and put it into the global list */ |
243 | strlcpy(new_client->name, "ds1621", I2C_NAME_SIZE); | 244 | strlcpy(new_client->name, "ds1621", I2C_NAME_SIZE); |
244 | data->valid = 0; | 245 | data->valid = 0; |
245 | init_MUTEX(&data->update_lock); | 246 | mutex_init(&data->update_lock); |
246 | 247 | ||
247 | /* Tell the I2C layer a new client has arrived */ | 248 | /* Tell the I2C layer a new client has arrived */ |
248 | if ((err = i2c_attach_client(new_client))) | 249 | if ((err = i2c_attach_client(new_client))) |
@@ -297,7 +298,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev) | |||
297 | struct ds1621_data *data = i2c_get_clientdata(client); | 298 | struct ds1621_data *data = i2c_get_clientdata(client); |
298 | u8 new_conf; | 299 | u8 new_conf; |
299 | 300 | ||
300 | down(&data->update_lock); | 301 | mutex_lock(&data->update_lock); |
301 | 302 | ||
302 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 303 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
303 | || !data->valid) { | 304 | || !data->valid) { |
@@ -327,7 +328,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev) | |||
327 | data->valid = 1; | 328 | data->valid = 1; |
328 | } | 329 | } |
329 | 330 | ||
330 | up(&data->update_lock); | 331 | mutex_unlock(&data->update_lock); |
331 | 332 | ||
332 | return data; | 333 | return data; |
333 | } | 334 | } |
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c index e029e0a94ecc..885465df6e6a 100644 --- a/drivers/hwmon/f71805f.c +++ b/drivers/hwmon/f71805f.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/hwmon.h> | 30 | #include <linux/hwmon.h> |
31 | #include <linux/hwmon-sysfs.h> | 31 | #include <linux/hwmon-sysfs.h> |
32 | #include <linux/err.h> | 32 | #include <linux/err.h> |
33 | #include <linux/mutex.h> | ||
33 | #include <asm/io.h> | 34 | #include <asm/io.h> |
34 | 35 | ||
35 | static struct platform_device *pdev; | 36 | static struct platform_device *pdev; |
@@ -131,10 +132,10 @@ static struct resource f71805f_resource __initdata = { | |||
131 | struct f71805f_data { | 132 | struct f71805f_data { |
132 | unsigned short addr; | 133 | unsigned short addr; |
133 | const char *name; | 134 | const char *name; |
134 | struct semaphore lock; | 135 | struct mutex lock; |
135 | struct class_device *class_dev; | 136 | struct class_device *class_dev; |
136 | 137 | ||
137 | struct semaphore update_lock; | 138 | struct mutex update_lock; |
138 | char valid; /* !=0 if following fields are valid */ | 139 | char valid; /* !=0 if following fields are valid */ |
139 | unsigned long last_updated; /* In jiffies */ | 140 | unsigned long last_updated; /* In jiffies */ |
140 | unsigned long last_limits; /* In jiffies */ | 141 | unsigned long last_limits; /* In jiffies */ |
@@ -224,20 +225,20 @@ static u8 f71805f_read8(struct f71805f_data *data, u8 reg) | |||
224 | { | 225 | { |
225 | u8 val; | 226 | u8 val; |
226 | 227 | ||
227 | down(&data->lock); | 228 | mutex_lock(&data->lock); |
228 | outb(reg, data->addr + ADDR_REG_OFFSET); | 229 | outb(reg, data->addr + ADDR_REG_OFFSET); |
229 | val = inb(data->addr + DATA_REG_OFFSET); | 230 | val = inb(data->addr + DATA_REG_OFFSET); |
230 | up(&data->lock); | 231 | mutex_unlock(&data->lock); |
231 | 232 | ||
232 | return val; | 233 | return val; |
233 | } | 234 | } |
234 | 235 | ||
235 | static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val) | 236 | static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val) |
236 | { | 237 | { |
237 | down(&data->lock); | 238 | mutex_lock(&data->lock); |
238 | outb(reg, data->addr + ADDR_REG_OFFSET); | 239 | outb(reg, data->addr + ADDR_REG_OFFSET); |
239 | outb(val, data->addr + DATA_REG_OFFSET); | 240 | outb(val, data->addr + DATA_REG_OFFSET); |
240 | up(&data->lock); | 241 | mutex_unlock(&data->lock); |
241 | } | 242 | } |
242 | 243 | ||
243 | /* It is important to read the MSB first, because doing so latches the | 244 | /* It is important to read the MSB first, because doing so latches the |
@@ -246,24 +247,24 @@ static u16 f71805f_read16(struct f71805f_data *data, u8 reg) | |||
246 | { | 247 | { |
247 | u16 val; | 248 | u16 val; |
248 | 249 | ||
249 | down(&data->lock); | 250 | mutex_lock(&data->lock); |
250 | outb(reg, data->addr + ADDR_REG_OFFSET); | 251 | outb(reg, data->addr + ADDR_REG_OFFSET); |
251 | val = inb(data->addr + DATA_REG_OFFSET) << 8; | 252 | val = inb(data->addr + DATA_REG_OFFSET) << 8; |
252 | outb(++reg, data->addr + ADDR_REG_OFFSET); | 253 | outb(++reg, data->addr + ADDR_REG_OFFSET); |
253 | val |= inb(data->addr + DATA_REG_OFFSET); | 254 | val |= inb(data->addr + DATA_REG_OFFSET); |
254 | up(&data->lock); | 255 | mutex_unlock(&data->lock); |
255 | 256 | ||
256 | return val; | 257 | return val; |
257 | } | 258 | } |
258 | 259 | ||
259 | static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val) | 260 | static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val) |
260 | { | 261 | { |
261 | down(&data->lock); | 262 | mutex_lock(&data->lock); |
262 | outb(reg, data->addr + ADDR_REG_OFFSET); | 263 | outb(reg, data->addr + ADDR_REG_OFFSET); |
263 | outb(val >> 8, data->addr + DATA_REG_OFFSET); | 264 | outb(val >> 8, data->addr + DATA_REG_OFFSET); |
264 | outb(++reg, data->addr + ADDR_REG_OFFSET); | 265 | outb(++reg, data->addr + ADDR_REG_OFFSET); |
265 | outb(val & 0xff, data->addr + DATA_REG_OFFSET); | 266 | outb(val & 0xff, data->addr + DATA_REG_OFFSET); |
266 | up(&data->lock); | 267 | mutex_unlock(&data->lock); |
267 | } | 268 | } |
268 | 269 | ||
269 | static struct f71805f_data *f71805f_update_device(struct device *dev) | 270 | static struct f71805f_data *f71805f_update_device(struct device *dev) |
@@ -271,7 +272,7 @@ static struct f71805f_data *f71805f_update_device(struct device *dev) | |||
271 | struct f71805f_data *data = dev_get_drvdata(dev); | 272 | struct f71805f_data *data = dev_get_drvdata(dev); |
272 | int nr; | 273 | int nr; |
273 | 274 | ||
274 | down(&data->update_lock); | 275 | mutex_lock(&data->update_lock); |
275 | 276 | ||
276 | /* Limit registers cache is refreshed after 60 seconds */ | 277 | /* Limit registers cache is refreshed after 60 seconds */ |
277 | if (time_after(jiffies, data->last_updated + 60 * HZ) | 278 | if (time_after(jiffies, data->last_updated + 60 * HZ) |
@@ -323,7 +324,7 @@ static struct f71805f_data *f71805f_update_device(struct device *dev) | |||
323 | data->valid = 1; | 324 | data->valid = 1; |
324 | } | 325 | } |
325 | 326 | ||
326 | up(&data->update_lock); | 327 | mutex_unlock(&data->update_lock); |
327 | 328 | ||
328 | return data; | 329 | return data; |
329 | } | 330 | } |
@@ -362,10 +363,10 @@ static ssize_t set_in0_max(struct device *dev, struct device_attribute | |||
362 | struct f71805f_data *data = dev_get_drvdata(dev); | 363 | struct f71805f_data *data = dev_get_drvdata(dev); |
363 | long val = simple_strtol(buf, NULL, 10); | 364 | long val = simple_strtol(buf, NULL, 10); |
364 | 365 | ||
365 | down(&data->update_lock); | 366 | mutex_lock(&data->update_lock); |
366 | data->in_high[0] = in0_to_reg(val); | 367 | data->in_high[0] = in0_to_reg(val); |
367 | f71805f_write8(data, F71805F_REG_IN_HIGH(0), data->in_high[0]); | 368 | f71805f_write8(data, F71805F_REG_IN_HIGH(0), data->in_high[0]); |
368 | up(&data->update_lock); | 369 | mutex_unlock(&data->update_lock); |
369 | 370 | ||
370 | return count; | 371 | return count; |
371 | } | 372 | } |
@@ -376,18 +377,14 @@ static ssize_t set_in0_min(struct device *dev, struct device_attribute | |||
376 | struct f71805f_data *data = dev_get_drvdata(dev); | 377 | struct f71805f_data *data = dev_get_drvdata(dev); |
377 | long val = simple_strtol(buf, NULL, 10); | 378 | long val = simple_strtol(buf, NULL, 10); |
378 | 379 | ||
379 | down(&data->update_lock); | 380 | mutex_lock(&data->update_lock); |
380 | data->in_low[0] = in0_to_reg(val); | 381 | data->in_low[0] = in0_to_reg(val); |
381 | f71805f_write8(data, F71805F_REG_IN_LOW(0), data->in_low[0]); | 382 | f71805f_write8(data, F71805F_REG_IN_LOW(0), data->in_low[0]); |
382 | up(&data->update_lock); | 383 | mutex_unlock(&data->update_lock); |
383 | 384 | ||
384 | return count; | 385 | return count; |
385 | } | 386 | } |
386 | 387 | ||
387 | static DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL); | ||
388 | static DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max); | ||
389 | static DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min); | ||
390 | |||
391 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, | 388 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, |
392 | char *buf) | 389 | char *buf) |
393 | { | 390 | { |
@@ -426,10 +423,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute | |||
426 | int nr = attr->index; | 423 | int nr = attr->index; |
427 | long val = simple_strtol(buf, NULL, 10); | 424 | long val = simple_strtol(buf, NULL, 10); |
428 | 425 | ||
429 | down(&data->update_lock); | 426 | mutex_lock(&data->update_lock); |
430 | data->in_high[nr] = in_to_reg(val); | 427 | data->in_high[nr] = in_to_reg(val); |
431 | f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]); | 428 | f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]); |
432 | up(&data->update_lock); | 429 | mutex_unlock(&data->update_lock); |
433 | 430 | ||
434 | return count; | 431 | return count; |
435 | } | 432 | } |
@@ -442,31 +439,14 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute | |||
442 | int nr = attr->index; | 439 | int nr = attr->index; |
443 | long val = simple_strtol(buf, NULL, 10); | 440 | long val = simple_strtol(buf, NULL, 10); |
444 | 441 | ||
445 | down(&data->update_lock); | 442 | mutex_lock(&data->update_lock); |
446 | data->in_low[nr] = in_to_reg(val); | 443 | data->in_low[nr] = in_to_reg(val); |
447 | f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]); | 444 | f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]); |
448 | up(&data->update_lock); | 445 | mutex_unlock(&data->update_lock); |
449 | 446 | ||
450 | return count; | 447 | return count; |
451 | } | 448 | } |
452 | 449 | ||
453 | #define sysfs_in(offset) \ | ||
454 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ | ||
455 | show_in, NULL, offset); \ | ||
456 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | ||
457 | show_in_max, set_in_max, offset); \ | ||
458 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | ||
459 | show_in_min, set_in_min, offset) | ||
460 | |||
461 | sysfs_in(1); | ||
462 | sysfs_in(2); | ||
463 | sysfs_in(3); | ||
464 | sysfs_in(4); | ||
465 | sysfs_in(5); | ||
466 | sysfs_in(6); | ||
467 | sysfs_in(7); | ||
468 | sysfs_in(8); | ||
469 | |||
470 | static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, | 450 | static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, |
471 | char *buf) | 451 | char *buf) |
472 | { | 452 | { |
@@ -495,24 +475,14 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute | |||
495 | int nr = attr->index; | 475 | int nr = attr->index; |
496 | long val = simple_strtol(buf, NULL, 10); | 476 | long val = simple_strtol(buf, NULL, 10); |
497 | 477 | ||
498 | down(&data->update_lock); | 478 | mutex_lock(&data->update_lock); |
499 | data->fan_low[nr] = fan_to_reg(val); | 479 | data->fan_low[nr] = fan_to_reg(val); |
500 | f71805f_write16(data, F71805F_REG_FAN_LOW(nr), data->fan_low[nr]); | 480 | f71805f_write16(data, F71805F_REG_FAN_LOW(nr), data->fan_low[nr]); |
501 | up(&data->update_lock); | 481 | mutex_unlock(&data->update_lock); |
502 | 482 | ||
503 | return count; | 483 | return count; |
504 | } | 484 | } |
505 | 485 | ||
506 | #define sysfs_fan(offset) \ | ||
507 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
508 | show_fan, NULL, offset - 1); \ | ||
509 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
510 | show_fan_min, set_fan_min, offset - 1) | ||
511 | |||
512 | sysfs_fan(1); | ||
513 | sysfs_fan(2); | ||
514 | sysfs_fan(3); | ||
515 | |||
516 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, | 486 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, |
517 | char *buf) | 487 | char *buf) |
518 | { | 488 | { |
@@ -562,10 +532,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute | |||
562 | int nr = attr->index; | 532 | int nr = attr->index; |
563 | long val = simple_strtol(buf, NULL, 10); | 533 | long val = simple_strtol(buf, NULL, 10); |
564 | 534 | ||
565 | down(&data->update_lock); | 535 | mutex_lock(&data->update_lock); |
566 | data->temp_high[nr] = temp_to_reg(val); | 536 | data->temp_high[nr] = temp_to_reg(val); |
567 | f71805f_write8(data, F71805F_REG_TEMP_HIGH(nr), data->temp_high[nr]); | 537 | f71805f_write8(data, F71805F_REG_TEMP_HIGH(nr), data->temp_high[nr]); |
568 | up(&data->update_lock); | 538 | mutex_unlock(&data->update_lock); |
569 | 539 | ||
570 | return count; | 540 | return count; |
571 | } | 541 | } |
@@ -578,28 +548,14 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute | |||
578 | int nr = attr->index; | 548 | int nr = attr->index; |
579 | long val = simple_strtol(buf, NULL, 10); | 549 | long val = simple_strtol(buf, NULL, 10); |
580 | 550 | ||
581 | down(&data->update_lock); | 551 | mutex_lock(&data->update_lock); |
582 | data->temp_hyst[nr] = temp_to_reg(val); | 552 | data->temp_hyst[nr] = temp_to_reg(val); |
583 | f71805f_write8(data, F71805F_REG_TEMP_HYST(nr), data->temp_hyst[nr]); | 553 | f71805f_write8(data, F71805F_REG_TEMP_HYST(nr), data->temp_hyst[nr]); |
584 | up(&data->update_lock); | 554 | mutex_unlock(&data->update_lock); |
585 | 555 | ||
586 | return count; | 556 | return count; |
587 | } | 557 | } |
588 | 558 | ||
589 | #define sysfs_temp(offset) \ | ||
590 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | ||
591 | show_temp, NULL, offset - 1); \ | ||
592 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ | ||
593 | show_temp_max, set_temp_max, offset - 1); \ | ||
594 | static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ | ||
595 | show_temp_hyst, set_temp_hyst, offset - 1); \ | ||
596 | static SENSOR_DEVICE_ATTR(temp##offset##_type, S_IRUGO, \ | ||
597 | show_temp_type, NULL, offset - 1) | ||
598 | |||
599 | sysfs_temp(1); | ||
600 | sysfs_temp(2); | ||
601 | sysfs_temp(3); | ||
602 | |||
603 | static ssize_t show_alarms_in(struct device *dev, struct device_attribute | 559 | static ssize_t show_alarms_in(struct device *dev, struct device_attribute |
604 | *devattr, char *buf) | 560 | *devattr, char *buf) |
605 | { | 561 | { |
@@ -625,10 +581,6 @@ static ssize_t show_alarms_temp(struct device *dev, struct device_attribute | |||
625 | return sprintf(buf, "%d\n", (data->alarms[1] >> 3) & 0x07); | 581 | return sprintf(buf, "%d\n", (data->alarms[1] >> 3) & 0x07); |
626 | } | 582 | } |
627 | 583 | ||
628 | static DEVICE_ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL); | ||
629 | static DEVICE_ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL); | ||
630 | static DEVICE_ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL); | ||
631 | |||
632 | static ssize_t show_name(struct device *dev, struct device_attribute | 584 | static ssize_t show_name(struct device *dev, struct device_attribute |
633 | *devattr, char *buf) | 585 | *devattr, char *buf) |
634 | { | 586 | { |
@@ -637,7 +589,89 @@ static ssize_t show_name(struct device *dev, struct device_attribute | |||
637 | return sprintf(buf, "%s\n", data->name); | 589 | return sprintf(buf, "%s\n", data->name); |
638 | } | 590 | } |
639 | 591 | ||
640 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | 592 | static struct device_attribute f71805f_dev_attr[] = { |
593 | __ATTR(in0_input, S_IRUGO, show_in0, NULL), | ||
594 | __ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max), | ||
595 | __ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min), | ||
596 | __ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL), | ||
597 | __ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL), | ||
598 | __ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL), | ||
599 | __ATTR(name, S_IRUGO, show_name, NULL), | ||
600 | }; | ||
601 | |||
602 | static struct sensor_device_attribute f71805f_sensor_attr[] = { | ||
603 | SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1), | ||
604 | SENSOR_ATTR(in1_max, S_IRUGO | S_IWUSR, | ||
605 | show_in_max, set_in_max, 1), | ||
606 | SENSOR_ATTR(in1_min, S_IRUGO | S_IWUSR, | ||
607 | show_in_min, set_in_min, 1), | ||
608 | SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2), | ||
609 | SENSOR_ATTR(in2_max, S_IRUGO | S_IWUSR, | ||
610 | show_in_max, set_in_max, 2), | ||
611 | SENSOR_ATTR(in2_min, S_IRUGO | S_IWUSR, | ||
612 | show_in_min, set_in_min, 2), | ||
613 | SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3), | ||
614 | SENSOR_ATTR(in3_max, S_IRUGO | S_IWUSR, | ||
615 | show_in_max, set_in_max, 3), | ||
616 | SENSOR_ATTR(in3_min, S_IRUGO | S_IWUSR, | ||
617 | show_in_min, set_in_min, 3), | ||
618 | SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4), | ||
619 | SENSOR_ATTR(in4_max, S_IRUGO | S_IWUSR, | ||
620 | show_in_max, set_in_max, 4), | ||
621 | SENSOR_ATTR(in4_min, S_IRUGO | S_IWUSR, | ||
622 | show_in_min, set_in_min, 4), | ||
623 | SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5), | ||
624 | SENSOR_ATTR(in5_max, S_IRUGO | S_IWUSR, | ||
625 | show_in_max, set_in_max, 5), | ||
626 | SENSOR_ATTR(in5_min, S_IRUGO | S_IWUSR, | ||
627 | show_in_min, set_in_min, 5), | ||
628 | SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6), | ||
629 | SENSOR_ATTR(in6_max, S_IRUGO | S_IWUSR, | ||
630 | show_in_max, set_in_max, 6), | ||
631 | SENSOR_ATTR(in6_min, S_IRUGO | S_IWUSR, | ||
632 | show_in_min, set_in_min, 6), | ||
633 | SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7), | ||
634 | SENSOR_ATTR(in7_max, S_IRUGO | S_IWUSR, | ||
635 | show_in_max, set_in_max, 7), | ||
636 | SENSOR_ATTR(in7_min, S_IRUGO | S_IWUSR, | ||
637 | show_in_min, set_in_min, 7), | ||
638 | SENSOR_ATTR(in8_input, S_IRUGO, show_in, NULL, 8), | ||
639 | SENSOR_ATTR(in8_max, S_IRUGO | S_IWUSR, | ||
640 | show_in_max, set_in_max, 8), | ||
641 | SENSOR_ATTR(in8_min, S_IRUGO | S_IWUSR, | ||
642 | show_in_min, set_in_min, 8), | ||
643 | |||
644 | SENSOR_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0), | ||
645 | SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, | ||
646 | show_temp_max, set_temp_max, 0), | ||
647 | SENSOR_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, | ||
648 | show_temp_hyst, set_temp_hyst, 0), | ||
649 | SENSOR_ATTR(temp1_type, S_IRUGO, show_temp_type, NULL, 0), | ||
650 | SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1), | ||
651 | SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, | ||
652 | show_temp_max, set_temp_max, 1), | ||
653 | SENSOR_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, | ||
654 | show_temp_hyst, set_temp_hyst, 1), | ||
655 | SENSOR_ATTR(temp2_type, S_IRUGO, show_temp_type, NULL, 1), | ||
656 | SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2), | ||
657 | SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, | ||
658 | show_temp_max, set_temp_max, 2), | ||
659 | SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, | ||
660 | show_temp_hyst, set_temp_hyst, 2), | ||
661 | SENSOR_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2), | ||
662 | }; | ||
663 | |||
664 | static struct sensor_device_attribute f71805f_fan_attr[] = { | ||
665 | SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0), | ||
666 | SENSOR_ATTR(fan1_min, S_IRUGO | S_IWUSR, | ||
667 | show_fan_min, set_fan_min, 0), | ||
668 | SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1), | ||
669 | SENSOR_ATTR(fan2_min, S_IRUGO | S_IWUSR, | ||
670 | show_fan_min, set_fan_min, 1), | ||
671 | SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2), | ||
672 | SENSOR_ATTR(fan3_min, S_IRUGO | S_IWUSR, | ||
673 | show_fan_min, set_fan_min, 2), | ||
674 | }; | ||
641 | 675 | ||
642 | /* | 676 | /* |
643 | * Device registration and initialization | 677 | * Device registration and initialization |
@@ -668,7 +702,7 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
668 | { | 702 | { |
669 | struct f71805f_data *data; | 703 | struct f71805f_data *data; |
670 | struct resource *res; | 704 | struct resource *res; |
671 | int err; | 705 | int i, err; |
672 | 706 | ||
673 | if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) { | 707 | if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) { |
674 | err = -ENOMEM; | 708 | err = -ENOMEM; |
@@ -678,9 +712,9 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
678 | 712 | ||
679 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 713 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
680 | data->addr = res->start; | 714 | data->addr = res->start; |
681 | init_MUTEX(&data->lock); | 715 | mutex_init(&data->lock); |
682 | data->name = "f71805f"; | 716 | data->name = "f71805f"; |
683 | init_MUTEX(&data->update_lock); | 717 | mutex_init(&data->update_lock); |
684 | 718 | ||
685 | platform_set_drvdata(pdev, data); | 719 | platform_set_drvdata(pdev, data); |
686 | 720 | ||
@@ -695,76 +729,31 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
695 | f71805f_init_device(data); | 729 | f71805f_init_device(data); |
696 | 730 | ||
697 | /* Register sysfs interface files */ | 731 | /* Register sysfs interface files */ |
698 | device_create_file(&pdev->dev, &dev_attr_in0_input); | 732 | for (i = 0; i < ARRAY_SIZE(f71805f_dev_attr); i++) { |
699 | device_create_file(&pdev->dev, &dev_attr_in0_max); | 733 | err = device_create_file(&pdev->dev, &f71805f_dev_attr[i]); |
700 | device_create_file(&pdev->dev, &dev_attr_in0_min); | 734 | if (err) |
701 | device_create_file(&pdev->dev, &sensor_dev_attr_in1_input.dev_attr); | 735 | goto exit_class; |
702 | device_create_file(&pdev->dev, &sensor_dev_attr_in2_input.dev_attr); | ||
703 | device_create_file(&pdev->dev, &sensor_dev_attr_in3_input.dev_attr); | ||
704 | device_create_file(&pdev->dev, &sensor_dev_attr_in4_input.dev_attr); | ||
705 | device_create_file(&pdev->dev, &sensor_dev_attr_in5_input.dev_attr); | ||
706 | device_create_file(&pdev->dev, &sensor_dev_attr_in6_input.dev_attr); | ||
707 | device_create_file(&pdev->dev, &sensor_dev_attr_in7_input.dev_attr); | ||
708 | device_create_file(&pdev->dev, &sensor_dev_attr_in8_input.dev_attr); | ||
709 | device_create_file(&pdev->dev, &sensor_dev_attr_in1_max.dev_attr); | ||
710 | device_create_file(&pdev->dev, &sensor_dev_attr_in2_max.dev_attr); | ||
711 | device_create_file(&pdev->dev, &sensor_dev_attr_in3_max.dev_attr); | ||
712 | device_create_file(&pdev->dev, &sensor_dev_attr_in4_max.dev_attr); | ||
713 | device_create_file(&pdev->dev, &sensor_dev_attr_in5_max.dev_attr); | ||
714 | device_create_file(&pdev->dev, &sensor_dev_attr_in6_max.dev_attr); | ||
715 | device_create_file(&pdev->dev, &sensor_dev_attr_in7_max.dev_attr); | ||
716 | device_create_file(&pdev->dev, &sensor_dev_attr_in8_max.dev_attr); | ||
717 | device_create_file(&pdev->dev, &sensor_dev_attr_in1_min.dev_attr); | ||
718 | device_create_file(&pdev->dev, &sensor_dev_attr_in2_min.dev_attr); | ||
719 | device_create_file(&pdev->dev, &sensor_dev_attr_in3_min.dev_attr); | ||
720 | device_create_file(&pdev->dev, &sensor_dev_attr_in4_min.dev_attr); | ||
721 | device_create_file(&pdev->dev, &sensor_dev_attr_in5_min.dev_attr); | ||
722 | device_create_file(&pdev->dev, &sensor_dev_attr_in6_min.dev_attr); | ||
723 | device_create_file(&pdev->dev, &sensor_dev_attr_in7_min.dev_attr); | ||
724 | device_create_file(&pdev->dev, &sensor_dev_attr_in8_min.dev_attr); | ||
725 | if (data->fan_enabled & (1 << 0)) { | ||
726 | device_create_file(&pdev->dev, | ||
727 | &sensor_dev_attr_fan1_input.dev_attr); | ||
728 | device_create_file(&pdev->dev, | ||
729 | &sensor_dev_attr_fan1_min.dev_attr); | ||
730 | } | 736 | } |
731 | if (data->fan_enabled & (1 << 1)) { | 737 | for (i = 0; i < ARRAY_SIZE(f71805f_sensor_attr); i++) { |
732 | device_create_file(&pdev->dev, | 738 | err = device_create_file(&pdev->dev, |
733 | &sensor_dev_attr_fan2_input.dev_attr); | 739 | &f71805f_sensor_attr[i].dev_attr); |
734 | device_create_file(&pdev->dev, | 740 | if (err) |
735 | &sensor_dev_attr_fan2_min.dev_attr); | 741 | goto exit_class; |
736 | } | 742 | } |
737 | if (data->fan_enabled & (1 << 2)) { | 743 | for (i = 0; i < ARRAY_SIZE(f71805f_fan_attr); i++) { |
738 | device_create_file(&pdev->dev, | 744 | if (!(data->fan_enabled & (1 << (i / 2)))) |
739 | &sensor_dev_attr_fan3_input.dev_attr); | 745 | continue; |
740 | device_create_file(&pdev->dev, | 746 | err = device_create_file(&pdev->dev, |
741 | &sensor_dev_attr_fan3_min.dev_attr); | 747 | &f71805f_fan_attr[i].dev_attr); |
748 | if (err) | ||
749 | goto exit_class; | ||
742 | } | 750 | } |
743 | device_create_file(&pdev->dev, | ||
744 | &sensor_dev_attr_temp1_input.dev_attr); | ||
745 | device_create_file(&pdev->dev, | ||
746 | &sensor_dev_attr_temp2_input.dev_attr); | ||
747 | device_create_file(&pdev->dev, | ||
748 | &sensor_dev_attr_temp3_input.dev_attr); | ||
749 | device_create_file(&pdev->dev, &sensor_dev_attr_temp1_max.dev_attr); | ||
750 | device_create_file(&pdev->dev, &sensor_dev_attr_temp2_max.dev_attr); | ||
751 | device_create_file(&pdev->dev, &sensor_dev_attr_temp3_max.dev_attr); | ||
752 | device_create_file(&pdev->dev, | ||
753 | &sensor_dev_attr_temp1_max_hyst.dev_attr); | ||
754 | device_create_file(&pdev->dev, | ||
755 | &sensor_dev_attr_temp2_max_hyst.dev_attr); | ||
756 | device_create_file(&pdev->dev, | ||
757 | &sensor_dev_attr_temp3_max_hyst.dev_attr); | ||
758 | device_create_file(&pdev->dev, &sensor_dev_attr_temp1_type.dev_attr); | ||
759 | device_create_file(&pdev->dev, &sensor_dev_attr_temp2_type.dev_attr); | ||
760 | device_create_file(&pdev->dev, &sensor_dev_attr_temp3_type.dev_attr); | ||
761 | device_create_file(&pdev->dev, &dev_attr_alarms_in); | ||
762 | device_create_file(&pdev->dev, &dev_attr_alarms_fan); | ||
763 | device_create_file(&pdev->dev, &dev_attr_alarms_temp); | ||
764 | device_create_file(&pdev->dev, &dev_attr_name); | ||
765 | 751 | ||
766 | return 0; | 752 | return 0; |
767 | 753 | ||
754 | exit_class: | ||
755 | dev_err(&pdev->dev, "Sysfs interface creation failed\n"); | ||
756 | hwmon_device_unregister(data->class_dev); | ||
768 | exit_free: | 757 | exit_free: |
769 | kfree(data); | 758 | kfree(data); |
770 | exit: | 759 | exit: |
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index 25409181d1eb..6bc76b407636 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
34 | #include <linux/hwmon.h> | 34 | #include <linux/hwmon.h> |
35 | #include <linux/err.h> | 35 | #include <linux/err.h> |
36 | #include <linux/mutex.h> | ||
36 | 37 | ||
37 | /* | 38 | /* |
38 | * Addresses to scan | 39 | * Addresses to scan |
@@ -133,7 +134,7 @@ static struct i2c_driver fscher_driver = { | |||
133 | struct fscher_data { | 134 | struct fscher_data { |
134 | struct i2c_client client; | 135 | struct i2c_client client; |
135 | struct class_device *class_dev; | 136 | struct class_device *class_dev; |
136 | struct semaphore update_lock; | 137 | struct mutex update_lock; |
137 | char valid; /* zero until following fields are valid */ | 138 | char valid; /* zero until following fields are valid */ |
138 | unsigned long last_updated; /* in jiffies */ | 139 | unsigned long last_updated; /* in jiffies */ |
139 | 140 | ||
@@ -332,7 +333,7 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind) | |||
332 | * global list */ | 333 | * global list */ |
333 | strlcpy(new_client->name, "fscher", I2C_NAME_SIZE); | 334 | strlcpy(new_client->name, "fscher", I2C_NAME_SIZE); |
334 | data->valid = 0; | 335 | data->valid = 0; |
335 | init_MUTEX(&data->update_lock); | 336 | mutex_init(&data->update_lock); |
336 | 337 | ||
337 | /* Tell the I2C layer a new client has arrived */ | 338 | /* Tell the I2C layer a new client has arrived */ |
338 | if ((err = i2c_attach_client(new_client))) | 339 | if ((err = i2c_attach_client(new_client))) |
@@ -417,7 +418,7 @@ static struct fscher_data *fscher_update_device(struct device *dev) | |||
417 | struct i2c_client *client = to_i2c_client(dev); | 418 | struct i2c_client *client = to_i2c_client(dev); |
418 | struct fscher_data *data = i2c_get_clientdata(client); | 419 | struct fscher_data *data = i2c_get_clientdata(client); |
419 | 420 | ||
420 | down(&data->update_lock); | 421 | mutex_lock(&data->update_lock); |
421 | 422 | ||
422 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { | 423 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { |
423 | 424 | ||
@@ -457,7 +458,7 @@ static struct fscher_data *fscher_update_device(struct device *dev) | |||
457 | data->valid = 1; | 458 | data->valid = 1; |
458 | } | 459 | } |
459 | 460 | ||
460 | up(&data->update_lock); | 461 | mutex_unlock(&data->update_lock); |
461 | 462 | ||
462 | return data; | 463 | return data; |
463 | } | 464 | } |
@@ -472,10 +473,10 @@ static ssize_t set_fan_status(struct i2c_client *client, struct fscher_data *dat | |||
472 | /* bits 0..1, 3..7 reserved => mask with 0x04 */ | 473 | /* bits 0..1, 3..7 reserved => mask with 0x04 */ |
473 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x04; | 474 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x04; |
474 | 475 | ||
475 | down(&data->update_lock); | 476 | mutex_lock(&data->update_lock); |
476 | data->fan_status[FAN_INDEX_FROM_NUM(nr)] &= ~v; | 477 | data->fan_status[FAN_INDEX_FROM_NUM(nr)] &= ~v; |
477 | fscher_write_value(client, reg, v); | 478 | fscher_write_value(client, reg, v); |
478 | up(&data->update_lock); | 479 | mutex_unlock(&data->update_lock); |
479 | return count; | 480 | return count; |
480 | } | 481 | } |
481 | 482 | ||
@@ -490,10 +491,10 @@ static ssize_t set_pwm(struct i2c_client *client, struct fscher_data *data, | |||
490 | { | 491 | { |
491 | unsigned long v = simple_strtoul(buf, NULL, 10); | 492 | unsigned long v = simple_strtoul(buf, NULL, 10); |
492 | 493 | ||
493 | down(&data->update_lock); | 494 | mutex_lock(&data->update_lock); |
494 | data->fan_min[FAN_INDEX_FROM_NUM(nr)] = v > 0xff ? 0xff : v; | 495 | data->fan_min[FAN_INDEX_FROM_NUM(nr)] = v > 0xff ? 0xff : v; |
495 | fscher_write_value(client, reg, data->fan_min[FAN_INDEX_FROM_NUM(nr)]); | 496 | fscher_write_value(client, reg, data->fan_min[FAN_INDEX_FROM_NUM(nr)]); |
496 | up(&data->update_lock); | 497 | mutex_unlock(&data->update_lock); |
497 | return count; | 498 | return count; |
498 | } | 499 | } |
499 | 500 | ||
@@ -518,14 +519,14 @@ static ssize_t set_fan_div(struct i2c_client *client, struct fscher_data *data, | |||
518 | return -EINVAL; | 519 | return -EINVAL; |
519 | } | 520 | } |
520 | 521 | ||
521 | down(&data->update_lock); | 522 | mutex_lock(&data->update_lock); |
522 | 523 | ||
523 | /* bits 2..7 reserved => mask with 0x03 */ | 524 | /* bits 2..7 reserved => mask with 0x03 */ |
524 | data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] &= ~0x03; | 525 | data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] &= ~0x03; |
525 | data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] |= v; | 526 | data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] |= v; |
526 | 527 | ||
527 | fscher_write_value(client, reg, data->fan_ripple[FAN_INDEX_FROM_NUM(nr)]); | 528 | fscher_write_value(client, reg, data->fan_ripple[FAN_INDEX_FROM_NUM(nr)]); |
528 | up(&data->update_lock); | 529 | mutex_unlock(&data->update_lock); |
529 | return count; | 530 | return count; |
530 | } | 531 | } |
531 | 532 | ||
@@ -552,10 +553,10 @@ static ssize_t set_temp_status(struct i2c_client *client, struct fscher_data *da | |||
552 | /* bits 2..7 reserved, 0 read only => mask with 0x02 */ | 553 | /* bits 2..7 reserved, 0 read only => mask with 0x02 */ |
553 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02; | 554 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02; |
554 | 555 | ||
555 | down(&data->update_lock); | 556 | mutex_lock(&data->update_lock); |
556 | data->temp_status[TEMP_INDEX_FROM_NUM(nr)] &= ~v; | 557 | data->temp_status[TEMP_INDEX_FROM_NUM(nr)] &= ~v; |
557 | fscher_write_value(client, reg, v); | 558 | fscher_write_value(client, reg, v); |
558 | up(&data->update_lock); | 559 | mutex_unlock(&data->update_lock); |
559 | return count; | 560 | return count; |
560 | } | 561 | } |
561 | 562 | ||
@@ -609,10 +610,10 @@ static ssize_t set_control(struct i2c_client *client, struct fscher_data *data, | |||
609 | /* bits 1..7 reserved => mask with 0x01 */ | 610 | /* bits 1..7 reserved => mask with 0x01 */ |
610 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x01; | 611 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x01; |
611 | 612 | ||
612 | down(&data->update_lock); | 613 | mutex_lock(&data->update_lock); |
613 | data->global_control &= ~v; | 614 | data->global_control &= ~v; |
614 | fscher_write_value(client, reg, v); | 615 | fscher_write_value(client, reg, v); |
615 | up(&data->update_lock); | 616 | mutex_unlock(&data->update_lock); |
616 | return count; | 617 | return count; |
617 | } | 618 | } |
618 | 619 | ||
@@ -631,11 +632,11 @@ static ssize_t set_watchdog_control(struct i2c_client *client, struct | |||
631 | /* bits 0..3 reserved => mask with 0xf0 */ | 632 | /* bits 0..3 reserved => mask with 0xf0 */ |
632 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; | 633 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; |
633 | 634 | ||
634 | down(&data->update_lock); | 635 | mutex_lock(&data->update_lock); |
635 | data->watchdog[2] &= ~0xf0; | 636 | data->watchdog[2] &= ~0xf0; |
636 | data->watchdog[2] |= v; | 637 | data->watchdog[2] |= v; |
637 | fscher_write_value(client, reg, data->watchdog[2]); | 638 | fscher_write_value(client, reg, data->watchdog[2]); |
638 | up(&data->update_lock); | 639 | mutex_unlock(&data->update_lock); |
639 | return count; | 640 | return count; |
640 | } | 641 | } |
641 | 642 | ||
@@ -651,10 +652,10 @@ static ssize_t set_watchdog_status(struct i2c_client *client, struct fscher_data | |||
651 | /* bits 0, 2..7 reserved => mask with 0x02 */ | 652 | /* bits 0, 2..7 reserved => mask with 0x02 */ |
652 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02; | 653 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02; |
653 | 654 | ||
654 | down(&data->update_lock); | 655 | mutex_lock(&data->update_lock); |
655 | data->watchdog[1] &= ~v; | 656 | data->watchdog[1] &= ~v; |
656 | fscher_write_value(client, reg, v); | 657 | fscher_write_value(client, reg, v); |
657 | up(&data->update_lock); | 658 | mutex_unlock(&data->update_lock); |
658 | return count; | 659 | return count; |
659 | } | 660 | } |
660 | 661 | ||
@@ -669,10 +670,10 @@ static ssize_t set_watchdog_preset(struct i2c_client *client, struct fscher_data | |||
669 | { | 670 | { |
670 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; | 671 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; |
671 | 672 | ||
672 | down(&data->update_lock); | 673 | mutex_lock(&data->update_lock); |
673 | data->watchdog[0] = v; | 674 | data->watchdog[0] = v; |
674 | fscher_write_value(client, reg, data->watchdog[0]); | 675 | fscher_write_value(client, reg, data->watchdog[0]); |
675 | up(&data->update_lock); | 676 | mutex_unlock(&data->update_lock); |
676 | return count; | 677 | return count; |
677 | } | 678 | } |
678 | 679 | ||
diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 6d0146b57020..6dc4846b9eeb 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/hwmon.h> | 38 | #include <linux/hwmon.h> |
39 | #include <linux/err.h> | 39 | #include <linux/err.h> |
40 | #include <linux/mutex.h> | ||
40 | 41 | ||
41 | /* | 42 | /* |
42 | * Addresses to scan | 43 | * Addresses to scan |
@@ -89,8 +90,8 @@ static int fscpos_attach_adapter(struct i2c_adapter *adapter); | |||
89 | static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind); | 90 | static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind); |
90 | static int fscpos_detach_client(struct i2c_client *client); | 91 | static int fscpos_detach_client(struct i2c_client *client); |
91 | 92 | ||
92 | static int fscpos_read_value(struct i2c_client *client, u8 register); | 93 | static int fscpos_read_value(struct i2c_client *client, u8 reg); |
93 | static int fscpos_write_value(struct i2c_client *client, u8 register, u8 value); | 94 | static int fscpos_write_value(struct i2c_client *client, u8 reg, u8 value); |
94 | static struct fscpos_data *fscpos_update_device(struct device *dev); | 95 | static struct fscpos_data *fscpos_update_device(struct device *dev); |
95 | static void fscpos_init_client(struct i2c_client *client); | 96 | static void fscpos_init_client(struct i2c_client *client); |
96 | 97 | ||
@@ -114,7 +115,7 @@ static struct i2c_driver fscpos_driver = { | |||
114 | struct fscpos_data { | 115 | struct fscpos_data { |
115 | struct i2c_client client; | 116 | struct i2c_client client; |
116 | struct class_device *class_dev; | 117 | struct class_device *class_dev; |
117 | struct semaphore update_lock; | 118 | struct mutex update_lock; |
118 | char valid; /* 0 until following fields are valid */ | 119 | char valid; /* 0 until following fields are valid */ |
119 | unsigned long last_updated; /* In jiffies */ | 120 | unsigned long last_updated; /* In jiffies */ |
120 | 121 | ||
@@ -208,13 +209,13 @@ static ssize_t set_fan_ripple(struct i2c_client *client, struct fscpos_data | |||
208 | return -EINVAL; | 209 | return -EINVAL; |
209 | } | 210 | } |
210 | 211 | ||
211 | down(&data->update_lock); | 212 | mutex_lock(&data->update_lock); |
212 | /* bits 2..7 reserved => mask with 0x03 */ | 213 | /* bits 2..7 reserved => mask with 0x03 */ |
213 | data->fan_ripple[nr - 1] &= ~0x03; | 214 | data->fan_ripple[nr - 1] &= ~0x03; |
214 | data->fan_ripple[nr - 1] |= v; | 215 | data->fan_ripple[nr - 1] |= v; |
215 | 216 | ||
216 | fscpos_write_value(client, reg, data->fan_ripple[nr - 1]); | 217 | fscpos_write_value(client, reg, data->fan_ripple[nr - 1]); |
217 | up(&data->update_lock); | 218 | mutex_unlock(&data->update_lock); |
218 | return count; | 219 | return count; |
219 | } | 220 | } |
220 | 221 | ||
@@ -232,10 +233,10 @@ static ssize_t set_pwm(struct i2c_client *client, struct fscpos_data *data, | |||
232 | if (v < 0) v = 0; | 233 | if (v < 0) v = 0; |
233 | if (v > 255) v = 255; | 234 | if (v > 255) v = 255; |
234 | 235 | ||
235 | down(&data->update_lock); | 236 | mutex_lock(&data->update_lock); |
236 | data->pwm[nr - 1] = v; | 237 | data->pwm[nr - 1] = v; |
237 | fscpos_write_value(client, reg, data->pwm[nr - 1]); | 238 | fscpos_write_value(client, reg, data->pwm[nr - 1]); |
238 | up(&data->update_lock); | 239 | mutex_unlock(&data->update_lock); |
239 | return count; | 240 | return count; |
240 | } | 241 | } |
241 | 242 | ||
@@ -278,11 +279,11 @@ static ssize_t set_wdog_control(struct i2c_client *client, struct fscpos_data | |||
278 | /* bits 0..3 reserved => mask with 0xf0 */ | 279 | /* bits 0..3 reserved => mask with 0xf0 */ |
279 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; | 280 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; |
280 | 281 | ||
281 | down(&data->update_lock); | 282 | mutex_lock(&data->update_lock); |
282 | data->wdog_control &= ~0xf0; | 283 | data->wdog_control &= ~0xf0; |
283 | data->wdog_control |= v; | 284 | data->wdog_control |= v; |
284 | fscpos_write_value(client, reg, data->wdog_control); | 285 | fscpos_write_value(client, reg, data->wdog_control); |
285 | up(&data->update_lock); | 286 | mutex_unlock(&data->update_lock); |
286 | return count; | 287 | return count; |
287 | } | 288 | } |
288 | 289 | ||
@@ -304,10 +305,10 @@ static ssize_t set_wdog_state(struct i2c_client *client, struct fscpos_data | |||
304 | return -EINVAL; | 305 | return -EINVAL; |
305 | } | 306 | } |
306 | 307 | ||
307 | down(&data->update_lock); | 308 | mutex_lock(&data->update_lock); |
308 | data->wdog_state &= ~v; | 309 | data->wdog_state &= ~v; |
309 | fscpos_write_value(client, reg, v); | 310 | fscpos_write_value(client, reg, v); |
310 | up(&data->update_lock); | 311 | mutex_unlock(&data->update_lock); |
311 | return count; | 312 | return count; |
312 | } | 313 | } |
313 | 314 | ||
@@ -321,10 +322,10 @@ static ssize_t set_wdog_preset(struct i2c_client *client, struct fscpos_data | |||
321 | { | 322 | { |
322 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; | 323 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; |
323 | 324 | ||
324 | down(&data->update_lock); | 325 | mutex_lock(&data->update_lock); |
325 | data->wdog_preset = v; | 326 | data->wdog_preset = v; |
326 | fscpos_write_value(client, reg, data->wdog_preset); | 327 | fscpos_write_value(client, reg, data->wdog_preset); |
327 | up(&data->update_lock); | 328 | mutex_unlock(&data->update_lock); |
328 | return count; | 329 | return count; |
329 | } | 330 | } |
330 | 331 | ||
@@ -483,7 +484,7 @@ static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) | |||
483 | strlcpy(new_client->name, "fscpos", I2C_NAME_SIZE); | 484 | strlcpy(new_client->name, "fscpos", I2C_NAME_SIZE); |
484 | 485 | ||
485 | data->valid = 0; | 486 | data->valid = 0; |
486 | init_MUTEX(&data->update_lock); | 487 | mutex_init(&data->update_lock); |
487 | 488 | ||
488 | /* Tell the I2C layer a new client has arrived */ | 489 | /* Tell the I2C layer a new client has arrived */ |
489 | if ((err = i2c_attach_client(new_client))) | 490 | if ((err = i2c_attach_client(new_client))) |
@@ -579,7 +580,7 @@ static struct fscpos_data *fscpos_update_device(struct device *dev) | |||
579 | struct i2c_client *client = to_i2c_client(dev); | 580 | struct i2c_client *client = to_i2c_client(dev); |
580 | struct fscpos_data *data = i2c_get_clientdata(client); | 581 | struct fscpos_data *data = i2c_get_clientdata(client); |
581 | 582 | ||
582 | down(&data->update_lock); | 583 | mutex_lock(&data->update_lock); |
583 | 584 | ||
584 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { | 585 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { |
585 | int i; | 586 | int i; |
@@ -625,7 +626,7 @@ static struct fscpos_data *fscpos_update_device(struct device *dev) | |||
625 | data->last_updated = jiffies; | 626 | data->last_updated = jiffies; |
626 | data->valid = 1; | 627 | data->valid = 1; |
627 | } | 628 | } |
628 | up(&data->update_lock); | 629 | mutex_unlock(&data->update_lock); |
629 | return data; | 630 | return data; |
630 | } | 631 | } |
631 | 632 | ||
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 9e685e3a3bc9..6606aabdb49d 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include <linux/i2c.h> | 43 | #include <linux/i2c.h> |
44 | #include <linux/hwmon.h> | 44 | #include <linux/hwmon.h> |
45 | #include <linux/err.h> | 45 | #include <linux/err.h> |
46 | #include <linux/mutex.h> | ||
46 | 47 | ||
47 | /* Addresses to scan */ | 48 | /* Addresses to scan */ |
48 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; | 49 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; |
@@ -120,7 +121,7 @@ struct gl518_data { | |||
120 | struct class_device *class_dev; | 121 | struct class_device *class_dev; |
121 | enum chips type; | 122 | enum chips type; |
122 | 123 | ||
123 | struct semaphore update_lock; | 124 | struct mutex update_lock; |
124 | char valid; /* !=0 if following fields are valid */ | 125 | char valid; /* !=0 if following fields are valid */ |
125 | unsigned long last_updated; /* In jiffies */ | 126 | unsigned long last_updated; /* In jiffies */ |
126 | 127 | ||
@@ -212,10 +213,10 @@ static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, c | |||
212 | struct gl518_data *data = i2c_get_clientdata(client); \ | 213 | struct gl518_data *data = i2c_get_clientdata(client); \ |
213 | long val = simple_strtol(buf, NULL, 10); \ | 214 | long val = simple_strtol(buf, NULL, 10); \ |
214 | \ | 215 | \ |
215 | down(&data->update_lock); \ | 216 | mutex_lock(&data->update_lock); \ |
216 | data->value = type##_TO_REG(val); \ | 217 | data->value = type##_TO_REG(val); \ |
217 | gl518_write_value(client, reg, data->value); \ | 218 | gl518_write_value(client, reg, data->value); \ |
218 | up(&data->update_lock); \ | 219 | mutex_unlock(&data->update_lock); \ |
219 | return count; \ | 220 | return count; \ |
220 | } | 221 | } |
221 | 222 | ||
@@ -228,12 +229,12 @@ static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, c | |||
228 | int regvalue; \ | 229 | int regvalue; \ |
229 | unsigned long val = simple_strtoul(buf, NULL, 10); \ | 230 | unsigned long val = simple_strtoul(buf, NULL, 10); \ |
230 | \ | 231 | \ |
231 | down(&data->update_lock); \ | 232 | mutex_lock(&data->update_lock); \ |
232 | regvalue = gl518_read_value(client, reg); \ | 233 | regvalue = gl518_read_value(client, reg); \ |
233 | data->value = type##_TO_REG(val); \ | 234 | data->value = type##_TO_REG(val); \ |
234 | regvalue = (regvalue & ~mask) | (data->value << shift); \ | 235 | regvalue = (regvalue & ~mask) | (data->value << shift); \ |
235 | gl518_write_value(client, reg, regvalue); \ | 236 | gl518_write_value(client, reg, regvalue); \ |
236 | up(&data->update_lock); \ | 237 | mutex_unlock(&data->update_lock); \ |
237 | return count; \ | 238 | return count; \ |
238 | } | 239 | } |
239 | 240 | ||
@@ -265,7 +266,7 @@ static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, c | |||
265 | int regvalue; | 266 | int regvalue; |
266 | unsigned long val = simple_strtoul(buf, NULL, 10); | 267 | unsigned long val = simple_strtoul(buf, NULL, 10); |
267 | 268 | ||
268 | down(&data->update_lock); | 269 | mutex_lock(&data->update_lock); |
269 | regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); | 270 | regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); |
270 | data->fan_min[0] = FAN_TO_REG(val, | 271 | data->fan_min[0] = FAN_TO_REG(val, |
271 | DIV_FROM_REG(data->fan_div[0])); | 272 | DIV_FROM_REG(data->fan_div[0])); |
@@ -280,7 +281,7 @@ static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, c | |||
280 | data->beep_mask &= data->alarm_mask; | 281 | data->beep_mask &= data->alarm_mask; |
281 | gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); | 282 | gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); |
282 | 283 | ||
283 | up(&data->update_lock); | 284 | mutex_unlock(&data->update_lock); |
284 | return count; | 285 | return count; |
285 | } | 286 | } |
286 | 287 | ||
@@ -291,7 +292,7 @@ static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, c | |||
291 | int regvalue; | 292 | int regvalue; |
292 | unsigned long val = simple_strtoul(buf, NULL, 10); | 293 | unsigned long val = simple_strtoul(buf, NULL, 10); |
293 | 294 | ||
294 | down(&data->update_lock); | 295 | mutex_lock(&data->update_lock); |
295 | regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); | 296 | regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); |
296 | data->fan_min[1] = FAN_TO_REG(val, | 297 | data->fan_min[1] = FAN_TO_REG(val, |
297 | DIV_FROM_REG(data->fan_div[1])); | 298 | DIV_FROM_REG(data->fan_div[1])); |
@@ -306,7 +307,7 @@ static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, c | |||
306 | data->beep_mask &= data->alarm_mask; | 307 | data->beep_mask &= data->alarm_mask; |
307 | gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); | 308 | gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); |
308 | 309 | ||
309 | up(&data->update_lock); | 310 | mutex_unlock(&data->update_lock); |
310 | return count; | 311 | return count; |
311 | } | 312 | } |
312 | 313 | ||
@@ -407,7 +408,7 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) | |||
407 | strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE); | 408 | strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE); |
408 | data->type = kind; | 409 | data->type = kind; |
409 | data->valid = 0; | 410 | data->valid = 0; |
410 | init_MUTEX(&data->update_lock); | 411 | mutex_init(&data->update_lock); |
411 | 412 | ||
412 | /* Tell the I2C layer a new client has arrived */ | 413 | /* Tell the I2C layer a new client has arrived */ |
413 | if ((err = i2c_attach_client(new_client))) | 414 | if ((err = i2c_attach_client(new_client))) |
@@ -525,7 +526,7 @@ static struct gl518_data *gl518_update_device(struct device *dev) | |||
525 | struct gl518_data *data = i2c_get_clientdata(client); | 526 | struct gl518_data *data = i2c_get_clientdata(client); |
526 | int val; | 527 | int val; |
527 | 528 | ||
528 | down(&data->update_lock); | 529 | mutex_lock(&data->update_lock); |
529 | 530 | ||
530 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 531 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
531 | || !data->valid) { | 532 | || !data->valid) { |
@@ -586,7 +587,7 @@ static struct gl518_data *gl518_update_device(struct device *dev) | |||
586 | data->valid = 1; | 587 | data->valid = 1; |
587 | } | 588 | } |
588 | 589 | ||
589 | up(&data->update_lock); | 590 | mutex_unlock(&data->update_lock); |
590 | 591 | ||
591 | return data; | 592 | return data; |
592 | } | 593 | } |
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index baee60e44b52..47b4d49f75c6 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/hwmon.h> | 29 | #include <linux/hwmon.h> |
30 | #include <linux/hwmon-vid.h> | 30 | #include <linux/hwmon-vid.h> |
31 | #include <linux/err.h> | 31 | #include <linux/err.h> |
32 | #include <linux/mutex.h> | ||
32 | 33 | ||
33 | /* Type of the extra sensor */ | 34 | /* Type of the extra sensor */ |
34 | static unsigned short extra_sensor_type; | 35 | static unsigned short extra_sensor_type; |
@@ -121,7 +122,7 @@ static struct i2c_driver gl520_driver = { | |||
121 | struct gl520_data { | 122 | struct gl520_data { |
122 | struct i2c_client client; | 123 | struct i2c_client client; |
123 | struct class_device *class_dev; | 124 | struct class_device *class_dev; |
124 | struct semaphore update_lock; | 125 | struct mutex update_lock; |
125 | char valid; /* zero until the following fields are valid */ | 126 | char valid; /* zero until the following fields are valid */ |
126 | unsigned long last_updated; /* in jiffies */ | 127 | unsigned long last_updated; /* in jiffies */ |
127 | 128 | ||
@@ -303,7 +304,7 @@ static ssize_t set_in_min(struct i2c_client *client, struct gl520_data *data, co | |||
303 | long v = simple_strtol(buf, NULL, 10); | 304 | long v = simple_strtol(buf, NULL, 10); |
304 | u8 r; | 305 | u8 r; |
305 | 306 | ||
306 | down(&data->update_lock); | 307 | mutex_lock(&data->update_lock); |
307 | 308 | ||
308 | if (n == 0) | 309 | if (n == 0) |
309 | r = VDD_TO_REG(v); | 310 | r = VDD_TO_REG(v); |
@@ -317,7 +318,7 @@ static ssize_t set_in_min(struct i2c_client *client, struct gl520_data *data, co | |||
317 | else | 318 | else |
318 | gl520_write_value(client, reg, r); | 319 | gl520_write_value(client, reg, r); |
319 | 320 | ||
320 | up(&data->update_lock); | 321 | mutex_unlock(&data->update_lock); |
321 | return count; | 322 | return count; |
322 | } | 323 | } |
323 | 324 | ||
@@ -331,7 +332,7 @@ static ssize_t set_in_max(struct i2c_client *client, struct gl520_data *data, co | |||
331 | else | 332 | else |
332 | r = IN_TO_REG(v); | 333 | r = IN_TO_REG(v); |
333 | 334 | ||
334 | down(&data->update_lock); | 335 | mutex_lock(&data->update_lock); |
335 | 336 | ||
336 | data->in_max[n] = r; | 337 | data->in_max[n] = r; |
337 | 338 | ||
@@ -340,7 +341,7 @@ static ssize_t set_in_max(struct i2c_client *client, struct gl520_data *data, co | |||
340 | else | 341 | else |
341 | gl520_write_value(client, reg, r); | 342 | gl520_write_value(client, reg, r); |
342 | 343 | ||
343 | up(&data->update_lock); | 344 | mutex_unlock(&data->update_lock); |
344 | return count; | 345 | return count; |
345 | } | 346 | } |
346 | 347 | ||
@@ -373,7 +374,7 @@ static ssize_t set_fan_min(struct i2c_client *client, struct gl520_data *data, c | |||
373 | unsigned long v = simple_strtoul(buf, NULL, 10); | 374 | unsigned long v = simple_strtoul(buf, NULL, 10); |
374 | u8 r; | 375 | u8 r; |
375 | 376 | ||
376 | down(&data->update_lock); | 377 | mutex_lock(&data->update_lock); |
377 | r = FAN_TO_REG(v, data->fan_div[n - 1]); | 378 | r = FAN_TO_REG(v, data->fan_div[n - 1]); |
378 | data->fan_min[n - 1] = r; | 379 | data->fan_min[n - 1] = r; |
379 | 380 | ||
@@ -390,7 +391,7 @@ static ssize_t set_fan_min(struct i2c_client *client, struct gl520_data *data, c | |||
390 | data->beep_mask &= data->alarm_mask; | 391 | data->beep_mask &= data->alarm_mask; |
391 | gl520_write_value(client, GL520_REG_BEEP_MASK, data->beep_mask); | 392 | gl520_write_value(client, GL520_REG_BEEP_MASK, data->beep_mask); |
392 | 393 | ||
393 | up(&data->update_lock); | 394 | mutex_unlock(&data->update_lock); |
394 | return count; | 395 | return count; |
395 | } | 396 | } |
396 | 397 | ||
@@ -409,7 +410,7 @@ static ssize_t set_fan_div(struct i2c_client *client, struct gl520_data *data, c | |||
409 | return -EINVAL; | 410 | return -EINVAL; |
410 | } | 411 | } |
411 | 412 | ||
412 | down(&data->update_lock); | 413 | mutex_lock(&data->update_lock); |
413 | data->fan_div[n - 1] = r; | 414 | data->fan_div[n - 1] = r; |
414 | 415 | ||
415 | if (n == 1) | 416 | if (n == 1) |
@@ -417,7 +418,7 @@ static ssize_t set_fan_div(struct i2c_client *client, struct gl520_data *data, c | |||
417 | else | 418 | else |
418 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x30) | (r << 4)); | 419 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x30) | (r << 4)); |
419 | 420 | ||
420 | up(&data->update_lock); | 421 | mutex_unlock(&data->update_lock); |
421 | return count; | 422 | return count; |
422 | } | 423 | } |
423 | 424 | ||
@@ -425,10 +426,10 @@ static ssize_t set_fan_off(struct i2c_client *client, struct gl520_data *data, c | |||
425 | { | 426 | { |
426 | u8 r = simple_strtoul(buf, NULL, 10)?1:0; | 427 | u8 r = simple_strtoul(buf, NULL, 10)?1:0; |
427 | 428 | ||
428 | down(&data->update_lock); | 429 | mutex_lock(&data->update_lock); |
429 | data->fan_off = r; | 430 | data->fan_off = r; |
430 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x0c) | (r << 2)); | 431 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x0c) | (r << 2)); |
431 | up(&data->update_lock); | 432 | mutex_unlock(&data->update_lock); |
432 | return count; | 433 | return count; |
433 | } | 434 | } |
434 | 435 | ||
@@ -454,10 +455,10 @@ static ssize_t set_temp_max(struct i2c_client *client, struct gl520_data *data, | |||
454 | { | 455 | { |
455 | long v = simple_strtol(buf, NULL, 10); | 456 | long v = simple_strtol(buf, NULL, 10); |
456 | 457 | ||
457 | down(&data->update_lock); | 458 | mutex_lock(&data->update_lock); |
458 | data->temp_max[n - 1] = TEMP_TO_REG(v);; | 459 | data->temp_max[n - 1] = TEMP_TO_REG(v);; |
459 | gl520_write_value(client, reg, data->temp_max[n - 1]); | 460 | gl520_write_value(client, reg, data->temp_max[n - 1]); |
460 | up(&data->update_lock); | 461 | mutex_unlock(&data->update_lock); |
461 | return count; | 462 | return count; |
462 | } | 463 | } |
463 | 464 | ||
@@ -465,10 +466,10 @@ static ssize_t set_temp_max_hyst(struct i2c_client *client, struct gl520_data *d | |||
465 | { | 466 | { |
466 | long v = simple_strtol(buf, NULL, 10); | 467 | long v = simple_strtol(buf, NULL, 10); |
467 | 468 | ||
468 | down(&data->update_lock); | 469 | mutex_lock(&data->update_lock); |
469 | data->temp_max_hyst[n - 1] = TEMP_TO_REG(v); | 470 | data->temp_max_hyst[n - 1] = TEMP_TO_REG(v); |
470 | gl520_write_value(client, reg, data->temp_max_hyst[n - 1]); | 471 | gl520_write_value(client, reg, data->temp_max_hyst[n - 1]); |
471 | up(&data->update_lock); | 472 | mutex_unlock(&data->update_lock); |
472 | return count; | 473 | return count; |
473 | } | 474 | } |
474 | 475 | ||
@@ -491,10 +492,10 @@ static ssize_t set_beep_enable(struct i2c_client *client, struct gl520_data *dat | |||
491 | { | 492 | { |
492 | u8 r = simple_strtoul(buf, NULL, 10)?0:1; | 493 | u8 r = simple_strtoul(buf, NULL, 10)?0:1; |
493 | 494 | ||
494 | down(&data->update_lock); | 495 | mutex_lock(&data->update_lock); |
495 | data->beep_enable = !r; | 496 | data->beep_enable = !r; |
496 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x04) | (r << 2)); | 497 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x04) | (r << 2)); |
497 | up(&data->update_lock); | 498 | mutex_unlock(&data->update_lock); |
498 | return count; | 499 | return count; |
499 | } | 500 | } |
500 | 501 | ||
@@ -502,11 +503,11 @@ static ssize_t set_beep_mask(struct i2c_client *client, struct gl520_data *data, | |||
502 | { | 503 | { |
503 | u8 r = simple_strtoul(buf, NULL, 10); | 504 | u8 r = simple_strtoul(buf, NULL, 10); |
504 | 505 | ||
505 | down(&data->update_lock); | 506 | mutex_lock(&data->update_lock); |
506 | r &= data->alarm_mask; | 507 | r &= data->alarm_mask; |
507 | data->beep_mask = r; | 508 | data->beep_mask = r; |
508 | gl520_write_value(client, reg, r); | 509 | gl520_write_value(client, reg, r); |
509 | up(&data->update_lock); | 510 | mutex_unlock(&data->update_lock); |
510 | return count; | 511 | return count; |
511 | } | 512 | } |
512 | 513 | ||
@@ -561,7 +562,7 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) | |||
561 | /* Fill in the remaining client fields */ | 562 | /* Fill in the remaining client fields */ |
562 | strlcpy(new_client->name, "gl520sm", I2C_NAME_SIZE); | 563 | strlcpy(new_client->name, "gl520sm", I2C_NAME_SIZE); |
563 | data->valid = 0; | 564 | data->valid = 0; |
564 | init_MUTEX(&data->update_lock); | 565 | mutex_init(&data->update_lock); |
565 | 566 | ||
566 | /* Tell the I2C layer a new client has arrived */ | 567 | /* Tell the I2C layer a new client has arrived */ |
567 | if ((err = i2c_attach_client(new_client))) | 568 | if ((err = i2c_attach_client(new_client))) |
@@ -685,7 +686,7 @@ static struct gl520_data *gl520_update_device(struct device *dev) | |||
685 | struct gl520_data *data = i2c_get_clientdata(client); | 686 | struct gl520_data *data = i2c_get_clientdata(client); |
686 | int val; | 687 | int val; |
687 | 688 | ||
688 | down(&data->update_lock); | 689 | mutex_lock(&data->update_lock); |
689 | 690 | ||
690 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { | 691 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { |
691 | 692 | ||
@@ -750,7 +751,7 @@ static struct gl520_data *gl520_update_device(struct device *dev) | |||
750 | data->valid = 1; | 751 | data->valid = 1; |
751 | } | 752 | } |
752 | 753 | ||
753 | up(&data->update_lock); | 754 | mutex_unlock(&data->update_lock); |
754 | 755 | ||
755 | return data; | 756 | return data; |
756 | } | 757 | } |
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c index 23a9e1ea8e32..7636c1a58f9c 100644 --- a/drivers/hwmon/hdaps.c +++ b/drivers/hwmon/hdaps.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
34 | #include <linux/timer.h> | 34 | #include <linux/timer.h> |
35 | #include <linux/dmi.h> | 35 | #include <linux/dmi.h> |
36 | #include <linux/mutex.h> | ||
36 | #include <asm/io.h> | 37 | #include <asm/io.h> |
37 | 38 | ||
38 | #define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */ | 39 | #define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */ |
@@ -70,10 +71,10 @@ static u8 km_activity; | |||
70 | static int rest_x; | 71 | static int rest_x; |
71 | static int rest_y; | 72 | static int rest_y; |
72 | 73 | ||
73 | static DECLARE_MUTEX(hdaps_sem); | 74 | static DEFINE_MUTEX(hdaps_mutex); |
74 | 75 | ||
75 | /* | 76 | /* |
76 | * __get_latch - Get the value from a given port. Callers must hold hdaps_sem. | 77 | * __get_latch - Get the value from a given port. Callers must hold hdaps_mutex. |
77 | */ | 78 | */ |
78 | static inline u8 __get_latch(u16 port) | 79 | static inline u8 __get_latch(u16 port) |
79 | { | 80 | { |
@@ -82,7 +83,7 @@ static inline u8 __get_latch(u16 port) | |||
82 | 83 | ||
83 | /* | 84 | /* |
84 | * __check_latch - Check a port latch for a given value. Returns zero if the | 85 | * __check_latch - Check a port latch for a given value. Returns zero if the |
85 | * port contains the given value. Callers must hold hdaps_sem. | 86 | * port contains the given value. Callers must hold hdaps_mutex. |
86 | */ | 87 | */ |
87 | static inline int __check_latch(u16 port, u8 val) | 88 | static inline int __check_latch(u16 port, u8 val) |
88 | { | 89 | { |
@@ -93,7 +94,7 @@ static inline int __check_latch(u16 port, u8 val) | |||
93 | 94 | ||
94 | /* | 95 | /* |
95 | * __wait_latch - Wait up to 100us for a port latch to get a certain value, | 96 | * __wait_latch - Wait up to 100us for a port latch to get a certain value, |
96 | * returning zero if the value is obtained. Callers must hold hdaps_sem. | 97 | * returning zero if the value is obtained. Callers must hold hdaps_mutex. |
97 | */ | 98 | */ |
98 | static int __wait_latch(u16 port, u8 val) | 99 | static int __wait_latch(u16 port, u8 val) |
99 | { | 100 | { |
@@ -110,7 +111,7 @@ static int __wait_latch(u16 port, u8 val) | |||
110 | 111 | ||
111 | /* | 112 | /* |
112 | * __device_refresh - request a refresh from the accelerometer. Does not wait | 113 | * __device_refresh - request a refresh from the accelerometer. Does not wait |
113 | * for refresh to complete. Callers must hold hdaps_sem. | 114 | * for refresh to complete. Callers must hold hdaps_mutex. |
114 | */ | 115 | */ |
115 | static void __device_refresh(void) | 116 | static void __device_refresh(void) |
116 | { | 117 | { |
@@ -124,7 +125,7 @@ static void __device_refresh(void) | |||
124 | /* | 125 | /* |
125 | * __device_refresh_sync - request a synchronous refresh from the | 126 | * __device_refresh_sync - request a synchronous refresh from the |
126 | * accelerometer. We wait for the refresh to complete. Returns zero if | 127 | * accelerometer. We wait for the refresh to complete. Returns zero if |
127 | * successful and nonzero on error. Callers must hold hdaps_sem. | 128 | * successful and nonzero on error. Callers must hold hdaps_mutex. |
128 | */ | 129 | */ |
129 | static int __device_refresh_sync(void) | 130 | static int __device_refresh_sync(void) |
130 | { | 131 | { |
@@ -134,7 +135,7 @@ static int __device_refresh_sync(void) | |||
134 | 135 | ||
135 | /* | 136 | /* |
136 | * __device_complete - indicate to the accelerometer that we are done reading | 137 | * __device_complete - indicate to the accelerometer that we are done reading |
137 | * data, and then initiate an async refresh. Callers must hold hdaps_sem. | 138 | * data, and then initiate an async refresh. Callers must hold hdaps_mutex. |
138 | */ | 139 | */ |
139 | static inline void __device_complete(void) | 140 | static inline void __device_complete(void) |
140 | { | 141 | { |
@@ -152,7 +153,7 @@ static int hdaps_readb_one(unsigned int port, u8 *val) | |||
152 | { | 153 | { |
153 | int ret; | 154 | int ret; |
154 | 155 | ||
155 | down(&hdaps_sem); | 156 | mutex_lock(&hdaps_mutex); |
156 | 157 | ||
157 | /* do a sync refresh -- we need to be sure that we read fresh data */ | 158 | /* do a sync refresh -- we need to be sure that we read fresh data */ |
158 | ret = __device_refresh_sync(); | 159 | ret = __device_refresh_sync(); |
@@ -163,7 +164,7 @@ static int hdaps_readb_one(unsigned int port, u8 *val) | |||
163 | __device_complete(); | 164 | __device_complete(); |
164 | 165 | ||
165 | out: | 166 | out: |
166 | up(&hdaps_sem); | 167 | mutex_unlock(&hdaps_mutex); |
167 | return ret; | 168 | return ret; |
168 | } | 169 | } |
169 | 170 | ||
@@ -198,9 +199,9 @@ static int hdaps_read_pair(unsigned int port1, unsigned int port2, | |||
198 | { | 199 | { |
199 | int ret; | 200 | int ret; |
200 | 201 | ||
201 | down(&hdaps_sem); | 202 | mutex_lock(&hdaps_mutex); |
202 | ret = __hdaps_read_pair(port1, port2, val1, val2); | 203 | ret = __hdaps_read_pair(port1, port2, val1, val2); |
203 | up(&hdaps_sem); | 204 | mutex_unlock(&hdaps_mutex); |
204 | 205 | ||
205 | return ret; | 206 | return ret; |
206 | } | 207 | } |
@@ -213,7 +214,7 @@ static int hdaps_device_init(void) | |||
213 | { | 214 | { |
214 | int total, ret = -ENXIO; | 215 | int total, ret = -ENXIO; |
215 | 216 | ||
216 | down(&hdaps_sem); | 217 | mutex_lock(&hdaps_mutex); |
217 | 218 | ||
218 | outb(0x13, 0x1610); | 219 | outb(0x13, 0x1610); |
219 | outb(0x01, 0x161f); | 220 | outb(0x01, 0x161f); |
@@ -279,7 +280,7 @@ static int hdaps_device_init(void) | |||
279 | } | 280 | } |
280 | 281 | ||
281 | out: | 282 | out: |
282 | up(&hdaps_sem); | 283 | mutex_unlock(&hdaps_mutex); |
283 | return ret; | 284 | return ret; |
284 | } | 285 | } |
285 | 286 | ||
@@ -313,7 +314,7 @@ static struct platform_driver hdaps_driver = { | |||
313 | }; | 314 | }; |
314 | 315 | ||
315 | /* | 316 | /* |
316 | * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_sem. | 317 | * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_mutex. |
317 | */ | 318 | */ |
318 | static void hdaps_calibrate(void) | 319 | static void hdaps_calibrate(void) |
319 | { | 320 | { |
@@ -325,7 +326,7 @@ static void hdaps_mousedev_poll(unsigned long unused) | |||
325 | int x, y; | 326 | int x, y; |
326 | 327 | ||
327 | /* Cannot sleep. Try nonblockingly. If we fail, try again later. */ | 328 | /* Cannot sleep. Try nonblockingly. If we fail, try again later. */ |
328 | if (down_trylock(&hdaps_sem)) { | 329 | if (!mutex_trylock(&hdaps_mutex)) { |
329 | mod_timer(&hdaps_timer,jiffies + HDAPS_POLL_PERIOD); | 330 | mod_timer(&hdaps_timer,jiffies + HDAPS_POLL_PERIOD); |
330 | return; | 331 | return; |
331 | } | 332 | } |
@@ -340,7 +341,7 @@ static void hdaps_mousedev_poll(unsigned long unused) | |||
340 | mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD); | 341 | mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD); |
341 | 342 | ||
342 | out: | 343 | out: |
343 | up(&hdaps_sem); | 344 | mutex_unlock(&hdaps_mutex); |
344 | } | 345 | } |
345 | 346 | ||
346 | 347 | ||
@@ -420,9 +421,9 @@ static ssize_t hdaps_calibrate_store(struct device *dev, | |||
420 | struct device_attribute *attr, | 421 | struct device_attribute *attr, |
421 | const char *buf, size_t count) | 422 | const char *buf, size_t count) |
422 | { | 423 | { |
423 | down(&hdaps_sem); | 424 | mutex_lock(&hdaps_mutex); |
424 | hdaps_calibrate(); | 425 | hdaps_calibrate(); |
425 | up(&hdaps_sem); | 426 | mutex_unlock(&hdaps_mutex); |
426 | 427 | ||
427 | return count; | 428 | return count; |
428 | } | 429 | } |
diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c index e497274916ce..a74a44f16f51 100644 --- a/drivers/hwmon/hwmon-vid.c +++ b/drivers/hwmon/hwmon-vid.c | |||
@@ -54,6 +54,10 @@ | |||
54 | (IMVP-II). You can find more information in the datasheet of Max1718 | 54 | (IMVP-II). You can find more information in the datasheet of Max1718 |
55 | http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2452 | 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 | /* vrm is the VRM/VRD document version multiplied by 10. | 63 | /* vrm is the VRM/VRD document version multiplied by 10. |
@@ -100,6 +104,8 @@ int vid_from_reg(int val, u8 vrm) | |||
100 | case 17: /* Intel IMVP-II */ | 104 | case 17: /* Intel IMVP-II */ |
101 | return(val & 0x10 ? 975 - (val & 0xF) * 25 : | 105 | return(val & 0x10 ? 975 - (val & 0xF) * 25 : |
102 | 1750 - val * 50); | 106 | 1750 - val * 50); |
107 | case 13: | ||
108 | return(1708 - (val & 0x3f) * 16); | ||
103 | default: /* report 0 for unknown */ | 109 | default: /* report 0 for unknown */ |
104 | printk(KERN_INFO "hwmon-vid: requested unknown VRM version\n"); | 110 | printk(KERN_INFO "hwmon-vid: requested unknown VRM version\n"); |
105 | return 0; | 111 | return 0; |
@@ -129,8 +135,9 @@ struct vrm_model { | |||
129 | static struct vrm_model vrm_models[] = { | 135 | static struct vrm_model vrm_models[] = { |
130 | {X86_VENDOR_AMD, 0x6, ANY, ANY, 90}, /* Athlon Duron etc */ | 136 | {X86_VENDOR_AMD, 0x6, ANY, ANY, 90}, /* Athlon Duron etc */ |
131 | {X86_VENDOR_AMD, 0xF, ANY, ANY, 24}, /* Athlon 64, Opteron and above VRM 24 */ | 137 | {X86_VENDOR_AMD, 0xF, ANY, ANY, 24}, /* Athlon 64, Opteron and above VRM 24 */ |
132 | {X86_VENDOR_INTEL, 0x6, 0x9, ANY, 85}, /* 0.13um too */ | 138 | {X86_VENDOR_INTEL, 0x6, 0x9, ANY, 13}, /* Pentium M (130 nm) */ |
133 | {X86_VENDOR_INTEL, 0x6, 0xB, ANY, 85}, /* Tualatin */ | 139 | {X86_VENDOR_INTEL, 0x6, 0xB, ANY, 85}, /* Tualatin */ |
140 | {X86_VENDOR_INTEL, 0x6, 0xD, ANY, 13}, /* Pentium M (90 nm) */ | ||
134 | {X86_VENDOR_INTEL, 0x6, ANY, ANY, 82}, /* any P6 */ | 141 | {X86_VENDOR_INTEL, 0x6, ANY, ANY, 82}, /* any P6 */ |
135 | {X86_VENDOR_INTEL, 0x7, ANY, ANY, 0}, /* Itanium */ | 142 | {X86_VENDOR_INTEL, 0x7, ANY, ANY, 0}, /* Itanium */ |
136 | {X86_VENDOR_INTEL, 0xF, 0x0, ANY, 90}, /* P4 */ | 143 | {X86_VENDOR_INTEL, 0xF, 0x0, ANY, 90}, /* P4 */ |
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index dddd3eb9b387..106fa01cdb60 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/idr.h> | 17 | #include <linux/idr.h> |
18 | #include <linux/hwmon.h> | 18 | #include <linux/hwmon.h> |
19 | #include <linux/gfp.h> | 19 | #include <linux/gfp.h> |
20 | #include <linux/spinlock.h> | ||
20 | 21 | ||
21 | #define HWMON_ID_PREFIX "hwmon" | 22 | #define HWMON_ID_PREFIX "hwmon" |
22 | #define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d" | 23 | #define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d" |
@@ -24,6 +25,7 @@ | |||
24 | static struct class *hwmon_class; | 25 | static struct class *hwmon_class; |
25 | 26 | ||
26 | static DEFINE_IDR(hwmon_idr); | 27 | static DEFINE_IDR(hwmon_idr); |
28 | static DEFINE_SPINLOCK(idr_lock); | ||
27 | 29 | ||
28 | /** | 30 | /** |
29 | * hwmon_device_register - register w/ hwmon sysfs class | 31 | * hwmon_device_register - register w/ hwmon sysfs class |
@@ -37,20 +39,30 @@ static DEFINE_IDR(hwmon_idr); | |||
37 | struct class_device *hwmon_device_register(struct device *dev) | 39 | struct class_device *hwmon_device_register(struct device *dev) |
38 | { | 40 | { |
39 | struct class_device *cdev; | 41 | struct class_device *cdev; |
40 | int id; | 42 | int id, err; |
41 | 43 | ||
42 | if (idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0) | 44 | again: |
45 | if (unlikely(idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0)) | ||
43 | return ERR_PTR(-ENOMEM); | 46 | return ERR_PTR(-ENOMEM); |
44 | 47 | ||
45 | if (idr_get_new(&hwmon_idr, NULL, &id) < 0) | 48 | spin_lock(&idr_lock); |
46 | return ERR_PTR(-ENOMEM); | 49 | err = idr_get_new(&hwmon_idr, NULL, &id); |
50 | spin_unlock(&idr_lock); | ||
51 | |||
52 | if (unlikely(err == -EAGAIN)) | ||
53 | goto again; | ||
54 | else if (unlikely(err)) | ||
55 | return ERR_PTR(err); | ||
47 | 56 | ||
48 | id = id & MAX_ID_MASK; | 57 | id = id & MAX_ID_MASK; |
49 | cdev = class_device_create(hwmon_class, NULL, MKDEV(0,0), dev, | 58 | cdev = class_device_create(hwmon_class, NULL, MKDEV(0,0), dev, |
50 | HWMON_ID_FORMAT, id); | 59 | HWMON_ID_FORMAT, id); |
51 | 60 | ||
52 | if (IS_ERR(cdev)) | 61 | if (IS_ERR(cdev)) { |
62 | spin_lock(&idr_lock); | ||
53 | idr_remove(&hwmon_idr, id); | 63 | idr_remove(&hwmon_idr, id); |
64 | spin_unlock(&idr_lock); | ||
65 | } | ||
54 | 66 | ||
55 | return cdev; | 67 | return cdev; |
56 | } | 68 | } |
@@ -64,9 +76,11 @@ void hwmon_device_unregister(struct class_device *cdev) | |||
64 | { | 76 | { |
65 | int id; | 77 | int id; |
66 | 78 | ||
67 | if (sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1) { | 79 | if (likely(sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1)) { |
68 | class_device_unregister(cdev); | 80 | class_device_unregister(cdev); |
81 | spin_lock(&idr_lock); | ||
69 | idr_remove(&hwmon_idr, id); | 82 | idr_remove(&hwmon_idr, id); |
83 | spin_unlock(&idr_lock); | ||
70 | } else | 84 | } else |
71 | dev_dbg(cdev->dev, | 85 | dev_dbg(cdev->dev, |
72 | "hwmon_device_unregister() failed: bad class ID!\n"); | 86 | "hwmon_device_unregister() failed: bad class ID!\n"); |
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index d7a9401600bb..06df92b3ee49 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/hwmon-sysfs.h> | 41 | #include <linux/hwmon-sysfs.h> |
42 | #include <linux/hwmon-vid.h> | 42 | #include <linux/hwmon-vid.h> |
43 | #include <linux/err.h> | 43 | #include <linux/err.h> |
44 | #include <linux/mutex.h> | ||
44 | #include <asm/io.h> | 45 | #include <asm/io.h> |
45 | 46 | ||
46 | 47 | ||
@@ -194,10 +195,10 @@ static int DIV_TO_REG(int val) | |||
194 | struct it87_data { | 195 | struct it87_data { |
195 | struct i2c_client client; | 196 | struct i2c_client client; |
196 | struct class_device *class_dev; | 197 | struct class_device *class_dev; |
197 | struct semaphore lock; | 198 | struct mutex lock; |
198 | enum chips type; | 199 | enum chips type; |
199 | 200 | ||
200 | struct semaphore update_lock; | 201 | struct mutex update_lock; |
201 | char valid; /* !=0 if following fields are valid */ | 202 | char valid; /* !=0 if following fields are valid */ |
202 | unsigned long last_updated; /* In jiffies */ | 203 | unsigned long last_updated; /* In jiffies */ |
203 | 204 | ||
@@ -224,9 +225,8 @@ static int it87_isa_attach_adapter(struct i2c_adapter *adapter); | |||
224 | static int it87_detect(struct i2c_adapter *adapter, int address, int kind); | 225 | static int it87_detect(struct i2c_adapter *adapter, int address, int kind); |
225 | static int it87_detach_client(struct i2c_client *client); | 226 | static int it87_detach_client(struct i2c_client *client); |
226 | 227 | ||
227 | static int it87_read_value(struct i2c_client *client, u8 register); | 228 | static int it87_read_value(struct i2c_client *client, u8 reg); |
228 | static int it87_write_value(struct i2c_client *client, u8 register, | 229 | static int it87_write_value(struct i2c_client *client, u8 reg, u8 value); |
229 | u8 value); | ||
230 | static struct it87_data *it87_update_device(struct device *dev); | 230 | static struct it87_data *it87_update_device(struct device *dev); |
231 | static int it87_check_pwm(struct i2c_client *client); | 231 | static int it87_check_pwm(struct i2c_client *client); |
232 | static void it87_init_client(struct i2c_client *client, struct it87_data *data); | 232 | static void it87_init_client(struct i2c_client *client, struct it87_data *data); |
@@ -290,11 +290,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | |||
290 | struct it87_data *data = i2c_get_clientdata(client); | 290 | struct it87_data *data = i2c_get_clientdata(client); |
291 | unsigned long val = simple_strtoul(buf, NULL, 10); | 291 | unsigned long val = simple_strtoul(buf, NULL, 10); |
292 | 292 | ||
293 | down(&data->update_lock); | 293 | mutex_lock(&data->update_lock); |
294 | data->in_min[nr] = IN_TO_REG(val); | 294 | data->in_min[nr] = IN_TO_REG(val); |
295 | it87_write_value(client, IT87_REG_VIN_MIN(nr), | 295 | it87_write_value(client, IT87_REG_VIN_MIN(nr), |
296 | data->in_min[nr]); | 296 | data->in_min[nr]); |
297 | up(&data->update_lock); | 297 | mutex_unlock(&data->update_lock); |
298 | return count; | 298 | return count; |
299 | } | 299 | } |
300 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | 300 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, |
@@ -307,11 +307,11 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | |||
307 | struct it87_data *data = i2c_get_clientdata(client); | 307 | struct it87_data *data = i2c_get_clientdata(client); |
308 | unsigned long val = simple_strtoul(buf, NULL, 10); | 308 | unsigned long val = simple_strtoul(buf, NULL, 10); |
309 | 309 | ||
310 | down(&data->update_lock); | 310 | mutex_lock(&data->update_lock); |
311 | data->in_max[nr] = IN_TO_REG(val); | 311 | data->in_max[nr] = IN_TO_REG(val); |
312 | it87_write_value(client, IT87_REG_VIN_MAX(nr), | 312 | it87_write_value(client, IT87_REG_VIN_MAX(nr), |
313 | data->in_max[nr]); | 313 | data->in_max[nr]); |
314 | up(&data->update_lock); | 314 | mutex_unlock(&data->update_lock); |
315 | return count; | 315 | return count; |
316 | } | 316 | } |
317 | 317 | ||
@@ -381,10 +381,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
381 | struct it87_data *data = i2c_get_clientdata(client); | 381 | struct it87_data *data = i2c_get_clientdata(client); |
382 | int val = simple_strtol(buf, NULL, 10); | 382 | int val = simple_strtol(buf, NULL, 10); |
383 | 383 | ||
384 | down(&data->update_lock); | 384 | mutex_lock(&data->update_lock); |
385 | data->temp_high[nr] = TEMP_TO_REG(val); | 385 | data->temp_high[nr] = TEMP_TO_REG(val); |
386 | it87_write_value(client, IT87_REG_TEMP_HIGH(nr), data->temp_high[nr]); | 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 | return count; | 388 | return count; |
389 | } | 389 | } |
390 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | 390 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
@@ -397,10 +397,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
397 | struct it87_data *data = i2c_get_clientdata(client); | 397 | struct it87_data *data = i2c_get_clientdata(client); |
398 | int val = simple_strtol(buf, NULL, 10); | 398 | int val = simple_strtol(buf, NULL, 10); |
399 | 399 | ||
400 | down(&data->update_lock); | 400 | mutex_lock(&data->update_lock); |
401 | data->temp_low[nr] = TEMP_TO_REG(val); | 401 | data->temp_low[nr] = TEMP_TO_REG(val); |
402 | it87_write_value(client, IT87_REG_TEMP_LOW(nr), data->temp_low[nr]); | 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 | return count; | 404 | return count; |
405 | } | 405 | } |
406 | #define show_temp_offset(offset) \ | 406 | #define show_temp_offset(offset) \ |
@@ -440,7 +440,7 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr, | |||
440 | struct it87_data *data = i2c_get_clientdata(client); | 440 | struct it87_data *data = i2c_get_clientdata(client); |
441 | int val = simple_strtol(buf, NULL, 10); | 441 | int val = simple_strtol(buf, NULL, 10); |
442 | 442 | ||
443 | down(&data->update_lock); | 443 | mutex_lock(&data->update_lock); |
444 | 444 | ||
445 | data->sensor &= ~(1 << nr); | 445 | data->sensor &= ~(1 << nr); |
446 | data->sensor &= ~(8 << nr); | 446 | data->sensor &= ~(8 << nr); |
@@ -450,11 +450,11 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr, | |||
450 | else if (val == 2) | 450 | else if (val == 2) |
451 | data->sensor |= 8 << nr; | 451 | data->sensor |= 8 << nr; |
452 | else if (val != 0) { | 452 | else if (val != 0) { |
453 | up(&data->update_lock); | 453 | mutex_unlock(&data->update_lock); |
454 | return -EINVAL; | 454 | return -EINVAL; |
455 | } | 455 | } |
456 | it87_write_value(client, IT87_REG_TEMP_ENABLE, data->sensor); | 456 | it87_write_value(client, IT87_REG_TEMP_ENABLE, data->sensor); |
457 | up(&data->update_lock); | 457 | mutex_unlock(&data->update_lock); |
458 | return count; | 458 | return count; |
459 | } | 459 | } |
460 | #define show_sensor_offset(offset) \ | 460 | #define show_sensor_offset(offset) \ |
@@ -524,7 +524,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
524 | int val = simple_strtol(buf, NULL, 10); | 524 | int val = simple_strtol(buf, NULL, 10); |
525 | u8 reg = it87_read_value(client, IT87_REG_FAN_DIV); | 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 | switch (nr) { | 528 | switch (nr) { |
529 | case 0: data->fan_div[nr] = reg & 0x07; break; | 529 | case 0: data->fan_div[nr] = reg & 0x07; break; |
530 | case 1: data->fan_div[nr] = (reg >> 3) & 0x07; break; | 530 | case 1: data->fan_div[nr] = (reg >> 3) & 0x07; break; |
@@ -533,7 +533,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
533 | 533 | ||
534 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 534 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
535 | it87_write_value(client, IT87_REG_FAN_MIN(nr), data->fan_min[nr]); | 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 | return count; | 537 | return count; |
538 | } | 538 | } |
539 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | 539 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, |
@@ -548,7 +548,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
548 | int i, min[3]; | 548 | int i, min[3]; |
549 | u8 old; | 549 | u8 old; |
550 | 550 | ||
551 | down(&data->update_lock); | 551 | mutex_lock(&data->update_lock); |
552 | old = it87_read_value(client, IT87_REG_FAN_DIV); | 552 | old = it87_read_value(client, IT87_REG_FAN_DIV); |
553 | 553 | ||
554 | for (i = 0; i < 3; i++) | 554 | for (i = 0; i < 3; i++) |
@@ -576,7 +576,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
576 | data->fan_min[i]=FAN_TO_REG(min[i], DIV_FROM_REG(data->fan_div[i])); | 576 | data->fan_min[i]=FAN_TO_REG(min[i], DIV_FROM_REG(data->fan_div[i])); |
577 | it87_write_value(client, IT87_REG_FAN_MIN(i), data->fan_min[i]); | 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 | return count; | 580 | return count; |
581 | } | 581 | } |
582 | static ssize_t set_pwm_enable(struct device *dev, | 582 | static ssize_t set_pwm_enable(struct device *dev, |
@@ -589,7 +589,7 @@ static ssize_t set_pwm_enable(struct device *dev, | |||
589 | struct it87_data *data = i2c_get_clientdata(client); | 589 | struct it87_data *data = i2c_get_clientdata(client); |
590 | int val = simple_strtol(buf, NULL, 10); | 590 | int val = simple_strtol(buf, NULL, 10); |
591 | 591 | ||
592 | down(&data->update_lock); | 592 | mutex_lock(&data->update_lock); |
593 | 593 | ||
594 | if (val == 0) { | 594 | if (val == 0) { |
595 | int tmp; | 595 | int tmp; |
@@ -606,11 +606,11 @@ static ssize_t set_pwm_enable(struct device *dev, | |||
606 | /* set saved pwm value, clear FAN_CTLX PWM mode bit */ | 606 | /* set saved pwm value, clear FAN_CTLX PWM mode bit */ |
607 | it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr])); | 607 | it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr])); |
608 | } else { | 608 | } else { |
609 | up(&data->update_lock); | 609 | mutex_unlock(&data->update_lock); |
610 | return -EINVAL; | 610 | return -EINVAL; |
611 | } | 611 | } |
612 | 612 | ||
613 | up(&data->update_lock); | 613 | mutex_unlock(&data->update_lock); |
614 | return count; | 614 | return count; |
615 | } | 615 | } |
616 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, | 616 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, |
@@ -626,11 +626,11 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, | |||
626 | if (val < 0 || val > 255) | 626 | if (val < 0 || val > 255) |
627 | return -EINVAL; | 627 | return -EINVAL; |
628 | 628 | ||
629 | down(&data->update_lock); | 629 | mutex_lock(&data->update_lock); |
630 | data->manual_pwm_ctl[nr] = val; | 630 | data->manual_pwm_ctl[nr] = val; |
631 | if (data->fan_main_ctrl & (1 << nr)) | 631 | if (data->fan_main_ctrl & (1 << nr)) |
632 | it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr])); | 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 | return count; | 634 | return count; |
635 | } | 635 | } |
636 | 636 | ||
@@ -776,7 +776,7 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
776 | 776 | ||
777 | new_client = &data->client; | 777 | new_client = &data->client; |
778 | if (is_isa) | 778 | if (is_isa) |
779 | init_MUTEX(&data->lock); | 779 | mutex_init(&data->lock); |
780 | i2c_set_clientdata(new_client, data); | 780 | i2c_set_clientdata(new_client, data); |
781 | new_client->addr = address; | 781 | new_client->addr = address; |
782 | new_client->adapter = adapter; | 782 | new_client->adapter = adapter; |
@@ -823,7 +823,7 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
823 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 823 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
824 | data->type = kind; | 824 | data->type = kind; |
825 | data->valid = 0; | 825 | data->valid = 0; |
826 | init_MUTEX(&data->update_lock); | 826 | mutex_init(&data->update_lock); |
827 | 827 | ||
828 | /* Tell the I2C layer a new client has arrived */ | 828 | /* Tell the I2C layer a new client has arrived */ |
829 | if ((err = i2c_attach_client(new_client))) | 829 | if ((err = i2c_attach_client(new_client))) |
@@ -950,10 +950,10 @@ static int it87_read_value(struct i2c_client *client, u8 reg) | |||
950 | 950 | ||
951 | int res; | 951 | int res; |
952 | if (i2c_is_isa_client(client)) { | 952 | if (i2c_is_isa_client(client)) { |
953 | down(&data->lock); | 953 | mutex_lock(&data->lock); |
954 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); | 954 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); |
955 | res = inb_p(client->addr + IT87_DATA_REG_OFFSET); | 955 | res = inb_p(client->addr + IT87_DATA_REG_OFFSET); |
956 | up(&data->lock); | 956 | mutex_unlock(&data->lock); |
957 | return res; | 957 | return res; |
958 | } else | 958 | } else |
959 | return i2c_smbus_read_byte_data(client, reg); | 959 | return i2c_smbus_read_byte_data(client, reg); |
@@ -969,10 +969,10 @@ static int it87_write_value(struct i2c_client *client, u8 reg, u8 value) | |||
969 | struct it87_data *data = i2c_get_clientdata(client); | 969 | struct it87_data *data = i2c_get_clientdata(client); |
970 | 970 | ||
971 | if (i2c_is_isa_client(client)) { | 971 | if (i2c_is_isa_client(client)) { |
972 | down(&data->lock); | 972 | mutex_lock(&data->lock); |
973 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); | 973 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); |
974 | outb_p(value, client->addr + IT87_DATA_REG_OFFSET); | 974 | outb_p(value, client->addr + IT87_DATA_REG_OFFSET); |
975 | up(&data->lock); | 975 | mutex_unlock(&data->lock); |
976 | return 0; | 976 | return 0; |
977 | } else | 977 | } else |
978 | return i2c_smbus_write_byte_data(client, reg, value); | 978 | return i2c_smbus_write_byte_data(client, reg, value); |
@@ -1098,7 +1098,7 @@ static struct it87_data *it87_update_device(struct device *dev) | |||
1098 | struct it87_data *data = i2c_get_clientdata(client); | 1098 | struct it87_data *data = i2c_get_clientdata(client); |
1099 | int i; | 1099 | int i; |
1100 | 1100 | ||
1101 | down(&data->update_lock); | 1101 | mutex_lock(&data->update_lock); |
1102 | 1102 | ||
1103 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 1103 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
1104 | || !data->valid) { | 1104 | || !data->valid) { |
@@ -1160,7 +1160,7 @@ static struct it87_data *it87_update_device(struct device *dev) | |||
1160 | data->valid = 1; | 1160 | data->valid = 1; |
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | up(&data->update_lock); | 1163 | mutex_unlock(&data->update_lock); |
1164 | 1164 | ||
1165 | return data; | 1165 | return data; |
1166 | } | 1166 | } |
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 6b1aa7ef552e..071f0fc6adec 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/hwmon-sysfs.h> | 45 | #include <linux/hwmon-sysfs.h> |
46 | #include <linux/hwmon.h> | 46 | #include <linux/hwmon.h> |
47 | #include <linux/err.h> | 47 | #include <linux/err.h> |
48 | #include <linux/mutex.h> | ||
48 | 49 | ||
49 | /* | 50 | /* |
50 | * Addresses to scan | 51 | * Addresses to scan |
@@ -153,7 +154,7 @@ static struct i2c_driver lm63_driver = { | |||
153 | struct lm63_data { | 154 | struct lm63_data { |
154 | struct i2c_client client; | 155 | struct i2c_client client; |
155 | struct class_device *class_dev; | 156 | struct class_device *class_dev; |
156 | struct semaphore update_lock; | 157 | struct mutex update_lock; |
157 | char valid; /* zero until following fields are valid */ | 158 | char valid; /* zero until following fields are valid */ |
158 | unsigned long last_updated; /* in jiffies */ | 159 | unsigned long last_updated; /* in jiffies */ |
159 | 160 | ||
@@ -192,13 +193,13 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *dummy, | |||
192 | struct lm63_data *data = i2c_get_clientdata(client); | 193 | struct lm63_data *data = i2c_get_clientdata(client); |
193 | unsigned long val = simple_strtoul(buf, NULL, 10); | 194 | unsigned long val = simple_strtoul(buf, NULL, 10); |
194 | 195 | ||
195 | down(&data->update_lock); | 196 | mutex_lock(&data->update_lock); |
196 | data->fan[1] = FAN_TO_REG(val); | 197 | data->fan[1] = FAN_TO_REG(val); |
197 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, | 198 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, |
198 | data->fan[1] & 0xFF); | 199 | data->fan[1] & 0xFF); |
199 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, | 200 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, |
200 | data->fan[1] >> 8); | 201 | data->fan[1] >> 8); |
201 | up(&data->update_lock); | 202 | mutex_unlock(&data->update_lock); |
202 | return count; | 203 | return count; |
203 | } | 204 | } |
204 | 205 | ||
@@ -222,12 +223,12 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy, | |||
222 | return -EPERM; | 223 | return -EPERM; |
223 | 224 | ||
224 | val = simple_strtoul(buf, NULL, 10); | 225 | val = simple_strtoul(buf, NULL, 10); |
225 | down(&data->update_lock); | 226 | mutex_lock(&data->update_lock); |
226 | data->pwm1_value = val <= 0 ? 0 : | 227 | data->pwm1_value = val <= 0 ? 0 : |
227 | val >= 255 ? 2 * data->pwm1_freq : | 228 | val >= 255 ? 2 * data->pwm1_freq : |
228 | (val * data->pwm1_freq * 2 + 127) / 255; | 229 | (val * data->pwm1_freq * 2 + 127) / 255; |
229 | i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1_value); | 230 | i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1_value); |
230 | up(&data->update_lock); | 231 | mutex_unlock(&data->update_lock); |
231 | return count; | 232 | return count; |
232 | } | 233 | } |
233 | 234 | ||
@@ -253,10 +254,10 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *dummy, | |||
253 | struct lm63_data *data = i2c_get_clientdata(client); | 254 | struct lm63_data *data = i2c_get_clientdata(client); |
254 | long val = simple_strtol(buf, NULL, 10); | 255 | long val = simple_strtol(buf, NULL, 10); |
255 | 256 | ||
256 | down(&data->update_lock); | 257 | mutex_lock(&data->update_lock); |
257 | data->temp8[1] = TEMP8_TO_REG(val); | 258 | data->temp8[1] = TEMP8_TO_REG(val); |
258 | i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]); | 259 | i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]); |
259 | up(&data->update_lock); | 260 | mutex_unlock(&data->update_lock); |
260 | return count; | 261 | return count; |
261 | } | 262 | } |
262 | 263 | ||
@@ -284,13 +285,13 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, | |||
284 | long val = simple_strtol(buf, NULL, 10); | 285 | long val = simple_strtol(buf, NULL, 10); |
285 | int nr = attr->index; | 286 | int nr = attr->index; |
286 | 287 | ||
287 | down(&data->update_lock); | 288 | mutex_lock(&data->update_lock); |
288 | data->temp11[nr] = TEMP11_TO_REG(val); | 289 | data->temp11[nr] = TEMP11_TO_REG(val); |
289 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], | 290 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], |
290 | data->temp11[nr] >> 8); | 291 | data->temp11[nr] >> 8); |
291 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], | 292 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], |
292 | data->temp11[nr] & 0xff); | 293 | data->temp11[nr] & 0xff); |
293 | up(&data->update_lock); | 294 | mutex_unlock(&data->update_lock); |
294 | return count; | 295 | return count; |
295 | } | 296 | } |
296 | 297 | ||
@@ -314,11 +315,11 @@ static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute * | |||
314 | long val = simple_strtol(buf, NULL, 10); | 315 | long val = simple_strtol(buf, NULL, 10); |
315 | long hyst; | 316 | long hyst; |
316 | 317 | ||
317 | down(&data->update_lock); | 318 | mutex_lock(&data->update_lock); |
318 | hyst = TEMP8_FROM_REG(data->temp8[2]) - val; | 319 | hyst = TEMP8_FROM_REG(data->temp8[2]) - val; |
319 | i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, | 320 | i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, |
320 | HYST_TO_REG(hyst)); | 321 | HYST_TO_REG(hyst)); |
321 | up(&data->update_lock); | 322 | mutex_unlock(&data->update_lock); |
322 | return count; | 323 | return count; |
323 | } | 324 | } |
324 | 325 | ||
@@ -427,7 +428,7 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) | |||
427 | 428 | ||
428 | strlcpy(new_client->name, "lm63", I2C_NAME_SIZE); | 429 | strlcpy(new_client->name, "lm63", I2C_NAME_SIZE); |
429 | data->valid = 0; | 430 | data->valid = 0; |
430 | init_MUTEX(&data->update_lock); | 431 | mutex_init(&data->update_lock); |
431 | 432 | ||
432 | /* Tell the I2C layer a new client has arrived */ | 433 | /* Tell the I2C layer a new client has arrived */ |
433 | if ((err = i2c_attach_client(new_client))) | 434 | if ((err = i2c_attach_client(new_client))) |
@@ -530,7 +531,7 @@ static struct lm63_data *lm63_update_device(struct device *dev) | |||
530 | struct i2c_client *client = to_i2c_client(dev); | 531 | struct i2c_client *client = to_i2c_client(dev); |
531 | struct lm63_data *data = i2c_get_clientdata(client); | 532 | struct lm63_data *data = i2c_get_clientdata(client); |
532 | 533 | ||
533 | down(&data->update_lock); | 534 | mutex_lock(&data->update_lock); |
534 | 535 | ||
535 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | 536 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
536 | if (data->config & 0x04) { /* tachometer enabled */ | 537 | if (data->config & 0x04) { /* tachometer enabled */ |
@@ -582,7 +583,7 @@ static struct lm63_data *lm63_update_device(struct device *dev) | |||
582 | data->valid = 1; | 583 | data->valid = 1; |
583 | } | 584 | } |
584 | 585 | ||
585 | up(&data->update_lock); | 586 | mutex_unlock(&data->update_lock); |
586 | 587 | ||
587 | return data; | 588 | return data; |
588 | } | 589 | } |
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 74ca2c8c61c3..fc25b90ec24a 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
26 | #include <linux/hwmon.h> | 26 | #include <linux/hwmon.h> |
27 | #include <linux/err.h> | 27 | #include <linux/err.h> |
28 | #include <linux/mutex.h> | ||
28 | #include "lm75.h" | 29 | #include "lm75.h" |
29 | 30 | ||
30 | 31 | ||
@@ -47,7 +48,7 @@ I2C_CLIENT_INSMOD_1(lm75); | |||
47 | struct lm75_data { | 48 | struct lm75_data { |
48 | struct i2c_client client; | 49 | struct i2c_client client; |
49 | struct class_device *class_dev; | 50 | struct class_device *class_dev; |
50 | struct semaphore update_lock; | 51 | struct mutex update_lock; |
51 | char valid; /* !=0 if following fields are valid */ | 52 | char valid; /* !=0 if following fields are valid */ |
52 | unsigned long last_updated; /* In jiffies */ | 53 | unsigned long last_updated; /* In jiffies */ |
53 | u16 temp_input; /* Register values */ | 54 | u16 temp_input; /* Register values */ |
@@ -91,10 +92,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co | |||
91 | struct lm75_data *data = i2c_get_clientdata(client); \ | 92 | struct lm75_data *data = i2c_get_clientdata(client); \ |
92 | int temp = simple_strtoul(buf, NULL, 10); \ | 93 | int temp = simple_strtoul(buf, NULL, 10); \ |
93 | \ | 94 | \ |
94 | down(&data->update_lock); \ | 95 | mutex_lock(&data->update_lock); \ |
95 | data->value = LM75_TEMP_TO_REG(temp); \ | 96 | data->value = LM75_TEMP_TO_REG(temp); \ |
96 | lm75_write_value(client, reg, data->value); \ | 97 | lm75_write_value(client, reg, data->value); \ |
97 | up(&data->update_lock); \ | 98 | mutex_unlock(&data->update_lock); \ |
98 | return count; \ | 99 | return count; \ |
99 | } | 100 | } |
100 | set(temp_max, LM75_REG_TEMP_OS); | 101 | set(temp_max, LM75_REG_TEMP_OS); |
@@ -188,7 +189,7 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) | |||
188 | /* Fill in the remaining client fields and put it into the global list */ | 189 | /* Fill in the remaining client fields and put it into the global list */ |
189 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 190 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
190 | data->valid = 0; | 191 | data->valid = 0; |
191 | init_MUTEX(&data->update_lock); | 192 | mutex_init(&data->update_lock); |
192 | 193 | ||
193 | /* Tell the I2C layer a new client has arrived */ | 194 | /* Tell the I2C layer a new client has arrived */ |
194 | if ((err = i2c_attach_client(new_client))) | 195 | if ((err = i2c_attach_client(new_client))) |
@@ -264,7 +265,7 @@ static struct lm75_data *lm75_update_device(struct device *dev) | |||
264 | struct i2c_client *client = to_i2c_client(dev); | 265 | struct i2c_client *client = to_i2c_client(dev); |
265 | struct lm75_data *data = i2c_get_clientdata(client); | 266 | struct lm75_data *data = i2c_get_clientdata(client); |
266 | 267 | ||
267 | down(&data->update_lock); | 268 | mutex_lock(&data->update_lock); |
268 | 269 | ||
269 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 270 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
270 | || !data->valid) { | 271 | || !data->valid) { |
@@ -277,7 +278,7 @@ static struct lm75_data *lm75_update_device(struct device *dev) | |||
277 | data->valid = 1; | 278 | data->valid = 1; |
278 | } | 279 | } |
279 | 280 | ||
280 | up(&data->update_lock); | 281 | mutex_unlock(&data->update_lock); |
281 | 282 | ||
282 | return data; | 283 | return data; |
283 | } | 284 | } |
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index df9e02aaa70a..459cc977380a 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/i2c.h> | 32 | #include <linux/i2c.h> |
33 | #include <linux/hwmon.h> | 33 | #include <linux/hwmon.h> |
34 | #include <linux/err.h> | 34 | #include <linux/err.h> |
35 | #include <linux/mutex.h> | ||
35 | 36 | ||
36 | /* Addresses to scan */ | 37 | /* Addresses to scan */ |
37 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; | 38 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; |
@@ -51,7 +52,7 @@ I2C_CLIENT_INSMOD_1(lm77); | |||
51 | struct lm77_data { | 52 | struct lm77_data { |
52 | struct i2c_client client; | 53 | struct i2c_client client; |
53 | struct class_device *class_dev; | 54 | struct class_device *class_dev; |
54 | struct semaphore update_lock; | 55 | struct mutex update_lock; |
55 | char valid; | 56 | char valid; |
56 | unsigned long last_updated; /* In jiffies */ | 57 | unsigned long last_updated; /* In jiffies */ |
57 | int temp_input; /* Temperatures */ | 58 | int temp_input; /* Temperatures */ |
@@ -139,10 +140,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co | |||
139 | struct lm77_data *data = i2c_get_clientdata(client); \ | 140 | struct lm77_data *data = i2c_get_clientdata(client); \ |
140 | long val = simple_strtoul(buf, NULL, 10); \ | 141 | long val = simple_strtoul(buf, NULL, 10); \ |
141 | \ | 142 | \ |
142 | down(&data->update_lock); \ | 143 | mutex_lock(&data->update_lock); \ |
143 | data->value = val; \ | 144 | data->value = val; \ |
144 | lm77_write_value(client, reg, LM77_TEMP_TO_REG(data->value)); \ | 145 | lm77_write_value(client, reg, LM77_TEMP_TO_REG(data->value)); \ |
145 | up(&data->update_lock); \ | 146 | mutex_unlock(&data->update_lock); \ |
146 | return count; \ | 147 | return count; \ |
147 | } | 148 | } |
148 | 149 | ||
@@ -157,11 +158,11 @@ static ssize_t set_temp_crit_hyst(struct device *dev, struct device_attribute *a | |||
157 | struct lm77_data *data = i2c_get_clientdata(client); | 158 | struct lm77_data *data = i2c_get_clientdata(client); |
158 | unsigned long val = simple_strtoul(buf, NULL, 10); | 159 | unsigned long val = simple_strtoul(buf, NULL, 10); |
159 | 160 | ||
160 | down(&data->update_lock); | 161 | mutex_lock(&data->update_lock); |
161 | data->temp_hyst = data->temp_crit - val; | 162 | data->temp_hyst = data->temp_crit - val; |
162 | lm77_write_value(client, LM77_REG_TEMP_HYST, | 163 | lm77_write_value(client, LM77_REG_TEMP_HYST, |
163 | LM77_TEMP_TO_REG(data->temp_hyst)); | 164 | LM77_TEMP_TO_REG(data->temp_hyst)); |
164 | up(&data->update_lock); | 165 | mutex_unlock(&data->update_lock); |
165 | return count; | 166 | return count; |
166 | } | 167 | } |
167 | 168 | ||
@@ -173,7 +174,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, | |||
173 | long val = simple_strtoul(buf, NULL, 10); | 174 | long val = simple_strtoul(buf, NULL, 10); |
174 | int oldcrithyst; | 175 | int oldcrithyst; |
175 | 176 | ||
176 | down(&data->update_lock); | 177 | mutex_lock(&data->update_lock); |
177 | oldcrithyst = data->temp_crit - data->temp_hyst; | 178 | oldcrithyst = data->temp_crit - data->temp_hyst; |
178 | data->temp_crit = val; | 179 | data->temp_crit = val; |
179 | data->temp_hyst = data->temp_crit - oldcrithyst; | 180 | data->temp_hyst = data->temp_crit - oldcrithyst; |
@@ -181,7 +182,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, | |||
181 | LM77_TEMP_TO_REG(data->temp_crit)); | 182 | LM77_TEMP_TO_REG(data->temp_crit)); |
182 | lm77_write_value(client, LM77_REG_TEMP_HYST, | 183 | lm77_write_value(client, LM77_REG_TEMP_HYST, |
183 | LM77_TEMP_TO_REG(data->temp_hyst)); | 184 | LM77_TEMP_TO_REG(data->temp_hyst)); |
184 | up(&data->update_lock); | 185 | mutex_unlock(&data->update_lock); |
185 | return count; | 186 | return count; |
186 | } | 187 | } |
187 | 188 | ||
@@ -306,7 +307,7 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) | |||
306 | /* Fill in the remaining client fields and put it into the global list */ | 307 | /* Fill in the remaining client fields and put it into the global list */ |
307 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 308 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
308 | data->valid = 0; | 309 | data->valid = 0; |
309 | init_MUTEX(&data->update_lock); | 310 | mutex_init(&data->update_lock); |
310 | 311 | ||
311 | /* Tell the I2C layer a new client has arrived */ | 312 | /* Tell the I2C layer a new client has arrived */ |
312 | if ((err = i2c_attach_client(new_client))) | 313 | if ((err = i2c_attach_client(new_client))) |
@@ -380,7 +381,7 @@ static struct lm77_data *lm77_update_device(struct device *dev) | |||
380 | struct i2c_client *client = to_i2c_client(dev); | 381 | struct i2c_client *client = to_i2c_client(dev); |
381 | struct lm77_data *data = i2c_get_clientdata(client); | 382 | struct lm77_data *data = i2c_get_clientdata(client); |
382 | 383 | ||
383 | down(&data->update_lock); | 384 | mutex_lock(&data->update_lock); |
384 | 385 | ||
385 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 386 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
386 | || !data->valid) { | 387 | || !data->valid) { |
@@ -406,7 +407,7 @@ static struct lm77_data *lm77_update_device(struct device *dev) | |||
406 | data->valid = 1; | 407 | data->valid = 1; |
407 | } | 408 | } |
408 | 409 | ||
409 | up(&data->update_lock); | 410 | mutex_unlock(&data->update_lock); |
410 | 411 | ||
411 | return data; | 412 | return data; |
412 | } | 413 | } |
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index e404001e20da..94be3d797e61 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/hwmon.h> | 27 | #include <linux/hwmon.h> |
28 | #include <linux/hwmon-vid.h> | 28 | #include <linux/hwmon-vid.h> |
29 | #include <linux/err.h> | 29 | #include <linux/err.h> |
30 | #include <linux/mutex.h> | ||
30 | #include <asm/io.h> | 31 | #include <asm/io.h> |
31 | 32 | ||
32 | /* Addresses to scan */ | 33 | /* Addresses to scan */ |
@@ -131,10 +132,10 @@ static inline int TEMP_FROM_REG(s8 val) | |||
131 | struct lm78_data { | 132 | struct lm78_data { |
132 | struct i2c_client client; | 133 | struct i2c_client client; |
133 | struct class_device *class_dev; | 134 | struct class_device *class_dev; |
134 | struct semaphore lock; | 135 | struct mutex lock; |
135 | enum chips type; | 136 | enum chips type; |
136 | 137 | ||
137 | struct semaphore update_lock; | 138 | struct mutex update_lock; |
138 | char valid; /* !=0 if following fields are valid */ | 139 | char valid; /* !=0 if following fields are valid */ |
139 | unsigned long last_updated; /* In jiffies */ | 140 | unsigned long last_updated; /* In jiffies */ |
140 | 141 | ||
@@ -157,8 +158,8 @@ static int lm78_isa_attach_adapter(struct i2c_adapter *adapter); | |||
157 | static int lm78_detect(struct i2c_adapter *adapter, int address, int kind); | 158 | static int lm78_detect(struct i2c_adapter *adapter, int address, int kind); |
158 | static int lm78_detach_client(struct i2c_client *client); | 159 | static int lm78_detach_client(struct i2c_client *client); |
159 | 160 | ||
160 | static int lm78_read_value(struct i2c_client *client, u8 register); | 161 | static int lm78_read_value(struct i2c_client *client, u8 reg); |
161 | static int lm78_write_value(struct i2c_client *client, u8 register, u8 value); | 162 | static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value); |
162 | static struct lm78_data *lm78_update_device(struct device *dev); | 163 | static struct lm78_data *lm78_update_device(struct device *dev); |
163 | static void lm78_init_client(struct i2c_client *client); | 164 | static void lm78_init_client(struct i2c_client *client); |
164 | 165 | ||
@@ -207,10 +208,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf, | |||
207 | struct lm78_data *data = i2c_get_clientdata(client); | 208 | struct lm78_data *data = i2c_get_clientdata(client); |
208 | unsigned long val = simple_strtoul(buf, NULL, 10); | 209 | unsigned long val = simple_strtoul(buf, NULL, 10); |
209 | 210 | ||
210 | down(&data->update_lock); | 211 | mutex_lock(&data->update_lock); |
211 | data->in_min[nr] = IN_TO_REG(val); | 212 | data->in_min[nr] = IN_TO_REG(val); |
212 | lm78_write_value(client, LM78_REG_IN_MIN(nr), data->in_min[nr]); | 213 | lm78_write_value(client, LM78_REG_IN_MIN(nr), data->in_min[nr]); |
213 | up(&data->update_lock); | 214 | mutex_unlock(&data->update_lock); |
214 | return count; | 215 | return count; |
215 | } | 216 | } |
216 | 217 | ||
@@ -221,10 +222,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
221 | struct lm78_data *data = i2c_get_clientdata(client); | 222 | struct lm78_data *data = i2c_get_clientdata(client); |
222 | unsigned long val = simple_strtoul(buf, NULL, 10); | 223 | unsigned long val = simple_strtoul(buf, NULL, 10); |
223 | 224 | ||
224 | down(&data->update_lock); | 225 | mutex_lock(&data->update_lock); |
225 | data->in_max[nr] = IN_TO_REG(val); | 226 | data->in_max[nr] = IN_TO_REG(val); |
226 | lm78_write_value(client, LM78_REG_IN_MAX(nr), data->in_max[nr]); | 227 | lm78_write_value(client, LM78_REG_IN_MAX(nr), data->in_max[nr]); |
227 | up(&data->update_lock); | 228 | mutex_unlock(&data->update_lock); |
228 | return count; | 229 | return count; |
229 | } | 230 | } |
230 | 231 | ||
@@ -288,10 +289,10 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr, | |||
288 | struct lm78_data *data = i2c_get_clientdata(client); | 289 | struct lm78_data *data = i2c_get_clientdata(client); |
289 | long val = simple_strtol(buf, NULL, 10); | 290 | long val = simple_strtol(buf, NULL, 10); |
290 | 291 | ||
291 | down(&data->update_lock); | 292 | mutex_lock(&data->update_lock); |
292 | data->temp_over = TEMP_TO_REG(val); | 293 | data->temp_over = TEMP_TO_REG(val); |
293 | lm78_write_value(client, LM78_REG_TEMP_OVER, data->temp_over); | 294 | lm78_write_value(client, LM78_REG_TEMP_OVER, data->temp_over); |
294 | up(&data->update_lock); | 295 | mutex_unlock(&data->update_lock); |
295 | return count; | 296 | return count; |
296 | } | 297 | } |
297 | 298 | ||
@@ -307,10 +308,10 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr, | |||
307 | struct lm78_data *data = i2c_get_clientdata(client); | 308 | struct lm78_data *data = i2c_get_clientdata(client); |
308 | long val = simple_strtol(buf, NULL, 10); | 309 | long val = simple_strtol(buf, NULL, 10); |
309 | 310 | ||
310 | down(&data->update_lock); | 311 | mutex_lock(&data->update_lock); |
311 | data->temp_hyst = TEMP_TO_REG(val); | 312 | data->temp_hyst = TEMP_TO_REG(val); |
312 | lm78_write_value(client, LM78_REG_TEMP_HYST, data->temp_hyst); | 313 | lm78_write_value(client, LM78_REG_TEMP_HYST, data->temp_hyst); |
313 | up(&data->update_lock); | 314 | mutex_unlock(&data->update_lock); |
314 | return count; | 315 | return count; |
315 | } | 316 | } |
316 | 317 | ||
@@ -342,10 +343,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
342 | struct lm78_data *data = i2c_get_clientdata(client); | 343 | struct lm78_data *data = i2c_get_clientdata(client); |
343 | unsigned long val = simple_strtoul(buf, NULL, 10); | 344 | unsigned long val = simple_strtoul(buf, NULL, 10); |
344 | 345 | ||
345 | down(&data->update_lock); | 346 | mutex_lock(&data->update_lock); |
346 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 347 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
347 | lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); | 348 | lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); |
348 | up(&data->update_lock); | 349 | mutex_unlock(&data->update_lock); |
349 | return count; | 350 | return count; |
350 | } | 351 | } |
351 | 352 | ||
@@ -368,7 +369,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
368 | unsigned long min; | 369 | unsigned long min; |
369 | u8 reg; | 370 | u8 reg; |
370 | 371 | ||
371 | down(&data->update_lock); | 372 | mutex_lock(&data->update_lock); |
372 | min = FAN_FROM_REG(data->fan_min[nr], | 373 | min = FAN_FROM_REG(data->fan_min[nr], |
373 | DIV_FROM_REG(data->fan_div[nr])); | 374 | DIV_FROM_REG(data->fan_div[nr])); |
374 | 375 | ||
@@ -380,7 +381,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
380 | default: | 381 | default: |
381 | dev_err(&client->dev, "fan_div value %ld not " | 382 | dev_err(&client->dev, "fan_div value %ld not " |
382 | "supported. Choose one of 1, 2, 4 or 8!\n", val); | 383 | "supported. Choose one of 1, 2, 4 or 8!\n", val); |
383 | up(&data->update_lock); | 384 | mutex_unlock(&data->update_lock); |
384 | return -EINVAL; | 385 | return -EINVAL; |
385 | } | 386 | } |
386 | 387 | ||
@@ -398,7 +399,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
398 | data->fan_min[nr] = | 399 | data->fan_min[nr] = |
399 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 400 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
400 | lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); | 401 | lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); |
401 | up(&data->update_lock); | 402 | mutex_unlock(&data->update_lock); |
402 | 403 | ||
403 | return count; | 404 | return count; |
404 | } | 405 | } |
@@ -548,7 +549,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind) | |||
548 | 549 | ||
549 | new_client = &data->client; | 550 | new_client = &data->client; |
550 | if (is_isa) | 551 | if (is_isa) |
551 | init_MUTEX(&data->lock); | 552 | mutex_init(&data->lock); |
552 | i2c_set_clientdata(new_client, data); | 553 | i2c_set_clientdata(new_client, data); |
553 | new_client->addr = address; | 554 | new_client->addr = address; |
554 | new_client->adapter = adapter; | 555 | new_client->adapter = adapter; |
@@ -598,7 +599,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind) | |||
598 | data->type = kind; | 599 | data->type = kind; |
599 | 600 | ||
600 | data->valid = 0; | 601 | data->valid = 0; |
601 | init_MUTEX(&data->update_lock); | 602 | mutex_init(&data->update_lock); |
602 | 603 | ||
603 | /* Tell the I2C layer a new client has arrived */ | 604 | /* Tell the I2C layer a new client has arrived */ |
604 | if ((err = i2c_attach_client(new_client))) | 605 | if ((err = i2c_attach_client(new_client))) |
@@ -697,10 +698,10 @@ static int lm78_read_value(struct i2c_client *client, u8 reg) | |||
697 | int res; | 698 | int res; |
698 | if (i2c_is_isa_client(client)) { | 699 | if (i2c_is_isa_client(client)) { |
699 | struct lm78_data *data = i2c_get_clientdata(client); | 700 | struct lm78_data *data = i2c_get_clientdata(client); |
700 | down(&data->lock); | 701 | mutex_lock(&data->lock); |
701 | outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); | 702 | outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); |
702 | res = inb_p(client->addr + LM78_DATA_REG_OFFSET); | 703 | res = inb_p(client->addr + LM78_DATA_REG_OFFSET); |
703 | up(&data->lock); | 704 | mutex_unlock(&data->lock); |
704 | return res; | 705 | return res; |
705 | } else | 706 | } else |
706 | return i2c_smbus_read_byte_data(client, reg); | 707 | return i2c_smbus_read_byte_data(client, reg); |
@@ -717,10 +718,10 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value) | |||
717 | { | 718 | { |
718 | if (i2c_is_isa_client(client)) { | 719 | if (i2c_is_isa_client(client)) { |
719 | struct lm78_data *data = i2c_get_clientdata(client); | 720 | struct lm78_data *data = i2c_get_clientdata(client); |
720 | down(&data->lock); | 721 | mutex_lock(&data->lock); |
721 | outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); | 722 | outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); |
722 | outb_p(value, client->addr + LM78_DATA_REG_OFFSET); | 723 | outb_p(value, client->addr + LM78_DATA_REG_OFFSET); |
723 | up(&data->lock); | 724 | mutex_unlock(&data->lock); |
724 | return 0; | 725 | return 0; |
725 | } else | 726 | } else |
726 | return i2c_smbus_write_byte_data(client, reg, value); | 727 | return i2c_smbus_write_byte_data(client, reg, value); |
@@ -742,7 +743,7 @@ static struct lm78_data *lm78_update_device(struct device *dev) | |||
742 | struct lm78_data *data = i2c_get_clientdata(client); | 743 | struct lm78_data *data = i2c_get_clientdata(client); |
743 | int i; | 744 | int i; |
744 | 745 | ||
745 | down(&data->update_lock); | 746 | mutex_lock(&data->update_lock); |
746 | 747 | ||
747 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 748 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
748 | || !data->valid) { | 749 | || !data->valid) { |
@@ -786,7 +787,7 @@ static struct lm78_data *lm78_update_device(struct device *dev) | |||
786 | data->fan_div[2] = 1; | 787 | data->fan_div[2] = 1; |
787 | } | 788 | } |
788 | 789 | ||
789 | up(&data->update_lock); | 790 | mutex_unlock(&data->update_lock); |
790 | 791 | ||
791 | return data; | 792 | return data; |
792 | } | 793 | } |
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index c9a7cdea7bd7..f72120d08c4c 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/hwmon.h> | 29 | #include <linux/hwmon.h> |
30 | #include <linux/err.h> | 30 | #include <linux/err.h> |
31 | #include <linux/mutex.h> | ||
31 | 32 | ||
32 | /* Addresses to scan */ | 33 | /* Addresses to scan */ |
33 | static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, | 34 | static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, |
@@ -108,7 +109,7 @@ static inline long TEMP_FROM_REG(u16 temp) | |||
108 | struct lm80_data { | 109 | struct lm80_data { |
109 | struct i2c_client client; | 110 | struct i2c_client client; |
110 | struct class_device *class_dev; | 111 | struct class_device *class_dev; |
111 | struct semaphore update_lock; | 112 | struct mutex update_lock; |
112 | char valid; /* !=0 if following fields are valid */ | 113 | char valid; /* !=0 if following fields are valid */ |
113 | unsigned long last_updated; /* In jiffies */ | 114 | unsigned long last_updated; /* In jiffies */ |
114 | 115 | ||
@@ -191,10 +192,10 @@ static ssize_t set_in_##suffix(struct device *dev, struct device_attribute *attr | |||
191 | struct lm80_data *data = i2c_get_clientdata(client); \ | 192 | struct lm80_data *data = i2c_get_clientdata(client); \ |
192 | long val = simple_strtol(buf, NULL, 10); \ | 193 | long val = simple_strtol(buf, NULL, 10); \ |
193 | \ | 194 | \ |
194 | down(&data->update_lock);\ | 195 | mutex_lock(&data->update_lock);\ |
195 | data->value = IN_TO_REG(val); \ | 196 | data->value = IN_TO_REG(val); \ |
196 | lm80_write_value(client, reg, data->value); \ | 197 | lm80_write_value(client, reg, data->value); \ |
197 | up(&data->update_lock);\ | 198 | mutex_unlock(&data->update_lock);\ |
198 | return count; \ | 199 | return count; \ |
199 | } | 200 | } |
200 | set_in(min0, in_min[0], LM80_REG_IN_MIN(0)); | 201 | set_in(min0, in_min[0], LM80_REG_IN_MIN(0)); |
@@ -241,10 +242,10 @@ static ssize_t set_fan_##suffix(struct device *dev, struct device_attribute *att | |||
241 | struct lm80_data *data = i2c_get_clientdata(client); \ | 242 | struct lm80_data *data = i2c_get_clientdata(client); \ |
242 | long val = simple_strtoul(buf, NULL, 10); \ | 243 | long val = simple_strtoul(buf, NULL, 10); \ |
243 | \ | 244 | \ |
244 | down(&data->update_lock);\ | 245 | mutex_lock(&data->update_lock);\ |
245 | data->value = FAN_TO_REG(val, DIV_FROM_REG(data->div)); \ | 246 | data->value = FAN_TO_REG(val, DIV_FROM_REG(data->div)); \ |
246 | lm80_write_value(client, reg, data->value); \ | 247 | lm80_write_value(client, reg, data->value); \ |
247 | up(&data->update_lock);\ | 248 | mutex_unlock(&data->update_lock);\ |
248 | return count; \ | 249 | return count; \ |
249 | } | 250 | } |
250 | set_fan(min1, fan_min[0], LM80_REG_FAN_MIN(1), fan_div[0]); | 251 | set_fan(min1, fan_min[0], LM80_REG_FAN_MIN(1), fan_div[0]); |
@@ -263,7 +264,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
263 | u8 reg; | 264 | u8 reg; |
264 | 265 | ||
265 | /* Save fan_min */ | 266 | /* Save fan_min */ |
266 | down(&data->update_lock); | 267 | mutex_lock(&data->update_lock); |
267 | min = FAN_FROM_REG(data->fan_min[nr], | 268 | min = FAN_FROM_REG(data->fan_min[nr], |
268 | DIV_FROM_REG(data->fan_div[nr])); | 269 | DIV_FROM_REG(data->fan_div[nr])); |
269 | 270 | ||
@@ -275,7 +276,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
275 | default: | 276 | default: |
276 | dev_err(&client->dev, "fan_div value %ld not " | 277 | dev_err(&client->dev, "fan_div value %ld not " |
277 | "supported. Choose one of 1, 2, 4 or 8!\n", val); | 278 | "supported. Choose one of 1, 2, 4 or 8!\n", val); |
278 | up(&data->update_lock); | 279 | mutex_unlock(&data->update_lock); |
279 | return -EINVAL; | 280 | return -EINVAL; |
280 | } | 281 | } |
281 | 282 | ||
@@ -286,7 +287,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
286 | /* Restore fan_min */ | 287 | /* Restore fan_min */ |
287 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 288 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
288 | lm80_write_value(client, LM80_REG_FAN_MIN(nr + 1), data->fan_min[nr]); | 289 | lm80_write_value(client, LM80_REG_FAN_MIN(nr + 1), data->fan_min[nr]); |
289 | up(&data->update_lock); | 290 | mutex_unlock(&data->update_lock); |
290 | 291 | ||
291 | return count; | 292 | return count; |
292 | } | 293 | } |
@@ -325,10 +326,10 @@ static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *at | |||
325 | struct lm80_data *data = i2c_get_clientdata(client); \ | 326 | struct lm80_data *data = i2c_get_clientdata(client); \ |
326 | long val = simple_strtoul(buf, NULL, 10); \ | 327 | long val = simple_strtoul(buf, NULL, 10); \ |
327 | \ | 328 | \ |
328 | down(&data->update_lock); \ | 329 | mutex_lock(&data->update_lock); \ |
329 | data->value = TEMP_LIMIT_TO_REG(val); \ | 330 | data->value = TEMP_LIMIT_TO_REG(val); \ |
330 | lm80_write_value(client, reg, data->value); \ | 331 | lm80_write_value(client, reg, data->value); \ |
331 | up(&data->update_lock); \ | 332 | mutex_unlock(&data->update_lock); \ |
332 | return count; \ | 333 | return count; \ |
333 | } | 334 | } |
334 | set_temp(hot_max, temp_hot_max, LM80_REG_TEMP_HOT_MAX); | 335 | set_temp(hot_max, temp_hot_max, LM80_REG_TEMP_HOT_MAX); |
@@ -437,7 +438,7 @@ static int lm80_detect(struct i2c_adapter *adapter, int address, int kind) | |||
437 | /* Fill in the remaining client fields and put it into the global list */ | 438 | /* Fill in the remaining client fields and put it into the global list */ |
438 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 439 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
439 | data->valid = 0; | 440 | data->valid = 0; |
440 | init_MUTEX(&data->update_lock); | 441 | mutex_init(&data->update_lock); |
441 | 442 | ||
442 | /* Tell the I2C layer a new client has arrived */ | 443 | /* Tell the I2C layer a new client has arrived */ |
443 | if ((err = i2c_attach_client(new_client))) | 444 | if ((err = i2c_attach_client(new_client))) |
@@ -545,7 +546,7 @@ static struct lm80_data *lm80_update_device(struct device *dev) | |||
545 | struct lm80_data *data = i2c_get_clientdata(client); | 546 | struct lm80_data *data = i2c_get_clientdata(client); |
546 | int i; | 547 | int i; |
547 | 548 | ||
548 | down(&data->update_lock); | 549 | mutex_lock(&data->update_lock); |
549 | 550 | ||
550 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { | 551 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { |
551 | dev_dbg(&client->dev, "Starting lm80 update\n"); | 552 | dev_dbg(&client->dev, "Starting lm80 update\n"); |
@@ -585,7 +586,7 @@ static struct lm80_data *lm80_update_device(struct device *dev) | |||
585 | data->valid = 1; | 586 | data->valid = 1; |
586 | } | 587 | } |
587 | 588 | ||
588 | up(&data->update_lock); | 589 | mutex_unlock(&data->update_lock); |
589 | 590 | ||
590 | return data; | 591 | return data; |
591 | } | 592 | } |
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index 26dfa9e216c2..aac4ec2bf694 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/hwmon-sysfs.h> | 35 | #include <linux/hwmon-sysfs.h> |
36 | #include <linux/hwmon.h> | 36 | #include <linux/hwmon.h> |
37 | #include <linux/err.h> | 37 | #include <linux/err.h> |
38 | #include <linux/mutex.h> | ||
38 | 39 | ||
39 | /* | 40 | /* |
40 | * Addresses to scan | 41 | * Addresses to scan |
@@ -139,7 +140,7 @@ static struct i2c_driver lm83_driver = { | |||
139 | struct lm83_data { | 140 | struct lm83_data { |
140 | struct i2c_client client; | 141 | struct i2c_client client; |
141 | struct class_device *class_dev; | 142 | struct class_device *class_dev; |
142 | struct semaphore update_lock; | 143 | struct mutex update_lock; |
143 | char valid; /* zero until following fields are valid */ | 144 | char valid; /* zero until following fields are valid */ |
144 | unsigned long last_updated; /* in jiffies */ | 145 | unsigned long last_updated; /* in jiffies */ |
145 | 146 | ||
@@ -171,11 +172,11 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, | |||
171 | long val = simple_strtol(buf, NULL, 10); | 172 | long val = simple_strtol(buf, NULL, 10); |
172 | int nr = attr->index; | 173 | int nr = attr->index; |
173 | 174 | ||
174 | down(&data->update_lock); | 175 | mutex_lock(&data->update_lock); |
175 | data->temp[nr] = TEMP_TO_REG(val); | 176 | data->temp[nr] = TEMP_TO_REG(val); |
176 | i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4], | 177 | i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4], |
177 | data->temp[nr]); | 178 | data->temp[nr]); |
178 | up(&data->update_lock); | 179 | mutex_unlock(&data->update_lock); |
179 | return count; | 180 | return count; |
180 | } | 181 | } |
181 | 182 | ||
@@ -300,7 +301,7 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) | |||
300 | /* We can fill in the remaining client fields */ | 301 | /* We can fill in the remaining client fields */ |
301 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 302 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
302 | data->valid = 0; | 303 | data->valid = 0; |
303 | init_MUTEX(&data->update_lock); | 304 | mutex_init(&data->update_lock); |
304 | 305 | ||
305 | /* Tell the I2C layer a new client has arrived */ | 306 | /* Tell the I2C layer a new client has arrived */ |
306 | if ((err = i2c_attach_client(new_client))) | 307 | if ((err = i2c_attach_client(new_client))) |
@@ -373,7 +374,7 @@ static struct lm83_data *lm83_update_device(struct device *dev) | |||
373 | struct i2c_client *client = to_i2c_client(dev); | 374 | struct i2c_client *client = to_i2c_client(dev); |
374 | struct lm83_data *data = i2c_get_clientdata(client); | 375 | struct lm83_data *data = i2c_get_clientdata(client); |
375 | 376 | ||
376 | down(&data->update_lock); | 377 | mutex_lock(&data->update_lock); |
377 | 378 | ||
378 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 379 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
379 | int nr; | 380 | int nr; |
@@ -393,7 +394,7 @@ static struct lm83_data *lm83_update_device(struct device *dev) | |||
393 | data->valid = 1; | 394 | data->valid = 1; |
394 | } | 395 | } |
395 | 396 | ||
396 | up(&data->update_lock); | 397 | mutex_unlock(&data->update_lock); |
397 | 398 | ||
398 | return data; | 399 | return data; |
399 | } | 400 | } |
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 7389a0127547..342e9663119d 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/hwmon.h> | 31 | #include <linux/hwmon.h> |
32 | #include <linux/hwmon-vid.h> | 32 | #include <linux/hwmon-vid.h> |
33 | #include <linux/err.h> | 33 | #include <linux/err.h> |
34 | #include <linux/mutex.h> | ||
34 | 35 | ||
35 | /* Addresses to scan */ | 36 | /* Addresses to scan */ |
36 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 37 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
@@ -331,10 +332,10 @@ struct lm85_autofan { | |||
331 | struct lm85_data { | 332 | struct lm85_data { |
332 | struct i2c_client client; | 333 | struct i2c_client client; |
333 | struct class_device *class_dev; | 334 | struct class_device *class_dev; |
334 | struct semaphore lock; | 335 | struct mutex lock; |
335 | enum chips type; | 336 | enum chips type; |
336 | 337 | ||
337 | struct semaphore update_lock; | 338 | struct mutex update_lock; |
338 | int valid; /* !=0 if following fields are valid */ | 339 | int valid; /* !=0 if following fields are valid */ |
339 | unsigned long last_reading; /* In jiffies */ | 340 | unsigned long last_reading; /* In jiffies */ |
340 | unsigned long last_config; /* In jiffies */ | 341 | unsigned long last_config; /* In jiffies */ |
@@ -373,8 +374,8 @@ static int lm85_detect(struct i2c_adapter *adapter, int address, | |||
373 | int kind); | 374 | int kind); |
374 | static int lm85_detach_client(struct i2c_client *client); | 375 | static int lm85_detach_client(struct i2c_client *client); |
375 | 376 | ||
376 | static int lm85_read_value(struct i2c_client *client, u8 register); | 377 | static int lm85_read_value(struct i2c_client *client, u8 reg); |
377 | static int lm85_write_value(struct i2c_client *client, u8 register, int value); | 378 | static int lm85_write_value(struct i2c_client *client, u8 reg, int value); |
378 | static struct lm85_data *lm85_update_device(struct device *dev); | 379 | static struct lm85_data *lm85_update_device(struct device *dev); |
379 | static void lm85_init_client(struct i2c_client *client); | 380 | static void lm85_init_client(struct i2c_client *client); |
380 | 381 | ||
@@ -407,10 +408,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
407 | struct lm85_data *data = i2c_get_clientdata(client); | 408 | struct lm85_data *data = i2c_get_clientdata(client); |
408 | long val = simple_strtol(buf, NULL, 10); | 409 | long val = simple_strtol(buf, NULL, 10); |
409 | 410 | ||
410 | down(&data->update_lock); | 411 | mutex_lock(&data->update_lock); |
411 | data->fan_min[nr] = FAN_TO_REG(val); | 412 | data->fan_min[nr] = FAN_TO_REG(val); |
412 | lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]); | 413 | lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]); |
413 | up(&data->update_lock); | 414 | mutex_unlock(&data->update_lock); |
414 | return count; | 415 | return count; |
415 | } | 416 | } |
416 | 417 | ||
@@ -499,10 +500,10 @@ static ssize_t set_pwm(struct device *dev, const char *buf, | |||
499 | struct lm85_data *data = i2c_get_clientdata(client); | 500 | struct lm85_data *data = i2c_get_clientdata(client); |
500 | long val = simple_strtol(buf, NULL, 10); | 501 | long val = simple_strtol(buf, NULL, 10); |
501 | 502 | ||
502 | down(&data->update_lock); | 503 | mutex_lock(&data->update_lock); |
503 | data->pwm[nr] = PWM_TO_REG(val); | 504 | data->pwm[nr] = PWM_TO_REG(val); |
504 | lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]); | 505 | lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]); |
505 | up(&data->update_lock); | 506 | mutex_unlock(&data->update_lock); |
506 | return count; | 507 | return count; |
507 | } | 508 | } |
508 | static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) | 509 | static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) |
@@ -559,10 +560,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf, | |||
559 | struct lm85_data *data = i2c_get_clientdata(client); | 560 | struct lm85_data *data = i2c_get_clientdata(client); |
560 | long val = simple_strtol(buf, NULL, 10); | 561 | long val = simple_strtol(buf, NULL, 10); |
561 | 562 | ||
562 | down(&data->update_lock); | 563 | mutex_lock(&data->update_lock); |
563 | data->in_min[nr] = INS_TO_REG(nr, val); | 564 | data->in_min[nr] = INS_TO_REG(nr, val); |
564 | lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]); | 565 | lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]); |
565 | up(&data->update_lock); | 566 | mutex_unlock(&data->update_lock); |
566 | return count; | 567 | return count; |
567 | } | 568 | } |
568 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) | 569 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) |
@@ -577,10 +578,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
577 | struct lm85_data *data = i2c_get_clientdata(client); | 578 | struct lm85_data *data = i2c_get_clientdata(client); |
578 | long val = simple_strtol(buf, NULL, 10); | 579 | long val = simple_strtol(buf, NULL, 10); |
579 | 580 | ||
580 | down(&data->update_lock); | 581 | mutex_lock(&data->update_lock); |
581 | data->in_max[nr] = INS_TO_REG(nr, val); | 582 | data->in_max[nr] = INS_TO_REG(nr, val); |
582 | lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]); | 583 | lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]); |
583 | up(&data->update_lock); | 584 | mutex_unlock(&data->update_lock); |
584 | return count; | 585 | return count; |
585 | } | 586 | } |
586 | #define show_in_reg(offset) \ | 587 | #define show_in_reg(offset) \ |
@@ -640,10 +641,10 @@ static ssize_t set_temp_min(struct device *dev, const char *buf, | |||
640 | struct lm85_data *data = i2c_get_clientdata(client); | 641 | struct lm85_data *data = i2c_get_clientdata(client); |
641 | long val = simple_strtol(buf, NULL, 10); | 642 | long val = simple_strtol(buf, NULL, 10); |
642 | 643 | ||
643 | down(&data->update_lock); | 644 | mutex_lock(&data->update_lock); |
644 | data->temp_min[nr] = TEMP_TO_REG(val); | 645 | data->temp_min[nr] = TEMP_TO_REG(val); |
645 | lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]); | 646 | lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]); |
646 | up(&data->update_lock); | 647 | mutex_unlock(&data->update_lock); |
647 | return count; | 648 | return count; |
648 | } | 649 | } |
649 | static ssize_t show_temp_max(struct device *dev, char *buf, int nr) | 650 | static ssize_t show_temp_max(struct device *dev, char *buf, int nr) |
@@ -658,10 +659,10 @@ static ssize_t set_temp_max(struct device *dev, const char *buf, | |||
658 | struct lm85_data *data = i2c_get_clientdata(client); | 659 | struct lm85_data *data = i2c_get_clientdata(client); |
659 | long val = simple_strtol(buf, NULL, 10); | 660 | long val = simple_strtol(buf, NULL, 10); |
660 | 661 | ||
661 | down(&data->update_lock); | 662 | mutex_lock(&data->update_lock); |
662 | data->temp_max[nr] = TEMP_TO_REG(val); | 663 | data->temp_max[nr] = TEMP_TO_REG(val); |
663 | lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]); | 664 | lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]); |
664 | up(&data->update_lock); | 665 | mutex_unlock(&data->update_lock); |
665 | return count; | 666 | return count; |
666 | } | 667 | } |
667 | #define show_temp_reg(offset) \ | 668 | #define show_temp_reg(offset) \ |
@@ -713,12 +714,12 @@ static ssize_t set_pwm_auto_channels(struct device *dev, const char *buf, | |||
713 | struct lm85_data *data = i2c_get_clientdata(client); | 714 | struct lm85_data *data = i2c_get_clientdata(client); |
714 | long val = simple_strtol(buf, NULL, 10); | 715 | long val = simple_strtol(buf, NULL, 10); |
715 | 716 | ||
716 | down(&data->update_lock); | 717 | mutex_lock(&data->update_lock); |
717 | data->autofan[nr].config = (data->autofan[nr].config & (~0xe0)) | 718 | data->autofan[nr].config = (data->autofan[nr].config & (~0xe0)) |
718 | | ZONE_TO_REG(val) ; | 719 | | ZONE_TO_REG(val) ; |
719 | lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), | 720 | lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), |
720 | data->autofan[nr].config); | 721 | data->autofan[nr].config); |
721 | up(&data->update_lock); | 722 | mutex_unlock(&data->update_lock); |
722 | return count; | 723 | return count; |
723 | } | 724 | } |
724 | static ssize_t show_pwm_auto_pwm_min(struct device *dev, char *buf, int nr) | 725 | static ssize_t show_pwm_auto_pwm_min(struct device *dev, char *buf, int nr) |
@@ -733,11 +734,11 @@ static ssize_t set_pwm_auto_pwm_min(struct device *dev, const char *buf, | |||
733 | struct lm85_data *data = i2c_get_clientdata(client); | 734 | struct lm85_data *data = i2c_get_clientdata(client); |
734 | long val = simple_strtol(buf, NULL, 10); | 735 | long val = simple_strtol(buf, NULL, 10); |
735 | 736 | ||
736 | down(&data->update_lock); | 737 | mutex_lock(&data->update_lock); |
737 | data->autofan[nr].min_pwm = PWM_TO_REG(val); | 738 | data->autofan[nr].min_pwm = PWM_TO_REG(val); |
738 | lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr), | 739 | lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr), |
739 | data->autofan[nr].min_pwm); | 740 | data->autofan[nr].min_pwm); |
740 | up(&data->update_lock); | 741 | mutex_unlock(&data->update_lock); |
741 | return count; | 742 | return count; |
742 | } | 743 | } |
743 | static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, char *buf, int nr) | 744 | static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, char *buf, int nr) |
@@ -752,7 +753,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf, | |||
752 | struct lm85_data *data = i2c_get_clientdata(client); | 753 | struct lm85_data *data = i2c_get_clientdata(client); |
753 | long val = simple_strtol(buf, NULL, 10); | 754 | long val = simple_strtol(buf, NULL, 10); |
754 | 755 | ||
755 | down(&data->update_lock); | 756 | mutex_lock(&data->update_lock); |
756 | data->autofan[nr].min_off = val; | 757 | data->autofan[nr].min_off = val; |
757 | lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0] | 758 | lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0] |
758 | | data->syncpwm3 | 759 | | data->syncpwm3 |
@@ -760,7 +761,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf, | |||
760 | | (data->autofan[1].min_off ? 0x40 : 0) | 761 | | (data->autofan[1].min_off ? 0x40 : 0) |
761 | | (data->autofan[2].min_off ? 0x80 : 0) | 762 | | (data->autofan[2].min_off ? 0x80 : 0) |
762 | ); | 763 | ); |
763 | up(&data->update_lock); | 764 | mutex_unlock(&data->update_lock); |
764 | return count; | 765 | return count; |
765 | } | 766 | } |
766 | static ssize_t show_pwm_auto_pwm_freq(struct device *dev, char *buf, int nr) | 767 | static ssize_t show_pwm_auto_pwm_freq(struct device *dev, char *buf, int nr) |
@@ -775,13 +776,13 @@ static ssize_t set_pwm_auto_pwm_freq(struct device *dev, const char *buf, | |||
775 | struct lm85_data *data = i2c_get_clientdata(client); | 776 | struct lm85_data *data = i2c_get_clientdata(client); |
776 | long val = simple_strtol(buf, NULL, 10); | 777 | long val = simple_strtol(buf, NULL, 10); |
777 | 778 | ||
778 | down(&data->update_lock); | 779 | mutex_lock(&data->update_lock); |
779 | data->autofan[nr].freq = FREQ_TO_REG(val); | 780 | data->autofan[nr].freq = FREQ_TO_REG(val); |
780 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), | 781 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), |
781 | (data->zone[nr].range << 4) | 782 | (data->zone[nr].range << 4) |
782 | | data->autofan[nr].freq | 783 | | data->autofan[nr].freq |
783 | ); | 784 | ); |
784 | up(&data->update_lock); | 785 | mutex_unlock(&data->update_lock); |
785 | return count; | 786 | return count; |
786 | } | 787 | } |
787 | #define pwm_auto(offset) \ | 788 | #define pwm_auto(offset) \ |
@@ -857,7 +858,7 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf, | |||
857 | int min; | 858 | int min; |
858 | long val = simple_strtol(buf, NULL, 10); | 859 | long val = simple_strtol(buf, NULL, 10); |
859 | 860 | ||
860 | down(&data->update_lock); | 861 | mutex_lock(&data->update_lock); |
861 | min = TEMP_FROM_REG(data->zone[nr].limit); | 862 | min = TEMP_FROM_REG(data->zone[nr].limit); |
862 | data->zone[nr].off_desired = TEMP_TO_REG(val); | 863 | data->zone[nr].off_desired = TEMP_TO_REG(val); |
863 | data->zone[nr].hyst = HYST_TO_REG(min - val); | 864 | data->zone[nr].hyst = HYST_TO_REG(min - val); |
@@ -871,7 +872,7 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf, | |||
871 | (data->zone[2].hyst << 4) | 872 | (data->zone[2].hyst << 4) |
872 | ); | 873 | ); |
873 | } | 874 | } |
874 | up(&data->update_lock); | 875 | mutex_unlock(&data->update_lock); |
875 | return count; | 876 | return count; |
876 | } | 877 | } |
877 | static ssize_t show_temp_auto_temp_min(struct device *dev, char *buf, int nr) | 878 | static ssize_t show_temp_auto_temp_min(struct device *dev, char *buf, int nr) |
@@ -886,7 +887,7 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf, | |||
886 | struct lm85_data *data = i2c_get_clientdata(client); | 887 | struct lm85_data *data = i2c_get_clientdata(client); |
887 | long val = simple_strtol(buf, NULL, 10); | 888 | long val = simple_strtol(buf, NULL, 10); |
888 | 889 | ||
889 | down(&data->update_lock); | 890 | mutex_lock(&data->update_lock); |
890 | data->zone[nr].limit = TEMP_TO_REG(val); | 891 | data->zone[nr].limit = TEMP_TO_REG(val); |
891 | lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr), | 892 | lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr), |
892 | data->zone[nr].limit); | 893 | data->zone[nr].limit); |
@@ -913,7 +914,7 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf, | |||
913 | (data->zone[2].hyst << 4) | 914 | (data->zone[2].hyst << 4) |
914 | ); | 915 | ); |
915 | } | 916 | } |
916 | up(&data->update_lock); | 917 | mutex_unlock(&data->update_lock); |
917 | return count; | 918 | return count; |
918 | } | 919 | } |
919 | static ssize_t show_temp_auto_temp_max(struct device *dev, char *buf, int nr) | 920 | static ssize_t show_temp_auto_temp_max(struct device *dev, char *buf, int nr) |
@@ -930,7 +931,7 @@ static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf, | |||
930 | int min; | 931 | int min; |
931 | long val = simple_strtol(buf, NULL, 10); | 932 | long val = simple_strtol(buf, NULL, 10); |
932 | 933 | ||
933 | down(&data->update_lock); | 934 | mutex_lock(&data->update_lock); |
934 | min = TEMP_FROM_REG(data->zone[nr].limit); | 935 | min = TEMP_FROM_REG(data->zone[nr].limit); |
935 | data->zone[nr].max_desired = TEMP_TO_REG(val); | 936 | data->zone[nr].max_desired = TEMP_TO_REG(val); |
936 | data->zone[nr].range = RANGE_TO_REG( | 937 | data->zone[nr].range = RANGE_TO_REG( |
@@ -938,7 +939,7 @@ static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf, | |||
938 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), | 939 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), |
939 | ((data->zone[nr].range & 0x0f) << 4) | 940 | ((data->zone[nr].range & 0x0f) << 4) |
940 | | (data->autofan[nr].freq & 0x07)); | 941 | | (data->autofan[nr].freq & 0x07)); |
941 | up(&data->update_lock); | 942 | mutex_unlock(&data->update_lock); |
942 | return count; | 943 | return count; |
943 | } | 944 | } |
944 | static ssize_t show_temp_auto_temp_crit(struct device *dev, char *buf, int nr) | 945 | static ssize_t show_temp_auto_temp_crit(struct device *dev, char *buf, int nr) |
@@ -953,11 +954,11 @@ static ssize_t set_temp_auto_temp_crit(struct device *dev, const char *buf, | |||
953 | struct lm85_data *data = i2c_get_clientdata(client); | 954 | struct lm85_data *data = i2c_get_clientdata(client); |
954 | long val = simple_strtol(buf, NULL, 10); | 955 | long val = simple_strtol(buf, NULL, 10); |
955 | 956 | ||
956 | down(&data->update_lock); | 957 | mutex_lock(&data->update_lock); |
957 | data->zone[nr].critical = TEMP_TO_REG(val); | 958 | data->zone[nr].critical = TEMP_TO_REG(val); |
958 | lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr), | 959 | lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr), |
959 | data->zone[nr].critical); | 960 | data->zone[nr].critical); |
960 | up(&data->update_lock); | 961 | mutex_unlock(&data->update_lock); |
961 | return count; | 962 | return count; |
962 | } | 963 | } |
963 | #define temp_auto(offset) \ | 964 | #define temp_auto(offset) \ |
@@ -1149,7 +1150,7 @@ static int lm85_detect(struct i2c_adapter *adapter, int address, | |||
1149 | /* Fill in the remaining client fields */ | 1150 | /* Fill in the remaining client fields */ |
1150 | data->type = kind; | 1151 | data->type = kind; |
1151 | data->valid = 0; | 1152 | data->valid = 0; |
1152 | init_MUTEX(&data->update_lock); | 1153 | mutex_init(&data->update_lock); |
1153 | 1154 | ||
1154 | /* Tell the I2C layer a new client has arrived */ | 1155 | /* Tell the I2C layer a new client has arrived */ |
1155 | if ((err = i2c_attach_client(new_client))) | 1156 | if ((err = i2c_attach_client(new_client))) |
@@ -1368,7 +1369,7 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1368 | struct lm85_data *data = i2c_get_clientdata(client); | 1369 | struct lm85_data *data = i2c_get_clientdata(client); |
1369 | int i; | 1370 | int i; |
1370 | 1371 | ||
1371 | down(&data->update_lock); | 1372 | mutex_lock(&data->update_lock); |
1372 | 1373 | ||
1373 | if ( !data->valid || | 1374 | if ( !data->valid || |
1374 | time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) { | 1375 | time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) { |
@@ -1571,7 +1572,7 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1571 | 1572 | ||
1572 | data->valid = 1; | 1573 | data->valid = 1; |
1573 | 1574 | ||
1574 | up(&data->update_lock); | 1575 | mutex_unlock(&data->update_lock); |
1575 | 1576 | ||
1576 | return data; | 1577 | return data; |
1577 | } | 1578 | } |
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 6ba34c302d8d..e229daf666de 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c | |||
@@ -60,6 +60,7 @@ | |||
60 | #include <linux/hwmon.h> | 60 | #include <linux/hwmon.h> |
61 | #include <linux/hwmon-vid.h> | 61 | #include <linux/hwmon-vid.h> |
62 | #include <linux/err.h> | 62 | #include <linux/err.h> |
63 | #include <linux/mutex.h> | ||
63 | 64 | ||
64 | /* | 65 | /* |
65 | * Addresses to scan | 66 | * Addresses to scan |
@@ -176,7 +177,7 @@ static struct i2c_driver lm87_driver = { | |||
176 | struct lm87_data { | 177 | struct lm87_data { |
177 | struct i2c_client client; | 178 | struct i2c_client client; |
178 | struct class_device *class_dev; | 179 | struct class_device *class_dev; |
179 | struct semaphore update_lock; | 180 | struct mutex update_lock; |
180 | char valid; /* zero until following fields are valid */ | 181 | char valid; /* zero until following fields are valid */ |
181 | unsigned long last_updated; /* In jiffies */ | 182 | unsigned long last_updated; /* In jiffies */ |
182 | 183 | ||
@@ -253,11 +254,11 @@ static void set_in_min(struct device *dev, const char *buf, int nr) | |||
253 | struct lm87_data *data = i2c_get_clientdata(client); | 254 | struct lm87_data *data = i2c_get_clientdata(client); |
254 | long val = simple_strtol(buf, NULL, 10); | 255 | long val = simple_strtol(buf, NULL, 10); |
255 | 256 | ||
256 | down(&data->update_lock); | 257 | mutex_lock(&data->update_lock); |
257 | data->in_min[nr] = IN_TO_REG(val, data->in_scale[nr]); | 258 | data->in_min[nr] = IN_TO_REG(val, data->in_scale[nr]); |
258 | lm87_write_value(client, nr<6 ? LM87_REG_IN_MIN(nr) : | 259 | lm87_write_value(client, nr<6 ? LM87_REG_IN_MIN(nr) : |
259 | LM87_REG_AIN_MIN(nr-6), data->in_min[nr]); | 260 | LM87_REG_AIN_MIN(nr-6), data->in_min[nr]); |
260 | up(&data->update_lock); | 261 | mutex_unlock(&data->update_lock); |
261 | } | 262 | } |
262 | 263 | ||
263 | static void set_in_max(struct device *dev, const char *buf, int nr) | 264 | static void set_in_max(struct device *dev, const char *buf, int nr) |
@@ -266,11 +267,11 @@ static void set_in_max(struct device *dev, const char *buf, int nr) | |||
266 | struct lm87_data *data = i2c_get_clientdata(client); | 267 | struct lm87_data *data = i2c_get_clientdata(client); |
267 | long val = simple_strtol(buf, NULL, 10); | 268 | long val = simple_strtol(buf, NULL, 10); |
268 | 269 | ||
269 | down(&data->update_lock); | 270 | mutex_lock(&data->update_lock); |
270 | data->in_max[nr] = IN_TO_REG(val, data->in_scale[nr]); | 271 | data->in_max[nr] = IN_TO_REG(val, data->in_scale[nr]); |
271 | lm87_write_value(client, nr<6 ? LM87_REG_IN_MAX(nr) : | 272 | lm87_write_value(client, nr<6 ? LM87_REG_IN_MAX(nr) : |
272 | LM87_REG_AIN_MAX(nr-6), data->in_max[nr]); | 273 | LM87_REG_AIN_MAX(nr-6), data->in_max[nr]); |
273 | up(&data->update_lock); | 274 | mutex_unlock(&data->update_lock); |
274 | } | 275 | } |
275 | 276 | ||
276 | #define set_in(offset) \ | 277 | #define set_in(offset) \ |
@@ -327,10 +328,10 @@ static void set_temp_low(struct device *dev, const char *buf, int nr) | |||
327 | struct lm87_data *data = i2c_get_clientdata(client); | 328 | struct lm87_data *data = i2c_get_clientdata(client); |
328 | long val = simple_strtol(buf, NULL, 10); | 329 | long val = simple_strtol(buf, NULL, 10); |
329 | 330 | ||
330 | down(&data->update_lock); | 331 | mutex_lock(&data->update_lock); |
331 | data->temp_low[nr] = TEMP_TO_REG(val); | 332 | data->temp_low[nr] = TEMP_TO_REG(val); |
332 | lm87_write_value(client, LM87_REG_TEMP_LOW[nr], data->temp_low[nr]); | 333 | lm87_write_value(client, LM87_REG_TEMP_LOW[nr], data->temp_low[nr]); |
333 | up(&data->update_lock); | 334 | mutex_unlock(&data->update_lock); |
334 | } | 335 | } |
335 | 336 | ||
336 | static void set_temp_high(struct device *dev, const char *buf, int nr) | 337 | static void set_temp_high(struct device *dev, const char *buf, int nr) |
@@ -339,10 +340,10 @@ static void set_temp_high(struct device *dev, const char *buf, int nr) | |||
339 | struct lm87_data *data = i2c_get_clientdata(client); | 340 | struct lm87_data *data = i2c_get_clientdata(client); |
340 | long val = simple_strtol(buf, NULL, 10); | 341 | long val = simple_strtol(buf, NULL, 10); |
341 | 342 | ||
342 | down(&data->update_lock); | 343 | mutex_lock(&data->update_lock); |
343 | data->temp_high[nr] = TEMP_TO_REG(val); | 344 | data->temp_high[nr] = TEMP_TO_REG(val); |
344 | lm87_write_value(client, LM87_REG_TEMP_HIGH[nr], data->temp_high[nr]); | 345 | lm87_write_value(client, LM87_REG_TEMP_HIGH[nr], data->temp_high[nr]); |
345 | up(&data->update_lock); | 346 | mutex_unlock(&data->update_lock); |
346 | } | 347 | } |
347 | 348 | ||
348 | #define set_temp(offset) \ | 349 | #define set_temp(offset) \ |
@@ -411,11 +412,11 @@ static void set_fan_min(struct device *dev, const char *buf, int nr) | |||
411 | struct lm87_data *data = i2c_get_clientdata(client); | 412 | struct lm87_data *data = i2c_get_clientdata(client); |
412 | long val = simple_strtol(buf, NULL, 10); | 413 | long val = simple_strtol(buf, NULL, 10); |
413 | 414 | ||
414 | down(&data->update_lock); | 415 | mutex_lock(&data->update_lock); |
415 | data->fan_min[nr] = FAN_TO_REG(val, | 416 | data->fan_min[nr] = FAN_TO_REG(val, |
416 | FAN_DIV_FROM_REG(data->fan_div[nr])); | 417 | FAN_DIV_FROM_REG(data->fan_div[nr])); |
417 | lm87_write_value(client, LM87_REG_FAN_MIN(nr), data->fan_min[nr]); | 418 | lm87_write_value(client, LM87_REG_FAN_MIN(nr), data->fan_min[nr]); |
418 | up(&data->update_lock); | 419 | mutex_unlock(&data->update_lock); |
419 | } | 420 | } |
420 | 421 | ||
421 | /* Note: we save and restore the fan minimum here, because its value is | 422 | /* Note: we save and restore the fan minimum here, because its value is |
@@ -431,7 +432,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
431 | unsigned long min; | 432 | unsigned long min; |
432 | u8 reg; | 433 | u8 reg; |
433 | 434 | ||
434 | down(&data->update_lock); | 435 | mutex_lock(&data->update_lock); |
435 | min = FAN_FROM_REG(data->fan_min[nr], | 436 | min = FAN_FROM_REG(data->fan_min[nr], |
436 | FAN_DIV_FROM_REG(data->fan_div[nr])); | 437 | FAN_DIV_FROM_REG(data->fan_div[nr])); |
437 | 438 | ||
@@ -441,7 +442,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
441 | case 4: data->fan_div[nr] = 2; break; | 442 | case 4: data->fan_div[nr] = 2; break; |
442 | case 8: data->fan_div[nr] = 3; break; | 443 | case 8: data->fan_div[nr] = 3; break; |
443 | default: | 444 | default: |
444 | up(&data->update_lock); | 445 | mutex_unlock(&data->update_lock); |
445 | return -EINVAL; | 446 | return -EINVAL; |
446 | } | 447 | } |
447 | 448 | ||
@@ -459,7 +460,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
459 | data->fan_min[nr] = FAN_TO_REG(min, val); | 460 | data->fan_min[nr] = FAN_TO_REG(min, val); |
460 | lm87_write_value(client, LM87_REG_FAN_MIN(nr), | 461 | lm87_write_value(client, LM87_REG_FAN_MIN(nr), |
461 | data->fan_min[nr]); | 462 | data->fan_min[nr]); |
462 | up(&data->update_lock); | 463 | mutex_unlock(&data->update_lock); |
463 | 464 | ||
464 | return count; | 465 | return count; |
465 | } | 466 | } |
@@ -522,10 +523,10 @@ static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const | |||
522 | struct lm87_data *data = i2c_get_clientdata(client); | 523 | struct lm87_data *data = i2c_get_clientdata(client); |
523 | long val = simple_strtol(buf, NULL, 10); | 524 | long val = simple_strtol(buf, NULL, 10); |
524 | 525 | ||
525 | down(&data->update_lock); | 526 | mutex_lock(&data->update_lock); |
526 | data->aout = AOUT_TO_REG(val); | 527 | data->aout = AOUT_TO_REG(val); |
527 | lm87_write_value(client, LM87_REG_AOUT, data->aout); | 528 | lm87_write_value(client, LM87_REG_AOUT, data->aout); |
528 | up(&data->update_lock); | 529 | mutex_unlock(&data->update_lock); |
529 | return count; | 530 | return count; |
530 | } | 531 | } |
531 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); | 532 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); |
@@ -589,7 +590,7 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
589 | /* We can fill in the remaining client fields */ | 590 | /* We can fill in the remaining client fields */ |
590 | strlcpy(new_client->name, "lm87", I2C_NAME_SIZE); | 591 | strlcpy(new_client->name, "lm87", I2C_NAME_SIZE); |
591 | data->valid = 0; | 592 | data->valid = 0; |
592 | init_MUTEX(&data->update_lock); | 593 | mutex_init(&data->update_lock); |
593 | 594 | ||
594 | /* Tell the I2C layer a new client has arrived */ | 595 | /* Tell the I2C layer a new client has arrived */ |
595 | if ((err = i2c_attach_client(new_client))) | 596 | if ((err = i2c_attach_client(new_client))) |
@@ -744,7 +745,7 @@ static struct lm87_data *lm87_update_device(struct device *dev) | |||
744 | struct i2c_client *client = to_i2c_client(dev); | 745 | struct i2c_client *client = to_i2c_client(dev); |
745 | struct lm87_data *data = i2c_get_clientdata(client); | 746 | struct lm87_data *data = i2c_get_clientdata(client); |
746 | 747 | ||
747 | down(&data->update_lock); | 748 | mutex_lock(&data->update_lock); |
748 | 749 | ||
749 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | 750 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
750 | int i, j; | 751 | int i, j; |
@@ -813,7 +814,7 @@ static struct lm87_data *lm87_update_device(struct device *dev) | |||
813 | data->valid = 1; | 814 | data->valid = 1; |
814 | } | 815 | } |
815 | 816 | ||
816 | up(&data->update_lock); | 817 | mutex_unlock(&data->update_lock); |
817 | 818 | ||
818 | return data; | 819 | return data; |
819 | } | 820 | } |
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 5679464447cc..d9eeaf7585bd 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
@@ -78,6 +78,7 @@ | |||
78 | #include <linux/hwmon-sysfs.h> | 78 | #include <linux/hwmon-sysfs.h> |
79 | #include <linux/hwmon.h> | 79 | #include <linux/hwmon.h> |
80 | #include <linux/err.h> | 80 | #include <linux/err.h> |
81 | #include <linux/mutex.h> | ||
81 | 82 | ||
82 | /* | 83 | /* |
83 | * Addresses to scan | 84 | * Addresses to scan |
@@ -201,7 +202,7 @@ static struct i2c_driver lm90_driver = { | |||
201 | struct lm90_data { | 202 | struct lm90_data { |
202 | struct i2c_client client; | 203 | struct i2c_client client; |
203 | struct class_device *class_dev; | 204 | struct class_device *class_dev; |
204 | struct semaphore update_lock; | 205 | struct mutex update_lock; |
205 | char valid; /* zero until following fields are valid */ | 206 | char valid; /* zero until following fields are valid */ |
206 | unsigned long last_updated; /* in jiffies */ | 207 | unsigned long last_updated; /* in jiffies */ |
207 | int kind; | 208 | int kind; |
@@ -247,13 +248,13 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, | |||
247 | long val = simple_strtol(buf, NULL, 10); | 248 | long val = simple_strtol(buf, NULL, 10); |
248 | int nr = attr->index; | 249 | int nr = attr->index; |
249 | 250 | ||
250 | down(&data->update_lock); | 251 | mutex_lock(&data->update_lock); |
251 | if (data->kind == adt7461) | 252 | if (data->kind == adt7461) |
252 | data->temp8[nr] = TEMP1_TO_REG_ADT7461(val); | 253 | data->temp8[nr] = TEMP1_TO_REG_ADT7461(val); |
253 | else | 254 | else |
254 | data->temp8[nr] = TEMP1_TO_REG(val); | 255 | data->temp8[nr] = TEMP1_TO_REG(val); |
255 | i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]); | 256 | i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]); |
256 | up(&data->update_lock); | 257 | mutex_unlock(&data->update_lock); |
257 | return count; | 258 | return count; |
258 | } | 259 | } |
259 | 260 | ||
@@ -281,7 +282,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, | |||
281 | long val = simple_strtol(buf, NULL, 10); | 282 | long val = simple_strtol(buf, NULL, 10); |
282 | int nr = attr->index; | 283 | int nr = attr->index; |
283 | 284 | ||
284 | down(&data->update_lock); | 285 | mutex_lock(&data->update_lock); |
285 | if (data->kind == adt7461) | 286 | if (data->kind == adt7461) |
286 | data->temp11[nr] = TEMP2_TO_REG_ADT7461(val); | 287 | data->temp11[nr] = TEMP2_TO_REG_ADT7461(val); |
287 | else | 288 | else |
@@ -290,7 +291,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, | |||
290 | data->temp11[nr] >> 8); | 291 | data->temp11[nr] >> 8); |
291 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], | 292 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], |
292 | data->temp11[nr] & 0xff); | 293 | data->temp11[nr] & 0xff); |
293 | up(&data->update_lock); | 294 | mutex_unlock(&data->update_lock); |
294 | return count; | 295 | return count; |
295 | } | 296 | } |
296 | 297 | ||
@@ -311,11 +312,11 @@ static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy, | |||
311 | long val = simple_strtol(buf, NULL, 10); | 312 | long val = simple_strtol(buf, NULL, 10); |
312 | long hyst; | 313 | long hyst; |
313 | 314 | ||
314 | down(&data->update_lock); | 315 | mutex_lock(&data->update_lock); |
315 | hyst = TEMP1_FROM_REG(data->temp8[3]) - val; | 316 | hyst = TEMP1_FROM_REG(data->temp8[3]) - val; |
316 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, | 317 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, |
317 | HYST_TO_REG(hyst)); | 318 | HYST_TO_REG(hyst)); |
318 | up(&data->update_lock); | 319 | mutex_unlock(&data->update_lock); |
319 | return count; | 320 | return count; |
320 | } | 321 | } |
321 | 322 | ||
@@ -558,7 +559,7 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
558 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 559 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
559 | data->valid = 0; | 560 | data->valid = 0; |
560 | data->kind = kind; | 561 | data->kind = kind; |
561 | init_MUTEX(&data->update_lock); | 562 | mutex_init(&data->update_lock); |
562 | 563 | ||
563 | /* Tell the I2C layer a new client has arrived */ | 564 | /* Tell the I2C layer a new client has arrived */ |
564 | if ((err = i2c_attach_client(new_client))) | 565 | if ((err = i2c_attach_client(new_client))) |
@@ -646,7 +647,7 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
646 | struct i2c_client *client = to_i2c_client(dev); | 647 | struct i2c_client *client = to_i2c_client(dev); |
647 | struct lm90_data *data = i2c_get_clientdata(client); | 648 | struct lm90_data *data = i2c_get_clientdata(client); |
648 | 649 | ||
649 | down(&data->update_lock); | 650 | mutex_lock(&data->update_lock); |
650 | 651 | ||
651 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 652 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
652 | u8 oldh, newh, l; | 653 | u8 oldh, newh, l; |
@@ -692,7 +693,7 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
692 | data->valid = 1; | 693 | data->valid = 1; |
693 | } | 694 | } |
694 | 695 | ||
695 | up(&data->update_lock); | 696 | mutex_unlock(&data->update_lock); |
696 | 697 | ||
697 | return data; | 698 | return data; |
698 | } | 699 | } |
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index b0c4cb730a7e..197f77226dc4 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/i2c.h> | 46 | #include <linux/i2c.h> |
47 | #include <linux/hwmon.h> | 47 | #include <linux/hwmon.h> |
48 | #include <linux/err.h> | 48 | #include <linux/err.h> |
49 | #include <linux/mutex.h> | ||
49 | 50 | ||
50 | /* The LM92 and MAX6635 have 2 two-state pins for address selection, | 51 | /* The LM92 and MAX6635 have 2 two-state pins for address selection, |
51 | resulting in 4 possible addresses. */ | 52 | resulting in 4 possible addresses. */ |
@@ -96,7 +97,7 @@ static struct i2c_driver lm92_driver; | |||
96 | struct lm92_data { | 97 | struct lm92_data { |
97 | struct i2c_client client; | 98 | struct i2c_client client; |
98 | struct class_device *class_dev; | 99 | struct class_device *class_dev; |
99 | struct semaphore update_lock; | 100 | struct mutex update_lock; |
100 | char valid; /* zero until following fields are valid */ | 101 | char valid; /* zero until following fields are valid */ |
101 | unsigned long last_updated; /* in jiffies */ | 102 | unsigned long last_updated; /* in jiffies */ |
102 | 103 | ||
@@ -114,7 +115,7 @@ static struct lm92_data *lm92_update_device(struct device *dev) | |||
114 | struct i2c_client *client = to_i2c_client(dev); | 115 | struct i2c_client *client = to_i2c_client(dev); |
115 | struct lm92_data *data = i2c_get_clientdata(client); | 116 | struct lm92_data *data = i2c_get_clientdata(client); |
116 | 117 | ||
117 | down(&data->update_lock); | 118 | mutex_lock(&data->update_lock); |
118 | 119 | ||
119 | if (time_after(jiffies, data->last_updated + HZ) | 120 | if (time_after(jiffies, data->last_updated + HZ) |
120 | || !data->valid) { | 121 | || !data->valid) { |
@@ -134,7 +135,7 @@ static struct lm92_data *lm92_update_device(struct device *dev) | |||
134 | data->valid = 1; | 135 | data->valid = 1; |
135 | } | 136 | } |
136 | 137 | ||
137 | up(&data->update_lock); | 138 | mutex_unlock(&data->update_lock); |
138 | 139 | ||
139 | return data; | 140 | return data; |
140 | } | 141 | } |
@@ -158,10 +159,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co | |||
158 | struct lm92_data *data = i2c_get_clientdata(client); \ | 159 | struct lm92_data *data = i2c_get_clientdata(client); \ |
159 | long val = simple_strtol(buf, NULL, 10); \ | 160 | long val = simple_strtol(buf, NULL, 10); \ |
160 | \ | 161 | \ |
161 | down(&data->update_lock); \ | 162 | mutex_lock(&data->update_lock); \ |
162 | data->value = TEMP_TO_REG(val); \ | 163 | data->value = TEMP_TO_REG(val); \ |
163 | i2c_smbus_write_word_data(client, reg, swab16(data->value)); \ | 164 | i2c_smbus_write_word_data(client, reg, swab16(data->value)); \ |
164 | up(&data->update_lock); \ | 165 | mutex_unlock(&data->update_lock); \ |
165 | return count; \ | 166 | return count; \ |
166 | } | 167 | } |
167 | set_temp(temp1_crit, LM92_REG_TEMP_CRIT); | 168 | set_temp(temp1_crit, LM92_REG_TEMP_CRIT); |
@@ -194,11 +195,11 @@ static ssize_t set_temp1_crit_hyst(struct device *dev, struct device_attribute * | |||
194 | struct lm92_data *data = i2c_get_clientdata(client); | 195 | struct lm92_data *data = i2c_get_clientdata(client); |
195 | long val = simple_strtol(buf, NULL, 10); | 196 | long val = simple_strtol(buf, NULL, 10); |
196 | 197 | ||
197 | down(&data->update_lock); | 198 | mutex_lock(&data->update_lock); |
198 | data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val; | 199 | data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val; |
199 | i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST, | 200 | i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST, |
200 | swab16(TEMP_TO_REG(data->temp1_hyst))); | 201 | swab16(TEMP_TO_REG(data->temp1_hyst))); |
201 | up(&data->update_lock); | 202 | mutex_unlock(&data->update_lock); |
202 | return count; | 203 | return count; |
203 | } | 204 | } |
204 | 205 | ||
@@ -348,7 +349,7 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind) | |||
348 | /* Fill in the remaining client fields */ | 349 | /* Fill in the remaining client fields */ |
349 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 350 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
350 | data->valid = 0; | 351 | data->valid = 0; |
351 | init_MUTEX(&data->update_lock); | 352 | mutex_init(&data->update_lock); |
352 | 353 | ||
353 | /* Tell the i2c subsystem a new client has arrived */ | 354 | /* Tell the i2c subsystem a new client has arrived */ |
354 | if ((err = i2c_attach_client(new_client))) | 355 | if ((err = i2c_attach_client(new_client))) |
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 3abe330b22ce..b4135b5971f4 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
34 | #include <linux/hwmon.h> | 34 | #include <linux/hwmon.h> |
35 | #include <linux/err.h> | 35 | #include <linux/err.h> |
36 | #include <linux/mutex.h> | ||
36 | 37 | ||
37 | static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, | 38 | static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, |
38 | 0x29, 0x2a, 0x2b, | 39 | 0x29, 0x2a, 0x2b, |
@@ -104,7 +105,7 @@ static struct i2c_driver max1619_driver = { | |||
104 | struct max1619_data { | 105 | struct max1619_data { |
105 | struct i2c_client client; | 106 | struct i2c_client client; |
106 | struct class_device *class_dev; | 107 | struct class_device *class_dev; |
107 | struct semaphore update_lock; | 108 | struct mutex update_lock; |
108 | char valid; /* zero until following fields are valid */ | 109 | char valid; /* zero until following fields are valid */ |
109 | unsigned long last_updated; /* in jiffies */ | 110 | unsigned long last_updated; /* in jiffies */ |
110 | 111 | ||
@@ -141,10 +142,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co | |||
141 | struct max1619_data *data = i2c_get_clientdata(client); \ | 142 | struct max1619_data *data = i2c_get_clientdata(client); \ |
142 | long val = simple_strtol(buf, NULL, 10); \ | 143 | long val = simple_strtol(buf, NULL, 10); \ |
143 | \ | 144 | \ |
144 | down(&data->update_lock); \ | 145 | mutex_lock(&data->update_lock); \ |
145 | data->value = TEMP_TO_REG(val); \ | 146 | data->value = TEMP_TO_REG(val); \ |
146 | i2c_smbus_write_byte_data(client, reg, data->value); \ | 147 | i2c_smbus_write_byte_data(client, reg, data->value); \ |
147 | up(&data->update_lock); \ | 148 | mutex_unlock(&data->update_lock); \ |
148 | return count; \ | 149 | return count; \ |
149 | } | 150 | } |
150 | 151 | ||
@@ -262,7 +263,7 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind) | |||
262 | /* We can fill in the remaining client fields */ | 263 | /* We can fill in the remaining client fields */ |
263 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 264 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
264 | data->valid = 0; | 265 | data->valid = 0; |
265 | init_MUTEX(&data->update_lock); | 266 | mutex_init(&data->update_lock); |
266 | 267 | ||
267 | /* Tell the I2C layer a new client has arrived */ | 268 | /* Tell the I2C layer a new client has arrived */ |
268 | if ((err = i2c_attach_client(new_client))) | 269 | if ((err = i2c_attach_client(new_client))) |
@@ -330,7 +331,7 @@ static struct max1619_data *max1619_update_device(struct device *dev) | |||
330 | struct i2c_client *client = to_i2c_client(dev); | 331 | struct i2c_client *client = to_i2c_client(dev); |
331 | struct max1619_data *data = i2c_get_clientdata(client); | 332 | struct max1619_data *data = i2c_get_clientdata(client); |
332 | 333 | ||
333 | down(&data->update_lock); | 334 | mutex_lock(&data->update_lock); |
334 | 335 | ||
335 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 336 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
336 | dev_dbg(&client->dev, "Updating max1619 data.\n"); | 337 | dev_dbg(&client->dev, "Updating max1619 data.\n"); |
@@ -353,7 +354,7 @@ static struct max1619_data *max1619_update_device(struct device *dev) | |||
353 | data->valid = 1; | 354 | data->valid = 1; |
354 | } | 355 | } |
355 | 356 | ||
356 | up(&data->update_lock); | 357 | mutex_unlock(&data->update_lock); |
357 | 358 | ||
358 | return data; | 359 | return data; |
359 | } | 360 | } |
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index f161e88e3bb6..ae05e483a778 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include <linux/hwmon-sysfs.h> | 43 | #include <linux/hwmon-sysfs.h> |
44 | #include <linux/hwmon-vid.h> | 44 | #include <linux/hwmon-vid.h> |
45 | #include <linux/err.h> | 45 | #include <linux/err.h> |
46 | #include <linux/mutex.h> | ||
46 | #include <asm/io.h> | 47 | #include <asm/io.h> |
47 | 48 | ||
48 | static u8 devid; | 49 | static u8 devid; |
@@ -183,8 +184,8 @@ static inline u8 PWM_TO_REG(int val, int inv) | |||
183 | struct pc87360_data { | 184 | struct pc87360_data { |
184 | struct i2c_client client; | 185 | struct i2c_client client; |
185 | struct class_device *class_dev; | 186 | struct class_device *class_dev; |
186 | struct semaphore lock; | 187 | struct mutex lock; |
187 | struct semaphore update_lock; | 188 | struct mutex update_lock; |
188 | char valid; /* !=0 if following fields are valid */ | 189 | char valid; /* !=0 if following fields are valid */ |
189 | unsigned long last_updated; /* In jiffies */ | 190 | unsigned long last_updated; /* In jiffies */ |
190 | 191 | ||
@@ -283,7 +284,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr, | |||
283 | struct pc87360_data *data = i2c_get_clientdata(client); | 284 | struct pc87360_data *data = i2c_get_clientdata(client); |
284 | long fan_min = simple_strtol(buf, NULL, 10); | 285 | long fan_min = simple_strtol(buf, NULL, 10); |
285 | 286 | ||
286 | down(&data->update_lock); | 287 | mutex_lock(&data->update_lock); |
287 | fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index])); | 288 | fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index])); |
288 | 289 | ||
289 | /* If it wouldn't fit, change clock divisor */ | 290 | /* If it wouldn't fit, change clock divisor */ |
@@ -300,23 +301,31 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr, | |||
300 | /* Write new divider, preserve alarm bits */ | 301 | /* Write new divider, preserve alarm bits */ |
301 | pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(attr->index), | 302 | pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(attr->index), |
302 | data->fan_status[attr->index] & 0xF9); | 303 | data->fan_status[attr->index] & 0xF9); |
303 | up(&data->update_lock); | 304 | mutex_unlock(&data->update_lock); |
304 | 305 | ||
305 | return count; | 306 | return count; |
306 | } | 307 | } |
307 | 308 | ||
308 | #define show_and_set_fan(offset) \ | 309 | static struct sensor_device_attribute fan_input[] = { |
309 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | 310 | SENSOR_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0), |
310 | show_fan_input, NULL, offset-1); \ | 311 | SENSOR_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1), |
311 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IWUSR | S_IRUGO, \ | 312 | SENSOR_ATTR(fan3_input, S_IRUGO, show_fan_input, NULL, 2), |
312 | show_fan_min, set_fan_min, offset-1); \ | 313 | }; |
313 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | 314 | static struct sensor_device_attribute fan_status[] = { |
314 | show_fan_div, NULL, offset-1); \ | 315 | SENSOR_ATTR(fan1_status, S_IRUGO, show_fan_status, NULL, 0), |
315 | static SENSOR_DEVICE_ATTR(fan##offset##_status, S_IRUGO, \ | 316 | SENSOR_ATTR(fan2_status, S_IRUGO, show_fan_status, NULL, 1), |
316 | show_fan_status, NULL, offset-1); | 317 | SENSOR_ATTR(fan3_status, S_IRUGO, show_fan_status, NULL, 2), |
317 | show_and_set_fan(1) | 318 | }; |
318 | show_and_set_fan(2) | 319 | static struct sensor_device_attribute fan_div[] = { |
319 | show_and_set_fan(3) | 320 | SENSOR_ATTR(fan1_div, S_IRUGO, show_fan_div, NULL, 0), |
321 | SENSOR_ATTR(fan2_div, S_IRUGO, show_fan_div, NULL, 1), | ||
322 | SENSOR_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2), | ||
323 | }; | ||
324 | static struct sensor_device_attribute fan_min[] = { | ||
325 | SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 0), | ||
326 | SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 1), | ||
327 | SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 2), | ||
328 | }; | ||
320 | 329 | ||
321 | static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf) | 330 | static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf) |
322 | { | 331 | { |
@@ -335,21 +344,20 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, con | |||
335 | struct pc87360_data *data = i2c_get_clientdata(client); | 344 | struct pc87360_data *data = i2c_get_clientdata(client); |
336 | long val = simple_strtol(buf, NULL, 10); | 345 | long val = simple_strtol(buf, NULL, 10); |
337 | 346 | ||
338 | down(&data->update_lock); | 347 | mutex_lock(&data->update_lock); |
339 | data->pwm[attr->index] = PWM_TO_REG(val, | 348 | data->pwm[attr->index] = PWM_TO_REG(val, |
340 | FAN_CONFIG_INVERT(data->fan_conf, attr->index)); | 349 | FAN_CONFIG_INVERT(data->fan_conf, attr->index)); |
341 | pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index), | 350 | pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index), |
342 | data->pwm[attr->index]); | 351 | data->pwm[attr->index]); |
343 | up(&data->update_lock); | 352 | mutex_unlock(&data->update_lock); |
344 | return count; | 353 | return count; |
345 | } | 354 | } |
346 | 355 | ||
347 | #define show_and_set_pwm(offset) \ | 356 | static struct sensor_device_attribute pwm[] = { |
348 | static SENSOR_DEVICE_ATTR(pwm##offset, S_IWUSR | S_IRUGO, \ | 357 | SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0), |
349 | show_pwm, set_pwm, offset-1); | 358 | SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1), |
350 | show_and_set_pwm(1) | 359 | SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2), |
351 | show_and_set_pwm(2) | 360 | }; |
352 | show_and_set_pwm(3) | ||
353 | 361 | ||
354 | static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf) | 362 | static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf) |
355 | { | 363 | { |
@@ -386,11 +394,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *devattr, | |||
386 | struct pc87360_data *data = i2c_get_clientdata(client); | 394 | struct pc87360_data *data = i2c_get_clientdata(client); |
387 | long val = simple_strtol(buf, NULL, 10); | 395 | long val = simple_strtol(buf, NULL, 10); |
388 | 396 | ||
389 | down(&data->update_lock); | 397 | mutex_lock(&data->update_lock); |
390 | data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); | 398 | data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); |
391 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MIN, | 399 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MIN, |
392 | data->in_min[attr->index]); | 400 | data->in_min[attr->index]); |
393 | up(&data->update_lock); | 401 | mutex_unlock(&data->update_lock); |
394 | return count; | 402 | return count; |
395 | } | 403 | } |
396 | static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf, | 404 | static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf, |
@@ -401,35 +409,67 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, | |||
401 | struct pc87360_data *data = i2c_get_clientdata(client); | 409 | struct pc87360_data *data = i2c_get_clientdata(client); |
402 | long val = simple_strtol(buf, NULL, 10); | 410 | long val = simple_strtol(buf, NULL, 10); |
403 | 411 | ||
404 | down(&data->update_lock); | 412 | mutex_lock(&data->update_lock); |
405 | data->in_max[attr->index] = IN_TO_REG(val, | 413 | data->in_max[attr->index] = IN_TO_REG(val, |
406 | data->in_vref); | 414 | data->in_vref); |
407 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MAX, | 415 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MAX, |
408 | data->in_max[attr->index]); | 416 | data->in_max[attr->index]); |
409 | up(&data->update_lock); | 417 | mutex_unlock(&data->update_lock); |
410 | return count; | 418 | return count; |
411 | } | 419 | } |
412 | 420 | ||
413 | #define show_and_set_in(offset) \ | 421 | static struct sensor_device_attribute in_input[] = { |
414 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ | 422 | SENSOR_ATTR(in0_input, S_IRUGO, show_in_input, NULL, 0), |
415 | show_in_input, NULL, offset); \ | 423 | SENSOR_ATTR(in1_input, S_IRUGO, show_in_input, NULL, 1), |
416 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ | 424 | SENSOR_ATTR(in2_input, S_IRUGO, show_in_input, NULL, 2), |
417 | show_in_min, set_in_min, offset); \ | 425 | SENSOR_ATTR(in3_input, S_IRUGO, show_in_input, NULL, 3), |
418 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \ | 426 | SENSOR_ATTR(in4_input, S_IRUGO, show_in_input, NULL, 4), |
419 | show_in_max, set_in_max, offset); \ | 427 | SENSOR_ATTR(in5_input, S_IRUGO, show_in_input, NULL, 5), |
420 | static SENSOR_DEVICE_ATTR(in##offset##_status, S_IRUGO, \ | 428 | SENSOR_ATTR(in6_input, S_IRUGO, show_in_input, NULL, 6), |
421 | show_in_status, NULL, offset); | 429 | SENSOR_ATTR(in7_input, S_IRUGO, show_in_input, NULL, 7), |
422 | show_and_set_in(0) | 430 | SENSOR_ATTR(in8_input, S_IRUGO, show_in_input, NULL, 8), |
423 | show_and_set_in(1) | 431 | SENSOR_ATTR(in9_input, S_IRUGO, show_in_input, NULL, 9), |
424 | show_and_set_in(2) | 432 | SENSOR_ATTR(in10_input, S_IRUGO, show_in_input, NULL, 10), |
425 | show_and_set_in(3) | 433 | }; |
426 | show_and_set_in(4) | 434 | static struct sensor_device_attribute in_status[] = { |
427 | show_and_set_in(5) | 435 | SENSOR_ATTR(in0_status, S_IRUGO, show_in_status, NULL, 0), |
428 | show_and_set_in(6) | 436 | SENSOR_ATTR(in1_status, S_IRUGO, show_in_status, NULL, 1), |
429 | show_and_set_in(7) | 437 | SENSOR_ATTR(in2_status, S_IRUGO, show_in_status, NULL, 2), |
430 | show_and_set_in(8) | 438 | SENSOR_ATTR(in3_status, S_IRUGO, show_in_status, NULL, 3), |
431 | show_and_set_in(9) | 439 | SENSOR_ATTR(in4_status, S_IRUGO, show_in_status, NULL, 4), |
432 | show_and_set_in(10) | 440 | SENSOR_ATTR(in5_status, S_IRUGO, show_in_status, NULL, 5), |
441 | SENSOR_ATTR(in6_status, S_IRUGO, show_in_status, NULL, 6), | ||
442 | SENSOR_ATTR(in7_status, S_IRUGO, show_in_status, NULL, 7), | ||
443 | SENSOR_ATTR(in8_status, S_IRUGO, show_in_status, NULL, 8), | ||
444 | SENSOR_ATTR(in9_status, S_IRUGO, show_in_status, NULL, 9), | ||
445 | SENSOR_ATTR(in10_status, S_IRUGO, show_in_status, NULL, 10), | ||
446 | }; | ||
447 | static struct sensor_device_attribute in_min[] = { | ||
448 | SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 0), | ||
449 | SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 1), | ||
450 | SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 2), | ||
451 | SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 3), | ||
452 | SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 4), | ||
453 | SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 5), | ||
454 | SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 6), | ||
455 | SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 7), | ||
456 | SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 8), | ||
457 | SENSOR_ATTR(in9_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 9), | ||
458 | SENSOR_ATTR(in10_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 10), | ||
459 | }; | ||
460 | static struct sensor_device_attribute in_max[] = { | ||
461 | SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 0), | ||
462 | SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 1), | ||
463 | SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 2), | ||
464 | SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 3), | ||
465 | SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 4), | ||
466 | SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 5), | ||
467 | SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 6), | ||
468 | SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 7), | ||
469 | SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 8), | ||
470 | SENSOR_ATTR(in9_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 9), | ||
471 | SENSOR_ATTR(in10_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 10), | ||
472 | }; | ||
433 | 473 | ||
434 | static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf) | 474 | static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf) |
435 | { | 475 | { |
@@ -473,11 +513,11 @@ static ssize_t set_therm_min(struct device *dev, struct device_attribute *devatt | |||
473 | struct pc87360_data *data = i2c_get_clientdata(client); | 513 | struct pc87360_data *data = i2c_get_clientdata(client); |
474 | long val = simple_strtol(buf, NULL, 10); | 514 | long val = simple_strtol(buf, NULL, 10); |
475 | 515 | ||
476 | down(&data->update_lock); | 516 | mutex_lock(&data->update_lock); |
477 | data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); | 517 | data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); |
478 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MIN, | 518 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MIN, |
479 | data->in_min[attr->index]); | 519 | data->in_min[attr->index]); |
480 | up(&data->update_lock); | 520 | mutex_unlock(&data->update_lock); |
481 | return count; | 521 | return count; |
482 | } | 522 | } |
483 | static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf, | 523 | static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf, |
@@ -488,11 +528,11 @@ static ssize_t set_therm_max(struct device *dev, struct device_attribute *devatt | |||
488 | struct pc87360_data *data = i2c_get_clientdata(client); | 528 | struct pc87360_data *data = i2c_get_clientdata(client); |
489 | long val = simple_strtol(buf, NULL, 10); | 529 | long val = simple_strtol(buf, NULL, 10); |
490 | 530 | ||
491 | down(&data->update_lock); | 531 | mutex_lock(&data->update_lock); |
492 | data->in_max[attr->index] = IN_TO_REG(val, data->in_vref); | 532 | data->in_max[attr->index] = IN_TO_REG(val, data->in_vref); |
493 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MAX, | 533 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MAX, |
494 | data->in_max[attr->index]); | 534 | data->in_max[attr->index]); |
495 | up(&data->update_lock); | 535 | mutex_unlock(&data->update_lock); |
496 | return count; | 536 | return count; |
497 | } | 537 | } |
498 | static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf, | 538 | static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf, |
@@ -503,28 +543,51 @@ static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devat | |||
503 | struct pc87360_data *data = i2c_get_clientdata(client); | 543 | struct pc87360_data *data = i2c_get_clientdata(client); |
504 | long val = simple_strtol(buf, NULL, 10); | 544 | long val = simple_strtol(buf, NULL, 10); |
505 | 545 | ||
506 | down(&data->update_lock); | 546 | mutex_lock(&data->update_lock); |
507 | data->in_crit[attr->index-11] = IN_TO_REG(val, data->in_vref); | 547 | data->in_crit[attr->index-11] = IN_TO_REG(val, data->in_vref); |
508 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_CRIT, | 548 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_CRIT, |
509 | data->in_crit[attr->index-11]); | 549 | data->in_crit[attr->index-11]); |
510 | up(&data->update_lock); | 550 | mutex_unlock(&data->update_lock); |
511 | return count; | 551 | return count; |
512 | } | 552 | } |
513 | 553 | ||
514 | #define show_and_set_therm(offset) \ | 554 | /* the +11 term below reflects the fact that VLM units 11,12,13 are |
515 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | 555 | used in the chip to measure voltage across the thermistors |
516 | show_therm_input, NULL, 11+offset-4); \ | 556 | */ |
517 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ | 557 | static struct sensor_device_attribute therm_input[] = { |
518 | show_therm_min, set_therm_min, 11+offset-4); \ | 558 | SENSOR_ATTR(temp4_input, S_IRUGO, show_therm_input, NULL, 0+11), |
519 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ | 559 | SENSOR_ATTR(temp5_input, S_IRUGO, show_therm_input, NULL, 1+11), |
520 | show_therm_max, set_therm_max, 11+offset-4); \ | 560 | SENSOR_ATTR(temp6_input, S_IRUGO, show_therm_input, NULL, 2+11), |
521 | static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ | 561 | }; |
522 | show_therm_crit, set_therm_crit, 11+offset-4); \ | 562 | static struct sensor_device_attribute therm_status[] = { |
523 | static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ | 563 | SENSOR_ATTR(temp4_status, S_IRUGO, show_therm_status, NULL, 0+11), |
524 | show_therm_status, NULL, 11+offset-4); | 564 | SENSOR_ATTR(temp5_status, S_IRUGO, show_therm_status, NULL, 1+11), |
525 | show_and_set_therm(4) | 565 | SENSOR_ATTR(temp6_status, S_IRUGO, show_therm_status, NULL, 2+11), |
526 | show_and_set_therm(5) | 566 | }; |
527 | show_and_set_therm(6) | 567 | static struct sensor_device_attribute therm_min[] = { |
568 | SENSOR_ATTR(temp4_min, S_IRUGO | S_IWUSR, | ||
569 | show_therm_min, set_therm_min, 0+11), | ||
570 | SENSOR_ATTR(temp5_min, S_IRUGO | S_IWUSR, | ||
571 | show_therm_min, set_therm_min, 1+11), | ||
572 | SENSOR_ATTR(temp6_min, S_IRUGO | S_IWUSR, | ||
573 | show_therm_min, set_therm_min, 2+11), | ||
574 | }; | ||
575 | static struct sensor_device_attribute therm_max[] = { | ||
576 | SENSOR_ATTR(temp4_max, S_IRUGO | S_IWUSR, | ||
577 | show_therm_max, set_therm_max, 0+11), | ||
578 | SENSOR_ATTR(temp5_max, S_IRUGO | S_IWUSR, | ||
579 | show_therm_max, set_therm_max, 1+11), | ||
580 | SENSOR_ATTR(temp6_max, S_IRUGO | S_IWUSR, | ||
581 | show_therm_max, set_therm_max, 2+11), | ||
582 | }; | ||
583 | static struct sensor_device_attribute therm_crit[] = { | ||
584 | SENSOR_ATTR(temp4_crit, S_IRUGO | S_IWUSR, | ||
585 | show_therm_crit, set_therm_crit, 0+11), | ||
586 | SENSOR_ATTR(temp5_crit, S_IRUGO | S_IWUSR, | ||
587 | show_therm_crit, set_therm_crit, 1+11), | ||
588 | SENSOR_ATTR(temp6_crit, S_IRUGO | S_IWUSR, | ||
589 | show_therm_crit, set_therm_crit, 2+11), | ||
590 | }; | ||
528 | 591 | ||
529 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) | 592 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) |
530 | { | 593 | { |
@@ -592,11 +655,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *devattr | |||
592 | struct pc87360_data *data = i2c_get_clientdata(client); | 655 | struct pc87360_data *data = i2c_get_clientdata(client); |
593 | long val = simple_strtol(buf, NULL, 10); | 656 | long val = simple_strtol(buf, NULL, 10); |
594 | 657 | ||
595 | down(&data->update_lock); | 658 | mutex_lock(&data->update_lock); |
596 | data->temp_min[attr->index] = TEMP_TO_REG(val); | 659 | data->temp_min[attr->index] = TEMP_TO_REG(val); |
597 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MIN, | 660 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MIN, |
598 | data->temp_min[attr->index]); | 661 | data->temp_min[attr->index]); |
599 | up(&data->update_lock); | 662 | mutex_unlock(&data->update_lock); |
600 | return count; | 663 | return count; |
601 | } | 664 | } |
602 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf, | 665 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf, |
@@ -607,11 +670,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr | |||
607 | struct pc87360_data *data = i2c_get_clientdata(client); | 670 | struct pc87360_data *data = i2c_get_clientdata(client); |
608 | long val = simple_strtol(buf, NULL, 10); | 671 | long val = simple_strtol(buf, NULL, 10); |
609 | 672 | ||
610 | down(&data->update_lock); | 673 | mutex_lock(&data->update_lock); |
611 | data->temp_max[attr->index] = TEMP_TO_REG(val); | 674 | data->temp_max[attr->index] = TEMP_TO_REG(val); |
612 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MAX, | 675 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MAX, |
613 | data->temp_max[attr->index]); | 676 | data->temp_max[attr->index]); |
614 | up(&data->update_lock); | 677 | mutex_unlock(&data->update_lock); |
615 | return count; | 678 | return count; |
616 | } | 679 | } |
617 | static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf, | 680 | static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf, |
@@ -622,28 +685,48 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devatt | |||
622 | struct pc87360_data *data = i2c_get_clientdata(client); | 685 | struct pc87360_data *data = i2c_get_clientdata(client); |
623 | long val = simple_strtol(buf, NULL, 10); | 686 | long val = simple_strtol(buf, NULL, 10); |
624 | 687 | ||
625 | down(&data->update_lock); | 688 | mutex_lock(&data->update_lock); |
626 | data->temp_crit[attr->index] = TEMP_TO_REG(val); | 689 | data->temp_crit[attr->index] = TEMP_TO_REG(val); |
627 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_CRIT, | 690 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_CRIT, |
628 | data->temp_crit[attr->index]); | 691 | data->temp_crit[attr->index]); |
629 | up(&data->update_lock); | 692 | mutex_unlock(&data->update_lock); |
630 | return count; | 693 | return count; |
631 | } | 694 | } |
632 | 695 | ||
633 | #define show_and_set_temp(offset) \ | 696 | static struct sensor_device_attribute temp_input[] = { |
634 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | 697 | SENSOR_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0), |
635 | show_temp_input, NULL, offset-1); \ | 698 | SENSOR_ATTR(temp2_input, S_IRUGO, show_temp_input, NULL, 1), |
636 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ | 699 | SENSOR_ATTR(temp3_input, S_IRUGO, show_temp_input, NULL, 2), |
637 | show_temp_min, set_temp_min, offset-1); \ | 700 | }; |
638 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ | 701 | static struct sensor_device_attribute temp_status[] = { |
639 | show_temp_max, set_temp_max, offset-1); \ | 702 | SENSOR_ATTR(temp1_status, S_IRUGO, show_temp_status, NULL, 0), |
640 | static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ | 703 | SENSOR_ATTR(temp2_status, S_IRUGO, show_temp_status, NULL, 1), |
641 | show_temp_crit, set_temp_crit, offset-1); \ | 704 | SENSOR_ATTR(temp3_status, S_IRUGO, show_temp_status, NULL, 2), |
642 | static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ | 705 | }; |
643 | show_temp_status, NULL, offset-1); | 706 | static struct sensor_device_attribute temp_min[] = { |
644 | show_and_set_temp(1) | 707 | SENSOR_ATTR(temp1_min, S_IRUGO | S_IWUSR, |
645 | show_and_set_temp(2) | 708 | show_temp_min, set_temp_min, 0), |
646 | show_and_set_temp(3) | 709 | SENSOR_ATTR(temp2_min, S_IRUGO | S_IWUSR, |
710 | show_temp_min, set_temp_min, 1), | ||
711 | SENSOR_ATTR(temp3_min, S_IRUGO | S_IWUSR, | ||
712 | show_temp_min, set_temp_min, 2), | ||
713 | }; | ||
714 | static struct sensor_device_attribute temp_max[] = { | ||
715 | SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, | ||
716 | show_temp_max, set_temp_max, 0), | ||
717 | SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, | ||
718 | show_temp_max, set_temp_max, 1), | ||
719 | SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, | ||
720 | show_temp_max, set_temp_max, 2), | ||
721 | }; | ||
722 | static struct sensor_device_attribute temp_crit[] = { | ||
723 | SENSOR_ATTR(temp1_crit, S_IRUGO | S_IWUSR, | ||
724 | show_temp_crit, set_temp_crit, 0), | ||
725 | SENSOR_ATTR(temp2_crit, S_IRUGO | S_IWUSR, | ||
726 | show_temp_crit, set_temp_crit, 1), | ||
727 | SENSOR_ATTR(temp3_crit, S_IRUGO | S_IWUSR, | ||
728 | show_temp_crit, set_temp_crit, 2), | ||
729 | }; | ||
647 | 730 | ||
648 | static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 731 | static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
649 | { | 732 | { |
@@ -749,22 +832,24 @@ static int __init pc87360_find(int sioaddr, u8 *devid, unsigned short *addresses | |||
749 | static int pc87360_detect(struct i2c_adapter *adapter) | 832 | static int pc87360_detect(struct i2c_adapter *adapter) |
750 | { | 833 | { |
751 | int i; | 834 | int i; |
752 | struct i2c_client *new_client; | 835 | struct i2c_client *client; |
753 | struct pc87360_data *data; | 836 | struct pc87360_data *data; |
754 | int err = 0; | 837 | int err = 0; |
755 | const char *name = "pc87360"; | 838 | const char *name = "pc87360"; |
756 | int use_thermistors = 0; | 839 | int use_thermistors = 0; |
840 | struct device *dev; | ||
757 | 841 | ||
758 | if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL))) | 842 | if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL))) |
759 | return -ENOMEM; | 843 | return -ENOMEM; |
760 | 844 | ||
761 | new_client = &data->client; | 845 | client = &data->client; |
762 | i2c_set_clientdata(new_client, data); | 846 | dev = &client->dev; |
763 | new_client->addr = address; | 847 | i2c_set_clientdata(client, data); |
764 | init_MUTEX(&data->lock); | 848 | client->addr = address; |
765 | new_client->adapter = adapter; | 849 | mutex_init(&data->lock); |
766 | new_client->driver = &pc87360_driver; | 850 | client->adapter = adapter; |
767 | new_client->flags = 0; | 851 | client->driver = &pc87360_driver; |
852 | client->flags = 0; | ||
768 | 853 | ||
769 | data->fannr = 2; | 854 | data->fannr = 2; |
770 | data->innr = 0; | 855 | data->innr = 0; |
@@ -792,15 +877,15 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
792 | break; | 877 | break; |
793 | } | 878 | } |
794 | 879 | ||
795 | strcpy(new_client->name, name); | 880 | strlcpy(client->name, name, sizeof(client->name)); |
796 | data->valid = 0; | 881 | data->valid = 0; |
797 | init_MUTEX(&data->update_lock); | 882 | mutex_init(&data->update_lock); |
798 | 883 | ||
799 | for (i = 0; i < 3; i++) { | 884 | for (i = 0; i < 3; i++) { |
800 | if (((data->address[i] = extra_isa[i])) | 885 | if (((data->address[i] = extra_isa[i])) |
801 | && !request_region(extra_isa[i], PC87360_EXTENT, | 886 | && !request_region(extra_isa[i], PC87360_EXTENT, |
802 | pc87360_driver.driver.name)) { | 887 | pc87360_driver.driver.name)) { |
803 | dev_err(&new_client->dev, "Region 0x%x-0x%x already " | 888 | dev_err(&client->dev, "Region 0x%x-0x%x already " |
804 | "in use!\n", extra_isa[i], | 889 | "in use!\n", extra_isa[i], |
805 | extra_isa[i]+PC87360_EXTENT-1); | 890 | extra_isa[i]+PC87360_EXTENT-1); |
806 | for (i--; i >= 0; i--) | 891 | for (i--; i >= 0; i--) |
@@ -814,7 +899,7 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
814 | if (data->fannr) | 899 | if (data->fannr) |
815 | data->fan_conf = confreg[0] | (confreg[1] << 8); | 900 | data->fan_conf = confreg[0] | (confreg[1] << 8); |
816 | 901 | ||
817 | if ((err = i2c_attach_client(new_client))) | 902 | if ((err = i2c_attach_client(client))) |
818 | goto ERROR2; | 903 | goto ERROR2; |
819 | 904 | ||
820 | /* Use the correct reference voltage | 905 | /* Use the correct reference voltage |
@@ -828,7 +913,7 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
828 | PC87365_REG_TEMP_CONFIG); | 913 | PC87365_REG_TEMP_CONFIG); |
829 | } | 914 | } |
830 | data->in_vref = (i&0x02) ? 3025 : 2966; | 915 | data->in_vref = (i&0x02) ? 3025 : 2966; |
831 | dev_dbg(&new_client->dev, "Using %s reference voltage\n", | 916 | dev_dbg(&client->dev, "Using %s reference voltage\n", |
832 | (i&0x02) ? "external" : "internal"); | 917 | (i&0x02) ? "external" : "internal"); |
833 | 918 | ||
834 | data->vid_conf = confreg[3]; | 919 | data->vid_conf = confreg[3]; |
@@ -847,154 +932,64 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
847 | if (devid == 0xe9 && data->address[1]) /* PC87366 */ | 932 | if (devid == 0xe9 && data->address[1]) /* PC87366 */ |
848 | use_thermistors = confreg[2] & 0x40; | 933 | use_thermistors = confreg[2] & 0x40; |
849 | 934 | ||
850 | pc87360_init_client(new_client, use_thermistors); | 935 | pc87360_init_client(client, use_thermistors); |
851 | } | 936 | } |
852 | 937 | ||
853 | /* Register sysfs hooks */ | 938 | /* Register sysfs hooks */ |
854 | data->class_dev = hwmon_device_register(&new_client->dev); | 939 | data->class_dev = hwmon_device_register(&client->dev); |
855 | if (IS_ERR(data->class_dev)) { | 940 | if (IS_ERR(data->class_dev)) { |
856 | err = PTR_ERR(data->class_dev); | 941 | err = PTR_ERR(data->class_dev); |
857 | goto ERROR3; | 942 | goto ERROR3; |
858 | } | 943 | } |
859 | 944 | ||
860 | if (data->innr) { | 945 | if (data->innr) { |
861 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); | 946 | for (i = 0; i < 11; i++) { |
862 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr); | 947 | device_create_file(dev, &in_input[i].dev_attr); |
863 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr); | 948 | device_create_file(dev, &in_min[i].dev_attr); |
864 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr); | 949 | device_create_file(dev, &in_max[i].dev_attr); |
865 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr); | 950 | device_create_file(dev, &in_status[i].dev_attr); |
866 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr); | 951 | } |
867 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr); | 952 | device_create_file(dev, &dev_attr_cpu0_vid); |
868 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr); | 953 | device_create_file(dev, &dev_attr_vrm); |
869 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr); | 954 | device_create_file(dev, &dev_attr_alarms_in); |
870 | device_create_file(&new_client->dev, &sensor_dev_attr_in9_input.dev_attr); | ||
871 | device_create_file(&new_client->dev, &sensor_dev_attr_in10_input.dev_attr); | ||
872 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr); | ||
873 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr); | ||
874 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr); | ||
875 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr); | ||
876 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr); | ||
877 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr); | ||
878 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr); | ||
879 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr); | ||
880 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_min.dev_attr); | ||
881 | device_create_file(&new_client->dev, &sensor_dev_attr_in9_min.dev_attr); | ||
882 | device_create_file(&new_client->dev, &sensor_dev_attr_in10_min.dev_attr); | ||
883 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr); | ||
884 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr); | ||
885 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr); | ||
886 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr); | ||
887 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr); | ||
888 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr); | ||
889 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr); | ||
890 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr); | ||
891 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_max.dev_attr); | ||
892 | device_create_file(&new_client->dev, &sensor_dev_attr_in9_max.dev_attr); | ||
893 | device_create_file(&new_client->dev, &sensor_dev_attr_in10_max.dev_attr); | ||
894 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_status.dev_attr); | ||
895 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_status.dev_attr); | ||
896 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_status.dev_attr); | ||
897 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_status.dev_attr); | ||
898 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_status.dev_attr); | ||
899 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_status.dev_attr); | ||
900 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_status.dev_attr); | ||
901 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_status.dev_attr); | ||
902 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_status.dev_attr); | ||
903 | device_create_file(&new_client->dev, &sensor_dev_attr_in9_status.dev_attr); | ||
904 | device_create_file(&new_client->dev, &sensor_dev_attr_in10_status.dev_attr); | ||
905 | |||
906 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | ||
907 | device_create_file(&new_client->dev, &dev_attr_vrm); | ||
908 | device_create_file(&new_client->dev, &dev_attr_alarms_in); | ||
909 | } | 955 | } |
910 | 956 | ||
911 | if (data->tempnr) { | 957 | if (data->tempnr) { |
912 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr); | 958 | for (i = 0; i < data->tempnr; i++) { |
913 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr); | 959 | device_create_file(dev, &temp_input[i].dev_attr); |
914 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr); | 960 | device_create_file(dev, &temp_min[i].dev_attr); |
915 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr); | 961 | device_create_file(dev, &temp_max[i].dev_attr); |
916 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr); | 962 | device_create_file(dev, &temp_crit[i].dev_attr); |
917 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr); | 963 | device_create_file(dev, &temp_status[i].dev_attr); |
918 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_crit.dev_attr); | ||
919 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_crit.dev_attr); | ||
920 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_status.dev_attr); | ||
921 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_status.dev_attr); | ||
922 | |||
923 | device_create_file(&new_client->dev, &dev_attr_alarms_temp); | ||
924 | } | ||
925 | if (data->tempnr == 3) { | ||
926 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr); | ||
927 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr); | ||
928 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr); | ||
929 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_crit.dev_attr); | ||
930 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_status.dev_attr); | ||
931 | } | ||
932 | if (data->innr == 14) { | ||
933 | device_create_file(&new_client->dev, &sensor_dev_attr_temp4_input.dev_attr); | ||
934 | device_create_file(&new_client->dev, &sensor_dev_attr_temp5_input.dev_attr); | ||
935 | device_create_file(&new_client->dev, &sensor_dev_attr_temp6_input.dev_attr); | ||
936 | device_create_file(&new_client->dev, &sensor_dev_attr_temp4_min.dev_attr); | ||
937 | device_create_file(&new_client->dev, &sensor_dev_attr_temp5_min.dev_attr); | ||
938 | device_create_file(&new_client->dev, &sensor_dev_attr_temp6_min.dev_attr); | ||
939 | device_create_file(&new_client->dev, &sensor_dev_attr_temp4_max.dev_attr); | ||
940 | device_create_file(&new_client->dev, &sensor_dev_attr_temp5_max.dev_attr); | ||
941 | device_create_file(&new_client->dev, &sensor_dev_attr_temp6_max.dev_attr); | ||
942 | device_create_file(&new_client->dev, &sensor_dev_attr_temp4_crit.dev_attr); | ||
943 | device_create_file(&new_client->dev, &sensor_dev_attr_temp5_crit.dev_attr); | ||
944 | device_create_file(&new_client->dev, &sensor_dev_attr_temp6_crit.dev_attr); | ||
945 | device_create_file(&new_client->dev, &sensor_dev_attr_temp4_status.dev_attr); | ||
946 | device_create_file(&new_client->dev, &sensor_dev_attr_temp5_status.dev_attr); | ||
947 | device_create_file(&new_client->dev, &sensor_dev_attr_temp6_status.dev_attr); | ||
948 | } | ||
949 | |||
950 | if (data->fannr) { | ||
951 | if (FAN_CONFIG_MONITOR(data->fan_conf, 0)) { | ||
952 | device_create_file(&new_client->dev, | ||
953 | &sensor_dev_attr_fan1_input.dev_attr); | ||
954 | device_create_file(&new_client->dev, | ||
955 | &sensor_dev_attr_fan1_min.dev_attr); | ||
956 | device_create_file(&new_client->dev, | ||
957 | &sensor_dev_attr_fan1_div.dev_attr); | ||
958 | device_create_file(&new_client->dev, | ||
959 | &sensor_dev_attr_fan1_status.dev_attr); | ||
960 | } | 964 | } |
965 | device_create_file(dev, &dev_attr_alarms_temp); | ||
966 | } | ||
961 | 967 | ||
962 | if (FAN_CONFIG_MONITOR(data->fan_conf, 1)) { | 968 | if (data->innr == 14) { |
963 | device_create_file(&new_client->dev, | 969 | for (i = 0; i < 3; i++) { |
964 | &sensor_dev_attr_fan2_input.dev_attr); | 970 | device_create_file(dev, &therm_input[i].dev_attr); |
965 | device_create_file(&new_client->dev, | 971 | device_create_file(dev, &therm_min[i].dev_attr); |
966 | &sensor_dev_attr_fan2_min.dev_attr); | 972 | device_create_file(dev, &therm_max[i].dev_attr); |
967 | device_create_file(&new_client->dev, | 973 | device_create_file(dev, &therm_crit[i].dev_attr); |
968 | &sensor_dev_attr_fan2_div.dev_attr); | 974 | device_create_file(dev, &therm_status[i].dev_attr); |
969 | device_create_file(&new_client->dev, | ||
970 | &sensor_dev_attr_fan2_status.dev_attr); | ||
971 | } | 975 | } |
972 | |||
973 | if (FAN_CONFIG_CONTROL(data->fan_conf, 0)) | ||
974 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr); | ||
975 | if (FAN_CONFIG_CONTROL(data->fan_conf, 1)) | ||
976 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr); | ||
977 | } | 976 | } |
978 | if (data->fannr == 3) { | ||
979 | if (FAN_CONFIG_MONITOR(data->fan_conf, 2)) { | ||
980 | device_create_file(&new_client->dev, | ||
981 | &sensor_dev_attr_fan3_input.dev_attr); | ||
982 | device_create_file(&new_client->dev, | ||
983 | &sensor_dev_attr_fan3_min.dev_attr); | ||
984 | device_create_file(&new_client->dev, | ||
985 | &sensor_dev_attr_fan3_div.dev_attr); | ||
986 | device_create_file(&new_client->dev, | ||
987 | &sensor_dev_attr_fan3_status.dev_attr); | ||
988 | } | ||
989 | 977 | ||
990 | if (FAN_CONFIG_CONTROL(data->fan_conf, 2)) | 978 | for (i = 0; i < data->fannr; i++) { |
991 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr); | 979 | if (FAN_CONFIG_MONITOR(data->fan_conf, i)) { |
980 | device_create_file(dev, &fan_input[i].dev_attr); | ||
981 | device_create_file(dev, &fan_min[i].dev_attr); | ||
982 | device_create_file(dev, &fan_div[i].dev_attr); | ||
983 | device_create_file(dev, &fan_status[i].dev_attr); | ||
984 | } | ||
985 | if (FAN_CONFIG_CONTROL(data->fan_conf, i)) | ||
986 | device_create_file(dev, &pwm[i].dev_attr); | ||
992 | } | 987 | } |
993 | 988 | ||
994 | return 0; | 989 | return 0; |
995 | 990 | ||
996 | ERROR3: | 991 | ERROR3: |
997 | i2c_detach_client(new_client); | 992 | i2c_detach_client(client); |
998 | ERROR2: | 993 | ERROR2: |
999 | for (i = 0; i < 3; i++) { | 994 | for (i = 0; i < 3; i++) { |
1000 | if (data->address[i]) { | 995 | if (data->address[i]) { |
@@ -1033,11 +1028,11 @@ static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank, | |||
1033 | { | 1028 | { |
1034 | int res; | 1029 | int res; |
1035 | 1030 | ||
1036 | down(&(data->lock)); | 1031 | mutex_lock(&(data->lock)); |
1037 | if (bank != NO_BANK) | 1032 | if (bank != NO_BANK) |
1038 | outb_p(bank, data->address[ldi] + PC87365_REG_BANK); | 1033 | outb_p(bank, data->address[ldi] + PC87365_REG_BANK); |
1039 | res = inb_p(data->address[ldi] + reg); | 1034 | res = inb_p(data->address[ldi] + reg); |
1040 | up(&(data->lock)); | 1035 | mutex_unlock(&(data->lock)); |
1041 | 1036 | ||
1042 | return res; | 1037 | return res; |
1043 | } | 1038 | } |
@@ -1045,11 +1040,11 @@ static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank, | |||
1045 | static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank, | 1040 | static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank, |
1046 | u8 reg, u8 value) | 1041 | u8 reg, u8 value) |
1047 | { | 1042 | { |
1048 | down(&(data->lock)); | 1043 | mutex_lock(&(data->lock)); |
1049 | if (bank != NO_BANK) | 1044 | if (bank != NO_BANK) |
1050 | outb_p(bank, data->address[ldi] + PC87365_REG_BANK); | 1045 | outb_p(bank, data->address[ldi] + PC87365_REG_BANK); |
1051 | outb_p(value, data->address[ldi] + reg); | 1046 | outb_p(value, data->address[ldi] + reg); |
1052 | up(&(data->lock)); | 1047 | mutex_unlock(&(data->lock)); |
1053 | } | 1048 | } |
1054 | 1049 | ||
1055 | static void pc87360_init_client(struct i2c_client *client, int use_thermistors) | 1050 | static void pc87360_init_client(struct i2c_client *client, int use_thermistors) |
@@ -1071,7 +1066,7 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors) | |||
1071 | } | 1066 | } |
1072 | 1067 | ||
1073 | nr = data->innr < 11 ? data->innr : 11; | 1068 | nr = data->innr < 11 ? data->innr : 11; |
1074 | for (i=0; i<nr; i++) { | 1069 | for (i = 0; i < nr; i++) { |
1075 | if (init >= init_in[i]) { | 1070 | if (init >= init_in[i]) { |
1076 | /* Forcibly enable voltage channel */ | 1071 | /* Forcibly enable voltage channel */ |
1077 | reg = pc87360_read_value(data, LD_IN, i, | 1072 | reg = pc87360_read_value(data, LD_IN, i, |
@@ -1088,14 +1083,14 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors) | |||
1088 | 1083 | ||
1089 | /* We can't blindly trust the Super-I/O space configuration bit, | 1084 | /* We can't blindly trust the Super-I/O space configuration bit, |
1090 | most BIOS won't set it properly */ | 1085 | most BIOS won't set it properly */ |
1091 | for (i=11; i<data->innr; i++) { | 1086 | for (i = 11; i < data->innr; i++) { |
1092 | reg = pc87360_read_value(data, LD_IN, i, | 1087 | reg = pc87360_read_value(data, LD_IN, i, |
1093 | PC87365_REG_TEMP_STATUS); | 1088 | PC87365_REG_TEMP_STATUS); |
1094 | use_thermistors = use_thermistors || (reg & 0x01); | 1089 | use_thermistors = use_thermistors || (reg & 0x01); |
1095 | } | 1090 | } |
1096 | 1091 | ||
1097 | i = use_thermistors ? 2 : 0; | 1092 | i = use_thermistors ? 2 : 0; |
1098 | for (; i<data->tempnr; i++) { | 1093 | for (; i < data->tempnr; i++) { |
1099 | if (init >= init_temp[i]) { | 1094 | if (init >= init_temp[i]) { |
1100 | /* Forcibly enable temperature channel */ | 1095 | /* Forcibly enable temperature channel */ |
1101 | reg = pc87360_read_value(data, LD_TEMP, i, | 1096 | reg = pc87360_read_value(data, LD_TEMP, i, |
@@ -1111,7 +1106,7 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors) | |||
1111 | } | 1106 | } |
1112 | 1107 | ||
1113 | if (use_thermistors) { | 1108 | if (use_thermistors) { |
1114 | for (i=11; i<data->innr; i++) { | 1109 | for (i = 11; i < data->innr; i++) { |
1115 | if (init >= init_in[i]) { | 1110 | if (init >= init_in[i]) { |
1116 | /* The pin may already be used by thermal | 1111 | /* The pin may already be used by thermal |
1117 | diodes */ | 1112 | diodes */ |
@@ -1221,7 +1216,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev) | |||
1221 | struct pc87360_data *data = i2c_get_clientdata(client); | 1216 | struct pc87360_data *data = i2c_get_clientdata(client); |
1222 | u8 i; | 1217 | u8 i; |
1223 | 1218 | ||
1224 | down(&data->update_lock); | 1219 | mutex_lock(&data->update_lock); |
1225 | 1220 | ||
1226 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 1221 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
1227 | dev_dbg(&client->dev, "Data update\n"); | 1222 | dev_dbg(&client->dev, "Data update\n"); |
@@ -1321,7 +1316,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev) | |||
1321 | data->valid = 1; | 1316 | data->valid = 1; |
1322 | } | 1317 | } |
1323 | 1318 | ||
1324 | up(&data->update_lock); | 1319 | mutex_unlock(&data->update_lock); |
1325 | 1320 | ||
1326 | return data; | 1321 | return data; |
1327 | } | 1322 | } |
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 8be5189d9bd9..6f3fda73f70c 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c | |||
@@ -60,6 +60,7 @@ | |||
60 | #include <linux/err.h> | 60 | #include <linux/err.h> |
61 | #include <linux/init.h> | 61 | #include <linux/init.h> |
62 | #include <linux/jiffies.h> | 62 | #include <linux/jiffies.h> |
63 | #include <linux/mutex.h> | ||
63 | #include <asm/io.h> | 64 | #include <asm/io.h> |
64 | 65 | ||
65 | 66 | ||
@@ -167,9 +168,9 @@ static inline u8 DIV_TO_REG(int val) | |||
167 | struct sis5595_data { | 168 | struct sis5595_data { |
168 | struct i2c_client client; | 169 | struct i2c_client client; |
169 | struct class_device *class_dev; | 170 | struct class_device *class_dev; |
170 | struct semaphore lock; | 171 | struct mutex lock; |
171 | 172 | ||
172 | struct semaphore update_lock; | 173 | struct mutex update_lock; |
173 | char valid; /* !=0 if following fields are valid */ | 174 | char valid; /* !=0 if following fields are valid */ |
174 | unsigned long last_updated; /* In jiffies */ | 175 | unsigned long last_updated; /* In jiffies */ |
175 | char maxins; /* == 3 if temp enabled, otherwise == 4 */ | 176 | char maxins; /* == 3 if temp enabled, otherwise == 4 */ |
@@ -192,8 +193,8 @@ static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */ | |||
192 | static int sis5595_detect(struct i2c_adapter *adapter); | 193 | static int sis5595_detect(struct i2c_adapter *adapter); |
193 | static int sis5595_detach_client(struct i2c_client *client); | 194 | static int sis5595_detach_client(struct i2c_client *client); |
194 | 195 | ||
195 | static int sis5595_read_value(struct i2c_client *client, u8 register); | 196 | static int sis5595_read_value(struct i2c_client *client, u8 reg); |
196 | static int sis5595_write_value(struct i2c_client *client, u8 register, u8 value); | 197 | static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value); |
197 | static struct sis5595_data *sis5595_update_device(struct device *dev); | 198 | static struct sis5595_data *sis5595_update_device(struct device *dev); |
198 | static void sis5595_init_client(struct i2c_client *client); | 199 | static void sis5595_init_client(struct i2c_client *client); |
199 | 200 | ||
@@ -231,10 +232,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf, | |||
231 | struct sis5595_data *data = i2c_get_clientdata(client); | 232 | struct sis5595_data *data = i2c_get_clientdata(client); |
232 | unsigned long val = simple_strtoul(buf, NULL, 10); | 233 | unsigned long val = simple_strtoul(buf, NULL, 10); |
233 | 234 | ||
234 | down(&data->update_lock); | 235 | mutex_lock(&data->update_lock); |
235 | data->in_min[nr] = IN_TO_REG(val); | 236 | data->in_min[nr] = IN_TO_REG(val); |
236 | sis5595_write_value(client, SIS5595_REG_IN_MIN(nr), data->in_min[nr]); | 237 | sis5595_write_value(client, SIS5595_REG_IN_MIN(nr), data->in_min[nr]); |
237 | up(&data->update_lock); | 238 | mutex_unlock(&data->update_lock); |
238 | return count; | 239 | return count; |
239 | } | 240 | } |
240 | 241 | ||
@@ -245,10 +246,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
245 | struct sis5595_data *data = i2c_get_clientdata(client); | 246 | struct sis5595_data *data = i2c_get_clientdata(client); |
246 | unsigned long val = simple_strtoul(buf, NULL, 10); | 247 | unsigned long val = simple_strtoul(buf, NULL, 10); |
247 | 248 | ||
248 | down(&data->update_lock); | 249 | mutex_lock(&data->update_lock); |
249 | data->in_max[nr] = IN_TO_REG(val); | 250 | data->in_max[nr] = IN_TO_REG(val); |
250 | sis5595_write_value(client, SIS5595_REG_IN_MAX(nr), data->in_max[nr]); | 251 | sis5595_write_value(client, SIS5595_REG_IN_MAX(nr), data->in_max[nr]); |
251 | up(&data->update_lock); | 252 | mutex_unlock(&data->update_lock); |
252 | return count; | 253 | return count; |
253 | } | 254 | } |
254 | 255 | ||
@@ -310,10 +311,10 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr, | |||
310 | struct sis5595_data *data = i2c_get_clientdata(client); | 311 | struct sis5595_data *data = i2c_get_clientdata(client); |
311 | long val = simple_strtol(buf, NULL, 10); | 312 | long val = simple_strtol(buf, NULL, 10); |
312 | 313 | ||
313 | down(&data->update_lock); | 314 | mutex_lock(&data->update_lock); |
314 | data->temp_over = TEMP_TO_REG(val); | 315 | data->temp_over = TEMP_TO_REG(val); |
315 | sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over); | 316 | sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over); |
316 | up(&data->update_lock); | 317 | mutex_unlock(&data->update_lock); |
317 | return count; | 318 | return count; |
318 | } | 319 | } |
319 | 320 | ||
@@ -329,10 +330,10 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr, | |||
329 | struct sis5595_data *data = i2c_get_clientdata(client); | 330 | struct sis5595_data *data = i2c_get_clientdata(client); |
330 | long val = simple_strtol(buf, NULL, 10); | 331 | long val = simple_strtol(buf, NULL, 10); |
331 | 332 | ||
332 | down(&data->update_lock); | 333 | mutex_lock(&data->update_lock); |
333 | data->temp_hyst = TEMP_TO_REG(val); | 334 | data->temp_hyst = TEMP_TO_REG(val); |
334 | sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst); | 335 | sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst); |
335 | up(&data->update_lock); | 336 | mutex_unlock(&data->update_lock); |
336 | return count; | 337 | return count; |
337 | } | 338 | } |
338 | 339 | ||
@@ -364,10 +365,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
364 | struct sis5595_data *data = i2c_get_clientdata(client); | 365 | struct sis5595_data *data = i2c_get_clientdata(client); |
365 | unsigned long val = simple_strtoul(buf, NULL, 10); | 366 | unsigned long val = simple_strtoul(buf, NULL, 10); |
366 | 367 | ||
367 | down(&data->update_lock); | 368 | mutex_lock(&data->update_lock); |
368 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 369 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
369 | sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]); | 370 | sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]); |
370 | up(&data->update_lock); | 371 | mutex_unlock(&data->update_lock); |
371 | return count; | 372 | return count; |
372 | } | 373 | } |
373 | 374 | ||
@@ -390,7 +391,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
390 | unsigned long val = simple_strtoul(buf, NULL, 10); | 391 | unsigned long val = simple_strtoul(buf, NULL, 10); |
391 | int reg; | 392 | int reg; |
392 | 393 | ||
393 | down(&data->update_lock); | 394 | mutex_lock(&data->update_lock); |
394 | min = FAN_FROM_REG(data->fan_min[nr], | 395 | min = FAN_FROM_REG(data->fan_min[nr], |
395 | DIV_FROM_REG(data->fan_div[nr])); | 396 | DIV_FROM_REG(data->fan_div[nr])); |
396 | reg = sis5595_read_value(client, SIS5595_REG_FANDIV); | 397 | reg = sis5595_read_value(client, SIS5595_REG_FANDIV); |
@@ -403,7 +404,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
403 | default: | 404 | default: |
404 | dev_err(&client->dev, "fan_div value %ld not " | 405 | dev_err(&client->dev, "fan_div value %ld not " |
405 | "supported. Choose one of 1, 2, 4 or 8!\n", val); | 406 | "supported. Choose one of 1, 2, 4 or 8!\n", val); |
406 | up(&data->update_lock); | 407 | mutex_unlock(&data->update_lock); |
407 | return -EINVAL; | 408 | return -EINVAL; |
408 | } | 409 | } |
409 | 410 | ||
@@ -419,7 +420,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
419 | data->fan_min[nr] = | 420 | data->fan_min[nr] = |
420 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 421 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
421 | sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]); | 422 | sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]); |
422 | up(&data->update_lock); | 423 | mutex_unlock(&data->update_lock); |
423 | return count; | 424 | return count; |
424 | } | 425 | } |
425 | 426 | ||
@@ -527,7 +528,7 @@ static int sis5595_detect(struct i2c_adapter *adapter) | |||
527 | 528 | ||
528 | new_client = &data->client; | 529 | new_client = &data->client; |
529 | new_client->addr = address; | 530 | new_client->addr = address; |
530 | init_MUTEX(&data->lock); | 531 | mutex_init(&data->lock); |
531 | i2c_set_clientdata(new_client, data); | 532 | i2c_set_clientdata(new_client, data); |
532 | new_client->adapter = adapter; | 533 | new_client->adapter = adapter; |
533 | new_client->driver = &sis5595_driver; | 534 | new_client->driver = &sis5595_driver; |
@@ -548,7 +549,7 @@ static int sis5595_detect(struct i2c_adapter *adapter) | |||
548 | strlcpy(new_client->name, "sis5595", I2C_NAME_SIZE); | 549 | strlcpy(new_client->name, "sis5595", I2C_NAME_SIZE); |
549 | 550 | ||
550 | data->valid = 0; | 551 | data->valid = 0; |
551 | init_MUTEX(&data->update_lock); | 552 | mutex_init(&data->update_lock); |
552 | 553 | ||
553 | /* Tell the I2C layer a new client has arrived */ | 554 | /* Tell the I2C layer a new client has arrived */ |
554 | if ((err = i2c_attach_client(new_client))) | 555 | if ((err = i2c_attach_client(new_client))) |
@@ -635,20 +636,20 @@ static int sis5595_read_value(struct i2c_client *client, u8 reg) | |||
635 | int res; | 636 | int res; |
636 | 637 | ||
637 | struct sis5595_data *data = i2c_get_clientdata(client); | 638 | struct sis5595_data *data = i2c_get_clientdata(client); |
638 | down(&data->lock); | 639 | mutex_lock(&data->lock); |
639 | outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET); | 640 | outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET); |
640 | res = inb_p(client->addr + SIS5595_DATA_REG_OFFSET); | 641 | res = inb_p(client->addr + SIS5595_DATA_REG_OFFSET); |
641 | up(&data->lock); | 642 | mutex_unlock(&data->lock); |
642 | return res; | 643 | return res; |
643 | } | 644 | } |
644 | 645 | ||
645 | static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value) | 646 | static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value) |
646 | { | 647 | { |
647 | struct sis5595_data *data = i2c_get_clientdata(client); | 648 | struct sis5595_data *data = i2c_get_clientdata(client); |
648 | down(&data->lock); | 649 | mutex_lock(&data->lock); |
649 | outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET); | 650 | outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET); |
650 | outb_p(value, client->addr + SIS5595_DATA_REG_OFFSET); | 651 | outb_p(value, client->addr + SIS5595_DATA_REG_OFFSET); |
651 | up(&data->lock); | 652 | mutex_unlock(&data->lock); |
652 | return 0; | 653 | return 0; |
653 | } | 654 | } |
654 | 655 | ||
@@ -667,7 +668,7 @@ static struct sis5595_data *sis5595_update_device(struct device *dev) | |||
667 | struct sis5595_data *data = i2c_get_clientdata(client); | 668 | struct sis5595_data *data = i2c_get_clientdata(client); |
668 | int i; | 669 | int i; |
669 | 670 | ||
670 | down(&data->update_lock); | 671 | mutex_lock(&data->update_lock); |
671 | 672 | ||
672 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 673 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
673 | || !data->valid) { | 674 | || !data->valid) { |
@@ -707,7 +708,7 @@ static struct sis5595_data *sis5595_update_device(struct device *dev) | |||
707 | data->valid = 1; | 708 | data->valid = 1; |
708 | } | 709 | } |
709 | 710 | ||
710 | up(&data->update_lock); | 711 | mutex_unlock(&data->update_lock); |
711 | 712 | ||
712 | return data; | 713 | return data; |
713 | } | 714 | } |
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index 8663bbbe97f5..b6086186d225 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/hwmon.h> | 35 | #include <linux/hwmon.h> |
36 | #include <linux/err.h> | 36 | #include <linux/err.h> |
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/mutex.h> | ||
38 | #include <asm/io.h> | 39 | #include <asm/io.h> |
39 | 40 | ||
40 | /* Address is autodetected, there is no default value */ | 41 | /* Address is autodetected, there is no default value */ |
@@ -92,9 +93,9 @@ static u8 smsc47b397_reg_temp[] = {0x25, 0x26, 0x27, 0x80}; | |||
92 | struct smsc47b397_data { | 93 | struct smsc47b397_data { |
93 | struct i2c_client client; | 94 | struct i2c_client client; |
94 | struct class_device *class_dev; | 95 | struct class_device *class_dev; |
95 | struct semaphore lock; | 96 | struct mutex lock; |
96 | 97 | ||
97 | struct semaphore update_lock; | 98 | struct mutex update_lock; |
98 | unsigned long last_updated; /* in jiffies */ | 99 | unsigned long last_updated; /* in jiffies */ |
99 | int valid; | 100 | int valid; |
100 | 101 | ||
@@ -108,10 +109,10 @@ static int smsc47b397_read_value(struct i2c_client *client, u8 reg) | |||
108 | struct smsc47b397_data *data = i2c_get_clientdata(client); | 109 | struct smsc47b397_data *data = i2c_get_clientdata(client); |
109 | int res; | 110 | int res; |
110 | 111 | ||
111 | down(&data->lock); | 112 | mutex_lock(&data->lock); |
112 | outb(reg, client->addr); | 113 | outb(reg, client->addr); |
113 | res = inb_p(client->addr + 1); | 114 | res = inb_p(client->addr + 1); |
114 | up(&data->lock); | 115 | mutex_unlock(&data->lock); |
115 | return res; | 116 | return res; |
116 | } | 117 | } |
117 | 118 | ||
@@ -121,7 +122,7 @@ static struct smsc47b397_data *smsc47b397_update_device(struct device *dev) | |||
121 | struct smsc47b397_data *data = i2c_get_clientdata(client); | 122 | struct smsc47b397_data *data = i2c_get_clientdata(client); |
122 | int i; | 123 | int i; |
123 | 124 | ||
124 | down(&data->update_lock); | 125 | mutex_lock(&data->update_lock); |
125 | 126 | ||
126 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | 127 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
127 | dev_dbg(&client->dev, "starting device update...\n"); | 128 | dev_dbg(&client->dev, "starting device update...\n"); |
@@ -144,7 +145,7 @@ static struct smsc47b397_data *smsc47b397_update_device(struct device *dev) | |||
144 | dev_dbg(&client->dev, "... device update complete\n"); | 145 | dev_dbg(&client->dev, "... device update complete\n"); |
145 | } | 146 | } |
146 | 147 | ||
147 | up(&data->update_lock); | 148 | mutex_unlock(&data->update_lock); |
148 | 149 | ||
149 | return data; | 150 | return data; |
150 | } | 151 | } |
@@ -254,14 +255,14 @@ static int smsc47b397_detect(struct i2c_adapter *adapter) | |||
254 | new_client = &data->client; | 255 | new_client = &data->client; |
255 | i2c_set_clientdata(new_client, data); | 256 | i2c_set_clientdata(new_client, data); |
256 | new_client->addr = address; | 257 | new_client->addr = address; |
257 | init_MUTEX(&data->lock); | 258 | mutex_init(&data->lock); |
258 | new_client->adapter = adapter; | 259 | new_client->adapter = adapter; |
259 | new_client->driver = &smsc47b397_driver; | 260 | new_client->driver = &smsc47b397_driver; |
260 | new_client->flags = 0; | 261 | new_client->flags = 0; |
261 | 262 | ||
262 | strlcpy(new_client->name, "smsc47b397", I2C_NAME_SIZE); | 263 | strlcpy(new_client->name, "smsc47b397", I2C_NAME_SIZE); |
263 | 264 | ||
264 | init_MUTEX(&data->update_lock); | 265 | mutex_init(&data->update_lock); |
265 | 266 | ||
266 | if ((err = i2c_attach_client(new_client))) | 267 | if ((err = i2c_attach_client(new_client))) |
267 | goto error_free; | 268 | goto error_free; |
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index d1e3ec0fe4df..7732aec54594 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/hwmon.h> | 34 | #include <linux/hwmon.h> |
35 | #include <linux/err.h> | 35 | #include <linux/err.h> |
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/mutex.h> | ||
37 | #include <asm/io.h> | 38 | #include <asm/io.h> |
38 | 39 | ||
39 | /* Address is autodetected, there is no default value */ | 40 | /* Address is autodetected, there is no default value */ |
@@ -102,9 +103,9 @@ superio_exit(void) | |||
102 | struct smsc47m1_data { | 103 | struct smsc47m1_data { |
103 | struct i2c_client client; | 104 | struct i2c_client client; |
104 | struct class_device *class_dev; | 105 | struct class_device *class_dev; |
105 | struct semaphore lock; | 106 | struct mutex lock; |
106 | 107 | ||
107 | struct semaphore update_lock; | 108 | struct mutex update_lock; |
108 | unsigned long last_updated; /* In jiffies */ | 109 | unsigned long last_updated; /* In jiffies */ |
109 | 110 | ||
110 | u8 fan[2]; /* Register value */ | 111 | u8 fan[2]; /* Register value */ |
@@ -188,18 +189,18 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
188 | struct smsc47m1_data *data = i2c_get_clientdata(client); | 189 | struct smsc47m1_data *data = i2c_get_clientdata(client); |
189 | long rpmdiv, val = simple_strtol(buf, NULL, 10); | 190 | long rpmdiv, val = simple_strtol(buf, NULL, 10); |
190 | 191 | ||
191 | down(&data->update_lock); | 192 | mutex_lock(&data->update_lock); |
192 | rpmdiv = val * DIV_FROM_REG(data->fan_div[nr]); | 193 | rpmdiv = val * DIV_FROM_REG(data->fan_div[nr]); |
193 | 194 | ||
194 | if (983040 > 192 * rpmdiv || 2 * rpmdiv > 983040) { | 195 | if (983040 > 192 * rpmdiv || 2 * rpmdiv > 983040) { |
195 | up(&data->update_lock); | 196 | mutex_unlock(&data->update_lock); |
196 | return -EINVAL; | 197 | return -EINVAL; |
197 | } | 198 | } |
198 | 199 | ||
199 | data->fan_preload[nr] = 192 - ((983040 + rpmdiv / 2) / rpmdiv); | 200 | data->fan_preload[nr] = 192 - ((983040 + rpmdiv / 2) / rpmdiv); |
200 | smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr), | 201 | smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr), |
201 | data->fan_preload[nr]); | 202 | data->fan_preload[nr]); |
202 | up(&data->update_lock); | 203 | mutex_unlock(&data->update_lock); |
203 | 204 | ||
204 | return count; | 205 | return count; |
205 | } | 206 | } |
@@ -220,14 +221,14 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
220 | if (new_div == old_div) /* No change */ | 221 | if (new_div == old_div) /* No change */ |
221 | return count; | 222 | return count; |
222 | 223 | ||
223 | down(&data->update_lock); | 224 | mutex_lock(&data->update_lock); |
224 | switch (new_div) { | 225 | switch (new_div) { |
225 | case 1: data->fan_div[nr] = 0; break; | 226 | case 1: data->fan_div[nr] = 0; break; |
226 | case 2: data->fan_div[nr] = 1; break; | 227 | case 2: data->fan_div[nr] = 1; break; |
227 | case 4: data->fan_div[nr] = 2; break; | 228 | case 4: data->fan_div[nr] = 2; break; |
228 | case 8: data->fan_div[nr] = 3; break; | 229 | case 8: data->fan_div[nr] = 3; break; |
229 | default: | 230 | default: |
230 | up(&data->update_lock); | 231 | mutex_unlock(&data->update_lock); |
231 | return -EINVAL; | 232 | return -EINVAL; |
232 | } | 233 | } |
233 | 234 | ||
@@ -241,7 +242,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
241 | data->fan_preload[nr] = SENSORS_LIMIT(tmp, 0, 191); | 242 | data->fan_preload[nr] = SENSORS_LIMIT(tmp, 0, 191); |
242 | smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr), | 243 | smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr), |
243 | data->fan_preload[nr]); | 244 | data->fan_preload[nr]); |
244 | up(&data->update_lock); | 245 | mutex_unlock(&data->update_lock); |
245 | 246 | ||
246 | return count; | 247 | return count; |
247 | } | 248 | } |
@@ -257,12 +258,12 @@ static ssize_t set_pwm(struct device *dev, const char *buf, | |||
257 | if (val < 0 || val > 255) | 258 | if (val < 0 || val > 255) |
258 | return -EINVAL; | 259 | return -EINVAL; |
259 | 260 | ||
260 | down(&data->update_lock); | 261 | mutex_lock(&data->update_lock); |
261 | data->pwm[nr] &= 0x81; /* Preserve additional bits */ | 262 | data->pwm[nr] &= 0x81; /* Preserve additional bits */ |
262 | data->pwm[nr] |= PWM_TO_REG(val); | 263 | data->pwm[nr] |= PWM_TO_REG(val); |
263 | smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr), | 264 | smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr), |
264 | data->pwm[nr]); | 265 | data->pwm[nr]); |
265 | up(&data->update_lock); | 266 | mutex_unlock(&data->update_lock); |
266 | 267 | ||
267 | return count; | 268 | return count; |
268 | } | 269 | } |
@@ -278,12 +279,12 @@ static ssize_t set_pwm_en(struct device *dev, const char *buf, | |||
278 | if (val != 0 && val != 1) | 279 | if (val != 0 && val != 1) |
279 | return -EINVAL; | 280 | return -EINVAL; |
280 | 281 | ||
281 | down(&data->update_lock); | 282 | mutex_lock(&data->update_lock); |
282 | data->pwm[nr] &= 0xFE; /* preserve the other bits */ | 283 | data->pwm[nr] &= 0xFE; /* preserve the other bits */ |
283 | data->pwm[nr] |= !val; | 284 | data->pwm[nr] |= !val; |
284 | smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr), | 285 | smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr), |
285 | data->pwm[nr]); | 286 | data->pwm[nr]); |
286 | up(&data->update_lock); | 287 | mutex_unlock(&data->update_lock); |
287 | 288 | ||
288 | return count; | 289 | return count; |
289 | } | 290 | } |
@@ -408,13 +409,13 @@ static int smsc47m1_detect(struct i2c_adapter *adapter) | |||
408 | new_client = &data->client; | 409 | new_client = &data->client; |
409 | i2c_set_clientdata(new_client, data); | 410 | i2c_set_clientdata(new_client, data); |
410 | new_client->addr = address; | 411 | new_client->addr = address; |
411 | init_MUTEX(&data->lock); | 412 | mutex_init(&data->lock); |
412 | new_client->adapter = adapter; | 413 | new_client->adapter = adapter; |
413 | new_client->driver = &smsc47m1_driver; | 414 | new_client->driver = &smsc47m1_driver; |
414 | new_client->flags = 0; | 415 | new_client->flags = 0; |
415 | 416 | ||
416 | strlcpy(new_client->name, "smsc47m1", I2C_NAME_SIZE); | 417 | strlcpy(new_client->name, "smsc47m1", I2C_NAME_SIZE); |
417 | init_MUTEX(&data->update_lock); | 418 | mutex_init(&data->update_lock); |
418 | 419 | ||
419 | /* If no function is properly configured, there's no point in | 420 | /* If no function is properly configured, there's no point in |
420 | actually registering the chip. */ | 421 | actually registering the chip. */ |
@@ -512,17 +513,17 @@ static int smsc47m1_read_value(struct i2c_client *client, u8 reg) | |||
512 | { | 513 | { |
513 | int res; | 514 | int res; |
514 | 515 | ||
515 | down(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); | 516 | mutex_lock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); |
516 | res = inb_p(client->addr + reg); | 517 | res = inb_p(client->addr + reg); |
517 | up(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); | 518 | mutex_unlock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); |
518 | return res; | 519 | return res; |
519 | } | 520 | } |
520 | 521 | ||
521 | static void smsc47m1_write_value(struct i2c_client *client, u8 reg, u8 value) | 522 | static void smsc47m1_write_value(struct i2c_client *client, u8 reg, u8 value) |
522 | { | 523 | { |
523 | down(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); | 524 | mutex_lock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); |
524 | outb_p(value, client->addr + reg); | 525 | outb_p(value, client->addr + reg); |
525 | up(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); | 526 | mutex_unlock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); |
526 | } | 527 | } |
527 | 528 | ||
528 | static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, | 529 | static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, |
@@ -531,7 +532,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, | |||
531 | struct i2c_client *client = to_i2c_client(dev); | 532 | struct i2c_client *client = to_i2c_client(dev); |
532 | struct smsc47m1_data *data = i2c_get_clientdata(client); | 533 | struct smsc47m1_data *data = i2c_get_clientdata(client); |
533 | 534 | ||
534 | down(&data->update_lock); | 535 | mutex_lock(&data->update_lock); |
535 | 536 | ||
536 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || init) { | 537 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || init) { |
537 | int i; | 538 | int i; |
@@ -558,7 +559,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, | |||
558 | data->last_updated = jiffies; | 559 | data->last_updated = jiffies; |
559 | } | 560 | } |
560 | 561 | ||
561 | up(&data->update_lock); | 562 | mutex_unlock(&data->update_lock); |
562 | return data; | 563 | return data; |
563 | } | 564 | } |
564 | 565 | ||
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index cb01848729b5..166298f1f190 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/hwmon.h> | 39 | #include <linux/hwmon.h> |
40 | #include <linux/err.h> | 40 | #include <linux/err.h> |
41 | #include <linux/init.h> | 41 | #include <linux/init.h> |
42 | #include <linux/mutex.h> | ||
42 | #include <asm/io.h> | 43 | #include <asm/io.h> |
43 | 44 | ||
44 | 45 | ||
@@ -296,7 +297,7 @@ static inline long TEMP_FROM_REG10(u16 val) | |||
296 | struct via686a_data { | 297 | struct via686a_data { |
297 | struct i2c_client client; | 298 | struct i2c_client client; |
298 | struct class_device *class_dev; | 299 | struct class_device *class_dev; |
299 | struct semaphore update_lock; | 300 | struct mutex update_lock; |
300 | char valid; /* !=0 if following fields are valid */ | 301 | char valid; /* !=0 if following fields are valid */ |
301 | unsigned long last_updated; /* In jiffies */ | 302 | unsigned long last_updated; /* In jiffies */ |
302 | 303 | ||
@@ -355,11 +356,11 @@ static ssize_t set_in_min(struct device *dev, const char *buf, | |||
355 | struct via686a_data *data = i2c_get_clientdata(client); | 356 | struct via686a_data *data = i2c_get_clientdata(client); |
356 | unsigned long val = simple_strtoul(buf, NULL, 10); | 357 | unsigned long val = simple_strtoul(buf, NULL, 10); |
357 | 358 | ||
358 | down(&data->update_lock); | 359 | mutex_lock(&data->update_lock); |
359 | data->in_min[nr] = IN_TO_REG(val, nr); | 360 | data->in_min[nr] = IN_TO_REG(val, nr); |
360 | via686a_write_value(client, VIA686A_REG_IN_MIN(nr), | 361 | via686a_write_value(client, VIA686A_REG_IN_MIN(nr), |
361 | data->in_min[nr]); | 362 | data->in_min[nr]); |
362 | up(&data->update_lock); | 363 | mutex_unlock(&data->update_lock); |
363 | return count; | 364 | return count; |
364 | } | 365 | } |
365 | static ssize_t set_in_max(struct device *dev, const char *buf, | 366 | static ssize_t set_in_max(struct device *dev, const char *buf, |
@@ -368,11 +369,11 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
368 | struct via686a_data *data = i2c_get_clientdata(client); | 369 | struct via686a_data *data = i2c_get_clientdata(client); |
369 | unsigned long val = simple_strtoul(buf, NULL, 10); | 370 | unsigned long val = simple_strtoul(buf, NULL, 10); |
370 | 371 | ||
371 | down(&data->update_lock); | 372 | mutex_lock(&data->update_lock); |
372 | data->in_max[nr] = IN_TO_REG(val, nr); | 373 | data->in_max[nr] = IN_TO_REG(val, nr); |
373 | via686a_write_value(client, VIA686A_REG_IN_MAX(nr), | 374 | via686a_write_value(client, VIA686A_REG_IN_MAX(nr), |
374 | data->in_max[nr]); | 375 | data->in_max[nr]); |
375 | up(&data->update_lock); | 376 | mutex_unlock(&data->update_lock); |
376 | return count; | 377 | return count; |
377 | } | 378 | } |
378 | #define show_in_offset(offset) \ | 379 | #define show_in_offset(offset) \ |
@@ -432,11 +433,11 @@ static ssize_t set_temp_over(struct device *dev, const char *buf, | |||
432 | struct via686a_data *data = i2c_get_clientdata(client); | 433 | struct via686a_data *data = i2c_get_clientdata(client); |
433 | int val = simple_strtol(buf, NULL, 10); | 434 | int val = simple_strtol(buf, NULL, 10); |
434 | 435 | ||
435 | down(&data->update_lock); | 436 | mutex_lock(&data->update_lock); |
436 | data->temp_over[nr] = TEMP_TO_REG(val); | 437 | data->temp_over[nr] = TEMP_TO_REG(val); |
437 | via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr], | 438 | via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr], |
438 | data->temp_over[nr]); | 439 | data->temp_over[nr]); |
439 | up(&data->update_lock); | 440 | mutex_unlock(&data->update_lock); |
440 | return count; | 441 | return count; |
441 | } | 442 | } |
442 | static ssize_t set_temp_hyst(struct device *dev, const char *buf, | 443 | static ssize_t set_temp_hyst(struct device *dev, const char *buf, |
@@ -445,11 +446,11 @@ static ssize_t set_temp_hyst(struct device *dev, const char *buf, | |||
445 | struct via686a_data *data = i2c_get_clientdata(client); | 446 | struct via686a_data *data = i2c_get_clientdata(client); |
446 | int val = simple_strtol(buf, NULL, 10); | 447 | int val = simple_strtol(buf, NULL, 10); |
447 | 448 | ||
448 | down(&data->update_lock); | 449 | mutex_lock(&data->update_lock); |
449 | data->temp_hyst[nr] = TEMP_TO_REG(val); | 450 | data->temp_hyst[nr] = TEMP_TO_REG(val); |
450 | via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr], | 451 | via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr], |
451 | data->temp_hyst[nr]); | 452 | data->temp_hyst[nr]); |
452 | up(&data->update_lock); | 453 | mutex_unlock(&data->update_lock); |
453 | return count; | 454 | return count; |
454 | } | 455 | } |
455 | #define show_temp_offset(offset) \ | 456 | #define show_temp_offset(offset) \ |
@@ -508,10 +509,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
508 | struct via686a_data *data = i2c_get_clientdata(client); | 509 | struct via686a_data *data = i2c_get_clientdata(client); |
509 | int val = simple_strtol(buf, NULL, 10); | 510 | int val = simple_strtol(buf, NULL, 10); |
510 | 511 | ||
511 | down(&data->update_lock); | 512 | mutex_lock(&data->update_lock); |
512 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 513 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
513 | via686a_write_value(client, VIA686A_REG_FAN_MIN(nr+1), data->fan_min[nr]); | 514 | via686a_write_value(client, VIA686A_REG_FAN_MIN(nr+1), data->fan_min[nr]); |
514 | up(&data->update_lock); | 515 | mutex_unlock(&data->update_lock); |
515 | return count; | 516 | return count; |
516 | } | 517 | } |
517 | static ssize_t set_fan_div(struct device *dev, const char *buf, | 518 | static ssize_t set_fan_div(struct device *dev, const char *buf, |
@@ -521,12 +522,12 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
521 | int val = simple_strtol(buf, NULL, 10); | 522 | int val = simple_strtol(buf, NULL, 10); |
522 | int old; | 523 | int old; |
523 | 524 | ||
524 | down(&data->update_lock); | 525 | mutex_lock(&data->update_lock); |
525 | old = via686a_read_value(client, VIA686A_REG_FANDIV); | 526 | old = via686a_read_value(client, VIA686A_REG_FANDIV); |
526 | data->fan_div[nr] = DIV_TO_REG(val); | 527 | data->fan_div[nr] = DIV_TO_REG(val); |
527 | old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); | 528 | old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); |
528 | via686a_write_value(client, VIA686A_REG_FANDIV, old); | 529 | via686a_write_value(client, VIA686A_REG_FANDIV, old); |
529 | up(&data->update_lock); | 530 | mutex_unlock(&data->update_lock); |
530 | return count; | 531 | return count; |
531 | } | 532 | } |
532 | 533 | ||
@@ -639,7 +640,7 @@ static int via686a_detect(struct i2c_adapter *adapter) | |||
639 | strlcpy(new_client->name, client_name, I2C_NAME_SIZE); | 640 | strlcpy(new_client->name, client_name, I2C_NAME_SIZE); |
640 | 641 | ||
641 | data->valid = 0; | 642 | data->valid = 0; |
642 | init_MUTEX(&data->update_lock); | 643 | mutex_init(&data->update_lock); |
643 | /* Tell the I2C layer a new client has arrived */ | 644 | /* Tell the I2C layer a new client has arrived */ |
644 | if ((err = i2c_attach_client(new_client))) | 645 | if ((err = i2c_attach_client(new_client))) |
645 | goto exit_free; | 646 | goto exit_free; |
@@ -733,7 +734,7 @@ static struct via686a_data *via686a_update_device(struct device *dev) | |||
733 | struct via686a_data *data = i2c_get_clientdata(client); | 734 | struct via686a_data *data = i2c_get_clientdata(client); |
734 | int i; | 735 | int i; |
735 | 736 | ||
736 | down(&data->update_lock); | 737 | mutex_lock(&data->update_lock); |
737 | 738 | ||
738 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 739 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
739 | || !data->valid) { | 740 | || !data->valid) { |
@@ -788,7 +789,7 @@ static struct via686a_data *via686a_update_device(struct device *dev) | |||
788 | data->valid = 1; | 789 | data->valid = 1; |
789 | } | 790 | } |
790 | 791 | ||
791 | up(&data->update_lock); | 792 | mutex_unlock(&data->update_lock); |
792 | 793 | ||
793 | return data; | 794 | return data; |
794 | } | 795 | } |
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c index 271e9cb9532c..686f3deb3093 100644 --- a/drivers/hwmon/vt8231.c +++ b/drivers/hwmon/vt8231.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/hwmon-sysfs.h> | 35 | #include <linux/hwmon-sysfs.h> |
36 | #include <linux/hwmon-vid.h> | 36 | #include <linux/hwmon-vid.h> |
37 | #include <linux/err.h> | 37 | #include <linux/err.h> |
38 | #include <linux/mutex.h> | ||
38 | #include <asm/io.h> | 39 | #include <asm/io.h> |
39 | 40 | ||
40 | static int force_addr; | 41 | static int force_addr; |
@@ -148,7 +149,7 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
148 | 149 | ||
149 | struct vt8231_data { | 150 | struct vt8231_data { |
150 | struct i2c_client client; | 151 | struct i2c_client client; |
151 | struct semaphore update_lock; | 152 | struct mutex update_lock; |
152 | struct class_device *class_dev; | 153 | struct class_device *class_dev; |
153 | char valid; /* !=0 if following fields are valid */ | 154 | char valid; /* !=0 if following fields are valid */ |
154 | unsigned long last_updated; /* In jiffies */ | 155 | unsigned long last_updated; /* In jiffies */ |
@@ -223,10 +224,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | |||
223 | struct vt8231_data *data = i2c_get_clientdata(client); | 224 | struct vt8231_data *data = i2c_get_clientdata(client); |
224 | unsigned long val = simple_strtoul(buf, NULL, 10); | 225 | unsigned long val = simple_strtoul(buf, NULL, 10); |
225 | 226 | ||
226 | down(&data->update_lock); | 227 | mutex_lock(&data->update_lock); |
227 | data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); | 228 | data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); |
228 | vt8231_write_value(client, regvoltmin[nr], data->in_min[nr]); | 229 | vt8231_write_value(client, regvoltmin[nr], data->in_min[nr]); |
229 | up(&data->update_lock); | 230 | mutex_unlock(&data->update_lock); |
230 | return count; | 231 | return count; |
231 | } | 232 | } |
232 | 233 | ||
@@ -239,10 +240,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | |||
239 | struct vt8231_data *data = i2c_get_clientdata(client); | 240 | struct vt8231_data *data = i2c_get_clientdata(client); |
240 | unsigned long val = simple_strtoul(buf, NULL, 10); | 241 | unsigned long val = simple_strtoul(buf, NULL, 10); |
241 | 242 | ||
242 | down(&data->update_lock); | 243 | mutex_lock(&data->update_lock); |
243 | data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); | 244 | data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); |
244 | vt8231_write_value(client, regvoltmax[nr], data->in_max[nr]); | 245 | vt8231_write_value(client, regvoltmax[nr], data->in_max[nr]); |
245 | up(&data->update_lock); | 246 | mutex_unlock(&data->update_lock); |
246 | return count; | 247 | return count; |
247 | } | 248 | } |
248 | 249 | ||
@@ -281,11 +282,11 @@ static ssize_t set_in5_min(struct device *dev, struct device_attribute *attr, | |||
281 | struct vt8231_data *data = i2c_get_clientdata(client); | 282 | struct vt8231_data *data = i2c_get_clientdata(client); |
282 | unsigned long val = simple_strtoul(buf, NULL, 10); | 283 | unsigned long val = simple_strtoul(buf, NULL, 10); |
283 | 284 | ||
284 | down(&data->update_lock); | 285 | mutex_lock(&data->update_lock); |
285 | data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, | 286 | data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, |
286 | 0, 255); | 287 | 0, 255); |
287 | vt8231_write_value(client, regvoltmin[5], data->in_min[5]); | 288 | vt8231_write_value(client, regvoltmin[5], data->in_min[5]); |
288 | up(&data->update_lock); | 289 | mutex_unlock(&data->update_lock); |
289 | return count; | 290 | return count; |
290 | } | 291 | } |
291 | 292 | ||
@@ -296,11 +297,11 @@ static ssize_t set_in5_max(struct device *dev, struct device_attribute *attr, | |||
296 | struct vt8231_data *data = i2c_get_clientdata(client); | 297 | struct vt8231_data *data = i2c_get_clientdata(client); |
297 | unsigned long val = simple_strtoul(buf, NULL, 10); | 298 | unsigned long val = simple_strtoul(buf, NULL, 10); |
298 | 299 | ||
299 | down(&data->update_lock); | 300 | mutex_lock(&data->update_lock); |
300 | data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, | 301 | data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, |
301 | 0, 255); | 302 | 0, 255); |
302 | vt8231_write_value(client, regvoltmax[5], data->in_max[5]); | 303 | vt8231_write_value(client, regvoltmax[5], data->in_max[5]); |
303 | up(&data->update_lock); | 304 | mutex_unlock(&data->update_lock); |
304 | return count; | 305 | return count; |
305 | } | 306 | } |
306 | 307 | ||
@@ -351,10 +352,10 @@ static ssize_t set_temp0_max(struct device *dev, struct device_attribute *attr, | |||
351 | struct vt8231_data *data = i2c_get_clientdata(client); | 352 | struct vt8231_data *data = i2c_get_clientdata(client); |
352 | int val = simple_strtol(buf, NULL, 10); | 353 | int val = simple_strtol(buf, NULL, 10); |
353 | 354 | ||
354 | down(&data->update_lock); | 355 | mutex_lock(&data->update_lock); |
355 | data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); | 356 | data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); |
356 | vt8231_write_value(client, regtempmax[0], data->temp_max[0]); | 357 | vt8231_write_value(client, regtempmax[0], data->temp_max[0]); |
357 | up(&data->update_lock); | 358 | mutex_unlock(&data->update_lock); |
358 | return count; | 359 | return count; |
359 | } | 360 | } |
360 | static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, | 361 | static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, |
@@ -364,10 +365,10 @@ static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, | |||
364 | struct vt8231_data *data = i2c_get_clientdata(client); | 365 | struct vt8231_data *data = i2c_get_clientdata(client); |
365 | int val = simple_strtol(buf, NULL, 10); | 366 | int val = simple_strtol(buf, NULL, 10); |
366 | 367 | ||
367 | down(&data->update_lock); | 368 | mutex_lock(&data->update_lock); |
368 | data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); | 369 | data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); |
369 | vt8231_write_value(client, regtempmin[0], data->temp_min[0]); | 370 | vt8231_write_value(client, regtempmin[0], data->temp_min[0]); |
370 | up(&data->update_lock); | 371 | mutex_unlock(&data->update_lock); |
371 | return count; | 372 | return count; |
372 | } | 373 | } |
373 | 374 | ||
@@ -407,10 +408,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
407 | struct vt8231_data *data = i2c_get_clientdata(client); | 408 | struct vt8231_data *data = i2c_get_clientdata(client); |
408 | int val = simple_strtol(buf, NULL, 10); | 409 | int val = simple_strtol(buf, NULL, 10); |
409 | 410 | ||
410 | down(&data->update_lock); | 411 | mutex_lock(&data->update_lock); |
411 | data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); | 412 | data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); |
412 | vt8231_write_value(client, regtempmax[nr], data->temp_max[nr]); | 413 | vt8231_write_value(client, regtempmax[nr], data->temp_max[nr]); |
413 | up(&data->update_lock); | 414 | mutex_unlock(&data->update_lock); |
414 | return count; | 415 | return count; |
415 | } | 416 | } |
416 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | 417 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
@@ -422,10 +423,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
422 | struct vt8231_data *data = i2c_get_clientdata(client); | 423 | struct vt8231_data *data = i2c_get_clientdata(client); |
423 | int val = simple_strtol(buf, NULL, 10); | 424 | int val = simple_strtol(buf, NULL, 10); |
424 | 425 | ||
425 | down(&data->update_lock); | 426 | mutex_lock(&data->update_lock); |
426 | data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); | 427 | data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); |
427 | vt8231_write_value(client, regtempmin[nr], data->temp_min[nr]); | 428 | vt8231_write_value(client, regtempmin[nr], data->temp_min[nr]); |
428 | up(&data->update_lock); | 429 | mutex_unlock(&data->update_lock); |
429 | return count; | 430 | return count; |
430 | } | 431 | } |
431 | 432 | ||
@@ -520,10 +521,10 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
520 | struct vt8231_data *data = i2c_get_clientdata(client); | 521 | struct vt8231_data *data = i2c_get_clientdata(client); |
521 | int val = simple_strtoul(buf, NULL, 10); | 522 | int val = simple_strtoul(buf, NULL, 10); |
522 | 523 | ||
523 | down(&data->update_lock); | 524 | mutex_lock(&data->update_lock); |
524 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 525 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
525 | vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]); | 526 | vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]); |
526 | up(&data->update_lock); | 527 | mutex_unlock(&data->update_lock); |
527 | return count; | 528 | return count; |
528 | } | 529 | } |
529 | 530 | ||
@@ -539,7 +540,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
539 | long min = FAN_FROM_REG(data->fan_min[nr], | 540 | long min = FAN_FROM_REG(data->fan_min[nr], |
540 | DIV_FROM_REG(data->fan_div[nr])); | 541 | DIV_FROM_REG(data->fan_div[nr])); |
541 | 542 | ||
542 | down(&data->update_lock); | 543 | mutex_lock(&data->update_lock); |
543 | switch (val) { | 544 | switch (val) { |
544 | case 1: data->fan_div[nr] = 0; break; | 545 | case 1: data->fan_div[nr] = 0; break; |
545 | case 2: data->fan_div[nr] = 1; break; | 546 | case 2: data->fan_div[nr] = 1; break; |
@@ -548,7 +549,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
548 | default: | 549 | default: |
549 | dev_err(&client->dev, "fan_div value %ld not supported." | 550 | dev_err(&client->dev, "fan_div value %ld not supported." |
550 | "Choose one of 1, 2, 4 or 8!\n", val); | 551 | "Choose one of 1, 2, 4 or 8!\n", val); |
551 | up(&data->update_lock); | 552 | mutex_unlock(&data->update_lock); |
552 | return -EINVAL; | 553 | return -EINVAL; |
553 | } | 554 | } |
554 | 555 | ||
@@ -558,7 +559,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
558 | 559 | ||
559 | old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); | 560 | old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); |
560 | vt8231_write_value(client, VT8231_REG_FANDIV, old); | 561 | vt8231_write_value(client, VT8231_REG_FANDIV, old); |
561 | up(&data->update_lock); | 562 | mutex_unlock(&data->update_lock); |
562 | return count; | 563 | return count; |
563 | } | 564 | } |
564 | 565 | ||
@@ -660,7 +661,7 @@ int vt8231_detect(struct i2c_adapter *adapter) | |||
660 | /* Fill in the remaining client fields and put into the global list */ | 661 | /* Fill in the remaining client fields and put into the global list */ |
661 | strlcpy(client->name, "vt8231", I2C_NAME_SIZE); | 662 | strlcpy(client->name, "vt8231", I2C_NAME_SIZE); |
662 | 663 | ||
663 | init_MUTEX(&data->update_lock); | 664 | mutex_init(&data->update_lock); |
664 | 665 | ||
665 | /* Tell the I2C layer a new client has arrived */ | 666 | /* Tell the I2C layer a new client has arrived */ |
666 | if ((err = i2c_attach_client(client))) | 667 | if ((err = i2c_attach_client(client))) |
@@ -745,7 +746,7 @@ static struct vt8231_data *vt8231_update_device(struct device *dev) | |||
745 | int i; | 746 | int i; |
746 | u16 low; | 747 | u16 low; |
747 | 748 | ||
748 | down(&data->update_lock); | 749 | mutex_lock(&data->update_lock); |
749 | 750 | ||
750 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 751 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
751 | || !data->valid) { | 752 | || !data->valid) { |
@@ -804,7 +805,7 @@ static struct vt8231_data *vt8231_update_device(struct device *dev) | |||
804 | data->valid = 1; | 805 | data->valid = 1; |
805 | } | 806 | } |
806 | 807 | ||
807 | up(&data->update_lock); | 808 | mutex_unlock(&data->update_lock); |
808 | 809 | ||
809 | return data; | 810 | return data; |
810 | } | 811 | } |
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index 12d79f5e4900..b6bd5685fd38 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c | |||
@@ -42,7 +42,9 @@ | |||
42 | #include <linux/i2c.h> | 42 | #include <linux/i2c.h> |
43 | #include <linux/i2c-isa.h> | 43 | #include <linux/i2c-isa.h> |
44 | #include <linux/hwmon.h> | 44 | #include <linux/hwmon.h> |
45 | #include <linux/hwmon-sysfs.h> | ||
45 | #include <linux/err.h> | 46 | #include <linux/err.h> |
47 | #include <linux/mutex.h> | ||
46 | #include <asm/io.h> | 48 | #include <asm/io.h> |
47 | #include "lm75.h" | 49 | #include "lm75.h" |
48 | 50 | ||
@@ -177,9 +179,9 @@ temp1_to_reg(int temp) | |||
177 | struct w83627ehf_data { | 179 | struct w83627ehf_data { |
178 | struct i2c_client client; | 180 | struct i2c_client client; |
179 | struct class_device *class_dev; | 181 | struct class_device *class_dev; |
180 | struct semaphore lock; | 182 | struct mutex lock; |
181 | 183 | ||
182 | struct semaphore update_lock; | 184 | struct mutex update_lock; |
183 | char valid; /* !=0 if following fields are valid */ | 185 | char valid; /* !=0 if following fields are valid */ |
184 | unsigned long last_updated; /* In jiffies */ | 186 | unsigned long last_updated; /* In jiffies */ |
185 | 187 | ||
@@ -230,7 +232,7 @@ static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg) | |||
230 | struct w83627ehf_data *data = i2c_get_clientdata(client); | 232 | struct w83627ehf_data *data = i2c_get_clientdata(client); |
231 | int res, word_sized = is_word_sized(reg); | 233 | int res, word_sized = is_word_sized(reg); |
232 | 234 | ||
233 | down(&data->lock); | 235 | mutex_lock(&data->lock); |
234 | 236 | ||
235 | w83627ehf_set_bank(client, reg); | 237 | w83627ehf_set_bank(client, reg); |
236 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); | 238 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); |
@@ -242,7 +244,7 @@ static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg) | |||
242 | } | 244 | } |
243 | w83627ehf_reset_bank(client, reg); | 245 | w83627ehf_reset_bank(client, reg); |
244 | 246 | ||
245 | up(&data->lock); | 247 | mutex_unlock(&data->lock); |
246 | 248 | ||
247 | return res; | 249 | return res; |
248 | } | 250 | } |
@@ -252,7 +254,7 @@ static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
252 | struct w83627ehf_data *data = i2c_get_clientdata(client); | 254 | struct w83627ehf_data *data = i2c_get_clientdata(client); |
253 | int word_sized = is_word_sized(reg); | 255 | int word_sized = is_word_sized(reg); |
254 | 256 | ||
255 | down(&data->lock); | 257 | mutex_lock(&data->lock); |
256 | 258 | ||
257 | w83627ehf_set_bank(client, reg); | 259 | w83627ehf_set_bank(client, reg); |
258 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); | 260 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); |
@@ -264,7 +266,7 @@ static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
264 | outb_p(value & 0xff, client->addr + DATA_REG_OFFSET); | 266 | outb_p(value & 0xff, client->addr + DATA_REG_OFFSET); |
265 | w83627ehf_reset_bank(client, reg); | 267 | w83627ehf_reset_bank(client, reg); |
266 | 268 | ||
267 | up(&data->lock); | 269 | mutex_unlock(&data->lock); |
268 | return 0; | 270 | return 0; |
269 | } | 271 | } |
270 | 272 | ||
@@ -322,7 +324,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) | |||
322 | struct w83627ehf_data *data = i2c_get_clientdata(client); | 324 | struct w83627ehf_data *data = i2c_get_clientdata(client); |
323 | int i; | 325 | int i; |
324 | 326 | ||
325 | down(&data->update_lock); | 327 | mutex_lock(&data->update_lock); |
326 | 328 | ||
327 | if (time_after(jiffies, data->last_updated + HZ) | 329 | if (time_after(jiffies, data->last_updated + HZ) |
328 | || !data->valid) { | 330 | || !data->valid) { |
@@ -397,7 +399,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) | |||
397 | data->valid = 1; | 399 | data->valid = 1; |
398 | } | 400 | } |
399 | 401 | ||
400 | up(&data->update_lock); | 402 | mutex_unlock(&data->update_lock); |
401 | return data; | 403 | return data; |
402 | } | 404 | } |
403 | 405 | ||
@@ -407,9 +409,12 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) | |||
407 | 409 | ||
408 | #define show_fan_reg(reg) \ | 410 | #define show_fan_reg(reg) \ |
409 | static ssize_t \ | 411 | static ssize_t \ |
410 | show_##reg(struct device *dev, char *buf, int nr) \ | 412 | show_##reg(struct device *dev, struct device_attribute *attr, \ |
413 | char *buf) \ | ||
411 | { \ | 414 | { \ |
412 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | 415 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ |
416 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ | ||
417 | int nr = sensor_attr->index; \ | ||
413 | return sprintf(buf, "%d\n", \ | 418 | return sprintf(buf, "%d\n", \ |
414 | fan_from_reg(data->reg[nr], \ | 419 | fan_from_reg(data->reg[nr], \ |
415 | div_from_reg(data->fan_div[nr]))); \ | 420 | div_from_reg(data->fan_div[nr]))); \ |
@@ -418,23 +423,28 @@ show_fan_reg(fan); | |||
418 | show_fan_reg(fan_min); | 423 | show_fan_reg(fan_min); |
419 | 424 | ||
420 | static ssize_t | 425 | static ssize_t |
421 | show_fan_div(struct device *dev, char *buf, int nr) | 426 | show_fan_div(struct device *dev, struct device_attribute *attr, |
427 | char *buf) | ||
422 | { | 428 | { |
423 | struct w83627ehf_data *data = w83627ehf_update_device(dev); | 429 | struct w83627ehf_data *data = w83627ehf_update_device(dev); |
424 | return sprintf(buf, "%u\n", | 430 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
425 | div_from_reg(data->fan_div[nr])); | 431 | int nr = sensor_attr->index; |
432 | return sprintf(buf, "%u\n", div_from_reg(data->fan_div[nr])); | ||
426 | } | 433 | } |
427 | 434 | ||
428 | static ssize_t | 435 | static ssize_t |
429 | store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | 436 | store_fan_min(struct device *dev, struct device_attribute *attr, |
437 | const char *buf, size_t count) | ||
430 | { | 438 | { |
431 | struct i2c_client *client = to_i2c_client(dev); | 439 | struct i2c_client *client = to_i2c_client(dev); |
432 | struct w83627ehf_data *data = i2c_get_clientdata(client); | 440 | struct w83627ehf_data *data = i2c_get_clientdata(client); |
441 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
442 | int nr = sensor_attr->index; | ||
433 | unsigned int val = simple_strtoul(buf, NULL, 10); | 443 | unsigned int val = simple_strtoul(buf, NULL, 10); |
434 | unsigned int reg; | 444 | unsigned int reg; |
435 | u8 new_div; | 445 | u8 new_div; |
436 | 446 | ||
437 | down(&data->update_lock); | 447 | mutex_lock(&data->update_lock); |
438 | if (!val) { | 448 | if (!val) { |
439 | /* No min limit, alarm disabled */ | 449 | /* No min limit, alarm disabled */ |
440 | data->fan_min[nr] = 255; | 450 | data->fan_min[nr] = 255; |
@@ -482,63 +492,46 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
482 | } | 492 | } |
483 | w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr], | 493 | w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr], |
484 | data->fan_min[nr]); | 494 | data->fan_min[nr]); |
485 | up(&data->update_lock); | 495 | mutex_unlock(&data->update_lock); |
486 | 496 | ||
487 | return count; | 497 | return count; |
488 | } | 498 | } |
489 | 499 | ||
490 | #define sysfs_fan_offset(offset) \ | 500 | static struct sensor_device_attribute sda_fan_input[] = { |
491 | static ssize_t \ | 501 | SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0), |
492 | show_reg_fan_##offset(struct device *dev, struct device_attribute *attr, \ | 502 | SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1), |
493 | char *buf) \ | 503 | SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2), |
494 | { \ | 504 | SENSOR_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3), |
495 | return show_fan(dev, buf, offset-1); \ | 505 | SENSOR_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 4), |
496 | } \ | 506 | }; |
497 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
498 | show_reg_fan_##offset, NULL); | ||
499 | 507 | ||
500 | #define sysfs_fan_min_offset(offset) \ | 508 | static struct sensor_device_attribute sda_fan_min[] = { |
501 | static ssize_t \ | 509 | SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, |
502 | show_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ | 510 | store_fan_min, 0), |
503 | char *buf) \ | 511 | SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, |
504 | { \ | 512 | store_fan_min, 1), |
505 | return show_fan_min(dev, buf, offset-1); \ | 513 | SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, |
506 | } \ | 514 | store_fan_min, 2), |
507 | static ssize_t \ | 515 | SENSOR_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min, |
508 | store_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ | 516 | store_fan_min, 3), |
509 | const char *buf, size_t count) \ | 517 | SENSOR_ATTR(fan5_min, S_IWUSR | S_IRUGO, show_fan_min, |
510 | { \ | 518 | store_fan_min, 4), |
511 | return store_fan_min(dev, buf, count, offset-1); \ | 519 | }; |
512 | } \ | ||
513 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
514 | show_reg_fan##offset##_min, \ | ||
515 | store_reg_fan##offset##_min); | ||
516 | 520 | ||
517 | #define sysfs_fan_div_offset(offset) \ | 521 | static struct sensor_device_attribute sda_fan_div[] = { |
518 | static ssize_t \ | 522 | SENSOR_ATTR(fan1_div, S_IRUGO, show_fan_div, NULL, 0), |
519 | show_reg_fan##offset##_div(struct device *dev, struct device_attribute *attr, \ | 523 | SENSOR_ATTR(fan2_div, S_IRUGO, show_fan_div, NULL, 1), |
520 | char *buf) \ | 524 | SENSOR_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2), |
521 | { \ | 525 | SENSOR_ATTR(fan4_div, S_IRUGO, show_fan_div, NULL, 3), |
522 | return show_fan_div(dev, buf, offset - 1); \ | 526 | SENSOR_ATTR(fan5_div, S_IRUGO, show_fan_div, NULL, 4), |
523 | } \ | 527 | }; |
524 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | 528 | |
525 | show_reg_fan##offset##_div, NULL); | 529 | static void device_create_file_fan(struct device *dev, int i) |
526 | 530 | { | |
527 | sysfs_fan_offset(1); | 531 | device_create_file(dev, &sda_fan_input[i].dev_attr); |
528 | sysfs_fan_min_offset(1); | 532 | device_create_file(dev, &sda_fan_div[i].dev_attr); |
529 | sysfs_fan_div_offset(1); | 533 | device_create_file(dev, &sda_fan_min[i].dev_attr); |
530 | sysfs_fan_offset(2); | 534 | } |
531 | sysfs_fan_min_offset(2); | ||
532 | sysfs_fan_div_offset(2); | ||
533 | sysfs_fan_offset(3); | ||
534 | sysfs_fan_min_offset(3); | ||
535 | sysfs_fan_div_offset(3); | ||
536 | sysfs_fan_offset(4); | ||
537 | sysfs_fan_min_offset(4); | ||
538 | sysfs_fan_div_offset(4); | ||
539 | sysfs_fan_offset(5); | ||
540 | sysfs_fan_min_offset(5); | ||
541 | sysfs_fan_div_offset(5); | ||
542 | 535 | ||
543 | #define show_temp1_reg(reg) \ | 536 | #define show_temp1_reg(reg) \ |
544 | static ssize_t \ | 537 | static ssize_t \ |
@@ -561,27 +554,24 @@ store_temp1_##reg(struct device *dev, struct device_attribute *attr, \ | |||
561 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ | 554 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ |
562 | u32 val = simple_strtoul(buf, NULL, 10); \ | 555 | u32 val = simple_strtoul(buf, NULL, 10); \ |
563 | \ | 556 | \ |
564 | down(&data->update_lock); \ | 557 | mutex_lock(&data->update_lock); \ |
565 | data->temp1_##reg = temp1_to_reg(val); \ | 558 | data->temp1_##reg = temp1_to_reg(val); \ |
566 | w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \ | 559 | w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \ |
567 | data->temp1_##reg); \ | 560 | data->temp1_##reg); \ |
568 | up(&data->update_lock); \ | 561 | mutex_unlock(&data->update_lock); \ |
569 | return count; \ | 562 | return count; \ |
570 | } | 563 | } |
571 | store_temp1_reg(OVER, max); | 564 | store_temp1_reg(OVER, max); |
572 | store_temp1_reg(HYST, max_hyst); | 565 | store_temp1_reg(HYST, max_hyst); |
573 | 566 | ||
574 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL); | ||
575 | static DEVICE_ATTR(temp1_max, S_IRUGO| S_IWUSR, | ||
576 | show_temp1_max, store_temp1_max); | ||
577 | static DEVICE_ATTR(temp1_max_hyst, S_IRUGO| S_IWUSR, | ||
578 | show_temp1_max_hyst, store_temp1_max_hyst); | ||
579 | |||
580 | #define show_temp_reg(reg) \ | 567 | #define show_temp_reg(reg) \ |
581 | static ssize_t \ | 568 | static ssize_t \ |
582 | show_##reg (struct device *dev, char *buf, int nr) \ | 569 | show_##reg(struct device *dev, struct device_attribute *attr, \ |
570 | char *buf) \ | ||
583 | { \ | 571 | { \ |
584 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | 572 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ |
573 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ | ||
574 | int nr = sensor_attr->index; \ | ||
585 | return sprintf(buf, "%d\n", \ | 575 | return sprintf(buf, "%d\n", \ |
586 | LM75_TEMP_FROM_REG(data->reg[nr])); \ | 576 | LM75_TEMP_FROM_REG(data->reg[nr])); \ |
587 | } | 577 | } |
@@ -591,55 +581,42 @@ show_temp_reg(temp_max_hyst); | |||
591 | 581 | ||
592 | #define store_temp_reg(REG, reg) \ | 582 | #define store_temp_reg(REG, reg) \ |
593 | static ssize_t \ | 583 | static ssize_t \ |
594 | store_##reg (struct device *dev, const char *buf, size_t count, int nr) \ | 584 | store_##reg(struct device *dev, struct device_attribute *attr, \ |
585 | const char *buf, size_t count) \ | ||
595 | { \ | 586 | { \ |
596 | struct i2c_client *client = to_i2c_client(dev); \ | 587 | struct i2c_client *client = to_i2c_client(dev); \ |
597 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ | 588 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ |
589 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ | ||
590 | int nr = sensor_attr->index; \ | ||
598 | u32 val = simple_strtoul(buf, NULL, 10); \ | 591 | u32 val = simple_strtoul(buf, NULL, 10); \ |
599 | \ | 592 | \ |
600 | down(&data->update_lock); \ | 593 | mutex_lock(&data->update_lock); \ |
601 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ | 594 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ |
602 | w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \ | 595 | w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \ |
603 | data->reg[nr]); \ | 596 | data->reg[nr]); \ |
604 | up(&data->update_lock); \ | 597 | mutex_unlock(&data->update_lock); \ |
605 | return count; \ | 598 | return count; \ |
606 | } | 599 | } |
607 | store_temp_reg(OVER, temp_max); | 600 | store_temp_reg(OVER, temp_max); |
608 | store_temp_reg(HYST, temp_max_hyst); | 601 | store_temp_reg(HYST, temp_max_hyst); |
609 | 602 | ||
610 | #define sysfs_temp_offset(offset) \ | 603 | static struct sensor_device_attribute sda_temp[] = { |
611 | static ssize_t \ | 604 | SENSOR_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0), |
612 | show_reg_temp##offset (struct device *dev, struct device_attribute *attr, \ | 605 | SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 0), |
613 | char *buf) \ | 606 | SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 1), |
614 | { \ | 607 | SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp1_max, |
615 | return show_temp(dev, buf, offset - 2); \ | 608 | store_temp1_max, 0), |
616 | } \ | 609 | SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, show_temp_max, |
617 | static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | 610 | store_temp_max, 0), |
618 | show_reg_temp##offset, NULL); | 611 | SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, show_temp_max, |
619 | 612 | store_temp_max, 1), | |
620 | #define sysfs_temp_reg_offset(reg, offset) \ | 613 | SENSOR_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1_max_hyst, |
621 | static ssize_t \ | 614 | store_temp1_max_hyst, 0), |
622 | show_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ | 615 | SENSOR_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst, |
623 | char *buf) \ | 616 | store_temp_max_hyst, 0), |
624 | { \ | 617 | SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst, |
625 | return show_temp_##reg(dev, buf, offset - 2); \ | 618 | store_temp_max_hyst, 1), |
626 | } \ | 619 | }; |
627 | static ssize_t \ | ||
628 | store_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ | ||
629 | const char *buf, size_t count) \ | ||
630 | { \ | ||
631 | return store_temp_##reg(dev, buf, count, offset - 2); \ | ||
632 | } \ | ||
633 | static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \ | ||
634 | show_reg_temp##offset##_##reg, \ | ||
635 | store_reg_temp##offset##_##reg); | ||
636 | |||
637 | sysfs_temp_offset(2); | ||
638 | sysfs_temp_reg_offset(max, 2); | ||
639 | sysfs_temp_reg_offset(max_hyst, 2); | ||
640 | sysfs_temp_offset(3); | ||
641 | sysfs_temp_reg_offset(max, 3); | ||
642 | sysfs_temp_reg_offset(max_hyst, 3); | ||
643 | 620 | ||
644 | /* | 621 | /* |
645 | * Driver and client management | 622 | * Driver and client management |
@@ -673,6 +650,7 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) | |||
673 | { | 650 | { |
674 | struct i2c_client *client; | 651 | struct i2c_client *client; |
675 | struct w83627ehf_data *data; | 652 | struct w83627ehf_data *data; |
653 | struct device *dev; | ||
676 | int i, err = 0; | 654 | int i, err = 0; |
677 | 655 | ||
678 | if (!request_region(address + REGION_OFFSET, REGION_LENGTH, | 656 | if (!request_region(address + REGION_OFFSET, REGION_LENGTH, |
@@ -689,14 +667,15 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) | |||
689 | client = &data->client; | 667 | client = &data->client; |
690 | i2c_set_clientdata(client, data); | 668 | i2c_set_clientdata(client, data); |
691 | client->addr = address; | 669 | client->addr = address; |
692 | init_MUTEX(&data->lock); | 670 | mutex_init(&data->lock); |
693 | client->adapter = adapter; | 671 | client->adapter = adapter; |
694 | client->driver = &w83627ehf_driver; | 672 | client->driver = &w83627ehf_driver; |
695 | client->flags = 0; | 673 | client->flags = 0; |
674 | dev = &client->dev; | ||
696 | 675 | ||
697 | strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE); | 676 | strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE); |
698 | data->valid = 0; | 677 | data->valid = 0; |
699 | init_MUTEX(&data->update_lock); | 678 | mutex_init(&data->update_lock); |
700 | 679 | ||
701 | /* Tell the i2c layer a new client has arrived */ | 680 | /* Tell the i2c layer a new client has arrived */ |
702 | if ((err = i2c_attach_client(client))) | 681 | if ((err = i2c_attach_client(client))) |
@@ -720,42 +699,18 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) | |||
720 | data->has_fan |= (1 << 4); | 699 | data->has_fan |= (1 << 4); |
721 | 700 | ||
722 | /* Register sysfs hooks */ | 701 | /* Register sysfs hooks */ |
723 | data->class_dev = hwmon_device_register(&client->dev); | 702 | data->class_dev = hwmon_device_register(dev); |
724 | if (IS_ERR(data->class_dev)) { | 703 | if (IS_ERR(data->class_dev)) { |
725 | err = PTR_ERR(data->class_dev); | 704 | err = PTR_ERR(data->class_dev); |
726 | goto exit_detach; | 705 | goto exit_detach; |
727 | } | 706 | } |
728 | 707 | ||
729 | device_create_file(&client->dev, &dev_attr_fan1_input); | 708 | for (i = 0; i < 5; i++) { |
730 | device_create_file(&client->dev, &dev_attr_fan1_min); | 709 | if (data->has_fan & (1 << i)) |
731 | device_create_file(&client->dev, &dev_attr_fan1_div); | 710 | device_create_file_fan(dev, i); |
732 | device_create_file(&client->dev, &dev_attr_fan2_input); | ||
733 | device_create_file(&client->dev, &dev_attr_fan2_min); | ||
734 | device_create_file(&client->dev, &dev_attr_fan2_div); | ||
735 | device_create_file(&client->dev, &dev_attr_fan3_input); | ||
736 | device_create_file(&client->dev, &dev_attr_fan3_min); | ||
737 | device_create_file(&client->dev, &dev_attr_fan3_div); | ||
738 | |||
739 | if (data->has_fan & (1 << 3)) { | ||
740 | device_create_file(&client->dev, &dev_attr_fan4_input); | ||
741 | device_create_file(&client->dev, &dev_attr_fan4_min); | ||
742 | device_create_file(&client->dev, &dev_attr_fan4_div); | ||
743 | } | ||
744 | if (data->has_fan & (1 << 4)) { | ||
745 | device_create_file(&client->dev, &dev_attr_fan5_input); | ||
746 | device_create_file(&client->dev, &dev_attr_fan5_min); | ||
747 | device_create_file(&client->dev, &dev_attr_fan5_div); | ||
748 | } | 711 | } |
749 | 712 | for (i = 0; i < ARRAY_SIZE(sda_temp); i++) | |
750 | device_create_file(&client->dev, &dev_attr_temp1_input); | 713 | device_create_file(dev, &sda_temp[i].dev_attr); |
751 | device_create_file(&client->dev, &dev_attr_temp1_max); | ||
752 | device_create_file(&client->dev, &dev_attr_temp1_max_hyst); | ||
753 | device_create_file(&client->dev, &dev_attr_temp2_input); | ||
754 | device_create_file(&client->dev, &dev_attr_temp2_max); | ||
755 | device_create_file(&client->dev, &dev_attr_temp2_max_hyst); | ||
756 | device_create_file(&client->dev, &dev_attr_temp3_input); | ||
757 | device_create_file(&client->dev, &dev_attr_temp3_max); | ||
758 | device_create_file(&client->dev, &dev_attr_temp3_max_hyst); | ||
759 | 714 | ||
760 | return 0; | 715 | return 0; |
761 | 716 | ||
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 7ea441d4da63..71fb7f1af8f5 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c | |||
@@ -28,6 +28,7 @@ | |||
28 | w83627hf 9 3 2 3 0x20 0x5ca3 no yes(LPC) | 28 | w83627hf 9 3 2 3 0x20 0x5ca3 no yes(LPC) |
29 | w83627thf 7 3 3 3 0x90 0x5ca3 no yes(LPC) | 29 | w83627thf 7 3 3 3 0x90 0x5ca3 no yes(LPC) |
30 | w83637hf 7 3 3 3 0x80 0x5ca3 no yes(LPC) | 30 | w83637hf 7 3 3 3 0x80 0x5ca3 no yes(LPC) |
31 | w83687thf 7 3 3 3 0x90 0x5ca3 no yes(LPC) | ||
31 | w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC) | 32 | w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC) |
32 | 33 | ||
33 | For other winbond chips, and for i2c support in the above chips, | 34 | For other winbond chips, and for i2c support in the above chips, |
@@ -46,6 +47,7 @@ | |||
46 | #include <linux/hwmon.h> | 47 | #include <linux/hwmon.h> |
47 | #include <linux/hwmon-vid.h> | 48 | #include <linux/hwmon-vid.h> |
48 | #include <linux/err.h> | 49 | #include <linux/err.h> |
50 | #include <linux/mutex.h> | ||
49 | #include <asm/io.h> | 51 | #include <asm/io.h> |
50 | #include "lm75.h" | 52 | #include "lm75.h" |
51 | 53 | ||
@@ -62,7 +64,7 @@ MODULE_PARM_DESC(force_i2c, | |||
62 | static unsigned short address; | 64 | static unsigned short address; |
63 | 65 | ||
64 | /* Insmod parameters */ | 66 | /* Insmod parameters */ |
65 | enum chips { any_chip, w83627hf, w83627thf, w83697hf, w83637hf }; | 67 | enum chips { any_chip, w83627hf, w83627thf, w83697hf, w83637hf, w83687thf }; |
66 | 68 | ||
67 | static int reset; | 69 | static int reset; |
68 | module_param(reset, bool, 0); | 70 | module_param(reset, bool, 0); |
@@ -100,6 +102,10 @@ static int VAL; /* The value to read/write */ | |||
100 | #define W83627THF_GPIO5_IOSR 0xf3 /* w83627thf only */ | 102 | #define W83627THF_GPIO5_IOSR 0xf3 /* w83627thf only */ |
101 | #define W83627THF_GPIO5_DR 0xf4 /* w83627thf only */ | 103 | #define W83627THF_GPIO5_DR 0xf4 /* w83627thf only */ |
102 | 104 | ||
105 | #define W83687THF_VID_EN 0x29 /* w83687thf only */ | ||
106 | #define W83687THF_VID_CFG 0xF0 /* w83687thf only */ | ||
107 | #define W83687THF_VID_DATA 0xF1 /* w83687thf only */ | ||
108 | |||
103 | static inline void | 109 | static inline void |
104 | superio_outb(int reg, int val) | 110 | superio_outb(int reg, int val) |
105 | { | 111 | { |
@@ -138,6 +144,7 @@ superio_exit(void) | |||
138 | #define W627THF_DEVID 0x82 | 144 | #define W627THF_DEVID 0x82 |
139 | #define W697_DEVID 0x60 | 145 | #define W697_DEVID 0x60 |
140 | #define W637_DEVID 0x70 | 146 | #define W637_DEVID 0x70 |
147 | #define W687THF_DEVID 0x85 | ||
141 | #define WINB_ACT_REG 0x30 | 148 | #define WINB_ACT_REG 0x30 |
142 | #define WINB_BASE_REG 0x60 | 149 | #define WINB_BASE_REG 0x60 |
143 | /* Constants specified below */ | 150 | /* Constants specified below */ |
@@ -201,11 +208,11 @@ superio_exit(void) | |||
201 | #define W83627HF_REG_PWM1 0x5A | 208 | #define W83627HF_REG_PWM1 0x5A |
202 | #define W83627HF_REG_PWM2 0x5B | 209 | #define W83627HF_REG_PWM2 0x5B |
203 | 210 | ||
204 | #define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */ | 211 | #define W83627THF_REG_PWM1 0x01 /* 697HF/637HF/687THF too */ |
205 | #define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */ | 212 | #define W83627THF_REG_PWM2 0x03 /* 697HF/637HF/687THF too */ |
206 | #define W83627THF_REG_PWM3 0x11 /* 637HF too */ | 213 | #define W83627THF_REG_PWM3 0x11 /* 637HF/687THF too */ |
207 | 214 | ||
208 | #define W83627THF_REG_VRM_OVT_CFG 0x18 /* 637HF too */ | 215 | #define W83627THF_REG_VRM_OVT_CFG 0x18 /* 637HF/687THF too */ |
209 | 216 | ||
210 | static const u8 regpwm_627hf[] = { W83627HF_REG_PWM1, W83627HF_REG_PWM2 }; | 217 | static const u8 regpwm_627hf[] = { W83627HF_REG_PWM1, W83627HF_REG_PWM2 }; |
211 | static const u8 regpwm[] = { W83627THF_REG_PWM1, W83627THF_REG_PWM2, | 218 | static const u8 regpwm[] = { W83627THF_REG_PWM1, W83627THF_REG_PWM2, |
@@ -285,10 +292,10 @@ static inline u8 DIV_TO_REG(long val) | |||
285 | struct w83627hf_data { | 292 | struct w83627hf_data { |
286 | struct i2c_client client; | 293 | struct i2c_client client; |
287 | struct class_device *class_dev; | 294 | struct class_device *class_dev; |
288 | struct semaphore lock; | 295 | struct mutex lock; |
289 | enum chips type; | 296 | enum chips type; |
290 | 297 | ||
291 | struct semaphore update_lock; | 298 | struct mutex update_lock; |
292 | char valid; /* !=0 if following fields are valid */ | 299 | char valid; /* !=0 if following fields are valid */ |
293 | unsigned long last_updated; /* In jiffies */ | 300 | unsigned long last_updated; /* In jiffies */ |
294 | 301 | ||
@@ -318,16 +325,15 @@ struct w83627hf_data { | |||
318 | Default = 3435. | 325 | Default = 3435. |
319 | Other Betas unimplemented */ | 326 | Other Betas unimplemented */ |
320 | u8 vrm; | 327 | u8 vrm; |
321 | u8 vrm_ovt; /* Register value, 627thf & 637hf only */ | 328 | u8 vrm_ovt; /* Register value, 627THF/637HF/687THF only */ |
322 | }; | 329 | }; |
323 | 330 | ||
324 | 331 | ||
325 | static int w83627hf_detect(struct i2c_adapter *adapter); | 332 | static int w83627hf_detect(struct i2c_adapter *adapter); |
326 | static int w83627hf_detach_client(struct i2c_client *client); | 333 | static int w83627hf_detach_client(struct i2c_client *client); |
327 | 334 | ||
328 | static int w83627hf_read_value(struct i2c_client *client, u16 register); | 335 | static int w83627hf_read_value(struct i2c_client *client, u16 reg); |
329 | static int w83627hf_write_value(struct i2c_client *client, u16 register, | 336 | static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value); |
330 | u16 value); | ||
331 | static struct w83627hf_data *w83627hf_update_device(struct device *dev); | 337 | static struct w83627hf_data *w83627hf_update_device(struct device *dev); |
332 | static void w83627hf_init_client(struct i2c_client *client); | 338 | static void w83627hf_init_client(struct i2c_client *client); |
333 | 339 | ||
@@ -360,12 +366,12 @@ store_in_##reg (struct device *dev, const char *buf, size_t count, int nr) \ | |||
360 | \ | 366 | \ |
361 | val = simple_strtoul(buf, NULL, 10); \ | 367 | val = simple_strtoul(buf, NULL, 10); \ |
362 | \ | 368 | \ |
363 | down(&data->update_lock); \ | 369 | mutex_lock(&data->update_lock); \ |
364 | data->in_##reg[nr] = IN_TO_REG(val); \ | 370 | data->in_##reg[nr] = IN_TO_REG(val); \ |
365 | w83627hf_write_value(client, W83781D_REG_IN_##REG(nr), \ | 371 | w83627hf_write_value(client, W83781D_REG_IN_##REG(nr), \ |
366 | data->in_##reg[nr]); \ | 372 | data->in_##reg[nr]); \ |
367 | \ | 373 | \ |
368 | up(&data->update_lock); \ | 374 | mutex_unlock(&data->update_lock); \ |
369 | return count; \ | 375 | return count; \ |
370 | } | 376 | } |
371 | store_in_reg(MIN, min) | 377 | store_in_reg(MIN, min) |
@@ -413,7 +419,8 @@ static ssize_t show_in_0(struct w83627hf_data *data, char *buf, u8 reg) | |||
413 | long in0; | 419 | long in0; |
414 | 420 | ||
415 | if ((data->vrm_ovt & 0x01) && | 421 | if ((data->vrm_ovt & 0x01) && |
416 | (w83627thf == data->type || w83637hf == data->type)) | 422 | (w83627thf == data->type || w83637hf == data->type |
423 | || w83687thf == data->type)) | ||
417 | 424 | ||
418 | /* use VRM9 calculation */ | 425 | /* use VRM9 calculation */ |
419 | in0 = (long)((reg * 488 + 70000 + 50) / 100); | 426 | in0 = (long)((reg * 488 + 70000 + 50) / 100); |
@@ -451,10 +458,11 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a | |||
451 | 458 | ||
452 | val = simple_strtoul(buf, NULL, 10); | 459 | val = simple_strtoul(buf, NULL, 10); |
453 | 460 | ||
454 | down(&data->update_lock); | 461 | mutex_lock(&data->update_lock); |
455 | 462 | ||
456 | if ((data->vrm_ovt & 0x01) && | 463 | if ((data->vrm_ovt & 0x01) && |
457 | (w83627thf == data->type || w83637hf == data->type)) | 464 | (w83627thf == data->type || w83637hf == data->type |
465 | || w83687thf == data->type)) | ||
458 | 466 | ||
459 | /* use VRM9 calculation */ | 467 | /* use VRM9 calculation */ |
460 | data->in_min[0] = | 468 | data->in_min[0] = |
@@ -465,7 +473,7 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a | |||
465 | data->in_min[0] = IN_TO_REG(val); | 473 | data->in_min[0] = IN_TO_REG(val); |
466 | 474 | ||
467 | w83627hf_write_value(client, W83781D_REG_IN_MIN(0), data->in_min[0]); | 475 | w83627hf_write_value(client, W83781D_REG_IN_MIN(0), data->in_min[0]); |
468 | up(&data->update_lock); | 476 | mutex_unlock(&data->update_lock); |
469 | return count; | 477 | return count; |
470 | } | 478 | } |
471 | 479 | ||
@@ -478,10 +486,11 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a | |||
478 | 486 | ||
479 | val = simple_strtoul(buf, NULL, 10); | 487 | val = simple_strtoul(buf, NULL, 10); |
480 | 488 | ||
481 | down(&data->update_lock); | 489 | mutex_lock(&data->update_lock); |
482 | 490 | ||
483 | if ((data->vrm_ovt & 0x01) && | 491 | if ((data->vrm_ovt & 0x01) && |
484 | (w83627thf == data->type || w83637hf == data->type)) | 492 | (w83627thf == data->type || w83637hf == data->type |
493 | || w83687thf == data->type)) | ||
485 | 494 | ||
486 | /* use VRM9 calculation */ | 495 | /* use VRM9 calculation */ |
487 | data->in_max[0] = | 496 | data->in_max[0] = |
@@ -492,7 +501,7 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a | |||
492 | data->in_max[0] = IN_TO_REG(val); | 501 | data->in_max[0] = IN_TO_REG(val); |
493 | 502 | ||
494 | w83627hf_write_value(client, W83781D_REG_IN_MAX(0), data->in_max[0]); | 503 | w83627hf_write_value(client, W83781D_REG_IN_MAX(0), data->in_max[0]); |
495 | up(&data->update_lock); | 504 | mutex_unlock(&data->update_lock); |
496 | return count; | 505 | return count; |
497 | } | 506 | } |
498 | 507 | ||
@@ -529,13 +538,13 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
529 | 538 | ||
530 | val = simple_strtoul(buf, NULL, 10); | 539 | val = simple_strtoul(buf, NULL, 10); |
531 | 540 | ||
532 | down(&data->update_lock); | 541 | mutex_lock(&data->update_lock); |
533 | data->fan_min[nr - 1] = | 542 | data->fan_min[nr - 1] = |
534 | FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); | 543 | FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); |
535 | w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr), | 544 | w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr), |
536 | data->fan_min[nr - 1]); | 545 | data->fan_min[nr - 1]); |
537 | 546 | ||
538 | up(&data->update_lock); | 547 | mutex_unlock(&data->update_lock); |
539 | return count; | 548 | return count; |
540 | } | 549 | } |
541 | 550 | ||
@@ -597,7 +606,7 @@ store_temp_##reg (struct device *dev, const char *buf, size_t count, int nr) \ | |||
597 | \ | 606 | \ |
598 | val = simple_strtoul(buf, NULL, 10); \ | 607 | val = simple_strtoul(buf, NULL, 10); \ |
599 | \ | 608 | \ |
600 | down(&data->update_lock); \ | 609 | mutex_lock(&data->update_lock); \ |
601 | \ | 610 | \ |
602 | if (nr >= 2) { /* TEMP2 and TEMP3 */ \ | 611 | if (nr >= 2) { /* TEMP2 and TEMP3 */ \ |
603 | data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ | 612 | data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ |
@@ -609,7 +618,7 @@ store_temp_##reg (struct device *dev, const char *buf, size_t count, int nr) \ | |||
609 | data->temp_##reg); \ | 618 | data->temp_##reg); \ |
610 | } \ | 619 | } \ |
611 | \ | 620 | \ |
612 | up(&data->update_lock); \ | 621 | mutex_unlock(&data->update_lock); \ |
613 | return count; \ | 622 | return count; \ |
614 | } | 623 | } |
615 | store_temp_reg(OVER, max); | 624 | store_temp_reg(OVER, max); |
@@ -718,7 +727,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count, | |||
718 | 727 | ||
719 | val = simple_strtoul(buf, NULL, 10); | 728 | val = simple_strtoul(buf, NULL, 10); |
720 | 729 | ||
721 | down(&data->update_lock); | 730 | mutex_lock(&data->update_lock); |
722 | 731 | ||
723 | if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ | 732 | if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ |
724 | data->beep_mask = BEEP_MASK_TO_REG(val); | 733 | data->beep_mask = BEEP_MASK_TO_REG(val); |
@@ -736,7 +745,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count, | |||
736 | w83627hf_write_value(client, W83781D_REG_BEEP_INTS2, | 745 | w83627hf_write_value(client, W83781D_REG_BEEP_INTS2, |
737 | val2 | data->beep_enable << 7); | 746 | val2 | data->beep_enable << 7); |
738 | 747 | ||
739 | up(&data->update_lock); | 748 | mutex_unlock(&data->update_lock); |
740 | return count; | 749 | return count; |
741 | } | 750 | } |
742 | 751 | ||
@@ -783,7 +792,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
783 | u8 reg; | 792 | u8 reg; |
784 | unsigned long val = simple_strtoul(buf, NULL, 10); | 793 | unsigned long val = simple_strtoul(buf, NULL, 10); |
785 | 794 | ||
786 | down(&data->update_lock); | 795 | mutex_lock(&data->update_lock); |
787 | 796 | ||
788 | /* Save fan_min */ | 797 | /* Save fan_min */ |
789 | min = FAN_FROM_REG(data->fan_min[nr], | 798 | min = FAN_FROM_REG(data->fan_min[nr], |
@@ -805,7 +814,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
805 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 814 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
806 | w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); | 815 | w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); |
807 | 816 | ||
808 | up(&data->update_lock); | 817 | mutex_unlock(&data->update_lock); |
809 | return count; | 818 | return count; |
810 | } | 819 | } |
811 | 820 | ||
@@ -848,7 +857,7 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
848 | 857 | ||
849 | val = simple_strtoul(buf, NULL, 10); | 858 | val = simple_strtoul(buf, NULL, 10); |
850 | 859 | ||
851 | down(&data->update_lock); | 860 | mutex_lock(&data->update_lock); |
852 | 861 | ||
853 | if (data->type == w83627thf) { | 862 | if (data->type == w83627thf) { |
854 | /* bits 0-3 are reserved in 627THF */ | 863 | /* bits 0-3 are reserved in 627THF */ |
@@ -865,7 +874,7 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
865 | data->pwm[nr - 1]); | 874 | data->pwm[nr - 1]); |
866 | } | 875 | } |
867 | 876 | ||
868 | up(&data->update_lock); | 877 | mutex_unlock(&data->update_lock); |
869 | return count; | 878 | return count; |
870 | } | 879 | } |
871 | 880 | ||
@@ -907,7 +916,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
907 | 916 | ||
908 | val = simple_strtoul(buf, NULL, 10); | 917 | val = simple_strtoul(buf, NULL, 10); |
909 | 918 | ||
910 | down(&data->update_lock); | 919 | mutex_lock(&data->update_lock); |
911 | 920 | ||
912 | switch (val) { | 921 | switch (val) { |
913 | case 1: /* PII/Celeron diode */ | 922 | case 1: /* PII/Celeron diode */ |
@@ -941,7 +950,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
941 | break; | 950 | break; |
942 | } | 951 | } |
943 | 952 | ||
944 | up(&data->update_lock); | 953 | mutex_unlock(&data->update_lock); |
945 | return count; | 954 | return count; |
946 | } | 955 | } |
947 | 956 | ||
@@ -980,7 +989,8 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr) | |||
980 | if(val != W627_DEVID && | 989 | if(val != W627_DEVID && |
981 | val != W627THF_DEVID && | 990 | val != W627THF_DEVID && |
982 | val != W697_DEVID && | 991 | val != W697_DEVID && |
983 | val != W637_DEVID) { | 992 | val != W637_DEVID && |
993 | val != W687THF_DEVID) { | ||
984 | superio_exit(); | 994 | superio_exit(); |
985 | return -ENODEV; | 995 | return -ENODEV; |
986 | } | 996 | } |
@@ -1034,6 +1044,8 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1034 | kind = w83627thf; | 1044 | kind = w83627thf; |
1035 | else if(val == W637_DEVID) | 1045 | else if(val == W637_DEVID) |
1036 | kind = w83637hf; | 1046 | kind = w83637hf; |
1047 | else if (val == W687THF_DEVID) | ||
1048 | kind = w83687thf; | ||
1037 | else { | 1049 | else { |
1038 | dev_info(&adapter->dev, | 1050 | dev_info(&adapter->dev, |
1039 | "Unsupported chip (dev_id=0x%02X).\n", val); | 1051 | "Unsupported chip (dev_id=0x%02X).\n", val); |
@@ -1057,7 +1069,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1057 | new_client = &data->client; | 1069 | new_client = &data->client; |
1058 | i2c_set_clientdata(new_client, data); | 1070 | i2c_set_clientdata(new_client, data); |
1059 | new_client->addr = address; | 1071 | new_client->addr = address; |
1060 | init_MUTEX(&data->lock); | 1072 | mutex_init(&data->lock); |
1061 | new_client->adapter = adapter; | 1073 | new_client->adapter = adapter; |
1062 | new_client->driver = &w83627hf_driver; | 1074 | new_client->driver = &w83627hf_driver; |
1063 | new_client->flags = 0; | 1075 | new_client->flags = 0; |
@@ -1071,13 +1083,15 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1071 | client_name = "w83697hf"; | 1083 | client_name = "w83697hf"; |
1072 | } else if (kind == w83637hf) { | 1084 | } else if (kind == w83637hf) { |
1073 | client_name = "w83637hf"; | 1085 | client_name = "w83637hf"; |
1086 | } else if (kind == w83687thf) { | ||
1087 | client_name = "w83687thf"; | ||
1074 | } | 1088 | } |
1075 | 1089 | ||
1076 | /* Fill in the remaining client fields and put into the global list */ | 1090 | /* Fill in the remaining client fields and put into the global list */ |
1077 | strlcpy(new_client->name, client_name, I2C_NAME_SIZE); | 1091 | strlcpy(new_client->name, client_name, I2C_NAME_SIZE); |
1078 | data->type = kind; | 1092 | data->type = kind; |
1079 | data->valid = 0; | 1093 | data->valid = 0; |
1080 | init_MUTEX(&data->update_lock); | 1094 | mutex_init(&data->update_lock); |
1081 | 1095 | ||
1082 | /* Tell the I2C layer a new client has arrived */ | 1096 | /* Tell the I2C layer a new client has arrived */ |
1083 | if ((err = i2c_attach_client(new_client))) | 1097 | if ((err = i2c_attach_client(new_client))) |
@@ -1106,7 +1120,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1106 | device_create_file_in(new_client, 2); | 1120 | device_create_file_in(new_client, 2); |
1107 | device_create_file_in(new_client, 3); | 1121 | device_create_file_in(new_client, 3); |
1108 | device_create_file_in(new_client, 4); | 1122 | device_create_file_in(new_client, 4); |
1109 | if (kind != w83627thf && kind != w83637hf) { | 1123 | if (kind == w83627hf || kind == w83697hf) { |
1110 | device_create_file_in(new_client, 5); | 1124 | device_create_file_in(new_client, 5); |
1111 | device_create_file_in(new_client, 6); | 1125 | device_create_file_in(new_client, 6); |
1112 | } | 1126 | } |
@@ -1139,7 +1153,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1139 | 1153 | ||
1140 | device_create_file_pwm(new_client, 1); | 1154 | device_create_file_pwm(new_client, 1); |
1141 | device_create_file_pwm(new_client, 2); | 1155 | device_create_file_pwm(new_client, 2); |
1142 | if (kind == w83627thf || kind == w83637hf) | 1156 | if (kind == w83627thf || kind == w83637hf || kind == w83687thf) |
1143 | device_create_file_pwm(new_client, 3); | 1157 | device_create_file_pwm(new_client, 3); |
1144 | 1158 | ||
1145 | device_create_file_sensor(new_client, 1); | 1159 | device_create_file_sensor(new_client, 1); |
@@ -1187,7 +1201,7 @@ static int w83627hf_read_value(struct i2c_client *client, u16 reg) | |||
1187 | struct w83627hf_data *data = i2c_get_clientdata(client); | 1201 | struct w83627hf_data *data = i2c_get_clientdata(client); |
1188 | int res, word_sized; | 1202 | int res, word_sized; |
1189 | 1203 | ||
1190 | down(&data->lock); | 1204 | mutex_lock(&data->lock); |
1191 | word_sized = (((reg & 0xff00) == 0x100) | 1205 | word_sized = (((reg & 0xff00) == 0x100) |
1192 | || ((reg & 0xff00) == 0x200)) | 1206 | || ((reg & 0xff00) == 0x200)) |
1193 | && (((reg & 0x00ff) == 0x50) | 1207 | && (((reg & 0x00ff) == 0x50) |
@@ -1213,7 +1227,7 @@ static int w83627hf_read_value(struct i2c_client *client, u16 reg) | |||
1213 | client->addr + W83781D_ADDR_REG_OFFSET); | 1227 | client->addr + W83781D_ADDR_REG_OFFSET); |
1214 | outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); | 1228 | outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); |
1215 | } | 1229 | } |
1216 | up(&data->lock); | 1230 | mutex_unlock(&data->lock); |
1217 | return res; | 1231 | return res; |
1218 | } | 1232 | } |
1219 | 1233 | ||
@@ -1247,12 +1261,39 @@ exit: | |||
1247 | return res; | 1261 | return res; |
1248 | } | 1262 | } |
1249 | 1263 | ||
1264 | static int w83687thf_read_vid(struct i2c_client *client) | ||
1265 | { | ||
1266 | int res = 0xff; | ||
1267 | |||
1268 | superio_enter(); | ||
1269 | superio_select(W83627HF_LD_HWM); | ||
1270 | |||
1271 | /* Make sure these GPIO pins are enabled */ | ||
1272 | if (!(superio_inb(W83687THF_VID_EN) & (1 << 2))) { | ||
1273 | dev_dbg(&client->dev, "VID disabled, no VID function\n"); | ||
1274 | goto exit; | ||
1275 | } | ||
1276 | |||
1277 | /* Make sure the pins are configured for input */ | ||
1278 | if (!(superio_inb(W83687THF_VID_CFG) & (1 << 4))) { | ||
1279 | dev_dbg(&client->dev, "VID configured as output, " | ||
1280 | "no VID function\n"); | ||
1281 | goto exit; | ||
1282 | } | ||
1283 | |||
1284 | res = superio_inb(W83687THF_VID_DATA) & 0x3f; | ||
1285 | |||
1286 | exit: | ||
1287 | superio_exit(); | ||
1288 | return res; | ||
1289 | } | ||
1290 | |||
1250 | static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value) | 1291 | static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value) |
1251 | { | 1292 | { |
1252 | struct w83627hf_data *data = i2c_get_clientdata(client); | 1293 | struct w83627hf_data *data = i2c_get_clientdata(client); |
1253 | int word_sized; | 1294 | int word_sized; |
1254 | 1295 | ||
1255 | down(&data->lock); | 1296 | mutex_lock(&data->lock); |
1256 | word_sized = (((reg & 0xff00) == 0x100) | 1297 | word_sized = (((reg & 0xff00) == 0x100) |
1257 | || ((reg & 0xff00) == 0x200)) | 1298 | || ((reg & 0xff00) == 0x200)) |
1258 | && (((reg & 0x00ff) == 0x53) | 1299 | && (((reg & 0x00ff) == 0x53) |
@@ -1277,7 +1318,7 @@ static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
1277 | client->addr + W83781D_ADDR_REG_OFFSET); | 1318 | client->addr + W83781D_ADDR_REG_OFFSET); |
1278 | outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); | 1319 | outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); |
1279 | } | 1320 | } |
1280 | up(&data->lock); | 1321 | mutex_unlock(&data->lock); |
1281 | return 0; | 1322 | return 0; |
1282 | } | 1323 | } |
1283 | 1324 | ||
@@ -1324,10 +1365,13 @@ static void w83627hf_init_client(struct i2c_client *client) | |||
1324 | data->vid = (lo & 0x0f) | ((hi & 0x01) << 4); | 1365 | data->vid = (lo & 0x0f) | ((hi & 0x01) << 4); |
1325 | } else if (w83627thf == data->type) { | 1366 | } else if (w83627thf == data->type) { |
1326 | data->vid = w83627thf_read_gpio5(client); | 1367 | data->vid = w83627thf_read_gpio5(client); |
1368 | } else if (w83687thf == data->type) { | ||
1369 | data->vid = w83687thf_read_vid(client); | ||
1327 | } | 1370 | } |
1328 | 1371 | ||
1329 | /* Read VRM & OVT Config only once */ | 1372 | /* Read VRM & OVT Config only once */ |
1330 | if (w83627thf == data->type || w83637hf == data->type) { | 1373 | if (w83627thf == data->type || w83637hf == data->type |
1374 | || w83687thf == data->type) { | ||
1331 | data->vrm_ovt = | 1375 | data->vrm_ovt = |
1332 | w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG); | 1376 | w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG); |
1333 | } | 1377 | } |
@@ -1387,14 +1431,14 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev) | |||
1387 | struct w83627hf_data *data = i2c_get_clientdata(client); | 1431 | struct w83627hf_data *data = i2c_get_clientdata(client); |
1388 | int i; | 1432 | int i; |
1389 | 1433 | ||
1390 | down(&data->update_lock); | 1434 | mutex_lock(&data->update_lock); |
1391 | 1435 | ||
1392 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 1436 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
1393 | || !data->valid) { | 1437 | || !data->valid) { |
1394 | for (i = 0; i <= 8; i++) { | 1438 | for (i = 0; i <= 8; i++) { |
1395 | /* skip missing sensors */ | 1439 | /* skip missing sensors */ |
1396 | if (((data->type == w83697hf) && (i == 1)) || | 1440 | if (((data->type == w83697hf) && (i == 1)) || |
1397 | ((data->type == w83627thf || data->type == w83637hf) | 1441 | ((data->type != w83627hf && data->type != w83697hf) |
1398 | && (i == 5 || i == 6))) | 1442 | && (i == 5 || i == 6))) |
1399 | continue; | 1443 | continue; |
1400 | data->in[i] = | 1444 | data->in[i] = |
@@ -1470,7 +1514,7 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev) | |||
1470 | data->valid = 1; | 1514 | data->valid = 1; |
1471 | } | 1515 | } |
1472 | 1516 | ||
1473 | up(&data->update_lock); | 1517 | mutex_unlock(&data->update_lock); |
1474 | 1518 | ||
1475 | return data; | 1519 | return data; |
1476 | } | 1520 | } |
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index 64c1f8af5bb2..e4c700356c44 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/hwmon.h> | 42 | #include <linux/hwmon.h> |
43 | #include <linux/hwmon-vid.h> | 43 | #include <linux/hwmon-vid.h> |
44 | #include <linux/err.h> | 44 | #include <linux/err.h> |
45 | #include <linux/mutex.h> | ||
45 | #include <asm/io.h> | 46 | #include <asm/io.h> |
46 | #include "lm75.h" | 47 | #include "lm75.h" |
47 | 48 | ||
@@ -56,6 +57,10 @@ I2C_CLIENT_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f); | |||
56 | I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " | 57 | I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " |
57 | "{bus, clientaddr, subclientaddr1, subclientaddr2}"); | 58 | "{bus, clientaddr, subclientaddr1, subclientaddr2}"); |
58 | 59 | ||
60 | static int reset; | ||
61 | module_param(reset, bool, 0); | ||
62 | MODULE_PARM_DESC(reset, "Set to one to reset chip on load"); | ||
63 | |||
59 | static int init = 1; | 64 | static int init = 1; |
60 | module_param(init, bool, 0); | 65 | module_param(init, bool, 0); |
61 | MODULE_PARM_DESC(init, "Set to zero to bypass chip initialization"); | 66 | MODULE_PARM_DESC(init, "Set to zero to bypass chip initialization"); |
@@ -226,10 +231,10 @@ DIV_TO_REG(long val, enum chips type) | |||
226 | struct w83781d_data { | 231 | struct w83781d_data { |
227 | struct i2c_client client; | 232 | struct i2c_client client; |
228 | struct class_device *class_dev; | 233 | struct class_device *class_dev; |
229 | struct semaphore lock; | 234 | struct mutex lock; |
230 | enum chips type; | 235 | enum chips type; |
231 | 236 | ||
232 | struct semaphore update_lock; | 237 | struct mutex update_lock; |
233 | char valid; /* !=0 if following fields are valid */ | 238 | char valid; /* !=0 if following fields are valid */ |
234 | unsigned long last_updated; /* In jiffies */ | 239 | unsigned long last_updated; /* In jiffies */ |
235 | 240 | ||
@@ -267,9 +272,8 @@ static int w83781d_isa_attach_adapter(struct i2c_adapter *adapter); | |||
267 | static int w83781d_detect(struct i2c_adapter *adapter, int address, int kind); | 272 | static int w83781d_detect(struct i2c_adapter *adapter, int address, int kind); |
268 | static int w83781d_detach_client(struct i2c_client *client); | 273 | static int w83781d_detach_client(struct i2c_client *client); |
269 | 274 | ||
270 | static int w83781d_read_value(struct i2c_client *client, u16 register); | 275 | static int w83781d_read_value(struct i2c_client *client, u16 reg); |
271 | static int w83781d_write_value(struct i2c_client *client, u16 register, | 276 | static int w83781d_write_value(struct i2c_client *client, u16 reg, u16 value); |
272 | u16 value); | ||
273 | static struct w83781d_data *w83781d_update_device(struct device *dev); | 277 | static struct w83781d_data *w83781d_update_device(struct device *dev); |
274 | static void w83781d_init_client(struct i2c_client *client); | 278 | static void w83781d_init_client(struct i2c_client *client); |
275 | 279 | ||
@@ -311,11 +315,11 @@ static ssize_t store_in_##reg (struct device *dev, const char *buf, size_t count | |||
311 | \ | 315 | \ |
312 | val = simple_strtoul(buf, NULL, 10) / 10; \ | 316 | val = simple_strtoul(buf, NULL, 10) / 10; \ |
313 | \ | 317 | \ |
314 | down(&data->update_lock); \ | 318 | mutex_lock(&data->update_lock); \ |
315 | data->in_##reg[nr] = IN_TO_REG(val); \ | 319 | data->in_##reg[nr] = IN_TO_REG(val); \ |
316 | w83781d_write_value(client, W83781D_REG_IN_##REG(nr), data->in_##reg[nr]); \ | 320 | w83781d_write_value(client, W83781D_REG_IN_##REG(nr), data->in_##reg[nr]); \ |
317 | \ | 321 | \ |
318 | up(&data->update_lock); \ | 322 | mutex_unlock(&data->update_lock); \ |
319 | return count; \ | 323 | return count; \ |
320 | } | 324 | } |
321 | store_in_reg(MIN, min); | 325 | store_in_reg(MIN, min); |
@@ -381,13 +385,13 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
381 | 385 | ||
382 | val = simple_strtoul(buf, NULL, 10); | 386 | val = simple_strtoul(buf, NULL, 10); |
383 | 387 | ||
384 | down(&data->update_lock); | 388 | mutex_lock(&data->update_lock); |
385 | data->fan_min[nr - 1] = | 389 | data->fan_min[nr - 1] = |
386 | FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); | 390 | FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); |
387 | w83781d_write_value(client, W83781D_REG_FAN_MIN(nr), | 391 | w83781d_write_value(client, W83781D_REG_FAN_MIN(nr), |
388 | data->fan_min[nr - 1]); | 392 | data->fan_min[nr - 1]); |
389 | 393 | ||
390 | up(&data->update_lock); | 394 | mutex_unlock(&data->update_lock); |
391 | return count; | 395 | return count; |
392 | } | 396 | } |
393 | 397 | ||
@@ -446,7 +450,7 @@ static ssize_t store_temp_##reg (struct device *dev, const char *buf, size_t cou | |||
446 | \ | 450 | \ |
447 | val = simple_strtol(buf, NULL, 10); \ | 451 | val = simple_strtol(buf, NULL, 10); \ |
448 | \ | 452 | \ |
449 | down(&data->update_lock); \ | 453 | mutex_lock(&data->update_lock); \ |
450 | \ | 454 | \ |
451 | if (nr >= 2) { /* TEMP2 and TEMP3 */ \ | 455 | if (nr >= 2) { /* TEMP2 and TEMP3 */ \ |
452 | data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ | 456 | data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ |
@@ -458,7 +462,7 @@ static ssize_t store_temp_##reg (struct device *dev, const char *buf, size_t cou | |||
458 | data->temp_##reg); \ | 462 | data->temp_##reg); \ |
459 | } \ | 463 | } \ |
460 | \ | 464 | \ |
461 | up(&data->update_lock); \ | 465 | mutex_unlock(&data->update_lock); \ |
462 | return count; \ | 466 | return count; \ |
463 | } | 467 | } |
464 | store_temp_reg(OVER, max); | 468 | store_temp_reg(OVER, max); |
@@ -571,7 +575,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count, | |||
571 | 575 | ||
572 | val = simple_strtoul(buf, NULL, 10); | 576 | val = simple_strtoul(buf, NULL, 10); |
573 | 577 | ||
574 | down(&data->update_lock); | 578 | mutex_lock(&data->update_lock); |
575 | 579 | ||
576 | if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ | 580 | if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ |
577 | data->beep_mask = BEEP_MASK_TO_REG(val, data->type); | 581 | data->beep_mask = BEEP_MASK_TO_REG(val, data->type); |
@@ -592,7 +596,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count, | |||
592 | w83781d_write_value(client, W83781D_REG_BEEP_INTS2, | 596 | w83781d_write_value(client, W83781D_REG_BEEP_INTS2, |
593 | val2 | data->beep_enable << 7); | 597 | val2 | data->beep_enable << 7); |
594 | 598 | ||
595 | up(&data->update_lock); | 599 | mutex_unlock(&data->update_lock); |
596 | return count; | 600 | return count; |
597 | } | 601 | } |
598 | 602 | ||
@@ -637,7 +641,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
637 | u8 reg; | 641 | u8 reg; |
638 | unsigned long val = simple_strtoul(buf, NULL, 10); | 642 | unsigned long val = simple_strtoul(buf, NULL, 10); |
639 | 643 | ||
640 | down(&data->update_lock); | 644 | mutex_lock(&data->update_lock); |
641 | 645 | ||
642 | /* Save fan_min */ | 646 | /* Save fan_min */ |
643 | min = FAN_FROM_REG(data->fan_min[nr], | 647 | min = FAN_FROM_REG(data->fan_min[nr], |
@@ -662,7 +666,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
662 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 666 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
663 | w83781d_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); | 667 | w83781d_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); |
664 | 668 | ||
665 | up(&data->update_lock); | 669 | mutex_unlock(&data->update_lock); |
666 | return count; | 670 | return count; |
667 | } | 671 | } |
668 | 672 | ||
@@ -709,10 +713,10 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
709 | 713 | ||
710 | val = simple_strtoul(buf, NULL, 10); | 714 | val = simple_strtoul(buf, NULL, 10); |
711 | 715 | ||
712 | down(&data->update_lock); | 716 | mutex_lock(&data->update_lock); |
713 | data->pwm[nr - 1] = PWM_TO_REG(val); | 717 | data->pwm[nr - 1] = PWM_TO_REG(val); |
714 | w83781d_write_value(client, W83781D_REG_PWM(nr), data->pwm[nr - 1]); | 718 | w83781d_write_value(client, W83781D_REG_PWM(nr), data->pwm[nr - 1]); |
715 | up(&data->update_lock); | 719 | mutex_unlock(&data->update_lock); |
716 | return count; | 720 | return count; |
717 | } | 721 | } |
718 | 722 | ||
@@ -725,7 +729,7 @@ store_pwmenable_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
725 | 729 | ||
726 | val = simple_strtoul(buf, NULL, 10); | 730 | val = simple_strtoul(buf, NULL, 10); |
727 | 731 | ||
728 | down(&data->update_lock); | 732 | mutex_lock(&data->update_lock); |
729 | 733 | ||
730 | switch (val) { | 734 | switch (val) { |
731 | case 0: | 735 | case 0: |
@@ -742,11 +746,11 @@ store_pwmenable_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
742 | break; | 746 | break; |
743 | 747 | ||
744 | default: | 748 | default: |
745 | up(&data->update_lock); | 749 | mutex_unlock(&data->update_lock); |
746 | return -EINVAL; | 750 | return -EINVAL; |
747 | } | 751 | } |
748 | 752 | ||
749 | up(&data->update_lock); | 753 | mutex_unlock(&data->update_lock); |
750 | return count; | 754 | return count; |
751 | } | 755 | } |
752 | 756 | ||
@@ -808,7 +812,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
808 | 812 | ||
809 | val = simple_strtoul(buf, NULL, 10); | 813 | val = simple_strtoul(buf, NULL, 10); |
810 | 814 | ||
811 | down(&data->update_lock); | 815 | mutex_lock(&data->update_lock); |
812 | 816 | ||
813 | switch (val) { | 817 | switch (val) { |
814 | case 1: /* PII/Celeron diode */ | 818 | case 1: /* PII/Celeron diode */ |
@@ -841,7 +845,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
841 | break; | 845 | break; |
842 | } | 846 | } |
843 | 847 | ||
844 | up(&data->update_lock); | 848 | mutex_unlock(&data->update_lock); |
845 | return count; | 849 | return count; |
846 | } | 850 | } |
847 | 851 | ||
@@ -1073,7 +1077,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1073 | new_client = &data->client; | 1077 | new_client = &data->client; |
1074 | i2c_set_clientdata(new_client, data); | 1078 | i2c_set_clientdata(new_client, data); |
1075 | new_client->addr = address; | 1079 | new_client->addr = address; |
1076 | init_MUTEX(&data->lock); | 1080 | mutex_init(&data->lock); |
1077 | new_client->adapter = adapter; | 1081 | new_client->adapter = adapter; |
1078 | new_client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver; | 1082 | new_client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver; |
1079 | new_client->flags = 0; | 1083 | new_client->flags = 0; |
@@ -1178,7 +1182,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1178 | data->type = kind; | 1182 | data->type = kind; |
1179 | 1183 | ||
1180 | data->valid = 0; | 1184 | data->valid = 0; |
1181 | init_MUTEX(&data->update_lock); | 1185 | mutex_init(&data->update_lock); |
1182 | 1186 | ||
1183 | /* Tell the I2C layer a new client has arrived */ | 1187 | /* Tell the I2C layer a new client has arrived */ |
1184 | if ((err = i2c_attach_client(new_client))) | 1188 | if ((err = i2c_attach_client(new_client))) |
@@ -1325,7 +1329,7 @@ w83781d_read_value(struct i2c_client *client, u16 reg) | |||
1325 | int res, word_sized, bank; | 1329 | int res, word_sized, bank; |
1326 | struct i2c_client *cl; | 1330 | struct i2c_client *cl; |
1327 | 1331 | ||
1328 | down(&data->lock); | 1332 | mutex_lock(&data->lock); |
1329 | if (i2c_is_isa_client(client)) { | 1333 | if (i2c_is_isa_client(client)) { |
1330 | word_sized = (((reg & 0xff00) == 0x100) | 1334 | word_sized = (((reg & 0xff00) == 0x100) |
1331 | || ((reg & 0xff00) == 0x200)) | 1335 | || ((reg & 0xff00) == 0x200)) |
@@ -1383,7 +1387,7 @@ w83781d_read_value(struct i2c_client *client, u16 reg) | |||
1383 | if (bank > 2) | 1387 | if (bank > 2) |
1384 | i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0); | 1388 | i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0); |
1385 | } | 1389 | } |
1386 | up(&data->lock); | 1390 | mutex_unlock(&data->lock); |
1387 | return res; | 1391 | return res; |
1388 | } | 1392 | } |
1389 | 1393 | ||
@@ -1394,7 +1398,7 @@ w83781d_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
1394 | int word_sized, bank; | 1398 | int word_sized, bank; |
1395 | struct i2c_client *cl; | 1399 | struct i2c_client *cl; |
1396 | 1400 | ||
1397 | down(&data->lock); | 1401 | mutex_lock(&data->lock); |
1398 | if (i2c_is_isa_client(client)) { | 1402 | if (i2c_is_isa_client(client)) { |
1399 | word_sized = (((reg & 0xff00) == 0x100) | 1403 | word_sized = (((reg & 0xff00) == 0x100) |
1400 | || ((reg & 0xff00) == 0x200)) | 1404 | || ((reg & 0xff00) == 0x200)) |
@@ -1447,7 +1451,7 @@ w83781d_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
1447 | if (bank > 2) | 1451 | if (bank > 2) |
1448 | i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0); | 1452 | i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0); |
1449 | } | 1453 | } |
1450 | up(&data->lock); | 1454 | mutex_unlock(&data->lock); |
1451 | return 0; | 1455 | return 0; |
1452 | } | 1456 | } |
1453 | 1457 | ||
@@ -1459,8 +1463,17 @@ w83781d_init_client(struct i2c_client *client) | |||
1459 | int type = data->type; | 1463 | int type = data->type; |
1460 | u8 tmp; | 1464 | u8 tmp; |
1461 | 1465 | ||
1462 | if (init && type != as99127f) { /* this resets registers we don't have | 1466 | if (reset && type != as99127f) { /* this resets registers we don't have |
1463 | documentation for on the as99127f */ | 1467 | documentation for on the as99127f */ |
1468 | /* Resetting the chip has been the default for a long time, | ||
1469 | but it causes the BIOS initializations (fan clock dividers, | ||
1470 | thermal sensor types...) to be lost, so it is now optional. | ||
1471 | It might even go away if nobody reports it as being useful, | ||
1472 | as I see very little reason why this would be needed at | ||
1473 | all. */ | ||
1474 | dev_info(&client->dev, "If reset=1 solved a problem you were " | ||
1475 | "having, please report!\n"); | ||
1476 | |||
1464 | /* save these registers */ | 1477 | /* save these registers */ |
1465 | i = w83781d_read_value(client, W83781D_REG_BEEP_CONFIG); | 1478 | i = w83781d_read_value(client, W83781D_REG_BEEP_CONFIG); |
1466 | p = w83781d_read_value(client, W83781D_REG_PWMCLK12); | 1479 | p = w83781d_read_value(client, W83781D_REG_PWMCLK12); |
@@ -1477,6 +1490,13 @@ w83781d_init_client(struct i2c_client *client) | |||
1477 | w83781d_write_value(client, W83781D_REG_BEEP_INTS2, 0); | 1490 | w83781d_write_value(client, W83781D_REG_BEEP_INTS2, 0); |
1478 | } | 1491 | } |
1479 | 1492 | ||
1493 | /* Disable power-on abnormal beep, as advised by the datasheet. | ||
1494 | Already done if reset=1. */ | ||
1495 | if (init && !reset && type != as99127f) { | ||
1496 | i = w83781d_read_value(client, W83781D_REG_BEEP_CONFIG); | ||
1497 | w83781d_write_value(client, W83781D_REG_BEEP_CONFIG, i | 0x80); | ||
1498 | } | ||
1499 | |||
1480 | data->vrm = vid_which_vrm(); | 1500 | data->vrm = vid_which_vrm(); |
1481 | 1501 | ||
1482 | if ((type != w83781d) && (type != as99127f)) { | 1502 | if ((type != w83781d) && (type != as99127f)) { |
@@ -1533,7 +1553,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1533 | struct w83781d_data *data = i2c_get_clientdata(client); | 1553 | struct w83781d_data *data = i2c_get_clientdata(client); |
1534 | int i; | 1554 | int i; |
1535 | 1555 | ||
1536 | down(&data->update_lock); | 1556 | mutex_lock(&data->update_lock); |
1537 | 1557 | ||
1538 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 1558 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
1539 | || !data->valid) { | 1559 | || !data->valid) { |
@@ -1641,7 +1661,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1641 | data->valid = 1; | 1661 | data->valid = 1; |
1642 | } | 1662 | } |
1643 | 1663 | ||
1644 | up(&data->update_lock); | 1664 | mutex_unlock(&data->update_lock); |
1645 | 1665 | ||
1646 | return data; | 1666 | return data; |
1647 | } | 1667 | } |
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index a2f6bb676235..6865c64d8a51 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include <linux/hwmon.h> | 43 | #include <linux/hwmon.h> |
44 | #include <linux/hwmon-sysfs.h> | 44 | #include <linux/hwmon-sysfs.h> |
45 | #include <linux/err.h> | 45 | #include <linux/err.h> |
46 | #include <linux/mutex.h> | ||
46 | 47 | ||
47 | /* Addresses to scan */ | 48 | /* Addresses to scan */ |
48 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; | 49 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; |
@@ -271,7 +272,7 @@ struct w83792d_data { | |||
271 | struct class_device *class_dev; | 272 | struct class_device *class_dev; |
272 | enum chips type; | 273 | enum chips type; |
273 | 274 | ||
274 | struct semaphore update_lock; | 275 | struct mutex update_lock; |
275 | char valid; /* !=0 if following fields are valid */ | 276 | char valid; /* !=0 if following fields are valid */ |
276 | unsigned long last_updated; /* In jiffies */ | 277 | unsigned long last_updated; /* In jiffies */ |
277 | 278 | ||
@@ -382,30 +383,40 @@ static ssize_t store_in_##reg (struct device *dev, \ | |||
382 | store_in_reg(MIN, min); | 383 | store_in_reg(MIN, min); |
383 | store_in_reg(MAX, max); | 384 | store_in_reg(MAX, max); |
384 | 385 | ||
385 | #define sysfs_in_reg(offset) \ | 386 | static struct sensor_device_attribute sda_in_input[] = { |
386 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in, \ | 387 | SENSOR_ATTR(in0_input, S_IRUGO, show_in, NULL, 0), |
387 | NULL, offset); \ | 388 | SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1), |
388 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | 389 | SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2), |
389 | show_in_min, store_in_min, offset); \ | 390 | SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3), |
390 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | 391 | SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4), |
391 | show_in_max, store_in_max, offset); | 392 | SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5), |
392 | 393 | SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6), | |
393 | sysfs_in_reg(0); | 394 | SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7), |
394 | sysfs_in_reg(1); | 395 | SENSOR_ATTR(in8_input, S_IRUGO, show_in, NULL, 8), |
395 | sysfs_in_reg(2); | 396 | }; |
396 | sysfs_in_reg(3); | 397 | static struct sensor_device_attribute sda_in_min[] = { |
397 | sysfs_in_reg(4); | 398 | SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 0), |
398 | sysfs_in_reg(5); | 399 | SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 1), |
399 | sysfs_in_reg(6); | 400 | SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 2), |
400 | sysfs_in_reg(7); | 401 | SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 3), |
401 | sysfs_in_reg(8); | 402 | SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 4), |
402 | 403 | SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 5), | |
403 | #define device_create_file_in(client, offset) \ | 404 | SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 6), |
404 | do { \ | 405 | SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 7), |
405 | device_create_file(&client->dev, &sensor_dev_attr_in##offset##_input.dev_attr); \ | 406 | SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 8), |
406 | device_create_file(&client->dev, &sensor_dev_attr_in##offset##_max.dev_attr); \ | 407 | }; |
407 | device_create_file(&client->dev, &sensor_dev_attr_in##offset##_min.dev_attr); \ | 408 | static struct sensor_device_attribute sda_in_max[] = { |
408 | } while (0) | 409 | SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 0), |
410 | SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 1), | ||
411 | SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 2), | ||
412 | SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 3), | ||
413 | SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 4), | ||
414 | SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 5), | ||
415 | SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 6), | ||
416 | SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 7), | ||
417 | SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 8), | ||
418 | }; | ||
419 | |||
409 | 420 | ||
410 | #define show_fan_reg(reg) \ | 421 | #define show_fan_reg(reg) \ |
411 | static ssize_t show_##reg (struct device *dev, struct device_attribute *attr, \ | 422 | static ssize_t show_##reg (struct device *dev, struct device_attribute *attr, \ |
@@ -486,28 +497,33 @@ store_fan_div(struct device *dev, struct device_attribute *attr, | |||
486 | return count; | 497 | return count; |
487 | } | 498 | } |
488 | 499 | ||
489 | #define sysfs_fan(offset) \ | 500 | static struct sensor_device_attribute sda_fan_input[] = { |
490 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL, \ | 501 | SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 1), |
491 | offset); \ | 502 | SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 2), |
492 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ | 503 | SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 3), |
493 | show_fan_div, store_fan_div, offset); \ | 504 | SENSOR_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 4), |
494 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | 505 | SENSOR_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 5), |
495 | show_fan_min, store_fan_min, offset); | 506 | SENSOR_ATTR(fan6_input, S_IRUGO, show_fan, NULL, 6), |
496 | 507 | SENSOR_ATTR(fan7_input, S_IRUGO, show_fan, NULL, 7), | |
497 | sysfs_fan(1); | 508 | }; |
498 | sysfs_fan(2); | 509 | static struct sensor_device_attribute sda_fan_min[] = { |
499 | sysfs_fan(3); | 510 | SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 1), |
500 | sysfs_fan(4); | 511 | SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 2), |
501 | sysfs_fan(5); | 512 | SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 3), |
502 | sysfs_fan(6); | 513 | SENSOR_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 4), |
503 | sysfs_fan(7); | 514 | SENSOR_ATTR(fan5_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 5), |
504 | 515 | SENSOR_ATTR(fan6_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 6), | |
505 | #define device_create_file_fan(client, offset) \ | 516 | SENSOR_ATTR(fan7_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 7), |
506 | do { \ | 517 | }; |
507 | device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_input.dev_attr); \ | 518 | static struct sensor_device_attribute sda_fan_div[] = { |
508 | device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_div.dev_attr); \ | 519 | SENSOR_ATTR(fan1_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 1), |
509 | device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_min.dev_attr); \ | 520 | SENSOR_ATTR(fan2_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 2), |
510 | } while (0) | 521 | SENSOR_ATTR(fan3_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 3), |
522 | SENSOR_ATTR(fan4_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 4), | ||
523 | SENSOR_ATTR(fan5_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 5), | ||
524 | SENSOR_ATTR(fan6_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 6), | ||
525 | SENSOR_ATTR(fan7_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 7), | ||
526 | }; | ||
511 | 527 | ||
512 | 528 | ||
513 | /* read/write the temperature1, includes measured value and limits */ | 529 | /* read/write the temperature1, includes measured value and limits */ |
@@ -539,21 +555,6 @@ static ssize_t store_temp1(struct device *dev, struct device_attribute *attr, | |||
539 | return count; | 555 | return count; |
540 | } | 556 | } |
541 | 557 | ||
542 | |||
543 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0); | ||
544 | static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp1, | ||
545 | store_temp1, 1); | ||
546 | static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1, | ||
547 | store_temp1, 2); | ||
548 | |||
549 | #define device_create_file_temp1(client) \ | ||
550 | do { \ | ||
551 | device_create_file(&client->dev, &sensor_dev_attr_temp1_input.dev_attr); \ | ||
552 | device_create_file(&client->dev, &sensor_dev_attr_temp1_max.dev_attr); \ | ||
553 | device_create_file(&client->dev, &sensor_dev_attr_temp1_max_hyst.dev_attr); \ | ||
554 | } while (0) | ||
555 | |||
556 | |||
557 | /* read/write the temperature2-3, includes measured value and limits */ | 558 | /* read/write the temperature2-3, includes measured value and limits */ |
558 | 559 | ||
559 | static ssize_t show_temp23(struct device *dev, struct device_attribute *attr, | 560 | static ssize_t show_temp23(struct device *dev, struct device_attribute *attr, |
@@ -590,25 +591,23 @@ static ssize_t store_temp23(struct device *dev, struct device_attribute *attr, | |||
590 | return count; | 591 | return count; |
591 | } | 592 | } |
592 | 593 | ||
593 | #define sysfs_temp23(name,idx) \ | 594 | static struct sensor_device_attribute_2 sda_temp_input[] = { |
594 | static SENSOR_DEVICE_ATTR_2(name##_input, S_IRUGO, show_temp23, NULL, \ | 595 | SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp1, NULL, 0, 0), |
595 | idx, 0); \ | 596 | SENSOR_ATTR_2(temp2_input, S_IRUGO, show_temp23, NULL, 0, 0), |
596 | static SENSOR_DEVICE_ATTR_2(name##_max, S_IRUGO | S_IWUSR, \ | 597 | SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp23, NULL, 1, 0), |
597 | show_temp23, store_temp23, idx, 2); \ | 598 | }; |
598 | static SENSOR_DEVICE_ATTR_2(name##_max_hyst, S_IRUGO | S_IWUSR, \ | ||
599 | show_temp23, store_temp23, idx, 4); | ||
600 | |||
601 | sysfs_temp23(temp2,0) | ||
602 | sysfs_temp23(temp3,1) | ||
603 | 599 | ||
604 | #define device_create_file_temp_add(client, offset) \ | 600 | static struct sensor_device_attribute_2 sda_temp_max[] = { |
605 | do { \ | 601 | SENSOR_ATTR_2(temp1_max, S_IRUGO | S_IWUSR, show_temp1, store_temp1, 0, 1), |
606 | device_create_file(&client->dev, &sensor_dev_attr_temp##offset##_input.dev_attr); \ | 602 | SENSOR_ATTR_2(temp2_max, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 0, 2), |
607 | device_create_file(&client->dev, &sensor_dev_attr_temp##offset##_max.dev_attr); \ | 603 | SENSOR_ATTR_2(temp3_max, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 1, 2), |
608 | device_create_file(&client->dev, \ | 604 | }; |
609 | &sensor_dev_attr_temp##offset##_max_hyst.dev_attr); \ | ||
610 | } while (0) | ||
611 | 605 | ||
606 | static struct sensor_device_attribute_2 sda_temp_max_hyst[] = { | ||
607 | SENSOR_ATTR_2(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1, store_temp1, 0, 2), | ||
608 | SENSOR_ATTR_2(temp2_max_hyst, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 0, 4), | ||
609 | SENSOR_ATTR_2(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 1, 4), | ||
610 | }; | ||
612 | 611 | ||
613 | /* get reatime status of all sensors items: voltage, temp, fan */ | 612 | /* get reatime status of all sensors items: voltage, temp, fan */ |
614 | static ssize_t | 613 | static ssize_t |
@@ -620,10 +619,6 @@ show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) | |||
620 | 619 | ||
621 | static | 620 | static |
622 | DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); | 621 | DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); |
623 | #define device_create_file_alarms(client) \ | ||
624 | device_create_file(&client->dev, &dev_attr_alarms); | ||
625 | |||
626 | |||
627 | 622 | ||
628 | static ssize_t | 623 | static ssize_t |
629 | show_pwm(struct device *dev, struct device_attribute *attr, | 624 | show_pwm(struct device *dev, struct device_attribute *attr, |
@@ -711,26 +706,19 @@ store_pwmenable(struct device *dev, struct device_attribute *attr, | |||
711 | return count; | 706 | return count; |
712 | } | 707 | } |
713 | 708 | ||
714 | #define sysfs_pwm(offset) \ | 709 | static struct sensor_device_attribute sda_pwm[] = { |
715 | static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ | 710 | SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 1), |
716 | show_pwm, store_pwm, offset); \ | 711 | SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 2), |
717 | static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ | 712 | SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 3), |
718 | show_pwmenable, store_pwmenable, offset); \ | 713 | }; |
719 | 714 | static struct sensor_device_attribute sda_pwm_enable[] = { | |
720 | sysfs_pwm(1); | 715 | SENSOR_ATTR(pwm1_enable, S_IWUSR | S_IRUGO, |
721 | sysfs_pwm(2); | 716 | show_pwmenable, store_pwmenable, 1), |
722 | sysfs_pwm(3); | 717 | SENSOR_ATTR(pwm2_enable, S_IWUSR | S_IRUGO, |
723 | 718 | show_pwmenable, store_pwmenable, 2), | |
724 | 719 | SENSOR_ATTR(pwm3_enable, S_IWUSR | S_IRUGO, | |
725 | #define device_create_file_pwm(client, offset) \ | 720 | show_pwmenable, store_pwmenable, 3), |
726 | do { \ | 721 | }; |
727 | device_create_file(&client->dev, &sensor_dev_attr_pwm##offset.dev_attr); \ | ||
728 | } while (0) | ||
729 | |||
730 | #define device_create_file_pwmenable(client, offset) \ | ||
731 | do { \ | ||
732 | device_create_file(&client->dev, &sensor_dev_attr_pwm##offset##_enable.dev_attr); \ | ||
733 | } while (0) | ||
734 | 722 | ||
735 | 723 | ||
736 | static ssize_t | 724 | static ssize_t |
@@ -764,18 +752,14 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr, | |||
764 | return count; | 752 | return count; |
765 | } | 753 | } |
766 | 754 | ||
767 | #define sysfs_pwm_mode(offset) \ | 755 | static struct sensor_device_attribute sda_pwm_mode[] = { |
768 | static SENSOR_DEVICE_ATTR(pwm##offset##_mode, S_IRUGO | S_IWUSR, \ | 756 | SENSOR_ATTR(pwm1_mode, S_IWUSR | S_IRUGO, |
769 | show_pwm_mode, store_pwm_mode, offset); | 757 | show_pwm_mode, store_pwm_mode, 1), |
770 | 758 | SENSOR_ATTR(pwm2_mode, S_IWUSR | S_IRUGO, | |
771 | sysfs_pwm_mode(1); | 759 | show_pwm_mode, store_pwm_mode, 2), |
772 | sysfs_pwm_mode(2); | 760 | SENSOR_ATTR(pwm3_mode, S_IWUSR | S_IRUGO, |
773 | sysfs_pwm_mode(3); | 761 | show_pwm_mode, store_pwm_mode, 3), |
774 | 762 | }; | |
775 | #define device_create_file_pwm_mode(client, offset) \ | ||
776 | do { \ | ||
777 | device_create_file(&client->dev, &sensor_dev_attr_pwm##offset##_mode.dev_attr); \ | ||
778 | } while (0) | ||
779 | 763 | ||
780 | 764 | ||
781 | static ssize_t | 765 | static ssize_t |
@@ -788,12 +772,6 @@ show_regs_chassis(struct device *dev, struct device_attribute *attr, | |||
788 | 772 | ||
789 | static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL); | 773 | static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL); |
790 | 774 | ||
791 | #define device_create_file_chassis(client) \ | ||
792 | do { \ | ||
793 | device_create_file(&client->dev, &dev_attr_chassis); \ | ||
794 | } while (0) | ||
795 | |||
796 | |||
797 | static ssize_t | 775 | static ssize_t |
798 | show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf) | 776 | show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf) |
799 | { | 777 | { |
@@ -824,13 +802,6 @@ store_chassis_clear(struct device *dev, struct device_attribute *attr, | |||
824 | static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR, | 802 | static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR, |
825 | show_chassis_clear, store_chassis_clear); | 803 | show_chassis_clear, store_chassis_clear); |
826 | 804 | ||
827 | #define device_create_file_chassis_clear(client) \ | ||
828 | do { \ | ||
829 | device_create_file(&client->dev, &dev_attr_chassis_clear); \ | ||
830 | } while (0) | ||
831 | |||
832 | |||
833 | |||
834 | /* For Smart Fan I / Thermal Cruise */ | 805 | /* For Smart Fan I / Thermal Cruise */ |
835 | static ssize_t | 806 | static ssize_t |
836 | show_thermal_cruise(struct device *dev, struct device_attribute *attr, | 807 | show_thermal_cruise(struct device *dev, struct device_attribute *attr, |
@@ -864,20 +835,14 @@ store_thermal_cruise(struct device *dev, struct device_attribute *attr, | |||
864 | return count; | 835 | return count; |
865 | } | 836 | } |
866 | 837 | ||
867 | #define sysfs_thermal_cruise(offset) \ | 838 | static struct sensor_device_attribute sda_thermal_cruise[] = { |
868 | static SENSOR_DEVICE_ATTR(thermal_cruise##offset, S_IRUGO | S_IWUSR, \ | 839 | SENSOR_ATTR(thermal_cruise1, S_IWUSR | S_IRUGO, |
869 | show_thermal_cruise, store_thermal_cruise, offset); | 840 | show_thermal_cruise, store_thermal_cruise, 1), |
870 | 841 | SENSOR_ATTR(thermal_cruise2, S_IWUSR | S_IRUGO, | |
871 | sysfs_thermal_cruise(1); | 842 | show_thermal_cruise, store_thermal_cruise, 2), |
872 | sysfs_thermal_cruise(2); | 843 | SENSOR_ATTR(thermal_cruise3, S_IWUSR | S_IRUGO, |
873 | sysfs_thermal_cruise(3); | 844 | show_thermal_cruise, store_thermal_cruise, 3), |
874 | 845 | }; | |
875 | #define device_create_file_thermal_cruise(client, offset) \ | ||
876 | do { \ | ||
877 | device_create_file(&client->dev, \ | ||
878 | &sensor_dev_attr_thermal_cruise##offset.dev_attr); \ | ||
879 | } while (0) | ||
880 | |||
881 | 846 | ||
882 | /* For Smart Fan I/Thermal Cruise and Smart Fan II */ | 847 | /* For Smart Fan I/Thermal Cruise and Smart Fan II */ |
883 | static ssize_t | 848 | static ssize_t |
@@ -916,19 +881,14 @@ store_tolerance(struct device *dev, struct device_attribute *attr, | |||
916 | return count; | 881 | return count; |
917 | } | 882 | } |
918 | 883 | ||
919 | #define sysfs_tolerance(offset) \ | 884 | static struct sensor_device_attribute sda_tolerance[] = { |
920 | static SENSOR_DEVICE_ATTR(tolerance##offset, S_IRUGO | S_IWUSR, \ | 885 | SENSOR_ATTR(tolerance1, S_IWUSR | S_IRUGO, |
921 | show_tolerance, store_tolerance, offset); | 886 | show_tolerance, store_tolerance, 1), |
922 | 887 | SENSOR_ATTR(tolerance2, S_IWUSR | S_IRUGO, | |
923 | sysfs_tolerance(1); | 888 | show_tolerance, store_tolerance, 2), |
924 | sysfs_tolerance(2); | 889 | SENSOR_ATTR(tolerance3, S_IWUSR | S_IRUGO, |
925 | sysfs_tolerance(3); | 890 | show_tolerance, store_tolerance, 3), |
926 | 891 | }; | |
927 | #define device_create_file_tolerance(client, offset) \ | ||
928 | do { \ | ||
929 | device_create_file(&client->dev, &sensor_dev_attr_tolerance##offset.dev_attr); \ | ||
930 | } while (0) | ||
931 | |||
932 | 892 | ||
933 | /* For Smart Fan II */ | 893 | /* For Smart Fan II */ |
934 | static ssize_t | 894 | static ssize_t |
@@ -964,28 +924,34 @@ store_sf2_point(struct device *dev, struct device_attribute *attr, | |||
964 | return count; | 924 | return count; |
965 | } | 925 | } |
966 | 926 | ||
967 | #define sysfs_sf2_point(offset, index) \ | 927 | static struct sensor_device_attribute_2 sda_sf2_point[] = { |
968 | static SENSOR_DEVICE_ATTR_2(sf2_point##offset##_fan##index, S_IRUGO | S_IWUSR, \ | 928 | SENSOR_ATTR_2(sf2_point1_fan1, S_IRUGO | S_IWUSR, |
969 | show_sf2_point, store_sf2_point, offset, index); | 929 | show_sf2_point, store_sf2_point, 1, 1), |
970 | 930 | SENSOR_ATTR_2(sf2_point2_fan1, S_IRUGO | S_IWUSR, | |
971 | sysfs_sf2_point(1, 1); /* Fan1 */ | 931 | show_sf2_point, store_sf2_point, 2, 1), |
972 | sysfs_sf2_point(2, 1); /* Fan1 */ | 932 | SENSOR_ATTR_2(sf2_point3_fan1, S_IRUGO | S_IWUSR, |
973 | sysfs_sf2_point(3, 1); /* Fan1 */ | 933 | show_sf2_point, store_sf2_point, 3, 1), |
974 | sysfs_sf2_point(4, 1); /* Fan1 */ | 934 | SENSOR_ATTR_2(sf2_point4_fan1, S_IRUGO | S_IWUSR, |
975 | sysfs_sf2_point(1, 2); /* Fan2 */ | 935 | show_sf2_point, store_sf2_point, 4, 1), |
976 | sysfs_sf2_point(2, 2); /* Fan2 */ | 936 | |
977 | sysfs_sf2_point(3, 2); /* Fan2 */ | 937 | SENSOR_ATTR_2(sf2_point1_fan2, S_IRUGO | S_IWUSR, |
978 | sysfs_sf2_point(4, 2); /* Fan2 */ | 938 | show_sf2_point, store_sf2_point, 1, 2), |
979 | sysfs_sf2_point(1, 3); /* Fan3 */ | 939 | SENSOR_ATTR_2(sf2_point2_fan2, S_IRUGO | S_IWUSR, |
980 | sysfs_sf2_point(2, 3); /* Fan3 */ | 940 | show_sf2_point, store_sf2_point, 2, 2), |
981 | sysfs_sf2_point(3, 3); /* Fan3 */ | 941 | SENSOR_ATTR_2(sf2_point3_fan2, S_IRUGO | S_IWUSR, |
982 | sysfs_sf2_point(4, 3); /* Fan3 */ | 942 | show_sf2_point, store_sf2_point, 3, 2), |
983 | 943 | SENSOR_ATTR_2(sf2_point4_fan2, S_IRUGO | S_IWUSR, | |
984 | #define device_create_file_sf2_point(client, offset, index) \ | 944 | show_sf2_point, store_sf2_point, 4, 2), |
985 | do { \ | 945 | |
986 | device_create_file(&client->dev, \ | 946 | SENSOR_ATTR_2(sf2_point1_fan3, S_IRUGO | S_IWUSR, |
987 | &sensor_dev_attr_sf2_point##offset##_fan##index.dev_attr); \ | 947 | show_sf2_point, store_sf2_point, 1, 3), |
988 | } while (0) | 948 | SENSOR_ATTR_2(sf2_point2_fan3, S_IRUGO | S_IWUSR, |
949 | show_sf2_point, store_sf2_point, 2, 3), | ||
950 | SENSOR_ATTR_2(sf2_point3_fan3, S_IRUGO | S_IWUSR, | ||
951 | show_sf2_point, store_sf2_point, 3, 3), | ||
952 | SENSOR_ATTR_2(sf2_point4_fan3, S_IRUGO | S_IWUSR, | ||
953 | show_sf2_point, store_sf2_point, 4, 3), | ||
954 | }; | ||
989 | 955 | ||
990 | 956 | ||
991 | static ssize_t | 957 | static ssize_t |
@@ -1026,26 +992,28 @@ store_sf2_level(struct device *dev, struct device_attribute *attr, | |||
1026 | return count; | 992 | return count; |
1027 | } | 993 | } |
1028 | 994 | ||
1029 | #define sysfs_sf2_level(offset, index) \ | 995 | static struct sensor_device_attribute_2 sda_sf2_level[] = { |
1030 | static SENSOR_DEVICE_ATTR_2(sf2_level##offset##_fan##index, S_IRUGO | S_IWUSR, \ | 996 | SENSOR_ATTR_2(sf2_level1_fan1, S_IRUGO | S_IWUSR, |
1031 | show_sf2_level, store_sf2_level, offset, index); | 997 | show_sf2_level, store_sf2_level, 1, 1), |
1032 | 998 | SENSOR_ATTR_2(sf2_level2_fan1, S_IRUGO | S_IWUSR, | |
1033 | sysfs_sf2_level(1, 1); /* Fan1 */ | 999 | show_sf2_level, store_sf2_level, 2, 1), |
1034 | sysfs_sf2_level(2, 1); /* Fan1 */ | 1000 | SENSOR_ATTR_2(sf2_level3_fan1, S_IRUGO | S_IWUSR, |
1035 | sysfs_sf2_level(3, 1); /* Fan1 */ | 1001 | show_sf2_level, store_sf2_level, 3, 1), |
1036 | sysfs_sf2_level(1, 2); /* Fan2 */ | 1002 | |
1037 | sysfs_sf2_level(2, 2); /* Fan2 */ | 1003 | SENSOR_ATTR_2(sf2_level1_fan2, S_IRUGO | S_IWUSR, |
1038 | sysfs_sf2_level(3, 2); /* Fan2 */ | 1004 | show_sf2_level, store_sf2_level, 1, 2), |
1039 | sysfs_sf2_level(1, 3); /* Fan3 */ | 1005 | SENSOR_ATTR_2(sf2_level2_fan2, S_IRUGO | S_IWUSR, |
1040 | sysfs_sf2_level(2, 3); /* Fan3 */ | 1006 | show_sf2_level, store_sf2_level, 2, 2), |
1041 | sysfs_sf2_level(3, 3); /* Fan3 */ | 1007 | SENSOR_ATTR_2(sf2_level3_fan2, S_IRUGO | S_IWUSR, |
1042 | 1008 | show_sf2_level, store_sf2_level, 3, 2), | |
1043 | #define device_create_file_sf2_level(client, offset, index) \ | 1009 | |
1044 | do { \ | 1010 | SENSOR_ATTR_2(sf2_level1_fan3, S_IRUGO | S_IWUSR, |
1045 | device_create_file(&client->dev, \ | 1011 | show_sf2_level, store_sf2_level, 1, 3), |
1046 | &sensor_dev_attr_sf2_level##offset##_fan##index.dev_attr); \ | 1012 | SENSOR_ATTR_2(sf2_level2_fan3, S_IRUGO | S_IWUSR, |
1047 | } while (0) | 1013 | show_sf2_level, store_sf2_level, 2, 3), |
1048 | 1014 | SENSOR_ATTR_2(sf2_level3_fan3, S_IRUGO | S_IWUSR, | |
1015 | show_sf2_level, store_sf2_level, 3, 3), | ||
1016 | }; | ||
1049 | 1017 | ||
1050 | /* This function is called when: | 1018 | /* This function is called when: |
1051 | * w83792d_driver is inserted (when this module is loaded), for each | 1019 | * w83792d_driver is inserted (when this module is loaded), for each |
@@ -1147,12 +1115,19 @@ ERROR_SC_0: | |||
1147 | return err; | 1115 | return err; |
1148 | } | 1116 | } |
1149 | 1117 | ||
1118 | static void device_create_file_fan(struct device *dev, int i) | ||
1119 | { | ||
1120 | device_create_file(dev, &sda_fan_input[i].dev_attr); | ||
1121 | device_create_file(dev, &sda_fan_div[i].dev_attr); | ||
1122 | device_create_file(dev, &sda_fan_min[i].dev_attr); | ||
1123 | } | ||
1150 | 1124 | ||
1151 | static int | 1125 | static int |
1152 | w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | 1126 | w83792d_detect(struct i2c_adapter *adapter, int address, int kind) |
1153 | { | 1127 | { |
1154 | int i = 0, val1 = 0, val2; | 1128 | int i = 0, val1 = 0, val2; |
1155 | struct i2c_client *new_client; | 1129 | struct i2c_client *client; |
1130 | struct device *dev; | ||
1156 | struct w83792d_data *data; | 1131 | struct w83792d_data *data; |
1157 | int err = 0; | 1132 | int err = 0; |
1158 | const char *client_name = ""; | 1133 | const char *client_name = ""; |
@@ -1170,12 +1145,13 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1170 | goto ERROR0; | 1145 | goto ERROR0; |
1171 | } | 1146 | } |
1172 | 1147 | ||
1173 | new_client = &data->client; | 1148 | client = &data->client; |
1174 | i2c_set_clientdata(new_client, data); | 1149 | dev = &client->dev; |
1175 | new_client->addr = address; | 1150 | i2c_set_clientdata(client, data); |
1176 | new_client->adapter = adapter; | 1151 | client->addr = address; |
1177 | new_client->driver = &w83792d_driver; | 1152 | client->adapter = adapter; |
1178 | new_client->flags = 0; | 1153 | client->driver = &w83792d_driver; |
1154 | client->flags = 0; | ||
1179 | 1155 | ||
1180 | /* Now, we do the remaining detection. */ | 1156 | /* Now, we do the remaining detection. */ |
1181 | 1157 | ||
@@ -1184,13 +1160,12 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1184 | force_*=... parameter, and the Winbond will be reset to the right | 1160 | force_*=... parameter, and the Winbond will be reset to the right |
1185 | bank. */ | 1161 | bank. */ |
1186 | if (kind < 0) { | 1162 | if (kind < 0) { |
1187 | if (w83792d_read_value(new_client, W83792D_REG_CONFIG) & 0x80) { | 1163 | if (w83792d_read_value(client, W83792D_REG_CONFIG) & 0x80) { |
1188 | dev_warn(&new_client->dev, "Detection failed at step " | 1164 | dev_warn(dev, "Detection failed at step 3\n"); |
1189 | "3\n"); | ||
1190 | goto ERROR1; | 1165 | goto ERROR1; |
1191 | } | 1166 | } |
1192 | val1 = w83792d_read_value(new_client, W83792D_REG_BANK); | 1167 | val1 = w83792d_read_value(client, W83792D_REG_BANK); |
1193 | val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN); | 1168 | val2 = w83792d_read_value(client, W83792D_REG_CHIPMAN); |
1194 | /* Check for Winbond ID if in bank 0 */ | 1169 | /* Check for Winbond ID if in bank 0 */ |
1195 | if (!(val1 & 0x07)) { /* is Bank0 */ | 1170 | if (!(val1 & 0x07)) { /* is Bank0 */ |
1196 | if (((!(val1 & 0x80)) && (val2 != 0xa3)) || | 1171 | if (((!(val1 & 0x80)) && (val2 != 0xa3)) || |
@@ -1200,34 +1175,33 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1200 | } | 1175 | } |
1201 | /* If Winbond chip, address of chip and W83792D_REG_I2C_ADDR | 1176 | /* If Winbond chip, address of chip and W83792D_REG_I2C_ADDR |
1202 | should match */ | 1177 | should match */ |
1203 | if (w83792d_read_value(new_client, | 1178 | if (w83792d_read_value(client, |
1204 | W83792D_REG_I2C_ADDR) != address) { | 1179 | W83792D_REG_I2C_ADDR) != address) { |
1205 | dev_warn(&new_client->dev, "Detection failed " | 1180 | dev_warn(dev, "Detection failed at step 5\n"); |
1206 | "at step 5\n"); | ||
1207 | goto ERROR1; | 1181 | goto ERROR1; |
1208 | } | 1182 | } |
1209 | } | 1183 | } |
1210 | 1184 | ||
1211 | /* We have either had a force parameter, or we have already detected the | 1185 | /* We have either had a force parameter, or we have already detected the |
1212 | Winbond. Put it now into bank 0 and Vendor ID High Byte */ | 1186 | Winbond. Put it now into bank 0 and Vendor ID High Byte */ |
1213 | w83792d_write_value(new_client, | 1187 | w83792d_write_value(client, |
1214 | W83792D_REG_BANK, | 1188 | W83792D_REG_BANK, |
1215 | (w83792d_read_value(new_client, | 1189 | (w83792d_read_value(client, |
1216 | W83792D_REG_BANK) & 0x78) | 0x80); | 1190 | W83792D_REG_BANK) & 0x78) | 0x80); |
1217 | 1191 | ||
1218 | /* Determine the chip type. */ | 1192 | /* Determine the chip type. */ |
1219 | if (kind <= 0) { | 1193 | if (kind <= 0) { |
1220 | /* get vendor ID */ | 1194 | /* get vendor ID */ |
1221 | val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN); | 1195 | val2 = w83792d_read_value(client, W83792D_REG_CHIPMAN); |
1222 | if (val2 != 0x5c) { /* the vendor is NOT Winbond */ | 1196 | if (val2 != 0x5c) { /* the vendor is NOT Winbond */ |
1223 | goto ERROR1; | 1197 | goto ERROR1; |
1224 | } | 1198 | } |
1225 | val1 = w83792d_read_value(new_client, W83792D_REG_WCHIPID); | 1199 | val1 = w83792d_read_value(client, W83792D_REG_WCHIPID); |
1226 | if (val1 == 0x7a) { | 1200 | if (val1 == 0x7a) { |
1227 | kind = w83792d; | 1201 | kind = w83792d; |
1228 | } else { | 1202 | } else { |
1229 | if (kind == 0) | 1203 | if (kind == 0) |
1230 | dev_warn(&new_client->dev, | 1204 | dev_warn(dev, |
1231 | "w83792d: Ignoring 'force' parameter for" | 1205 | "w83792d: Ignoring 'force' parameter for" |
1232 | " unknown chip at adapter %d, address" | 1206 | " unknown chip at adapter %d, address" |
1233 | " 0x%02x\n", i2c_adapter_id(adapter), | 1207 | " 0x%02x\n", i2c_adapter_id(adapter), |
@@ -1239,120 +1213,86 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1239 | if (kind == w83792d) { | 1213 | if (kind == w83792d) { |
1240 | client_name = "w83792d"; | 1214 | client_name = "w83792d"; |
1241 | } else { | 1215 | } else { |
1242 | dev_err(&new_client->dev, "w83792d: Internal error: unknown" | 1216 | dev_err(dev, "w83792d: Internal error: unknown" |
1243 | " kind (%d)?!?", kind); | 1217 | " kind (%d)?!?", kind); |
1244 | goto ERROR1; | 1218 | goto ERROR1; |
1245 | } | 1219 | } |
1246 | 1220 | ||
1247 | /* Fill in the remaining client fields and put into the global list */ | 1221 | /* Fill in the remaining client fields and put into the global list */ |
1248 | strlcpy(new_client->name, client_name, I2C_NAME_SIZE); | 1222 | strlcpy(client->name, client_name, I2C_NAME_SIZE); |
1249 | data->type = kind; | 1223 | data->type = kind; |
1250 | 1224 | ||
1251 | data->valid = 0; | 1225 | data->valid = 0; |
1252 | init_MUTEX(&data->update_lock); | 1226 | mutex_init(&data->update_lock); |
1253 | 1227 | ||
1254 | /* Tell the I2C layer a new client has arrived */ | 1228 | /* Tell the I2C layer a new client has arrived */ |
1255 | if ((err = i2c_attach_client(new_client))) | 1229 | if ((err = i2c_attach_client(client))) |
1256 | goto ERROR1; | 1230 | goto ERROR1; |
1257 | 1231 | ||
1258 | if ((err = w83792d_detect_subclients(adapter, address, | 1232 | if ((err = w83792d_detect_subclients(adapter, address, |
1259 | kind, new_client))) | 1233 | kind, client))) |
1260 | goto ERROR2; | 1234 | goto ERROR2; |
1261 | 1235 | ||
1262 | /* Initialize the chip */ | 1236 | /* Initialize the chip */ |
1263 | w83792d_init_client(new_client); | 1237 | w83792d_init_client(client); |
1264 | 1238 | ||
1265 | /* A few vars need to be filled upon startup */ | 1239 | /* A few vars need to be filled upon startup */ |
1266 | for (i = 0; i < 7; i++) { | 1240 | for (i = 0; i < 7; i++) { |
1267 | data->fan_min[i] = w83792d_read_value(new_client, | 1241 | data->fan_min[i] = w83792d_read_value(client, |
1268 | W83792D_REG_FAN_MIN[i]); | 1242 | W83792D_REG_FAN_MIN[i]); |
1269 | } | 1243 | } |
1270 | 1244 | ||
1271 | /* Register sysfs hooks */ | 1245 | /* Register sysfs hooks */ |
1272 | data->class_dev = hwmon_device_register(&new_client->dev); | 1246 | data->class_dev = hwmon_device_register(dev); |
1273 | if (IS_ERR(data->class_dev)) { | 1247 | if (IS_ERR(data->class_dev)) { |
1274 | err = PTR_ERR(data->class_dev); | 1248 | err = PTR_ERR(data->class_dev); |
1275 | goto ERROR3; | 1249 | goto ERROR3; |
1276 | } | 1250 | } |
1277 | device_create_file_in(new_client, 0); | 1251 | for (i = 0; i < 9; i++) { |
1278 | device_create_file_in(new_client, 1); | 1252 | device_create_file(dev, &sda_in_input[i].dev_attr); |
1279 | device_create_file_in(new_client, 2); | 1253 | device_create_file(dev, &sda_in_max[i].dev_attr); |
1280 | device_create_file_in(new_client, 3); | 1254 | device_create_file(dev, &sda_in_min[i].dev_attr); |
1281 | device_create_file_in(new_client, 4); | 1255 | } |
1282 | device_create_file_in(new_client, 5); | 1256 | for (i = 0; i < 3; i++) |
1283 | device_create_file_in(new_client, 6); | 1257 | device_create_file_fan(dev, i); |
1284 | device_create_file_in(new_client, 7); | ||
1285 | device_create_file_in(new_client, 8); | ||
1286 | |||
1287 | device_create_file_fan(new_client, 1); | ||
1288 | device_create_file_fan(new_client, 2); | ||
1289 | device_create_file_fan(new_client, 3); | ||
1290 | 1258 | ||
1291 | /* Read GPIO enable register to check if pins for fan 4,5 are used as | 1259 | /* Read GPIO enable register to check if pins for fan 4,5 are used as |
1292 | GPIO */ | 1260 | GPIO */ |
1293 | val1 = w83792d_read_value(new_client, W83792D_REG_GPIO_EN); | 1261 | val1 = w83792d_read_value(client, W83792D_REG_GPIO_EN); |
1294 | if (!(val1 & 0x40)) | 1262 | if (!(val1 & 0x40)) |
1295 | device_create_file_fan(new_client, 4); | 1263 | device_create_file_fan(dev, 3); |
1296 | if (!(val1 & 0x20)) | 1264 | if (!(val1 & 0x20)) |
1297 | device_create_file_fan(new_client, 5); | 1265 | device_create_file_fan(dev, 4); |
1298 | 1266 | ||
1299 | val1 = w83792d_read_value(new_client, W83792D_REG_PIN); | 1267 | val1 = w83792d_read_value(client, W83792D_REG_PIN); |
1300 | if (val1 & 0x40) | 1268 | if (val1 & 0x40) |
1301 | device_create_file_fan(new_client, 6); | 1269 | device_create_file_fan(dev, 5); |
1302 | if (val1 & 0x04) | 1270 | if (val1 & 0x04) |
1303 | device_create_file_fan(new_client, 7); | 1271 | device_create_file_fan(dev, 6); |
1304 | 1272 | ||
1305 | device_create_file_temp1(new_client); /* Temp1 */ | 1273 | for (i = 0; i < 3; i++) { |
1306 | device_create_file_temp_add(new_client, 2); /* Temp2 */ | 1274 | device_create_file(dev, &sda_temp_input[i].dev_attr); |
1307 | device_create_file_temp_add(new_client, 3); /* Temp3 */ | 1275 | device_create_file(dev, &sda_temp_max[i].dev_attr); |
1308 | 1276 | device_create_file(dev, &sda_temp_max_hyst[i].dev_attr); | |
1309 | device_create_file_alarms(new_client); | 1277 | device_create_file(dev, &sda_thermal_cruise[i].dev_attr); |
1310 | 1278 | device_create_file(dev, &sda_tolerance[i].dev_attr); | |
1311 | device_create_file_pwm(new_client, 1); | 1279 | } |
1312 | device_create_file_pwm(new_client, 2); | 1280 | |
1313 | device_create_file_pwm(new_client, 3); | 1281 | for (i = 0; i < ARRAY_SIZE(sda_pwm); i++) { |
1314 | 1282 | device_create_file(dev, &sda_pwm[i].dev_attr); | |
1315 | device_create_file_pwmenable(new_client, 1); | 1283 | device_create_file(dev, &sda_pwm_enable[i].dev_attr); |
1316 | device_create_file_pwmenable(new_client, 2); | 1284 | device_create_file(dev, &sda_pwm_mode[i].dev_attr); |
1317 | device_create_file_pwmenable(new_client, 3); | 1285 | } |
1318 | 1286 | ||
1319 | device_create_file_pwm_mode(new_client, 1); | 1287 | device_create_file(dev, &dev_attr_alarms); |
1320 | device_create_file_pwm_mode(new_client, 2); | 1288 | device_create_file(dev, &dev_attr_chassis); |
1321 | device_create_file_pwm_mode(new_client, 3); | 1289 | device_create_file(dev, &dev_attr_chassis_clear); |
1322 | 1290 | ||
1323 | device_create_file_chassis(new_client); | 1291 | for (i = 0; i < ARRAY_SIZE(sda_sf2_point); i++) |
1324 | device_create_file_chassis_clear(new_client); | 1292 | device_create_file(dev, &sda_sf2_point[i].dev_attr); |
1325 | 1293 | ||
1326 | device_create_file_thermal_cruise(new_client, 1); | 1294 | for (i = 0; i < ARRAY_SIZE(sda_sf2_level); i++) |
1327 | device_create_file_thermal_cruise(new_client, 2); | 1295 | device_create_file(dev, &sda_sf2_level[i].dev_attr); |
1328 | device_create_file_thermal_cruise(new_client, 3); | ||
1329 | |||
1330 | device_create_file_tolerance(new_client, 1); | ||
1331 | device_create_file_tolerance(new_client, 2); | ||
1332 | device_create_file_tolerance(new_client, 3); | ||
1333 | |||
1334 | device_create_file_sf2_point(new_client, 1, 1); /* Fan1 */ | ||
1335 | device_create_file_sf2_point(new_client, 2, 1); /* Fan1 */ | ||
1336 | device_create_file_sf2_point(new_client, 3, 1); /* Fan1 */ | ||
1337 | device_create_file_sf2_point(new_client, 4, 1); /* Fan1 */ | ||
1338 | device_create_file_sf2_point(new_client, 1, 2); /* Fan2 */ | ||
1339 | device_create_file_sf2_point(new_client, 2, 2); /* Fan2 */ | ||
1340 | device_create_file_sf2_point(new_client, 3, 2); /* Fan2 */ | ||
1341 | device_create_file_sf2_point(new_client, 4, 2); /* Fan2 */ | ||
1342 | device_create_file_sf2_point(new_client, 1, 3); /* Fan3 */ | ||
1343 | device_create_file_sf2_point(new_client, 2, 3); /* Fan3 */ | ||
1344 | device_create_file_sf2_point(new_client, 3, 3); /* Fan3 */ | ||
1345 | device_create_file_sf2_point(new_client, 4, 3); /* Fan3 */ | ||
1346 | |||
1347 | device_create_file_sf2_level(new_client, 1, 1); /* Fan1 */ | ||
1348 | device_create_file_sf2_level(new_client, 2, 1); /* Fan1 */ | ||
1349 | device_create_file_sf2_level(new_client, 3, 1); /* Fan1 */ | ||
1350 | device_create_file_sf2_level(new_client, 1, 2); /* Fan2 */ | ||
1351 | device_create_file_sf2_level(new_client, 2, 2); /* Fan2 */ | ||
1352 | device_create_file_sf2_level(new_client, 3, 2); /* Fan2 */ | ||
1353 | device_create_file_sf2_level(new_client, 1, 3); /* Fan3 */ | ||
1354 | device_create_file_sf2_level(new_client, 2, 3); /* Fan3 */ | ||
1355 | device_create_file_sf2_level(new_client, 3, 3); /* Fan3 */ | ||
1356 | 1296 | ||
1357 | return 0; | 1297 | return 0; |
1358 | 1298 | ||
@@ -1366,7 +1306,7 @@ ERROR3: | |||
1366 | kfree(data->lm75[1]); | 1306 | kfree(data->lm75[1]); |
1367 | } | 1307 | } |
1368 | ERROR2: | 1308 | ERROR2: |
1369 | i2c_detach_client(new_client); | 1309 | i2c_detach_client(client); |
1370 | ERROR1: | 1310 | ERROR1: |
1371 | kfree(data); | 1311 | kfree(data); |
1372 | ERROR0: | 1312 | ERROR0: |
@@ -1434,7 +1374,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev) | |||
1434 | int i, j; | 1374 | int i, j; |
1435 | u8 reg_array_tmp[4], pwm_array_tmp[7], reg_tmp; | 1375 | u8 reg_array_tmp[4], pwm_array_tmp[7], reg_tmp; |
1436 | 1376 | ||
1437 | down(&data->update_lock); | 1377 | mutex_lock(&data->update_lock); |
1438 | 1378 | ||
1439 | if (time_after | 1379 | if (time_after |
1440 | (jiffies - data->last_updated, (unsigned long) (HZ * 3)) | 1380 | (jiffies - data->last_updated, (unsigned long) (HZ * 3)) |
@@ -1545,7 +1485,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev) | |||
1545 | data->valid = 1; | 1485 | data->valid = 1; |
1546 | } | 1486 | } |
1547 | 1487 | ||
1548 | up(&data->update_lock); | 1488 | mutex_unlock(&data->update_lock); |
1549 | 1489 | ||
1550 | #ifdef DEBUG | 1490 | #ifdef DEBUG |
1551 | w83792d_print_debug(data, dev); | 1491 | w83792d_print_debug(data, dev); |
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index f66c0cfdeda7..3f2bac125fb1 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/hwmon.h> | 39 | #include <linux/hwmon.h> |
40 | #include <linux/hwmon-sysfs.h> | 40 | #include <linux/hwmon-sysfs.h> |
41 | #include <linux/err.h> | 41 | #include <linux/err.h> |
42 | #include <linux/mutex.h> | ||
42 | 43 | ||
43 | /* How many retries on register read error */ | 44 | /* How many retries on register read error */ |
44 | #define MAX_RETRIES 5 | 45 | #define MAX_RETRIES 5 |
@@ -107,7 +108,7 @@ static struct i2c_driver w83l785ts_driver = { | |||
107 | struct w83l785ts_data { | 108 | struct w83l785ts_data { |
108 | struct i2c_client client; | 109 | struct i2c_client client; |
109 | struct class_device *class_dev; | 110 | struct class_device *class_dev; |
110 | struct semaphore update_lock; | 111 | struct mutex update_lock; |
111 | char valid; /* zero until following fields are valid */ | 112 | char valid; /* zero until following fields are valid */ |
112 | unsigned long last_updated; /* in jiffies */ | 113 | unsigned long last_updated; /* in jiffies */ |
113 | 114 | ||
@@ -221,7 +222,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) | |||
221 | /* We can fill in the remaining client fields. */ | 222 | /* We can fill in the remaining client fields. */ |
222 | strlcpy(new_client->name, "w83l785ts", I2C_NAME_SIZE); | 223 | strlcpy(new_client->name, "w83l785ts", I2C_NAME_SIZE); |
223 | data->valid = 0; | 224 | data->valid = 0; |
224 | init_MUTEX(&data->update_lock); | 225 | mutex_init(&data->update_lock); |
225 | 226 | ||
226 | /* Default values in case the first read fails (unlikely). */ | 227 | /* Default values in case the first read fails (unlikely). */ |
227 | data->temp[1] = data->temp[0] = 0; | 228 | data->temp[1] = data->temp[0] = 0; |
@@ -299,7 +300,7 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev) | |||
299 | struct i2c_client *client = to_i2c_client(dev); | 300 | struct i2c_client *client = to_i2c_client(dev); |
300 | struct w83l785ts_data *data = i2c_get_clientdata(client); | 301 | struct w83l785ts_data *data = i2c_get_clientdata(client); |
301 | 302 | ||
302 | down(&data->update_lock); | 303 | mutex_lock(&data->update_lock); |
303 | 304 | ||
304 | if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { | 305 | if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { |
305 | dev_dbg(&client->dev, "Updating w83l785ts data.\n"); | 306 | dev_dbg(&client->dev, "Updating w83l785ts data.\n"); |
@@ -312,7 +313,7 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev) | |||
312 | data->valid = 1; | 313 | data->valid = 1; |
313 | } | 314 | } |
314 | 315 | ||
315 | up(&data->update_lock); | 316 | mutex_unlock(&data->update_lock); |
316 | 317 | ||
317 | return data; | 318 | return data; |
318 | } | 319 | } |
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index ff92735c7c85..089c6f5b24de 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -168,12 +168,14 @@ config I2C_PIIX4 | |||
168 | help | 168 | help |
169 | If you say yes to this option, support will be included for the Intel | 169 | If you say yes to this option, support will be included for the Intel |
170 | PIIX4 family of mainboard I2C interfaces. Specifically, the following | 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 | Intel PIIX4 | 173 | Intel PIIX4 |
173 | Intel 440MX | 174 | Intel 440MX |
174 | Serverworks OSB4 | 175 | Serverworks OSB4 |
175 | Serverworks CSB5 | 176 | Serverworks CSB5 |
176 | Serverworks CSB6 | 177 | Serverworks CSB6 |
178 | Serverworks HT-1000 | ||
177 | SMSC Victory66 | 179 | SMSC Victory66 |
178 | 180 | ||
179 | This driver can also be built as a module. If so, the module | 181 | This driver can also be built as a module. If so, the module |
@@ -389,10 +391,11 @@ config SCx200_I2C_SDA | |||
389 | also be specified with a module parameter. | 391 | also be specified with a module parameter. |
390 | 392 | ||
391 | config SCx200_ACB | 393 | config SCx200_ACB |
392 | tristate "NatSemi SCx200 ACCESS.bus" | 394 | tristate "Geode ACCESS.bus support" |
393 | depends on I2C && PCI | 395 | depends on X86_32 && I2C && PCI |
394 | help | 396 | help |
395 | Enable the use of the ACCESS.bus controllers of a SCx200 processor. | 397 | Enable the use of the ACCESS.bus controllers on the Geode SCx200 and |
398 | SC1100 processors and the CS5535 and CS5536 Geode companion devices. | ||
396 | 399 | ||
397 | If you don't know what to do here, say N. | 400 | If you don't know what to do here, say N. |
398 | 401 | ||
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index 3eb47890db40..d3ef46aeeb3c 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c | |||
@@ -63,7 +63,6 @@ | |||
63 | #include <linux/i2c.h> | 63 | #include <linux/i2c.h> |
64 | #include <linux/init.h> | 64 | #include <linux/init.h> |
65 | #include <asm/io.h> | 65 | #include <asm/io.h> |
66 | #include <asm/semaphore.h> | ||
67 | 66 | ||
68 | 67 | ||
69 | /* ALI1535 SMBus address offsets */ | 68 | /* ALI1535 SMBus address offsets */ |
@@ -136,7 +135,6 @@ | |||
136 | 135 | ||
137 | static struct pci_driver ali1535_driver; | 136 | static struct pci_driver ali1535_driver; |
138 | static unsigned short ali1535_smba; | 137 | static unsigned short ali1535_smba; |
139 | static DECLARE_MUTEX(i2c_ali1535_sem); | ||
140 | 138 | ||
141 | /* Detect whether a ALI1535 can be found, and initialize it, where necessary. | 139 | /* Detect whether a ALI1535 can be found, and initialize it, where necessary. |
142 | Note the differences between kernels with the old PCI BIOS interface and | 140 | Note the differences between kernels with the old PCI BIOS interface and |
@@ -345,7 +343,6 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, | |||
345 | int timeout; | 343 | int timeout; |
346 | s32 result = 0; | 344 | s32 result = 0; |
347 | 345 | ||
348 | down(&i2c_ali1535_sem); | ||
349 | /* make sure SMBus is idle */ | 346 | /* make sure SMBus is idle */ |
350 | temp = inb_p(SMBHSTSTS); | 347 | temp = inb_p(SMBHSTSTS); |
351 | for (timeout = 0; | 348 | for (timeout = 0; |
@@ -460,7 +457,6 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, | |||
460 | break; | 457 | break; |
461 | } | 458 | } |
462 | EXIT: | 459 | EXIT: |
463 | up(&i2c_ali1535_sem); | ||
464 | return result; | 460 | return result; |
465 | } | 461 | } |
466 | 462 | ||
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c index 56c7d987590f..08e915730caf 100644 --- a/drivers/i2c/busses/i2c-amd756-s4882.c +++ b/drivers/i2c/busses/i2c-amd756-s4882.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
39 | #include <linux/init.h> | 39 | #include <linux/init.h> |
40 | #include <linux/i2c.h> | 40 | #include <linux/i2c.h> |
41 | #include <linux/mutex.h> | ||
41 | 42 | ||
42 | extern struct i2c_adapter amd756_smbus; | 43 | extern struct i2c_adapter amd756_smbus; |
43 | 44 | ||
@@ -45,7 +46,7 @@ static struct i2c_adapter *s4882_adapter; | |||
45 | static struct i2c_algorithm *s4882_algo; | 46 | static struct i2c_algorithm *s4882_algo; |
46 | 47 | ||
47 | /* Wrapper access functions for multiplexed SMBus */ | 48 | /* Wrapper access functions for multiplexed SMBus */ |
48 | static struct semaphore amd756_lock; | 49 | static DEFINE_MUTEX(amd756_lock); |
49 | 50 | ||
50 | static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr, | 51 | static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr, |
51 | unsigned short flags, char read_write, | 52 | unsigned short flags, char read_write, |
@@ -59,12 +60,12 @@ static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr, | |||
59 | || addr == 0x18) | 60 | || addr == 0x18) |
60 | return -1; | 61 | return -1; |
61 | 62 | ||
62 | down(&amd756_lock); | 63 | mutex_lock(&amd756_lock); |
63 | 64 | ||
64 | error = amd756_smbus.algo->smbus_xfer(adap, addr, flags, read_write, | 65 | error = amd756_smbus.algo->smbus_xfer(adap, addr, flags, read_write, |
65 | command, size, data); | 66 | command, size, data); |
66 | 67 | ||
67 | up(&amd756_lock); | 68 | mutex_unlock(&amd756_lock); |
68 | 69 | ||
69 | return error; | 70 | return error; |
70 | } | 71 | } |
@@ -87,7 +88,7 @@ static inline s32 amd756_access_channel(struct i2c_adapter * adap, u16 addr, | |||
87 | if (addr != 0x4c && (addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30) | 88 | if (addr != 0x4c && (addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30) |
88 | return -1; | 89 | return -1; |
89 | 90 | ||
90 | down(&amd756_lock); | 91 | mutex_lock(&amd756_lock); |
91 | 92 | ||
92 | if (last_channels != channels) { | 93 | if (last_channels != channels) { |
93 | union i2c_smbus_data mplxdata; | 94 | union i2c_smbus_data mplxdata; |
@@ -105,7 +106,7 @@ static inline s32 amd756_access_channel(struct i2c_adapter * adap, u16 addr, | |||
105 | command, size, data); | 106 | command, size, data); |
106 | 107 | ||
107 | UNLOCK: | 108 | UNLOCK: |
108 | up(&amd756_lock); | 109 | mutex_unlock(&amd756_lock); |
109 | return error; | 110 | return error; |
110 | } | 111 | } |
111 | 112 | ||
@@ -166,8 +167,6 @@ static int __init amd756_s4882_init(void) | |||
166 | } | 167 | } |
167 | 168 | ||
168 | printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n"); | 169 | printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n"); |
169 | init_MUTEX(&amd756_lock); | ||
170 | |||
171 | /* Define the 5 virtual adapters and algorithms structures */ | 170 | /* Define the 5 virtual adapters and algorithms structures */ |
172 | if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter), | 171 | if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter), |
173 | GFP_KERNEL))) { | 172 | GFP_KERNEL))) { |
diff --git a/drivers/i2c/busses/i2c-frodo.c b/drivers/i2c/busses/i2c-frodo.c deleted file mode 100644 index b6f52f5a4138..000000000000 --- a/drivers/i2c/busses/i2c-frodo.c +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
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 | |||
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index 4344ae6b1fcb..c3e1d3e888d7 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c | |||
@@ -125,7 +125,7 @@ int i2c_isa_del_driver(struct i2c_driver *driver) | |||
125 | 125 | ||
126 | static int __init i2c_isa_init(void) | 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 | INIT_LIST_HEAD(&isa_adapter.clients); | 129 | INIT_LIST_HEAD(&isa_adapter.clients); |
130 | 130 | ||
131 | isa_adapter.nr = ANY_I2C_ISA_BUS; | 131 | isa_adapter.nr = ANY_I2C_ISA_BUS; |
diff --git a/drivers/i2c/busses/i2c-ite.c b/drivers/i2c/busses/i2c-ite.c index 5f5d2944808b..d82e6dae8407 100644 --- a/drivers/i2c/busses/i2c-ite.c +++ b/drivers/i2c/busses/i2c-ite.c | |||
@@ -200,9 +200,7 @@ static struct i2c_adapter iic_ite_ops = { | |||
200 | .owner = THIS_MODULE, | 200 | .owner = THIS_MODULE, |
201 | .id = I2C_HW_I_IIC, | 201 | .id = I2C_HW_I_IIC, |
202 | .algo_data = &iic_ite_data, | 202 | .algo_data = &iic_ite_data, |
203 | .dev = { | 203 | .name = "ITE IIC adapter", |
204 | .name = "ITE IIC adapter", | ||
205 | }, | ||
206 | }; | 204 | }; |
207 | 205 | ||
208 | /* Called when the module is loaded. This function starts the | 206 | /* Called when the module is loaded. This function starts the |
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c index e422d8b2d4d6..2ed07112d683 100644 --- a/drivers/i2c/busses/i2c-ixp4xx.c +++ b/drivers/i2c/busses/i2c-ixp4xx.c | |||
@@ -126,6 +126,7 @@ static int ixp4xx_i2c_probe(struct platform_device *plat_dev) | |||
126 | drv_data->algo_data.timeout = 100; | 126 | drv_data->algo_data.timeout = 100; |
127 | 127 | ||
128 | drv_data->adapter.id = I2C_HW_B_IXP4XX; | 128 | drv_data->adapter.id = I2C_HW_B_IXP4XX; |
129 | drv_data->adapter.class = I2C_CLASS_HWMON; | ||
129 | strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name, | 130 | strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name, |
130 | I2C_NAME_SIZE); | 131 | I2C_NAME_SIZE); |
131 | drv_data->adapter.algo_data = &drv_data->algo_data; | 132 | drv_data->adapter.algo_data = &drv_data->algo_data; |
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 692f47345481..d9c7c00e71f9 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c | |||
@@ -22,7 +22,7 @@ | |||
22 | /* | 22 | /* |
23 | Supports: | 23 | Supports: |
24 | Intel PIIX4, 440MX | 24 | Intel PIIX4, 440MX |
25 | Serverworks OSB4, CSB5, CSB6 | 25 | Serverworks OSB4, CSB5, CSB6, HT-1000 |
26 | SMSC Victory66 | 26 | SMSC Victory66 |
27 | 27 | ||
28 | Note: we assume there can only be one device, with one SMBus interface. | 28 | Note: we assume there can only be one device, with one SMBus interface. |
@@ -419,6 +419,8 @@ static struct pci_device_id piix4_ids[] = { | |||
419 | .driver_data = 0 }, | 419 | .driver_data = 0 }, |
420 | { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6), | 420 | { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6), |
421 | .driver_data = 0 }, | 421 | .driver_data = 0 }, |
422 | { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000SB), | ||
423 | .driver_data = 0 }, | ||
422 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3), | 424 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3), |
423 | .driver_data = 3 }, | 425 | .driver_data = 3 }, |
424 | { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_3), | 426 | { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_3), |
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 7579f4b256a8..5155010b455e 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c | |||
@@ -647,7 +647,7 @@ static inline void i2c_pxa_start_message(struct pxa_i2c *i2c) | |||
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 | static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num) | 652 | static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num) |
653 | { | 653 | { |
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index d3478e084522..8bd305e47f0d 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c | |||
@@ -1,27 +1,26 @@ | |||
1 | /* linux/drivers/i2c/scx200_acb.c | 1 | /* |
2 | |||
3 | Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com> | 2 | Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com> |
4 | 3 | ||
5 | National Semiconductor SCx200 ACCESS.bus support | 4 | National Semiconductor SCx200 ACCESS.bus support |
6 | 5 | Also supports the AMD CS5535 and AMD CS5536 | |
6 | |||
7 | Based on i2c-keywest.c which is: | 7 | Based on i2c-keywest.c which is: |
8 | Copyright (c) 2001 Benjamin Herrenschmidt <benh@kernel.crashing.org> | 8 | Copyright (c) 2001 Benjamin Herrenschmidt <benh@kernel.crashing.org> |
9 | Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.com> | 9 | Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.com> |
10 | 10 | ||
11 | This program is free software; you can redistribute it and/or | 11 | This program is free software; you can redistribute it and/or |
12 | modify it under the terms of the GNU General Public License as | 12 | modify it under the terms of the GNU General Public License as |
13 | published by the Free Software Foundation; either version 2 of the | 13 | published by the Free Software Foundation; either version 2 of the |
14 | License, or (at your option) any later version. | 14 | License, or (at your option) any later version. |
15 | 15 | ||
16 | This program is distributed in the hope that it will be useful, | 16 | This program is distributed in the hope that it will be useful, |
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 | General Public License for more details. | 19 | General Public License for more details. |
20 | 20 | ||
21 | You should have received a copy of the GNU General Public License | 21 | You should have received a copy of the GNU General Public License |
22 | along with this program; if not, write to the Free Software | 22 | along with this program; if not, write to the Free Software |
23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | |||
25 | */ | 24 | */ |
26 | 25 | ||
27 | #include <linux/module.h> | 26 | #include <linux/module.h> |
@@ -32,7 +31,9 @@ | |||
32 | #include <linux/smp_lock.h> | 31 | #include <linux/smp_lock.h> |
33 | #include <linux/pci.h> | 32 | #include <linux/pci.h> |
34 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
34 | #include <linux/mutex.h> | ||
35 | #include <asm/io.h> | 35 | #include <asm/io.h> |
36 | #include <asm/msr.h> | ||
36 | 37 | ||
37 | #include <linux/scx200.h> | 38 | #include <linux/scx200.h> |
38 | 39 | ||
@@ -47,16 +48,7 @@ static int base[MAX_DEVICES] = { 0x820, 0x840 }; | |||
47 | module_param_array(base, int, NULL, 0); | 48 | module_param_array(base, int, NULL, 0); |
48 | MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers"); | 49 | MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers"); |
49 | 50 | ||
50 | #ifdef DEBUG | 51 | #define POLL_TIMEOUT (HZ/5) |
51 | #define DBG(x...) printk(KERN_DEBUG NAME ": " x) | ||
52 | #else | ||
53 | #define DBG(x...) | ||
54 | #endif | ||
55 | |||
56 | /* The hardware supports interrupt driven mode too, but I haven't | ||
57 | implemented that. */ | ||
58 | #define POLLED_MODE 1 | ||
59 | #define POLL_TIMEOUT (HZ) | ||
60 | 52 | ||
61 | enum scx200_acb_state { | 53 | enum scx200_acb_state { |
62 | state_idle, | 54 | state_idle, |
@@ -79,12 +71,11 @@ static const char *scx200_acb_state_name[] = { | |||
79 | }; | 71 | }; |
80 | 72 | ||
81 | /* Physical interface */ | 73 | /* Physical interface */ |
82 | struct scx200_acb_iface | 74 | struct scx200_acb_iface { |
83 | { | ||
84 | struct scx200_acb_iface *next; | 75 | struct scx200_acb_iface *next; |
85 | struct i2c_adapter adapter; | 76 | struct i2c_adapter adapter; |
86 | unsigned base; | 77 | unsigned base; |
87 | struct semaphore sem; | 78 | struct mutex mutex; |
88 | 79 | ||
89 | /* State machine data */ | 80 | /* State machine data */ |
90 | enum scx200_acb_state state; | 81 | enum scx200_acb_state state; |
@@ -100,7 +91,7 @@ struct scx200_acb_iface | |||
100 | #define ACBSDA (iface->base + 0) | 91 | #define ACBSDA (iface->base + 0) |
101 | #define ACBST (iface->base + 1) | 92 | #define ACBST (iface->base + 1) |
102 | #define ACBST_SDAST 0x40 /* SDA Status */ | 93 | #define ACBST_SDAST 0x40 /* SDA Status */ |
103 | #define ACBST_BER 0x20 | 94 | #define ACBST_BER 0x20 |
104 | #define ACBST_NEGACK 0x10 /* Negative Acknowledge */ | 95 | #define ACBST_NEGACK 0x10 /* Negative Acknowledge */ |
105 | #define ACBST_STASTR 0x08 /* Stall After Start */ | 96 | #define ACBST_STASTR 0x08 /* Stall After Start */ |
106 | #define ACBST_MASTER 0x02 | 97 | #define ACBST_MASTER 0x02 |
@@ -109,9 +100,9 @@ struct scx200_acb_iface | |||
109 | #define ACBCTL1 (iface->base + 3) | 100 | #define ACBCTL1 (iface->base + 3) |
110 | #define ACBCTL1_STASTRE 0x80 | 101 | #define ACBCTL1_STASTRE 0x80 |
111 | #define ACBCTL1_NMINTE 0x40 | 102 | #define ACBCTL1_NMINTE 0x40 |
112 | #define ACBCTL1_ACK 0x10 | 103 | #define ACBCTL1_ACK 0x10 |
113 | #define ACBCTL1_STOP 0x02 | 104 | #define ACBCTL1_STOP 0x02 |
114 | #define ACBCTL1_START 0x01 | 105 | #define ACBCTL1_START 0x01 |
115 | #define ACBADDR (iface->base + 4) | 106 | #define ACBADDR (iface->base + 4) |
116 | #define ACBCTL2 (iface->base + 5) | 107 | #define ACBCTL2 (iface->base + 5) |
117 | #define ACBCTL2_ENABLE 0x01 | 108 | #define ACBCTL2_ENABLE 0x01 |
@@ -122,8 +113,8 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
122 | { | 113 | { |
123 | const char *errmsg; | 114 | const char *errmsg; |
124 | 115 | ||
125 | DBG("state %s, status = 0x%02x\n", | 116 | dev_dbg(&iface->adapter.dev, "state %s, status = 0x%02x\n", |
126 | scx200_acb_state_name[iface->state], status); | 117 | scx200_acb_state_name[iface->state], status); |
127 | 118 | ||
128 | if (status & ACBST_BER) { | 119 | if (status & ACBST_BER) { |
129 | errmsg = "bus error"; | 120 | errmsg = "bus error"; |
@@ -133,8 +124,17 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
133 | errmsg = "not master"; | 124 | errmsg = "not master"; |
134 | goto error; | 125 | goto error; |
135 | } | 126 | } |
136 | if (status & ACBST_NEGACK) | 127 | if (status & ACBST_NEGACK) { |
137 | goto negack; | 128 | dev_dbg(&iface->adapter.dev, "negative ack in state %s\n", |
129 | scx200_acb_state_name[iface->state]); | ||
130 | |||
131 | iface->state = state_idle; | ||
132 | iface->result = -ENXIO; | ||
133 | |||
134 | outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); | ||
135 | outb(ACBST_STASTR | ACBST_NEGACK, ACBST); | ||
136 | return; | ||
137 | } | ||
138 | 138 | ||
139 | switch (iface->state) { | 139 | switch (iface->state) { |
140 | case state_idle: | 140 | case state_idle: |
@@ -160,10 +160,10 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
160 | case state_repeat_start: | 160 | case state_repeat_start: |
161 | outb(inb(ACBCTL1) | ACBCTL1_START, ACBCTL1); | 161 | outb(inb(ACBCTL1) | ACBCTL1_START, ACBCTL1); |
162 | /* fallthrough */ | 162 | /* fallthrough */ |
163 | 163 | ||
164 | case state_quick: | 164 | case state_quick: |
165 | if (iface->address_byte & 1) { | 165 | if (iface->address_byte & 1) { |
166 | if (iface->len == 1) | 166 | if (iface->len == 1) |
167 | outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1); | 167 | outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1); |
168 | else | 168 | else |
169 | outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1); | 169 | outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1); |
@@ -202,26 +202,15 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
202 | outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); | 202 | outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); |
203 | break; | 203 | break; |
204 | } | 204 | } |
205 | 205 | ||
206 | outb(*iface->ptr++, ACBSDA); | 206 | outb(*iface->ptr++, ACBSDA); |
207 | --iface->len; | 207 | --iface->len; |
208 | 208 | ||
209 | break; | 209 | break; |
210 | } | 210 | } |
211 | 211 | ||
212 | return; | 212 | return; |
213 | 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 | return; | ||
224 | |||
225 | error: | 214 | error: |
226 | dev_err(&iface->adapter.dev, "%s in state %s\n", errmsg, | 215 | dev_err(&iface->adapter.dev, "%s in state %s\n", errmsg, |
227 | scx200_acb_state_name[iface->state]); | 216 | scx200_acb_state_name[iface->state]); |
@@ -231,20 +220,9 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
231 | iface->needs_reset = 1; | 220 | iface->needs_reset = 1; |
232 | } | 221 | } |
233 | 222 | ||
234 | static void scx200_acb_timeout(struct scx200_acb_iface *iface) | ||
235 | { | ||
236 | dev_err(&iface->adapter.dev, "timeout in state %s\n", | ||
237 | scx200_acb_state_name[iface->state]); | ||
238 | |||
239 | iface->state = state_idle; | ||
240 | iface->result = -EIO; | ||
241 | iface->needs_reset = 1; | ||
242 | } | ||
243 | |||
244 | #ifdef POLLED_MODE | ||
245 | static void scx200_acb_poll(struct scx200_acb_iface *iface) | 223 | static void scx200_acb_poll(struct scx200_acb_iface *iface) |
246 | { | 224 | { |
247 | u8 status = 0; | 225 | u8 status; |
248 | unsigned long timeout; | 226 | unsigned long timeout; |
249 | 227 | ||
250 | timeout = jiffies + POLL_TIMEOUT; | 228 | timeout = jiffies + POLL_TIMEOUT; |
@@ -254,17 +232,21 @@ static void scx200_acb_poll(struct scx200_acb_iface *iface) | |||
254 | scx200_acb_machine(iface, status); | 232 | scx200_acb_machine(iface, status); |
255 | return; | 233 | return; |
256 | } | 234 | } |
257 | msleep(10); | 235 | yield(); |
258 | } | 236 | } |
259 | 237 | ||
260 | scx200_acb_timeout(iface); | 238 | dev_err(&iface->adapter.dev, "timeout in state %s\n", |
239 | scx200_acb_state_name[iface->state]); | ||
240 | |||
241 | iface->state = state_idle; | ||
242 | iface->result = -EIO; | ||
243 | iface->needs_reset = 1; | ||
261 | } | 244 | } |
262 | #endif /* POLLED_MODE */ | ||
263 | 245 | ||
264 | static void scx200_acb_reset(struct scx200_acb_iface *iface) | 246 | static void scx200_acb_reset(struct scx200_acb_iface *iface) |
265 | { | 247 | { |
266 | /* Disable the ACCESS.bus device and Configure the SCL | 248 | /* Disable the ACCESS.bus device and Configure the SCL |
267 | frequency: 16 clock cycles */ | 249 | frequency: 16 clock cycles */ |
268 | outb(0x70, ACBCTL2); | 250 | outb(0x70, ACBCTL2); |
269 | /* Polling mode */ | 251 | /* Polling mode */ |
270 | outb(0, ACBCTL1); | 252 | outb(0, ACBCTL1); |
@@ -283,9 +265,9 @@ static void scx200_acb_reset(struct scx200_acb_iface *iface) | |||
283 | } | 265 | } |
284 | 266 | ||
285 | static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter, | 267 | static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter, |
286 | u16 address, unsigned short flags, | 268 | u16 address, unsigned short flags, |
287 | char rw, u8 command, int size, | 269 | char rw, u8 command, int size, |
288 | union i2c_smbus_data *data) | 270 | union i2c_smbus_data *data) |
289 | { | 271 | { |
290 | struct scx200_acb_iface *iface = i2c_get_adapdata(adapter); | 272 | struct scx200_acb_iface *iface = i2c_get_adapdata(adapter); |
291 | int len; | 273 | int len; |
@@ -295,53 +277,47 @@ static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter, | |||
295 | 277 | ||
296 | switch (size) { | 278 | switch (size) { |
297 | case I2C_SMBUS_QUICK: | 279 | case I2C_SMBUS_QUICK: |
298 | len = 0; | 280 | len = 0; |
299 | buffer = NULL; | 281 | buffer = NULL; |
300 | break; | 282 | break; |
283 | |||
301 | case I2C_SMBUS_BYTE: | 284 | case I2C_SMBUS_BYTE: |
302 | if (rw == I2C_SMBUS_READ) { | 285 | len = 1; |
303 | len = 1; | 286 | buffer = rw ? &data->byte : &command; |
304 | buffer = &data->byte; | 287 | break; |
305 | } else { | 288 | |
306 | len = 1; | ||
307 | buffer = &command; | ||
308 | } | ||
309 | break; | ||
310 | case I2C_SMBUS_BYTE_DATA: | 289 | case I2C_SMBUS_BYTE_DATA: |
311 | len = 1; | 290 | len = 1; |
312 | buffer = &data->byte; | 291 | buffer = &data->byte; |
313 | break; | 292 | break; |
293 | |||
314 | case I2C_SMBUS_WORD_DATA: | 294 | case I2C_SMBUS_WORD_DATA: |
315 | len = 2; | 295 | len = 2; |
316 | cur_word = cpu_to_le16(data->word); | 296 | cur_word = cpu_to_le16(data->word); |
317 | buffer = (u8 *)&cur_word; | 297 | buffer = (u8 *)&cur_word; |
318 | break; | 298 | break; |
299 | |||
319 | case I2C_SMBUS_BLOCK_DATA: | 300 | case I2C_SMBUS_BLOCK_DATA: |
320 | len = data->block[0]; | 301 | len = data->block[0]; |
321 | buffer = &data->block[1]; | 302 | buffer = &data->block[1]; |
322 | break; | 303 | break; |
304 | |||
323 | default: | 305 | default: |
324 | return -EINVAL; | 306 | return -EINVAL; |
325 | } | 307 | } |
326 | 308 | ||
327 | DBG("size=%d, address=0x%x, command=0x%x, len=%d, read=%d\n", | 309 | dev_dbg(&adapter->dev, |
328 | size, address, command, len, rw == I2C_SMBUS_READ); | 310 | "size=%d, address=0x%x, command=0x%x, len=%d, read=%d\n", |
311 | size, address, command, len, rw); | ||
329 | 312 | ||
330 | if (!len && rw == I2C_SMBUS_READ) { | 313 | if (!len && rw == I2C_SMBUS_READ) { |
331 | dev_warn(&adapter->dev, "zero length read\n"); | 314 | dev_dbg(&adapter->dev, "zero length read\n"); |
332 | return -EINVAL; | 315 | return -EINVAL; |
333 | } | 316 | } |
334 | 317 | ||
335 | if (len && !buffer) { | 318 | mutex_lock(&iface->mutex); |
336 | dev_warn(&adapter->dev, "nonzero length but no buffer\n"); | ||
337 | return -EFAULT; | ||
338 | } | ||
339 | |||
340 | down(&iface->sem); | ||
341 | 319 | ||
342 | iface->address_byte = address<<1; | 320 | iface->address_byte = (address << 1) | rw; |
343 | if (rw == I2C_SMBUS_READ) | ||
344 | iface->address_byte |= 1; | ||
345 | iface->command = command; | 321 | iface->command = command; |
346 | iface->ptr = buffer; | 322 | iface->ptr = buffer; |
347 | iface->len = len; | 323 | iface->len = len; |
@@ -355,25 +331,21 @@ static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter, | |||
355 | else | 331 | else |
356 | iface->state = state_address; | 332 | iface->state = state_address; |
357 | 333 | ||
358 | #ifdef POLLED_MODE | ||
359 | while (iface->state != state_idle) | 334 | while (iface->state != state_idle) |
360 | scx200_acb_poll(iface); | 335 | scx200_acb_poll(iface); |
361 | #else /* POLLED_MODE */ | ||
362 | #error Interrupt driven mode not implemented | ||
363 | #endif /* POLLED_MODE */ | ||
364 | 336 | ||
365 | if (iface->needs_reset) | 337 | if (iface->needs_reset) |
366 | scx200_acb_reset(iface); | 338 | scx200_acb_reset(iface); |
367 | 339 | ||
368 | rc = iface->result; | 340 | rc = iface->result; |
369 | 341 | ||
370 | up(&iface->sem); | 342 | mutex_unlock(&iface->mutex); |
371 | 343 | ||
372 | if (rc == 0 && size == I2C_SMBUS_WORD_DATA && rw == I2C_SMBUS_READ) | 344 | if (rc == 0 && size == I2C_SMBUS_WORD_DATA && rw == I2C_SMBUS_READ) |
373 | data->word = le16_to_cpu(cur_word); | 345 | data->word = le16_to_cpu(cur_word); |
374 | 346 | ||
375 | #ifdef DEBUG | 347 | #ifdef DEBUG |
376 | DBG(": transfer done, result: %d", rc); | 348 | dev_dbg(&adapter->dev, "transfer done, result: %d", rc); |
377 | if (buffer) { | 349 | if (buffer) { |
378 | int i; | 350 | int i; |
379 | printk(" data:"); | 351 | printk(" data:"); |
@@ -400,17 +372,18 @@ static struct i2c_algorithm scx200_acb_algorithm = { | |||
400 | }; | 372 | }; |
401 | 373 | ||
402 | static struct scx200_acb_iface *scx200_acb_list; | 374 | static struct scx200_acb_iface *scx200_acb_list; |
375 | static DECLARE_MUTEX(scx200_acb_list_mutex); | ||
403 | 376 | ||
404 | static int scx200_acb_probe(struct scx200_acb_iface *iface) | 377 | static int scx200_acb_probe(struct scx200_acb_iface *iface) |
405 | { | 378 | { |
406 | u8 val; | 379 | u8 val; |
407 | 380 | ||
408 | /* Disable the ACCESS.bus device and Configure the SCL | 381 | /* Disable the ACCESS.bus device and Configure the SCL |
409 | frequency: 16 clock cycles */ | 382 | frequency: 16 clock cycles */ |
410 | outb(0x70, ACBCTL2); | 383 | outb(0x70, ACBCTL2); |
411 | 384 | ||
412 | if (inb(ACBCTL2) != 0x70) { | 385 | if (inb(ACBCTL2) != 0x70) { |
413 | DBG("ACBCTL2 readback failed\n"); | 386 | pr_debug(NAME ": ACBCTL2 readback failed\n"); |
414 | return -ENXIO; | 387 | return -ENXIO; |
415 | } | 388 | } |
416 | 389 | ||
@@ -418,7 +391,8 @@ static int scx200_acb_probe(struct scx200_acb_iface *iface) | |||
418 | 391 | ||
419 | val = inb(ACBCTL1); | 392 | val = inb(ACBCTL1); |
420 | if (val) { | 393 | if (val) { |
421 | DBG("disabled, but ACBCTL1=0x%02x\n", val); | 394 | pr_debug(NAME ": disabled, but ACBCTL1=0x%02x\n", |
395 | val); | ||
422 | return -ENXIO; | 396 | return -ENXIO; |
423 | } | 397 | } |
424 | 398 | ||
@@ -428,18 +402,19 @@ static int scx200_acb_probe(struct scx200_acb_iface *iface) | |||
428 | 402 | ||
429 | val = inb(ACBCTL1); | 403 | val = inb(ACBCTL1); |
430 | if ((val & ACBCTL1_NMINTE) != ACBCTL1_NMINTE) { | 404 | if ((val & ACBCTL1_NMINTE) != ACBCTL1_NMINTE) { |
431 | DBG("enabled, but NMINTE won't be set, ACBCTL1=0x%02x\n", val); | 405 | pr_debug(NAME ": enabled, but NMINTE won't be set, " |
406 | "ACBCTL1=0x%02x\n", val); | ||
432 | return -ENXIO; | 407 | return -ENXIO; |
433 | } | 408 | } |
434 | 409 | ||
435 | return 0; | 410 | return 0; |
436 | } | 411 | } |
437 | 412 | ||
438 | static int __init scx200_acb_create(int base, int index) | 413 | static int __init scx200_acb_create(const char *text, int base, int index) |
439 | { | 414 | { |
440 | struct scx200_acb_iface *iface; | 415 | struct scx200_acb_iface *iface; |
441 | struct i2c_adapter *adapter; | 416 | struct i2c_adapter *adapter; |
442 | int rc = 0; | 417 | int rc; |
443 | char description[64]; | 418 | char description[64]; |
444 | 419 | ||
445 | iface = kzalloc(sizeof(*iface), GFP_KERNEL); | 420 | iface = kzalloc(sizeof(*iface), GFP_KERNEL); |
@@ -451,50 +426,51 @@ static int __init scx200_acb_create(int base, int index) | |||
451 | 426 | ||
452 | adapter = &iface->adapter; | 427 | adapter = &iface->adapter; |
453 | i2c_set_adapdata(adapter, iface); | 428 | i2c_set_adapdata(adapter, iface); |
454 | snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index); | 429 | snprintf(adapter->name, I2C_NAME_SIZE, "%s ACB%d", text, index); |
455 | adapter->owner = THIS_MODULE; | 430 | adapter->owner = THIS_MODULE; |
456 | adapter->id = I2C_HW_SMBUS_SCX200; | 431 | adapter->id = I2C_HW_SMBUS_SCX200; |
457 | adapter->algo = &scx200_acb_algorithm; | 432 | adapter->algo = &scx200_acb_algorithm; |
458 | adapter->class = I2C_CLASS_HWMON; | 433 | adapter->class = I2C_CLASS_HWMON; |
459 | 434 | ||
460 | init_MUTEX(&iface->sem); | 435 | mutex_init(&iface->mutex); |
436 | |||
437 | snprintf(description, sizeof(description), "%s ACCESS.bus [%s]", | ||
438 | text, adapter->name); | ||
461 | 439 | ||
462 | snprintf(description, sizeof(description), "NatSemi SCx200 ACCESS.bus [%s]", adapter->name); | ||
463 | if (request_region(base, 8, description) == 0) { | 440 | if (request_region(base, 8, description) == 0) { |
464 | dev_err(&adapter->dev, "can't allocate io 0x%x-0x%x\n", | 441 | printk(KERN_ERR NAME ": can't allocate io 0x%x-0x%x\n", |
465 | base, base + 8-1); | 442 | base, base + 8-1); |
466 | rc = -EBUSY; | 443 | rc = -EBUSY; |
467 | goto errout; | 444 | goto errout_free; |
468 | } | 445 | } |
469 | iface->base = base; | 446 | iface->base = base; |
470 | 447 | ||
471 | rc = scx200_acb_probe(iface); | 448 | rc = scx200_acb_probe(iface); |
472 | if (rc) { | 449 | if (rc) { |
473 | dev_warn(&adapter->dev, "probe failed\n"); | 450 | printk(KERN_WARNING NAME ": probe failed\n"); |
474 | goto errout; | 451 | goto errout_release; |
475 | } | 452 | } |
476 | 453 | ||
477 | scx200_acb_reset(iface); | 454 | scx200_acb_reset(iface); |
478 | 455 | ||
479 | if (i2c_add_adapter(adapter) < 0) { | 456 | if (i2c_add_adapter(adapter) < 0) { |
480 | dev_err(&adapter->dev, "failed to register\n"); | 457 | printk(KERN_ERR NAME ": failed to register\n"); |
481 | rc = -ENODEV; | 458 | rc = -ENODEV; |
482 | goto errout; | 459 | goto errout_release; |
483 | } | 460 | } |
484 | 461 | ||
485 | lock_kernel(); | 462 | down(&scx200_acb_list_mutex); |
486 | iface->next = scx200_acb_list; | 463 | iface->next = scx200_acb_list; |
487 | scx200_acb_list = iface; | 464 | scx200_acb_list = iface; |
488 | unlock_kernel(); | 465 | up(&scx200_acb_list_mutex); |
489 | 466 | ||
490 | return 0; | 467 | return 0; |
491 | 468 | ||
469 | errout_release: | ||
470 | release_region(iface->base, 8); | ||
471 | errout_free: | ||
472 | kfree(iface); | ||
492 | errout: | 473 | errout: |
493 | if (iface) { | ||
494 | if (iface->base) | ||
495 | release_region(iface->base, 8); | ||
496 | kfree(iface); | ||
497 | } | ||
498 | return rc; | 474 | return rc; |
499 | } | 475 | } |
500 | 476 | ||
@@ -504,50 +480,69 @@ static struct pci_device_id scx200[] = { | |||
504 | { }, | 480 | { }, |
505 | }; | 481 | }; |
506 | 482 | ||
483 | static struct pci_device_id divil_pci[] = { | ||
484 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, | ||
485 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, | ||
486 | { } /* NULL entry */ | ||
487 | }; | ||
488 | |||
489 | #define MSR_LBAR_SMB 0x5140000B | ||
490 | |||
491 | static int scx200_add_cs553x(void) | ||
492 | { | ||
493 | u32 low, hi; | ||
494 | u32 smb_base; | ||
495 | |||
496 | /* Grab & reserve the SMB I/O range */ | ||
497 | rdmsr(MSR_LBAR_SMB, low, hi); | ||
498 | |||
499 | /* Check the IO mask and whether SMB is enabled */ | ||
500 | if (hi != 0x0000F001) { | ||
501 | printk(KERN_WARNING NAME ": SMBus not enabled\n"); | ||
502 | return -ENODEV; | ||
503 | } | ||
504 | |||
505 | /* SMBus IO size is 8 bytes */ | ||
506 | smb_base = low & 0x0000FFF8; | ||
507 | |||
508 | return scx200_acb_create("CS5535", smb_base, 0); | ||
509 | } | ||
510 | |||
507 | static int __init scx200_acb_init(void) | 511 | static int __init scx200_acb_init(void) |
508 | { | 512 | { |
509 | int i; | 513 | int i; |
510 | int rc; | 514 | int rc = -ENODEV; |
511 | 515 | ||
512 | pr_debug(NAME ": NatSemi SCx200 ACCESS.bus Driver\n"); | 516 | pr_debug(NAME ": NatSemi SCx200 ACCESS.bus Driver\n"); |
513 | 517 | ||
514 | /* Verify that this really is a SCx200 processor */ | 518 | /* Verify that this really is a SCx200 processor */ |
515 | if (pci_dev_present(scx200) == 0) | 519 | if (pci_dev_present(scx200)) { |
516 | return -ENODEV; | 520 | for (i = 0; i < MAX_DEVICES; ++i) { |
521 | if (base[i] > 0) | ||
522 | rc = scx200_acb_create("SCx200", base[i], i); | ||
523 | } | ||
524 | } else if (pci_dev_present(divil_pci)) | ||
525 | rc = scx200_add_cs553x(); | ||
517 | 526 | ||
518 | rc = -ENXIO; | ||
519 | for (i = 0; i < MAX_DEVICES; ++i) { | ||
520 | if (base[i] > 0) | ||
521 | rc = scx200_acb_create(base[i], i); | ||
522 | } | ||
523 | if (scx200_acb_list) | ||
524 | return 0; | ||
525 | return rc; | 527 | return rc; |
526 | } | 528 | } |
527 | 529 | ||
528 | static void __exit scx200_acb_cleanup(void) | 530 | static void __exit scx200_acb_cleanup(void) |
529 | { | 531 | { |
530 | struct scx200_acb_iface *iface; | 532 | struct scx200_acb_iface *iface; |
531 | lock_kernel(); | 533 | |
534 | down(&scx200_acb_list_mutex); | ||
532 | while ((iface = scx200_acb_list) != NULL) { | 535 | while ((iface = scx200_acb_list) != NULL) { |
533 | scx200_acb_list = iface->next; | 536 | scx200_acb_list = iface->next; |
534 | unlock_kernel(); | 537 | up(&scx200_acb_list_mutex); |
535 | 538 | ||
536 | i2c_del_adapter(&iface->adapter); | 539 | i2c_del_adapter(&iface->adapter); |
537 | release_region(iface->base, 8); | 540 | release_region(iface->base, 8); |
538 | kfree(iface); | 541 | kfree(iface); |
539 | lock_kernel(); | 542 | down(&scx200_acb_list_mutex); |
540 | } | 543 | } |
541 | unlock_kernel(); | 544 | up(&scx200_acb_list_mutex); |
542 | } | 545 | } |
543 | 546 | ||
544 | module_init(scx200_acb_init); | 547 | module_init(scx200_acb_init); |
545 | module_exit(scx200_acb_cleanup); | 548 | module_exit(scx200_acb_cleanup); |
546 | |||
547 | /* | ||
548 | Local variables: | ||
549 | compile-command: "make -k -C ../.. SUBDIRS=drivers/i2c modules" | ||
550 | c-basic-offset: 8 | ||
551 | End: | ||
552 | */ | ||
553 | |||
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index 0710b9da9d54..03d09ed5ec2c 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
27 | #include <linux/rtc.h> | 27 | #include <linux/rtc.h> |
28 | #include <linux/bcd.h> | 28 | #include <linux/bcd.h> |
29 | #include <linux/mutex.h> | ||
29 | 30 | ||
30 | #define DS1374_REG_TOD0 0x00 | 31 | #define DS1374_REG_TOD0 0x00 |
31 | #define DS1374_REG_TOD1 0x01 | 32 | #define DS1374_REG_TOD1 0x01 |
@@ -41,7 +42,7 @@ | |||
41 | 42 | ||
42 | #define DS1374_DRV_NAME "ds1374" | 43 | #define DS1374_DRV_NAME "ds1374" |
43 | 44 | ||
44 | static DECLARE_MUTEX(ds1374_mutex); | 45 | static DEFINE_MUTEX(ds1374_mutex); |
45 | 46 | ||
46 | static struct i2c_driver ds1374_driver; | 47 | static struct i2c_driver ds1374_driver; |
47 | static struct i2c_client *save_client; | 48 | static struct i2c_client *save_client; |
@@ -114,7 +115,7 @@ ulong ds1374_get_rtc_time(void) | |||
114 | ulong t1, t2; | 115 | ulong t1, t2; |
115 | int limit = 10; /* arbitrary retry limit */ | 116 | int limit = 10; /* arbitrary retry limit */ |
116 | 117 | ||
117 | down(&ds1374_mutex); | 118 | mutex_lock(&ds1374_mutex); |
118 | 119 | ||
119 | /* | 120 | /* |
120 | * Since the reads are being performed one byte at a time using | 121 | * Since the reads are being performed one byte at a time using |
@@ -127,7 +128,7 @@ ulong ds1374_get_rtc_time(void) | |||
127 | t2 = ds1374_read_rtc(); | 128 | t2 = ds1374_read_rtc(); |
128 | } while (t1 != t2 && limit--); | 129 | } while (t1 != t2 && limit--); |
129 | 130 | ||
130 | up(&ds1374_mutex); | 131 | mutex_unlock(&ds1374_mutex); |
131 | 132 | ||
132 | if (t1 != t2) { | 133 | if (t1 != t2) { |
133 | dev_warn(&save_client->dev, | 134 | dev_warn(&save_client->dev, |
@@ -145,7 +146,7 @@ static void ds1374_set_tlet(ulong arg) | |||
145 | 146 | ||
146 | t1 = *(ulong *) arg; | 147 | t1 = *(ulong *) arg; |
147 | 148 | ||
148 | down(&ds1374_mutex); | 149 | mutex_lock(&ds1374_mutex); |
149 | 150 | ||
150 | /* | 151 | /* |
151 | * Since the writes are being performed one byte at a time using | 152 | * Since the writes are being performed one byte at a time using |
@@ -158,7 +159,7 @@ static void ds1374_set_tlet(ulong arg) | |||
158 | t2 = ds1374_read_rtc(); | 159 | t2 = ds1374_read_rtc(); |
159 | } while (t1 != t2 && limit--); | 160 | } while (t1 != t2 && limit--); |
160 | 161 | ||
161 | up(&ds1374_mutex); | 162 | mutex_unlock(&ds1374_mutex); |
162 | 163 | ||
163 | if (t1 != t2) | 164 | if (t1 != t2) |
164 | dev_warn(&save_client->dev, | 165 | dev_warn(&save_client->dev, |
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index 41116b7947f6..13c108269a6d 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
34 | #include <linux/jiffies.h> | 34 | #include <linux/jiffies.h> |
35 | #include <linux/i2c.h> | 35 | #include <linux/i2c.h> |
36 | #include <linux/mutex.h> | ||
36 | 37 | ||
37 | /* Addresses to scan */ | 38 | /* Addresses to scan */ |
38 | static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54, | 39 | static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54, |
@@ -54,7 +55,7 @@ enum eeprom_nature { | |||
54 | /* Each client has this additional data */ | 55 | /* Each client has this additional data */ |
55 | struct eeprom_data { | 56 | struct eeprom_data { |
56 | struct i2c_client client; | 57 | struct i2c_client client; |
57 | struct semaphore update_lock; | 58 | struct mutex update_lock; |
58 | u8 valid; /* bitfield, bit!=0 if slice is valid */ | 59 | u8 valid; /* bitfield, bit!=0 if slice is valid */ |
59 | unsigned long last_updated[8]; /* In jiffies, 8 slices */ | 60 | unsigned long last_updated[8]; /* In jiffies, 8 slices */ |
60 | u8 data[EEPROM_SIZE]; /* Register values */ | 61 | u8 data[EEPROM_SIZE]; /* Register values */ |
@@ -81,7 +82,7 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice) | |||
81 | struct eeprom_data *data = i2c_get_clientdata(client); | 82 | struct eeprom_data *data = i2c_get_clientdata(client); |
82 | int i, j; | 83 | int i, j; |
83 | 84 | ||
84 | down(&data->update_lock); | 85 | mutex_lock(&data->update_lock); |
85 | 86 | ||
86 | if (!(data->valid & (1 << slice)) || | 87 | if (!(data->valid & (1 << slice)) || |
87 | time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { | 88 | time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { |
@@ -107,7 +108,7 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice) | |||
107 | data->valid |= (1 << slice); | 108 | data->valid |= (1 << slice); |
108 | } | 109 | } |
109 | exit: | 110 | exit: |
110 | up(&data->update_lock); | 111 | mutex_unlock(&data->update_lock); |
111 | } | 112 | } |
112 | 113 | ||
113 | static ssize_t eeprom_read(struct kobject *kobj, char *buf, loff_t off, size_t count) | 114 | static ssize_t eeprom_read(struct kobject *kobj, char *buf, loff_t off, size_t count) |
@@ -187,7 +188,7 @@ static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) | |||
187 | /* Fill in the remaining client fields */ | 188 | /* Fill in the remaining client fields */ |
188 | strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE); | 189 | strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE); |
189 | data->valid = 0; | 190 | data->valid = 0; |
190 | init_MUTEX(&data->update_lock); | 191 | mutex_init(&data->update_lock); |
191 | data->nature = UNKNOWN; | 192 | data->nature = UNKNOWN; |
192 | 193 | ||
193 | /* Tell the I2C layer a new client has arrived */ | 194 | /* Tell the I2C layer a new client has arrived */ |
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index 1251c7fc18d5..e6f1ab7b913c 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c | |||
@@ -1635,8 +1635,6 @@ static struct i2c_driver isp1301_driver = { | |||
1635 | .driver = { | 1635 | .driver = { |
1636 | .name = "isp1301_omap", | 1636 | .name = "isp1301_omap", |
1637 | }, | 1637 | }, |
1638 | .id = 1301, /* FIXME "official", i2c-ids.h */ | ||
1639 | .class = I2C_CLASS_HWMON, | ||
1640 | .attach_adapter = isp1301_scan_bus, | 1638 | .attach_adapter = isp1301_scan_bus, |
1641 | .detach_client = isp1301_detach_client, | 1639 | .detach_client = isp1301_detach_client, |
1642 | }; | 1640 | }; |
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index 2dc3d48375fc..b5aabe7cf792 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c | |||
@@ -24,13 +24,14 @@ | |||
24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <linux/rtc.h> | 25 | #include <linux/rtc.h> |
26 | #include <linux/bcd.h> | 26 | #include <linux/bcd.h> |
27 | #include <linux/mutex.h> | ||
27 | 28 | ||
28 | #include <asm/time.h> | 29 | #include <asm/time.h> |
29 | #include <asm/rtc.h> | 30 | #include <asm/rtc.h> |
30 | 31 | ||
31 | #define M41T00_DRV_NAME "m41t00" | 32 | #define M41T00_DRV_NAME "m41t00" |
32 | 33 | ||
33 | static DECLARE_MUTEX(m41t00_mutex); | 34 | static DEFINE_MUTEX(m41t00_mutex); |
34 | 35 | ||
35 | static struct i2c_driver m41t00_driver; | 36 | static struct i2c_driver m41t00_driver; |
36 | static struct i2c_client *save_client; | 37 | static struct i2c_client *save_client; |
@@ -54,7 +55,7 @@ m41t00_get_rtc_time(void) | |||
54 | sec = min = hour = day = mon = year = 0; | 55 | sec = min = hour = day = mon = year = 0; |
55 | sec1 = min1 = hour1 = day1 = mon1 = year1 = 0; | 56 | sec1 = min1 = hour1 = day1 = mon1 = year1 = 0; |
56 | 57 | ||
57 | down(&m41t00_mutex); | 58 | mutex_lock(&m41t00_mutex); |
58 | do { | 59 | do { |
59 | if (((sec = i2c_smbus_read_byte_data(save_client, 0)) >= 0) | 60 | if (((sec = i2c_smbus_read_byte_data(save_client, 0)) >= 0) |
60 | && ((min = i2c_smbus_read_byte_data(save_client, 1)) | 61 | && ((min = i2c_smbus_read_byte_data(save_client, 1)) |
@@ -80,7 +81,7 @@ m41t00_get_rtc_time(void) | |||
80 | mon1 = mon; | 81 | mon1 = mon; |
81 | year1 = year; | 82 | year1 = year; |
82 | } while (--limit > 0); | 83 | } while (--limit > 0); |
83 | up(&m41t00_mutex); | 84 | mutex_unlock(&m41t00_mutex); |
84 | 85 | ||
85 | if (limit == 0) { | 86 | if (limit == 0) { |
86 | dev_warn(&save_client->dev, | 87 | dev_warn(&save_client->dev, |
@@ -125,7 +126,7 @@ m41t00_set_tlet(ulong arg) | |||
125 | BIN_TO_BCD(tm.tm_mday); | 126 | BIN_TO_BCD(tm.tm_mday); |
126 | BIN_TO_BCD(tm.tm_year); | 127 | BIN_TO_BCD(tm.tm_year); |
127 | 128 | ||
128 | down(&m41t00_mutex); | 129 | mutex_lock(&m41t00_mutex); |
129 | if ((i2c_smbus_write_byte_data(save_client, 0, tm.tm_sec & 0x7f) < 0) | 130 | if ((i2c_smbus_write_byte_data(save_client, 0, tm.tm_sec & 0x7f) < 0) |
130 | || (i2c_smbus_write_byte_data(save_client, 1, tm.tm_min & 0x7f) | 131 | || (i2c_smbus_write_byte_data(save_client, 1, tm.tm_min & 0x7f) |
131 | < 0) | 132 | < 0) |
@@ -140,7 +141,7 @@ m41t00_set_tlet(ulong arg) | |||
140 | 141 | ||
141 | dev_warn(&save_client->dev,"m41t00: can't write to rtc chip\n"); | 142 | dev_warn(&save_client->dev,"m41t00: can't write to rtc chip\n"); |
142 | 143 | ||
143 | up(&m41t00_mutex); | 144 | mutex_unlock(&m41t00_mutex); |
144 | return; | 145 | return; |
145 | } | 146 | } |
146 | 147 | ||
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 6d3ff584155e..88d2ddee4490 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
34 | #include <asm/semaphore.h> | 34 | #include <linux/mutex.h> |
35 | 35 | ||
36 | /* Do not scan - the MAX6875 access method will write to some EEPROM chips */ | 36 | /* Do not scan - the MAX6875 access method will write to some EEPROM chips */ |
37 | static unsigned short normal_i2c[] = {I2C_CLIENT_END}; | 37 | static unsigned short normal_i2c[] = {I2C_CLIENT_END}; |
@@ -54,7 +54,7 @@ I2C_CLIENT_INSMOD_1(max6875); | |||
54 | /* Each client has this additional data */ | 54 | /* Each client has this additional data */ |
55 | struct max6875_data { | 55 | struct max6875_data { |
56 | struct i2c_client client; | 56 | struct i2c_client client; |
57 | struct semaphore update_lock; | 57 | struct mutex update_lock; |
58 | 58 | ||
59 | u32 valid; | 59 | u32 valid; |
60 | u8 data[USER_EEPROM_SIZE]; | 60 | u8 data[USER_EEPROM_SIZE]; |
@@ -83,7 +83,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice) | |||
83 | if (slice >= USER_EEPROM_SLICES) | 83 | if (slice >= USER_EEPROM_SLICES) |
84 | return; | 84 | return; |
85 | 85 | ||
86 | down(&data->update_lock); | 86 | mutex_lock(&data->update_lock); |
87 | 87 | ||
88 | buf = &data->data[slice << SLICE_BITS]; | 88 | buf = &data->data[slice << SLICE_BITS]; |
89 | 89 | ||
@@ -122,7 +122,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice) | |||
122 | data->valid |= (1 << slice); | 122 | data->valid |= (1 << slice); |
123 | } | 123 | } |
124 | exit_up: | 124 | exit_up: |
125 | up(&data->update_lock); | 125 | mutex_unlock(&data->update_lock); |
126 | } | 126 | } |
127 | 127 | ||
128 | static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, | 128 | static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, |
@@ -196,7 +196,7 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) | |||
196 | real_client->driver = &max6875_driver; | 196 | real_client->driver = &max6875_driver; |
197 | real_client->flags = 0; | 197 | real_client->flags = 0; |
198 | strlcpy(real_client->name, "max6875", I2C_NAME_SIZE); | 198 | strlcpy(real_client->name, "max6875", I2C_NAME_SIZE); |
199 | init_MUTEX(&data->update_lock); | 199 | mutex_init(&data->update_lock); |
200 | 200 | ||
201 | /* Init fake client data */ | 201 | /* Init fake client data */ |
202 | /* set the client data to the i2c_client so that it will get freed */ | 202 | /* set the client data to the i2c_client so that it will get freed */ |
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c index 36cff09c678d..925a6b371fd2 100644 --- a/drivers/i2c/chips/pcf8591.c +++ b/drivers/i2c/chips/pcf8591.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
27 | #include <linux/mutex.h> | ||
27 | 28 | ||
28 | /* Addresses to scan */ | 29 | /* Addresses to scan */ |
29 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, | 30 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, |
@@ -74,7 +75,7 @@ MODULE_PARM_DESC(input_mode, | |||
74 | 75 | ||
75 | struct pcf8591_data { | 76 | struct pcf8591_data { |
76 | struct i2c_client client; | 77 | struct i2c_client client; |
77 | struct semaphore update_lock; | 78 | struct mutex update_lock; |
78 | 79 | ||
79 | u8 control; | 80 | u8 control; |
80 | u8 aout; | 81 | u8 aout; |
@@ -144,13 +145,13 @@ static ssize_t set_out0_enable(struct device *dev, struct device_attribute *attr | |||
144 | struct pcf8591_data *data = i2c_get_clientdata(client); | 145 | struct pcf8591_data *data = i2c_get_clientdata(client); |
145 | unsigned long val = simple_strtoul(buf, NULL, 10); | 146 | unsigned long val = simple_strtoul(buf, NULL, 10); |
146 | 147 | ||
147 | down(&data->update_lock); | 148 | mutex_lock(&data->update_lock); |
148 | if (val) | 149 | if (val) |
149 | data->control |= PCF8591_CONTROL_AOEF; | 150 | data->control |= PCF8591_CONTROL_AOEF; |
150 | else | 151 | else |
151 | data->control &= ~PCF8591_CONTROL_AOEF; | 152 | data->control &= ~PCF8591_CONTROL_AOEF; |
152 | i2c_smbus_write_byte(client, data->control); | 153 | i2c_smbus_write_byte(client, data->control); |
153 | up(&data->update_lock); | 154 | mutex_unlock(&data->update_lock); |
154 | return count; | 155 | return count; |
155 | } | 156 | } |
156 | 157 | ||
@@ -200,7 +201,7 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) | |||
200 | /* Fill in the remaining client fields and put it into the global | 201 | /* Fill in the remaining client fields and put it into the global |
201 | list */ | 202 | list */ |
202 | strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE); | 203 | strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE); |
203 | init_MUTEX(&data->update_lock); | 204 | mutex_init(&data->update_lock); |
204 | 205 | ||
205 | /* Tell the I2C layer a new client has arrived */ | 206 | /* Tell the I2C layer a new client has arrived */ |
206 | if ((err = i2c_attach_client(new_client))) | 207 | if ((err = i2c_attach_client(new_client))) |
@@ -265,7 +266,7 @@ static int pcf8591_read_channel(struct device *dev, int channel) | |||
265 | struct i2c_client *client = to_i2c_client(dev); | 266 | struct i2c_client *client = to_i2c_client(dev); |
266 | struct pcf8591_data *data = i2c_get_clientdata(client); | 267 | struct pcf8591_data *data = i2c_get_clientdata(client); |
267 | 268 | ||
268 | down(&data->update_lock); | 269 | mutex_lock(&data->update_lock); |
269 | 270 | ||
270 | if ((data->control & PCF8591_CONTROL_AICH_MASK) != channel) { | 271 | if ((data->control & PCF8591_CONTROL_AICH_MASK) != channel) { |
271 | data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK) | 272 | data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK) |
@@ -278,7 +279,7 @@ static int pcf8591_read_channel(struct device *dev, int channel) | |||
278 | } | 279 | } |
279 | value = i2c_smbus_read_byte(client); | 280 | value = i2c_smbus_read_byte(client); |
280 | 281 | ||
281 | up(&data->update_lock); | 282 | mutex_unlock(&data->update_lock); |
282 | 283 | ||
283 | if ((channel == 2 && input_mode == 2) || | 284 | if ((channel == 2 && input_mode == 2) || |
284 | (channel != 3 && (input_mode == 1 || input_mode == 3))) | 285 | (channel != 3 && (input_mode == 1 || input_mode == 3))) |
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c index 1af3dfbb8086..179b1e022d80 100644 --- a/drivers/i2c/chips/tps65010.c +++ b/drivers/i2c/chips/tps65010.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/suspend.h> | 32 | #include <linux/suspend.h> |
33 | #include <linux/debugfs.h> | 33 | #include <linux/debugfs.h> |
34 | #include <linux/seq_file.h> | 34 | #include <linux/seq_file.h> |
35 | #include <linux/mutex.h> | ||
35 | 36 | ||
36 | #include <asm/irq.h> | 37 | #include <asm/irq.h> |
37 | #include <asm/mach-types.h> | 38 | #include <asm/mach-types.h> |
@@ -81,7 +82,7 @@ enum tps_model { | |||
81 | 82 | ||
82 | struct tps65010 { | 83 | struct tps65010 { |
83 | struct i2c_client client; | 84 | struct i2c_client client; |
84 | struct semaphore lock; | 85 | struct mutex lock; |
85 | int irq; | 86 | int irq; |
86 | struct work_struct work; | 87 | struct work_struct work; |
87 | struct dentry *file; | 88 | struct dentry *file; |
@@ -218,7 +219,7 @@ static int dbg_show(struct seq_file *s, void *_) | |||
218 | seq_printf(s, "driver %s\nversion %s\nchip %s\n\n", | 219 | seq_printf(s, "driver %s\nversion %s\nchip %s\n\n", |
219 | DRIVER_NAME, DRIVER_VERSION, chip); | 220 | DRIVER_NAME, DRIVER_VERSION, chip); |
220 | 221 | ||
221 | down(&tps->lock); | 222 | mutex_lock(&tps->lock); |
222 | 223 | ||
223 | /* FIXME how can we tell whether a battery is present? | 224 | /* FIXME how can we tell whether a battery is present? |
224 | * likely involves a charge gauging chip (like BQ26501). | 225 | * likely involves a charge gauging chip (like BQ26501). |
@@ -300,7 +301,7 @@ static int dbg_show(struct seq_file *s, void *_) | |||
300 | (v2 & (1 << (4 + i))) ? "rising" : "falling"); | 301 | (v2 & (1 << (4 + i))) ? "rising" : "falling"); |
301 | } | 302 | } |
302 | 303 | ||
303 | up(&tps->lock); | 304 | mutex_unlock(&tps->lock); |
304 | return 0; | 305 | return 0; |
305 | } | 306 | } |
306 | 307 | ||
@@ -416,7 +417,7 @@ static void tps65010_work(void *_tps) | |||
416 | { | 417 | { |
417 | struct tps65010 *tps = _tps; | 418 | struct tps65010 *tps = _tps; |
418 | 419 | ||
419 | down(&tps->lock); | 420 | mutex_lock(&tps->lock); |
420 | 421 | ||
421 | tps65010_interrupt(tps); | 422 | tps65010_interrupt(tps); |
422 | 423 | ||
@@ -444,7 +445,7 @@ static void tps65010_work(void *_tps) | |||
444 | if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags)) | 445 | if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags)) |
445 | enable_irq(tps->irq); | 446 | enable_irq(tps->irq); |
446 | 447 | ||
447 | up(&tps->lock); | 448 | mutex_unlock(&tps->lock); |
448 | } | 449 | } |
449 | 450 | ||
450 | static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs) | 451 | static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs) |
@@ -505,7 +506,7 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind) | |||
505 | if (!tps) | 506 | if (!tps) |
506 | return 0; | 507 | return 0; |
507 | 508 | ||
508 | init_MUTEX(&tps->lock); | 509 | mutex_init(&tps->lock); |
509 | INIT_WORK(&tps->work, tps65010_work, tps); | 510 | INIT_WORK(&tps->work, tps65010_work, tps); |
510 | tps->irq = -1; | 511 | tps->irq = -1; |
511 | tps->client.addr = address; | 512 | tps->client.addr = address; |
@@ -695,7 +696,7 @@ int tps65010_set_gpio_out_value(unsigned gpio, unsigned value) | |||
695 | if ((gpio < GPIO1) || (gpio > GPIO4)) | 696 | if ((gpio < GPIO1) || (gpio > GPIO4)) |
696 | return -EINVAL; | 697 | return -EINVAL; |
697 | 698 | ||
698 | down(&the_tps->lock); | 699 | mutex_lock(&the_tps->lock); |
699 | 700 | ||
700 | defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO); | 701 | defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO); |
701 | 702 | ||
@@ -720,7 +721,7 @@ int tps65010_set_gpio_out_value(unsigned gpio, unsigned value) | |||
720 | gpio, value ? "high" : "low", | 721 | gpio, value ? "high" : "low", |
721 | i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO)); | 722 | i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO)); |
722 | 723 | ||
723 | up(&the_tps->lock); | 724 | mutex_unlock(&the_tps->lock); |
724 | return status; | 725 | return status; |
725 | } | 726 | } |
726 | EXPORT_SYMBOL(tps65010_set_gpio_out_value); | 727 | EXPORT_SYMBOL(tps65010_set_gpio_out_value); |
@@ -745,7 +746,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
745 | led = LED2; | 746 | led = LED2; |
746 | } | 747 | } |
747 | 748 | ||
748 | down(&the_tps->lock); | 749 | mutex_lock(&the_tps->lock); |
749 | 750 | ||
750 | pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led, | 751 | pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led, |
751 | i2c_smbus_read_byte_data(&the_tps->client, | 752 | i2c_smbus_read_byte_data(&the_tps->client, |
@@ -771,7 +772,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
771 | default: | 772 | default: |
772 | printk(KERN_ERR "%s: Wrong mode parameter for set_led()\n", | 773 | printk(KERN_ERR "%s: Wrong mode parameter for set_led()\n", |
773 | DRIVER_NAME); | 774 | DRIVER_NAME); |
774 | up(&the_tps->lock); | 775 | mutex_unlock(&the_tps->lock); |
775 | return -EINVAL; | 776 | return -EINVAL; |
776 | } | 777 | } |
777 | 778 | ||
@@ -781,7 +782,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
781 | if (status != 0) { | 782 | if (status != 0) { |
782 | printk(KERN_ERR "%s: Failed to write led%i_on register\n", | 783 | printk(KERN_ERR "%s: Failed to write led%i_on register\n", |
783 | DRIVER_NAME, led); | 784 | DRIVER_NAME, led); |
784 | up(&the_tps->lock); | 785 | mutex_unlock(&the_tps->lock); |
785 | return status; | 786 | return status; |
786 | } | 787 | } |
787 | 788 | ||
@@ -794,7 +795,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
794 | if (status != 0) { | 795 | if (status != 0) { |
795 | printk(KERN_ERR "%s: Failed to write led%i_per register\n", | 796 | printk(KERN_ERR "%s: Failed to write led%i_per register\n", |
796 | DRIVER_NAME, led); | 797 | DRIVER_NAME, led); |
797 | up(&the_tps->lock); | 798 | mutex_unlock(&the_tps->lock); |
798 | return status; | 799 | return status; |
799 | } | 800 | } |
800 | 801 | ||
@@ -802,7 +803,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
802 | i2c_smbus_read_byte_data(&the_tps->client, | 803 | i2c_smbus_read_byte_data(&the_tps->client, |
803 | TPS_LED1_PER + offs)); | 804 | TPS_LED1_PER + offs)); |
804 | 805 | ||
805 | up(&the_tps->lock); | 806 | mutex_unlock(&the_tps->lock); |
806 | 807 | ||
807 | return status; | 808 | return status; |
808 | } | 809 | } |
@@ -820,7 +821,7 @@ int tps65010_set_vib(unsigned value) | |||
820 | if (!the_tps) | 821 | if (!the_tps) |
821 | return -ENODEV; | 822 | return -ENODEV; |
822 | 823 | ||
823 | down(&the_tps->lock); | 824 | mutex_lock(&the_tps->lock); |
824 | 825 | ||
825 | vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2); | 826 | vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2); |
826 | vdcdc2 &= ~(1 << 1); | 827 | vdcdc2 &= ~(1 << 1); |
@@ -831,7 +832,7 @@ int tps65010_set_vib(unsigned value) | |||
831 | 832 | ||
832 | pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off"); | 833 | pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off"); |
833 | 834 | ||
834 | up(&the_tps->lock); | 835 | mutex_unlock(&the_tps->lock); |
835 | return status; | 836 | return status; |
836 | } | 837 | } |
837 | EXPORT_SYMBOL(tps65010_set_vib); | 838 | EXPORT_SYMBOL(tps65010_set_vib); |
@@ -848,7 +849,7 @@ int tps65010_set_low_pwr(unsigned mode) | |||
848 | if (!the_tps) | 849 | if (!the_tps) |
849 | return -ENODEV; | 850 | return -ENODEV; |
850 | 851 | ||
851 | down(&the_tps->lock); | 852 | mutex_lock(&the_tps->lock); |
852 | 853 | ||
853 | pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME, | 854 | pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME, |
854 | mode ? "enable" : "disable", | 855 | mode ? "enable" : "disable", |
@@ -876,7 +877,7 @@ int tps65010_set_low_pwr(unsigned mode) | |||
876 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, | 877 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, |
877 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | 878 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); |
878 | 879 | ||
879 | up(&the_tps->lock); | 880 | mutex_unlock(&the_tps->lock); |
880 | 881 | ||
881 | return status; | 882 | return status; |
882 | } | 883 | } |
@@ -894,7 +895,7 @@ int tps65010_config_vregs1(unsigned value) | |||
894 | if (!the_tps) | 895 | if (!the_tps) |
895 | return -ENODEV; | 896 | return -ENODEV; |
896 | 897 | ||
897 | down(&the_tps->lock); | 898 | mutex_lock(&the_tps->lock); |
898 | 899 | ||
899 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, | 900 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, |
900 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); | 901 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); |
@@ -909,7 +910,7 @@ int tps65010_config_vregs1(unsigned value) | |||
909 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, | 910 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, |
910 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); | 911 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); |
911 | 912 | ||
912 | up(&the_tps->lock); | 913 | mutex_unlock(&the_tps->lock); |
913 | 914 | ||
914 | return status; | 915 | return status; |
915 | } | 916 | } |
@@ -931,7 +932,7 @@ int tps65013_set_low_pwr(unsigned mode) | |||
931 | if (!the_tps || the_tps->por) | 932 | if (!the_tps || the_tps->por) |
932 | return -ENODEV; | 933 | return -ENODEV; |
933 | 934 | ||
934 | down(&the_tps->lock); | 935 | mutex_lock(&the_tps->lock); |
935 | 936 | ||
936 | pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n", | 937 | pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n", |
937 | DRIVER_NAME, | 938 | DRIVER_NAME, |
@@ -959,7 +960,7 @@ int tps65013_set_low_pwr(unsigned mode) | |||
959 | if (status != 0) { | 960 | if (status != 0) { |
960 | printk(KERN_ERR "%s: Failed to write chconfig register\n", | 961 | printk(KERN_ERR "%s: Failed to write chconfig register\n", |
961 | DRIVER_NAME); | 962 | DRIVER_NAME); |
962 | up(&the_tps->lock); | 963 | mutex_unlock(&the_tps->lock); |
963 | return status; | 964 | return status; |
964 | } | 965 | } |
965 | 966 | ||
@@ -977,7 +978,7 @@ int tps65013_set_low_pwr(unsigned mode) | |||
977 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, | 978 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, |
978 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | 979 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); |
979 | 980 | ||
980 | up(&the_tps->lock); | 981 | mutex_unlock(&the_tps->lock); |
981 | 982 | ||
982 | return status; | 983 | return status; |
983 | } | 984 | } |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 1a2c9ab5d9e3..45e2cdf54736 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -31,12 +31,13 @@ | |||
31 | #include <linux/idr.h> | 31 | #include <linux/idr.h> |
32 | #include <linux/seq_file.h> | 32 | #include <linux/seq_file.h> |
33 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
34 | #include <linux/mutex.h> | ||
34 | #include <asm/uaccess.h> | 35 | #include <asm/uaccess.h> |
35 | 36 | ||
36 | 37 | ||
37 | static LIST_HEAD(adapters); | 38 | static LIST_HEAD(adapters); |
38 | static LIST_HEAD(drivers); | 39 | static LIST_HEAD(drivers); |
39 | static DECLARE_MUTEX(core_lists); | 40 | static DEFINE_MUTEX(core_lists); |
40 | static DEFINE_IDR(i2c_adapter_idr); | 41 | static DEFINE_IDR(i2c_adapter_idr); |
41 | 42 | ||
42 | /* match always succeeds, as we want the probe() to tell if we really accept this match */ | 43 | /* match always succeeds, as we want the probe() to tell if we really accept this match */ |
@@ -153,7 +154,7 @@ int i2c_add_adapter(struct i2c_adapter *adap) | |||
153 | struct list_head *item; | 154 | struct list_head *item; |
154 | struct i2c_driver *driver; | 155 | struct i2c_driver *driver; |
155 | 156 | ||
156 | down(&core_lists); | 157 | mutex_lock(&core_lists); |
157 | 158 | ||
158 | if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) { | 159 | if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) { |
159 | res = -ENOMEM; | 160 | res = -ENOMEM; |
@@ -168,8 +169,8 @@ int i2c_add_adapter(struct i2c_adapter *adap) | |||
168 | } | 169 | } |
169 | 170 | ||
170 | adap->nr = id & MAX_ID_MASK; | 171 | adap->nr = id & MAX_ID_MASK; |
171 | init_MUTEX(&adap->bus_lock); | 172 | mutex_init(&adap->bus_lock); |
172 | init_MUTEX(&adap->clist_lock); | 173 | mutex_init(&adap->clist_lock); |
173 | list_add_tail(&adap->list,&adapters); | 174 | list_add_tail(&adap->list,&adapters); |
174 | INIT_LIST_HEAD(&adap->clients); | 175 | INIT_LIST_HEAD(&adap->clients); |
175 | 176 | ||
@@ -203,7 +204,7 @@ int i2c_add_adapter(struct i2c_adapter *adap) | |||
203 | } | 204 | } |
204 | 205 | ||
205 | out_unlock: | 206 | out_unlock: |
206 | up(&core_lists); | 207 | mutex_unlock(&core_lists); |
207 | return res; | 208 | return res; |
208 | } | 209 | } |
209 | 210 | ||
@@ -216,7 +217,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
216 | struct i2c_client *client; | 217 | struct i2c_client *client; |
217 | int res = 0; | 218 | int res = 0; |
218 | 219 | ||
219 | down(&core_lists); | 220 | mutex_lock(&core_lists); |
220 | 221 | ||
221 | /* First make sure that this adapter was ever added */ | 222 | /* First make sure that this adapter was ever added */ |
222 | list_for_each_entry(adap_from_list, &adapters, list) { | 223 | list_for_each_entry(adap_from_list, &adapters, list) { |
@@ -272,7 +273,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
272 | dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); | 273 | dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); |
273 | 274 | ||
274 | out_unlock: | 275 | out_unlock: |
275 | up(&core_lists); | 276 | mutex_unlock(&core_lists); |
276 | return res; | 277 | return res; |
277 | } | 278 | } |
278 | 279 | ||
@@ -287,9 +288,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) | |||
287 | { | 288 | { |
288 | struct list_head *item; | 289 | struct list_head *item; |
289 | struct i2c_adapter *adapter; | 290 | struct i2c_adapter *adapter; |
290 | int res = 0; | 291 | int res; |
291 | |||
292 | down(&core_lists); | ||
293 | 292 | ||
294 | /* add the driver to the list of i2c drivers in the driver core */ | 293 | /* add the driver to the list of i2c drivers in the driver core */ |
295 | driver->driver.owner = owner; | 294 | driver->driver.owner = owner; |
@@ -297,8 +296,10 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) | |||
297 | 296 | ||
298 | res = driver_register(&driver->driver); | 297 | res = driver_register(&driver->driver); |
299 | if (res) | 298 | if (res) |
300 | goto out_unlock; | 299 | return res; |
301 | 300 | ||
301 | mutex_lock(&core_lists); | ||
302 | |||
302 | list_add_tail(&driver->list,&drivers); | 303 | list_add_tail(&driver->list,&drivers); |
303 | pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name); | 304 | pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name); |
304 | 305 | ||
@@ -310,9 +311,8 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) | |||
310 | } | 311 | } |
311 | } | 312 | } |
312 | 313 | ||
313 | out_unlock: | 314 | mutex_unlock(&core_lists); |
314 | up(&core_lists); | 315 | return 0; |
315 | return res; | ||
316 | } | 316 | } |
317 | EXPORT_SYMBOL(i2c_register_driver); | 317 | EXPORT_SYMBOL(i2c_register_driver); |
318 | 318 | ||
@@ -324,7 +324,7 @@ int i2c_del_driver(struct i2c_driver *driver) | |||
324 | 324 | ||
325 | int res = 0; | 325 | int res = 0; |
326 | 326 | ||
327 | down(&core_lists); | 327 | mutex_lock(&core_lists); |
328 | 328 | ||
329 | /* Have a look at each adapter, if clients of this driver are still | 329 | /* Have a look at each adapter, if clients of this driver are still |
330 | * attached. If so, detach them to be able to kill the driver | 330 | * attached. If so, detach them to be able to kill the driver |
@@ -363,7 +363,7 @@ int i2c_del_driver(struct i2c_driver *driver) | |||
363 | pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); | 363 | pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); |
364 | 364 | ||
365 | out_unlock: | 365 | out_unlock: |
366 | up(&core_lists); | 366 | mutex_unlock(&core_lists); |
367 | return 0; | 367 | return 0; |
368 | } | 368 | } |
369 | 369 | ||
@@ -384,9 +384,9 @@ int i2c_check_addr(struct i2c_adapter *adapter, int addr) | |||
384 | { | 384 | { |
385 | int rval; | 385 | int rval; |
386 | 386 | ||
387 | down(&adapter->clist_lock); | 387 | mutex_lock(&adapter->clist_lock); |
388 | rval = __i2c_check_addr(adapter, addr); | 388 | rval = __i2c_check_addr(adapter, addr); |
389 | up(&adapter->clist_lock); | 389 | mutex_unlock(&adapter->clist_lock); |
390 | 390 | ||
391 | return rval; | 391 | return rval; |
392 | } | 392 | } |
@@ -395,13 +395,13 @@ int i2c_attach_client(struct i2c_client *client) | |||
395 | { | 395 | { |
396 | struct i2c_adapter *adapter = client->adapter; | 396 | struct i2c_adapter *adapter = client->adapter; |
397 | 397 | ||
398 | down(&adapter->clist_lock); | 398 | mutex_lock(&adapter->clist_lock); |
399 | if (__i2c_check_addr(client->adapter, client->addr)) { | 399 | if (__i2c_check_addr(client->adapter, client->addr)) { |
400 | up(&adapter->clist_lock); | 400 | mutex_unlock(&adapter->clist_lock); |
401 | return -EBUSY; | 401 | return -EBUSY; |
402 | } | 402 | } |
403 | list_add_tail(&client->list,&adapter->clients); | 403 | list_add_tail(&client->list,&adapter->clients); |
404 | up(&adapter->clist_lock); | 404 | mutex_unlock(&adapter->clist_lock); |
405 | 405 | ||
406 | if (adapter->client_register) { | 406 | if (adapter->client_register) { |
407 | if (adapter->client_register(client)) { | 407 | if (adapter->client_register(client)) { |
@@ -450,12 +450,12 @@ int i2c_detach_client(struct i2c_client *client) | |||
450 | } | 450 | } |
451 | } | 451 | } |
452 | 452 | ||
453 | down(&adapter->clist_lock); | 453 | mutex_lock(&adapter->clist_lock); |
454 | list_del(&client->list); | 454 | list_del(&client->list); |
455 | init_completion(&client->released); | 455 | init_completion(&client->released); |
456 | device_remove_file(&client->dev, &dev_attr_client_name); | 456 | device_remove_file(&client->dev, &dev_attr_client_name); |
457 | device_unregister(&client->dev); | 457 | device_unregister(&client->dev); |
458 | up(&adapter->clist_lock); | 458 | mutex_unlock(&adapter->clist_lock); |
459 | wait_for_completion(&client->released); | 459 | wait_for_completion(&client->released); |
460 | 460 | ||
461 | out: | 461 | out: |
@@ -513,19 +513,19 @@ void i2c_clients_command(struct i2c_adapter *adap, unsigned int cmd, void *arg) | |||
513 | struct list_head *item; | 513 | struct list_head *item; |
514 | struct i2c_client *client; | 514 | struct i2c_client *client; |
515 | 515 | ||
516 | down(&adap->clist_lock); | 516 | mutex_lock(&adap->clist_lock); |
517 | list_for_each(item,&adap->clients) { | 517 | list_for_each(item,&adap->clients) { |
518 | client = list_entry(item, struct i2c_client, list); | 518 | client = list_entry(item, struct i2c_client, list); |
519 | if (!try_module_get(client->driver->driver.owner)) | 519 | if (!try_module_get(client->driver->driver.owner)) |
520 | continue; | 520 | continue; |
521 | if (NULL != client->driver->command) { | 521 | if (NULL != client->driver->command) { |
522 | up(&adap->clist_lock); | 522 | mutex_unlock(&adap->clist_lock); |
523 | client->driver->command(client,cmd,arg); | 523 | client->driver->command(client,cmd,arg); |
524 | down(&adap->clist_lock); | 524 | mutex_lock(&adap->clist_lock); |
525 | } | 525 | } |
526 | module_put(client->driver->driver.owner); | 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 | static int __init i2c_init(void) | 531 | static int __init i2c_init(void) |
@@ -569,9 +569,9 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num) | |||
569 | } | 569 | } |
570 | #endif | 570 | #endif |
571 | 571 | ||
572 | down(&adap->bus_lock); | 572 | mutex_lock(&adap->bus_lock); |
573 | ret = adap->algo->master_xfer(adap,msgs,num); | 573 | ret = adap->algo->master_xfer(adap,msgs,num); |
574 | up(&adap->bus_lock); | 574 | mutex_unlock(&adap->bus_lock); |
575 | 575 | ||
576 | return ret; | 576 | return ret; |
577 | } else { | 577 | } else { |
@@ -779,12 +779,12 @@ struct i2c_adapter* i2c_get_adapter(int id) | |||
779 | { | 779 | { |
780 | struct i2c_adapter *adapter; | 780 | struct i2c_adapter *adapter; |
781 | 781 | ||
782 | down(&core_lists); | 782 | mutex_lock(&core_lists); |
783 | adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); | 783 | adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); |
784 | if (adapter && !try_module_get(adapter->owner)) | 784 | if (adapter && !try_module_get(adapter->owner)) |
785 | adapter = NULL; | 785 | adapter = NULL; |
786 | 786 | ||
787 | up(&core_lists); | 787 | mutex_unlock(&core_lists); |
788 | return adapter; | 788 | return adapter; |
789 | } | 789 | } |
790 | 790 | ||
@@ -919,12 +919,11 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, | |||
919 | u8 length, u8 *values) | 919 | u8 length, u8 *values) |
920 | { | 920 | { |
921 | union i2c_smbus_data data; | 921 | union i2c_smbus_data data; |
922 | int i; | 922 | |
923 | if (length > I2C_SMBUS_BLOCK_MAX) | 923 | if (length > I2C_SMBUS_BLOCK_MAX) |
924 | length = I2C_SMBUS_BLOCK_MAX; | 924 | length = I2C_SMBUS_BLOCK_MAX; |
925 | for (i = 1; i <= length; i++) | ||
926 | data.block[i] = values[i-1]; | ||
927 | data.block[0] = length; | 925 | data.block[0] = length; |
926 | memcpy(&data.block[1], values, length); | ||
928 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 927 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, |
929 | I2C_SMBUS_WRITE,command, | 928 | I2C_SMBUS_WRITE,command, |
930 | I2C_SMBUS_BLOCK_DATA,&data); | 929 | I2C_SMBUS_BLOCK_DATA,&data); |
@@ -934,16 +933,14 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, | |||
934 | s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values) | 933 | s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values) |
935 | { | 934 | { |
936 | union i2c_smbus_data data; | 935 | union i2c_smbus_data data; |
937 | int i; | 936 | |
938 | if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 937 | if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, |
939 | I2C_SMBUS_READ,command, | 938 | I2C_SMBUS_READ,command, |
940 | I2C_SMBUS_I2C_BLOCK_DATA,&data)) | 939 | I2C_SMBUS_I2C_BLOCK_DATA,&data)) |
941 | return -1; | 940 | return -1; |
942 | else { | 941 | |
943 | for (i = 1; i <= data.block[0]; i++) | 942 | memcpy(values, &data.block[1], data.block[0]); |
944 | values[i-1] = data.block[i]; | 943 | return data.block[0]; |
945 | return data.block[0]; | ||
946 | } | ||
947 | } | 944 | } |
948 | 945 | ||
949 | s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command, | 946 | s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command, |
@@ -1118,10 +1115,10 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, | |||
1118 | flags &= I2C_M_TEN | I2C_CLIENT_PEC; | 1115 | flags &= I2C_M_TEN | I2C_CLIENT_PEC; |
1119 | 1116 | ||
1120 | if (adapter->algo->smbus_xfer) { | 1117 | if (adapter->algo->smbus_xfer) { |
1121 | down(&adapter->bus_lock); | 1118 | mutex_lock(&adapter->bus_lock); |
1122 | res = adapter->algo->smbus_xfer(adapter,addr,flags,read_write, | 1119 | res = adapter->algo->smbus_xfer(adapter,addr,flags,read_write, |
1123 | command,size,data); | 1120 | command,size,data); |
1124 | up(&adapter->bus_lock); | 1121 | mutex_unlock(&adapter->bus_lock); |
1125 | } else | 1122 | } else |
1126 | res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, | 1123 | res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, |
1127 | command,size,data); | 1124 | command,size,data); |
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index 4ce07ae62dac..6e2004cdec1f 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c | |||
@@ -53,7 +53,6 @@ MODULE_AUTHOR("Maxim Yevtyushkin"); | |||
53 | MODULE_LICENSE("GPL"); | 53 | MODULE_LICENSE("GPL"); |
54 | 54 | ||
55 | #include <linux/i2c.h> | 55 | #include <linux/i2c.h> |
56 | #include <linux/i2c-dev.h> | ||
57 | 56 | ||
58 | #define I2C_NAME(x) (x)->name | 57 | #define I2C_NAME(x) (x)->name |
59 | 58 | ||
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index 4e218f22b214..6b17247adf87 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c | |||
@@ -49,7 +49,6 @@ MODULE_AUTHOR("Dave Perks"); | |||
49 | MODULE_LICENSE("GPL"); | 49 | MODULE_LICENSE("GPL"); |
50 | 50 | ||
51 | #include <linux/i2c.h> | 51 | #include <linux/i2c.h> |
52 | #include <linux/i2c-dev.h> | ||
53 | 52 | ||
54 | #define I2C_NAME(s) (s)->name | 53 | #define I2C_NAME(s) (s)->name |
55 | 54 | ||
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c index d6447791d0e5..2bf63e7ab4e6 100644 --- a/drivers/media/video/bt819.c +++ b/drivers/media/video/bt819.c | |||
@@ -53,7 +53,6 @@ MODULE_AUTHOR("Mike Bernson & Dave Perks"); | |||
53 | MODULE_LICENSE("GPL"); | 53 | MODULE_LICENSE("GPL"); |
54 | 54 | ||
55 | #include <linux/i2c.h> | 55 | #include <linux/i2c.h> |
56 | #include <linux/i2c-dev.h> | ||
57 | 56 | ||
58 | #define I2C_NAME(s) (s)->name | 57 | #define I2C_NAME(s) (s)->name |
59 | 58 | ||
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c index 909b593530ed..da3be00ae2fb 100644 --- a/drivers/media/video/bt856.c +++ b/drivers/media/video/bt856.c | |||
@@ -53,7 +53,6 @@ MODULE_AUTHOR("Mike Bernson & Dave Perks"); | |||
53 | MODULE_LICENSE("GPL"); | 53 | MODULE_LICENSE("GPL"); |
54 | 54 | ||
55 | #include <linux/i2c.h> | 55 | #include <linux/i2c.h> |
56 | #include <linux/i2c-dev.h> | ||
57 | 56 | ||
58 | #define I2C_NAME(s) (s)->name | 57 | #define I2C_NAME(s) (s)->name |
59 | 58 | ||
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c index 7bb85a7b326e..dff06895171b 100644 --- a/drivers/media/video/saa7110.c +++ b/drivers/media/video/saa7110.c | |||
@@ -39,7 +39,6 @@ MODULE_AUTHOR("Pauline Middelink"); | |||
39 | MODULE_LICENSE("GPL"); | 39 | MODULE_LICENSE("GPL"); |
40 | 40 | ||
41 | #include <linux/i2c.h> | 41 | #include <linux/i2c.h> |
42 | #include <linux/i2c-dev.h> | ||
43 | 42 | ||
44 | #define I2C_NAME(s) (s)->name | 43 | #define I2C_NAME(s) (s)->name |
45 | 44 | ||
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index 8c06592b37ff..5e06cc98442d 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c | |||
@@ -52,7 +52,6 @@ MODULE_AUTHOR("Dave Perks"); | |||
52 | MODULE_LICENSE("GPL"); | 52 | MODULE_LICENSE("GPL"); |
53 | 53 | ||
54 | #include <linux/i2c.h> | 54 | #include <linux/i2c.h> |
55 | #include <linux/i2c-dev.h> | ||
56 | 55 | ||
57 | #define I2C_NAME(s) (s)->name | 56 | #define I2C_NAME(s) (s)->name |
58 | 57 | ||
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c index fd0a4b4ef014..ce5a740e923e 100644 --- a/drivers/media/video/saa7114.c +++ b/drivers/media/video/saa7114.c | |||
@@ -55,7 +55,6 @@ MODULE_AUTHOR("Maxim Yevtyushkin"); | |||
55 | MODULE_LICENSE("GPL"); | 55 | MODULE_LICENSE("GPL"); |
56 | 56 | ||
57 | #include <linux/i2c.h> | 57 | #include <linux/i2c.h> |
58 | #include <linux/i2c-dev.h> | ||
59 | 58 | ||
60 | #define I2C_NAME(x) (x)->name | 59 | #define I2C_NAME(x) (x)->name |
61 | 60 | ||
diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c index 6c161f2f5e2c..708fae51e8ee 100644 --- a/drivers/media/video/saa711x.c +++ b/drivers/media/video/saa711x.c | |||
@@ -45,7 +45,6 @@ MODULE_AUTHOR("Dave Perks, Jose Ignacio Gijon, Joerg Heckenbach, Mark McClelland | |||
45 | MODULE_LICENSE("GPL"); | 45 | MODULE_LICENSE("GPL"); |
46 | 46 | ||
47 | #include <linux/i2c.h> | 47 | #include <linux/i2c.h> |
48 | #include <linux/i2c-dev.h> | ||
49 | 48 | ||
50 | #define I2C_NAME(s) (s)->name | 49 | #define I2C_NAME(s) (s)->name |
51 | 50 | ||
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c index 3ed0edb870a4..e1718e85f6c4 100644 --- a/drivers/media/video/saa7185.c +++ b/drivers/media/video/saa7185.c | |||
@@ -49,7 +49,6 @@ MODULE_AUTHOR("Dave Perks"); | |||
49 | MODULE_LICENSE("GPL"); | 49 | MODULE_LICENSE("GPL"); |
50 | 50 | ||
51 | #include <linux/i2c.h> | 51 | #include <linux/i2c.h> |
52 | #include <linux/i2c-dev.h> | ||
53 | 52 | ||
54 | #define I2C_NAME(s) (s)->name | 53 | #define I2C_NAME(s) (s)->name |
55 | 54 | ||
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c index d0a1e72ea8c4..4cd579967487 100644 --- a/drivers/media/video/vpx3220.c +++ b/drivers/media/video/vpx3220.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
31 | 31 | ||
32 | #include <linux/i2c.h> | 32 | #include <linux/i2c.h> |
33 | #include <linux/i2c-dev.h> | ||
34 | 33 | ||
35 | #define I2C_NAME(x) (x)->name | 34 | #define I2C_NAME(x) (x)->name |
36 | 35 | ||
diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h index 7eb4004b3601..a90c09d331c1 100644 --- a/include/linux/hwmon-sysfs.h +++ b/include/linux/hwmon-sysfs.h | |||
@@ -27,11 +27,13 @@ struct sensor_device_attribute{ | |||
27 | #define to_sensor_dev_attr(_dev_attr) \ | 27 | #define to_sensor_dev_attr(_dev_attr) \ |
28 | container_of(_dev_attr, struct sensor_device_attribute, dev_attr) | 28 | container_of(_dev_attr, struct sensor_device_attribute, dev_attr) |
29 | 29 | ||
30 | #define SENSOR_DEVICE_ATTR(_name,_mode,_show,_store,_index) \ | 30 | #define SENSOR_ATTR(_name, _mode, _show, _store, _index) \ |
31 | struct sensor_device_attribute sensor_dev_attr_##_name = { \ | 31 | { .dev_attr = __ATTR(_name, _mode, _show, _store), \ |
32 | .dev_attr = __ATTR(_name,_mode,_show,_store), \ | 32 | .index = _index } |
33 | .index = _index, \ | 33 | |
34 | } | 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 | struct sensor_device_attribute_2 { | 38 | struct sensor_device_attribute_2 { |
37 | struct device_attribute dev_attr; | 39 | struct device_attribute dev_attr; |
@@ -41,11 +43,13 @@ struct sensor_device_attribute_2 { | |||
41 | #define to_sensor_dev_attr_2(_dev_attr) \ | 43 | #define to_sensor_dev_attr_2(_dev_attr) \ |
42 | container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr) | 44 | container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr) |
43 | 45 | ||
46 | #define SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index) \ | ||
47 | { .dev_attr = __ATTR(_name, _mode, _show, _store), \ | ||
48 | .index = _index, \ | ||
49 | .nr = _nr } | ||
50 | |||
44 | #define SENSOR_DEVICE_ATTR_2(_name,_mode,_show,_store,_nr,_index) \ | 51 | #define SENSOR_DEVICE_ATTR_2(_name,_mode,_show,_store,_nr,_index) \ |
45 | struct sensor_device_attribute_2 sensor_dev_attr_##_name = { \ | 52 | struct sensor_device_attribute_2 sensor_dev_attr_##_name \ |
46 | .dev_attr = __ATTR(_name,_mode,_show,_store), \ | 53 | = SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index) |
47 | .index = _index, \ | ||
48 | .nr = _nr, \ | ||
49 | } | ||
50 | 54 | ||
51 | #endif /* _LINUX_HWMON_SYSFS_H */ | 55 | #endif /* _LINUX_HWMON_SYSFS_H */ |
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index 474c8f4f5d4f..ec311bc89439 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h | |||
@@ -172,7 +172,6 @@ | |||
172 | #define I2C_HW_B_RIVA 0x010010 /* Riva based graphics cards */ | 172 | #define I2C_HW_B_RIVA 0x010010 /* Riva based graphics cards */ |
173 | #define I2C_HW_B_IOC 0x010011 /* IOC bit-wiggling */ | 173 | #define I2C_HW_B_IOC 0x010011 /* IOC bit-wiggling */ |
174 | #define I2C_HW_B_TSUNA 0x010012 /* DEC Tsunami chipset */ | 174 | #define I2C_HW_B_TSUNA 0x010012 /* DEC Tsunami chipset */ |
175 | #define I2C_HW_B_FRODO 0x010013 /* 2d3D SA-1110 Development Board */ | ||
176 | #define I2C_HW_B_OMAHA 0x010014 /* Omaha I2C interface (ARM) */ | 175 | #define I2C_HW_B_OMAHA 0x010014 /* Omaha I2C interface (ARM) */ |
177 | #define I2C_HW_B_GUIDE 0x010015 /* Guide bit-basher */ | 176 | #define I2C_HW_B_GUIDE 0x010015 /* Guide bit-basher */ |
178 | #define I2C_HW_B_IXP2000 0x010016 /* GPIO on IXP2000 systems */ | 177 | #define I2C_HW_B_IXP2000 0x010016 /* GPIO on IXP2000 systems */ |
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 63f1d63cc1d8..1635ee25918f 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <linux/mod_devicetable.h> | 32 | #include <linux/mod_devicetable.h> |
33 | #include <linux/device.h> /* for struct device */ | 33 | #include <linux/device.h> /* for struct device */ |
34 | #include <linux/sched.h> /* for completion */ | 34 | #include <linux/sched.h> /* for completion */ |
35 | #include <asm/semaphore.h> | 35 | #include <linux/mutex.h> |
36 | 36 | ||
37 | /* --- For i2c-isa ---------------------------------------------------- */ | 37 | /* --- For i2c-isa ---------------------------------------------------- */ |
38 | 38 | ||
@@ -225,8 +225,8 @@ struct i2c_adapter { | |||
225 | int (*client_unregister)(struct i2c_client *); | 225 | int (*client_unregister)(struct i2c_client *); |
226 | 226 | ||
227 | /* data fields that are valid for all devices */ | 227 | /* data fields that are valid for all devices */ |
228 | struct semaphore bus_lock; | 228 | struct mutex bus_lock; |
229 | struct semaphore clist_lock; | 229 | struct mutex clist_lock; |
230 | 230 | ||
231 | int timeout; | 231 | int timeout; |
232 | int retries; | 232 | int retries; |
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 989a9d00dec1..f3dcf89d5232 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h | |||
@@ -1371,6 +1371,7 @@ | |||
1371 | #define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200 | 1371 | #define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200 |
1372 | #define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201 | 1372 | #define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201 |
1373 | #define PCI_DEVICE_ID_SERVERWORKS_CSB6 0x0203 | 1373 | #define PCI_DEVICE_ID_SERVERWORKS_CSB6 0x0203 |
1374 | #define PCI_DEVICE_ID_SERVERWORKS_HT1000SB 0x0205 | ||
1374 | #define PCI_DEVICE_ID_SERVERWORKS_OSB4IDE 0x0211 | 1375 | #define PCI_DEVICE_ID_SERVERWORKS_OSB4IDE 0x0211 |
1375 | #define PCI_DEVICE_ID_SERVERWORKS_CSB5IDE 0x0212 | 1376 | #define PCI_DEVICE_ID_SERVERWORKS_CSB5IDE 0x0212 |
1376 | #define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE 0x0213 | 1377 | #define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE 0x0213 |
diff --git a/sound/oss/dmasound/dmasound_awacs.c b/sound/oss/dmasound/dmasound_awacs.c index a17375141c3a..6ba8d6f45fe8 100644 --- a/sound/oss/dmasound/dmasound_awacs.c +++ b/sound/oss/dmasound/dmasound_awacs.c | |||
@@ -88,8 +88,6 @@ | |||
88 | #include <linux/pmu.h> | 88 | #include <linux/pmu.h> |
89 | #endif | 89 | #endif |
90 | 90 | ||
91 | #include <linux/i2c-dev.h> | ||
92 | |||
93 | #include <asm/uaccess.h> | 91 | #include <asm/uaccess.h> |
94 | #include <asm/prom.h> | 92 | #include <asm/prom.h> |
95 | #include <asm/machdep.h> | 93 | #include <asm/machdep.h> |
diff --git a/sound/ppc/daca.c b/sound/ppc/daca.c index 08cde51177d7..aa09ebd9ffb8 100644 --- a/sound/ppc/daca.c +++ b/sound/ppc/daca.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <sound/driver.h> | 22 | #include <sound/driver.h> |
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <linux/i2c-dev.h> | ||
26 | #include <linux/kmod.h> | 25 | #include <linux/kmod.h> |
27 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
28 | #include <sound/core.h> | 27 | #include <sound/core.h> |
diff --git a/sound/ppc/keywest.c b/sound/ppc/keywest.c index 6058c2dd1b7f..fb05938dcbd9 100644 --- a/sound/ppc/keywest.c +++ b/sound/ppc/keywest.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
26 | #include <linux/i2c-dev.h> | ||
27 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
28 | #include <sound/core.h> | 27 | #include <sound/core.h> |
29 | #include "pmac.h" | 28 | #include "pmac.h" |
diff --git a/sound/ppc/toonie.c b/sound/ppc/toonie.c index 053b8f24e4dc..210be20dc27e 100644 --- a/sound/ppc/toonie.c +++ b/sound/ppc/toonie.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <linux/i2c-dev.h> | ||
26 | #include <linux/kmod.h> | 25 | #include <linux/kmod.h> |
27 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
28 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c index 838fc113c441..1146dd882bb1 100644 --- a/sound/ppc/tumbler.c +++ b/sound/ppc/tumbler.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/i2c.h> | 30 | #include <linux/i2c.h> |
31 | #include <linux/i2c-dev.h> | ||
32 | #include <linux/kmod.h> | 31 | #include <linux/kmod.h> |
33 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
34 | #include <linux/interrupt.h> | 33 | #include <linux/interrupt.h> |