aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/pc87360.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-03-23 18:51:32 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-23 18:51:32 -0500
commitb6585dedac232ca79fe978d97a95fdaa6da24f66 (patch)
tree4d2d78300bb9bcfb40cb35450f78dd3af82c78d3 /drivers/hwmon/pc87360.c
parenta3ea9b584ed2acdeae817f0dc91a5880e0828a05 (diff)
parentded2b66615613093eeb83b81499bc270de8fc499 (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 ...
Diffstat (limited to 'drivers/hwmon/pc87360.c')
-rw-r--r--drivers/hwmon/pc87360.c469
1 files changed, 232 insertions, 237 deletions
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
48static u8 devid; 49static u8 devid;
@@ -183,8 +184,8 @@ static inline u8 PWM_TO_REG(int val, int inv)
183struct pc87360_data { 184struct pc87360_data {
184 struct i2c_client client; 185 struct i2c_client client;
185 struct class_device *class_dev; 186 struct class_device *class_dev;
186 struct semaphore lock; 187 struct mutex lock;
187 struct semaphore update_lock; 188 struct mutex update_lock;
188 char valid; /* !=0 if following fields are valid */ 189 char valid; /* !=0 if following fields are valid */
189 unsigned long last_updated; /* In jiffies */ 190 unsigned long last_updated; /* In jiffies */
190 191
@@ -283,7 +284,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr,
283 struct pc87360_data *data = i2c_get_clientdata(client); 284 struct pc87360_data *data = i2c_get_clientdata(client);
284 long fan_min = simple_strtol(buf, NULL, 10); 285 long fan_min = simple_strtol(buf, NULL, 10);
285 286
286 down(&data->update_lock); 287 mutex_lock(&data->update_lock);
287 fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index])); 288 fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index]));
288 289
289 /* If it wouldn't fit, change clock divisor */ 290 /* If it wouldn't fit, change clock divisor */
@@ -300,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) \ 309static struct sensor_device_attribute fan_input[] = {
309static 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),
311static 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};
313static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ 314static 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),
315static 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),
317show_and_set_fan(1) 318};
318show_and_set_fan(2) 319static struct sensor_device_attribute fan_div[] = {
319show_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};
324static 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
321static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf) 330static 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) \ 356static struct sensor_device_attribute pwm[] = {
348static 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),
350show_and_set_pwm(1) 359 SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2),
351show_and_set_pwm(2) 360};
352show_and_set_pwm(3)
353 361
354static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf) 362static 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}
396static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf, 404static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -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) \ 421static struct sensor_device_attribute in_input[] = {
414static 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),
416static 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),
418static 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),
420static 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),
422show_and_set_in(0) 430 SENSOR_ATTR(in8_input, S_IRUGO, show_in_input, NULL, 8),
423show_and_set_in(1) 431 SENSOR_ATTR(in9_input, S_IRUGO, show_in_input, NULL, 9),
424show_and_set_in(2) 432 SENSOR_ATTR(in10_input, S_IRUGO, show_in_input, NULL, 10),
425show_and_set_in(3) 433};
426show_and_set_in(4) 434static struct sensor_device_attribute in_status[] = {
427show_and_set_in(5) 435 SENSOR_ATTR(in0_status, S_IRUGO, show_in_status, NULL, 0),
428show_and_set_in(6) 436 SENSOR_ATTR(in1_status, S_IRUGO, show_in_status, NULL, 1),
429show_and_set_in(7) 437 SENSOR_ATTR(in2_status, S_IRUGO, show_in_status, NULL, 2),
430show_and_set_in(8) 438 SENSOR_ATTR(in3_status, S_IRUGO, show_in_status, NULL, 3),
431show_and_set_in(9) 439 SENSOR_ATTR(in4_status, S_IRUGO, show_in_status, NULL, 4),
432show_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};
447static 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};
460static 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
434static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf) 474static 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}
483static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf, 523static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -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}
498static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf, 538static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -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
515static 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*/
517static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ 557static 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),
519static 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),
521static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ 561};
522 show_therm_crit, set_therm_crit, 11+offset-4); \ 562static struct sensor_device_attribute therm_status[] = {
523static 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),
525show_and_set_therm(4) 565 SENSOR_ATTR(temp6_status, S_IRUGO, show_therm_status, NULL, 2+11),
526show_and_set_therm(5) 566};
527show_and_set_therm(6) 567static 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};
575static 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};
583static 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
529static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) 592static 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}
602static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf, 665static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -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}
617static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf, 680static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -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) \ 696static struct sensor_device_attribute temp_input[] = {
634static 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),
636static 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};
638static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ 701static 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),
640static 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),
642static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ 705};
643 show_temp_status, NULL, offset-1); 706static struct sensor_device_attribute temp_min[] = {
644show_and_set_temp(1) 707 SENSOR_ATTR(temp1_min, S_IRUGO | S_IWUSR,
645show_and_set_temp(2) 708 show_temp_min, set_temp_min, 0),
646show_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};
714static 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};
722static 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
648static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf) 731static 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
749static int pc87360_detect(struct i2c_adapter *adapter) 832static 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
996ERROR3: 991ERROR3:
997 i2c_detach_client(new_client); 992 i2c_detach_client(client);
998ERROR2: 993ERROR2:
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,
1045static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank, 1040static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank,
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
1055static void pc87360_init_client(struct i2c_client *client, int use_thermistors) 1050static 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}