aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJim Cromie <jim.cromie@gmail.com>2006-01-09 17:24:41 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-23 17:21:48 -0500
commitdedc6a7803d9c9795b504ffd8530a4ba7b3fd9ed (patch)
treea9e1cb0d15b8bafbc27120945cfd1f02b03e6739 /drivers
parent42d3b83fecb7b576d477244347982baa02fa4f44 (diff)
[PATCH] hwmon: Use attribute arrays in pc87360
Convert individual sensors to sensor-attr arrays by each sensor type, and initialize them in loops instead of long blocks of individual calls. Signed-off-by: Jim Cromie <jim.cromie@gmail.com> Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hwmon/pc87360.c408
1 files changed, 201 insertions, 207 deletions
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c
index f161e88e3bb6..2de69322f525 100644
--- a/drivers/hwmon/pc87360.c
+++ b/drivers/hwmon/pc87360.c
@@ -305,18 +305,26 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr,
305 return count; 305 return count;
306} 306}
307 307
308#define show_and_set_fan(offset) \ 308static struct sensor_device_attribute fan_input[] = {
309static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ 309 SENSOR_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0),
310 show_fan_input, NULL, offset-1); \ 310 SENSOR_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1),
311static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IWUSR | S_IRUGO, \ 311 SENSOR_ATTR(fan3_input, S_IRUGO, show_fan_input, NULL, 2),
312 show_fan_min, set_fan_min, offset-1); \ 312};
313static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ 313static struct sensor_device_attribute fan_status[] = {
314 show_fan_div, NULL, offset-1); \ 314 SENSOR_ATTR(fan1_status, S_IRUGO, show_fan_status, NULL, 0),
315static SENSOR_DEVICE_ATTR(fan##offset##_status, S_IRUGO, \ 315 SENSOR_ATTR(fan2_status, S_IRUGO, show_fan_status, NULL, 1),
316 show_fan_status, NULL, offset-1); 316 SENSOR_ATTR(fan3_status, S_IRUGO, show_fan_status, NULL, 2),
317show_and_set_fan(1) 317};
318show_and_set_fan(2) 318static struct sensor_device_attribute fan_div[] = {
319show_and_set_fan(3) 319 SENSOR_ATTR(fan1_div, S_IRUGO, show_fan_div, NULL, 0),
320 SENSOR_ATTR(fan2_div, S_IRUGO, show_fan_div, NULL, 1),
321 SENSOR_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2),
322};
323static struct sensor_device_attribute fan_min[] = {
324 SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 0),
325 SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 1),
326 SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 2),
327};
320 328
321static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf) 329static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf)
322{ 330{
@@ -344,12 +352,11 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, con
344 return count; 352 return count;
345} 353}
346 354
347#define show_and_set_pwm(offset) \ 355static struct sensor_device_attribute pwm[] = {
348static SENSOR_DEVICE_ATTR(pwm##offset, S_IWUSR | S_IRUGO, \ 356 SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0),
349 show_pwm, set_pwm, offset-1); 357 SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1),
350show_and_set_pwm(1) 358 SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2),
351show_and_set_pwm(2) 359};
352show_and_set_pwm(3)
353 360
354static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf) 361static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf)
355{ 362{
@@ -410,26 +417,58 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr,
410 return count; 417 return count;
411} 418}
412 419
413#define show_and_set_in(offset) \ 420static struct sensor_device_attribute in_input[] = {
414static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ 421 SENSOR_ATTR(in0_input, S_IRUGO, show_in_input, NULL, 0),
415 show_in_input, NULL, offset); \ 422 SENSOR_ATTR(in1_input, S_IRUGO, show_in_input, NULL, 1),
416static SENSOR_DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ 423 SENSOR_ATTR(in2_input, S_IRUGO, show_in_input, NULL, 2),
417 show_in_min, set_in_min, offset); \ 424 SENSOR_ATTR(in3_input, S_IRUGO, show_in_input, NULL, 3),
418static SENSOR_DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \ 425 SENSOR_ATTR(in4_input, S_IRUGO, show_in_input, NULL, 4),
419 show_in_max, set_in_max, offset); \ 426 SENSOR_ATTR(in5_input, S_IRUGO, show_in_input, NULL, 5),
420static SENSOR_DEVICE_ATTR(in##offset##_status, S_IRUGO, \ 427 SENSOR_ATTR(in6_input, S_IRUGO, show_in_input, NULL, 6),
421 show_in_status, NULL, offset); 428 SENSOR_ATTR(in7_input, S_IRUGO, show_in_input, NULL, 7),
422show_and_set_in(0) 429 SENSOR_ATTR(in8_input, S_IRUGO, show_in_input, NULL, 8),
423show_and_set_in(1) 430 SENSOR_ATTR(in9_input, S_IRUGO, show_in_input, NULL, 9),
424show_and_set_in(2) 431 SENSOR_ATTR(in10_input, S_IRUGO, show_in_input, NULL, 10),
425show_and_set_in(3) 432};
426show_and_set_in(4) 433static struct sensor_device_attribute in_status[] = {
427show_and_set_in(5) 434 SENSOR_ATTR(in0_status, S_IRUGO, show_in_status, NULL, 0),
428show_and_set_in(6) 435 SENSOR_ATTR(in1_status, S_IRUGO, show_in_status, NULL, 1),
429show_and_set_in(7) 436 SENSOR_ATTR(in2_status, S_IRUGO, show_in_status, NULL, 2),
430show_and_set_in(8) 437 SENSOR_ATTR(in3_status, S_IRUGO, show_in_status, NULL, 3),
431show_and_set_in(9) 438 SENSOR_ATTR(in4_status, S_IRUGO, show_in_status, NULL, 4),
432show_and_set_in(10) 439 SENSOR_ATTR(in5_status, S_IRUGO, show_in_status, NULL, 5),
440 SENSOR_ATTR(in6_status, S_IRUGO, show_in_status, NULL, 6),
441 SENSOR_ATTR(in7_status, S_IRUGO, show_in_status, NULL, 7),
442 SENSOR_ATTR(in8_status, S_IRUGO, show_in_status, NULL, 8),
443 SENSOR_ATTR(in9_status, S_IRUGO, show_in_status, NULL, 9),
444 SENSOR_ATTR(in10_status, S_IRUGO, show_in_status, NULL, 10),
445};
446static struct sensor_device_attribute in_min[] = {
447 SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 0),
448 SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 1),
449 SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 2),
450 SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 3),
451 SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 4),
452 SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 5),
453 SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 6),
454 SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 7),
455 SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 8),
456 SENSOR_ATTR(in9_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 9),
457 SENSOR_ATTR(in10_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 10),
458};
459static struct sensor_device_attribute in_max[] = {
460 SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 0),
461 SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 1),
462 SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 2),
463 SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 3),
464 SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 4),
465 SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 5),
466 SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 6),
467 SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 7),
468 SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 8),
469 SENSOR_ATTR(in9_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 9),
470 SENSOR_ATTR(in10_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 10),
471};
433 472
434static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf) 473static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf)
435{ 474{
@@ -511,20 +550,43 @@ static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devat
511 return count; 550 return count;
512} 551}
513 552
514#define show_and_set_therm(offset) \ 553/* the +11 term below reflects the fact that VLM units 11,12,13 are
515static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ 554 used in the chip to measure voltage across the thermistors
516 show_therm_input, NULL, 11+offset-4); \ 555*/
517static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ 556static struct sensor_device_attribute therm_input[] = {
518 show_therm_min, set_therm_min, 11+offset-4); \ 557 SENSOR_ATTR(temp4_input, S_IRUGO, show_therm_input, NULL, 0+11),
519static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ 558 SENSOR_ATTR(temp5_input, S_IRUGO, show_therm_input, NULL, 1+11),
520 show_therm_max, set_therm_max, 11+offset-4); \ 559 SENSOR_ATTR(temp6_input, S_IRUGO, show_therm_input, NULL, 2+11),
521static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ 560};
522 show_therm_crit, set_therm_crit, 11+offset-4); \ 561static struct sensor_device_attribute therm_status[] = {
523static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ 562 SENSOR_ATTR(temp4_status, S_IRUGO, show_therm_status, NULL, 0+11),
524 show_therm_status, NULL, 11+offset-4); 563 SENSOR_ATTR(temp5_status, S_IRUGO, show_therm_status, NULL, 1+11),
525show_and_set_therm(4) 564 SENSOR_ATTR(temp6_status, S_IRUGO, show_therm_status, NULL, 2+11),
526show_and_set_therm(5) 565};
527show_and_set_therm(6) 566static struct sensor_device_attribute therm_min[] = {
567 SENSOR_ATTR(temp4_min, S_IRUGO | S_IWUSR,
568 show_therm_min, set_therm_min, 0+11),
569 SENSOR_ATTR(temp5_min, S_IRUGO | S_IWUSR,
570 show_therm_min, set_therm_min, 1+11),
571 SENSOR_ATTR(temp6_min, S_IRUGO | S_IWUSR,
572 show_therm_min, set_therm_min, 2+11),
573};
574static struct sensor_device_attribute therm_max[] = {
575 SENSOR_ATTR(temp4_max, S_IRUGO | S_IWUSR,
576 show_therm_max, set_therm_max, 0+11),
577 SENSOR_ATTR(temp5_max, S_IRUGO | S_IWUSR,
578 show_therm_max, set_therm_max, 1+11),
579 SENSOR_ATTR(temp6_max, S_IRUGO | S_IWUSR,
580 show_therm_max, set_therm_max, 2+11),
581};
582static struct sensor_device_attribute therm_crit[] = {
583 SENSOR_ATTR(temp4_crit, S_IRUGO | S_IWUSR,
584 show_therm_crit, set_therm_crit, 0+11),
585 SENSOR_ATTR(temp5_crit, S_IRUGO | S_IWUSR,
586 show_therm_crit, set_therm_crit, 1+11),
587 SENSOR_ATTR(temp6_crit, S_IRUGO | S_IWUSR,
588 show_therm_crit, set_therm_crit, 2+11),
589};
528 590
529static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) 591static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
530{ 592{
@@ -630,20 +692,40 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devatt
630 return count; 692 return count;
631} 693}
632 694
633#define show_and_set_temp(offset) \ 695static struct sensor_device_attribute temp_input[] = {
634static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ 696 SENSOR_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0),
635 show_temp_input, NULL, offset-1); \ 697 SENSOR_ATTR(temp2_input, S_IRUGO, show_temp_input, NULL, 1),
636static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ 698 SENSOR_ATTR(temp3_input, S_IRUGO, show_temp_input, NULL, 2),
637 show_temp_min, set_temp_min, offset-1); \ 699};
638static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ 700static struct sensor_device_attribute temp_status[] = {
639 show_temp_max, set_temp_max, offset-1); \ 701 SENSOR_ATTR(temp1_status, S_IRUGO, show_temp_status, NULL, 0),
640static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ 702 SENSOR_ATTR(temp2_status, S_IRUGO, show_temp_status, NULL, 1),
641 show_temp_crit, set_temp_crit, offset-1); \ 703 SENSOR_ATTR(temp3_status, S_IRUGO, show_temp_status, NULL, 2),
642static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ 704};
643 show_temp_status, NULL, offset-1); 705static struct sensor_device_attribute temp_min[] = {
644show_and_set_temp(1) 706 SENSOR_ATTR(temp1_min, S_IRUGO | S_IWUSR,
645show_and_set_temp(2) 707 show_temp_min, set_temp_min, 0),
646show_and_set_temp(3) 708 SENSOR_ATTR(temp2_min, S_IRUGO | S_IWUSR,
709 show_temp_min, set_temp_min, 1),
710 SENSOR_ATTR(temp3_min, S_IRUGO | S_IWUSR,
711 show_temp_min, set_temp_min, 2),
712};
713static struct sensor_device_attribute temp_max[] = {
714 SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR,
715 show_temp_max, set_temp_max, 0),
716 SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR,
717 show_temp_max, set_temp_max, 1),
718 SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR,
719 show_temp_max, set_temp_max, 2),
720};
721static struct sensor_device_attribute temp_crit[] = {
722 SENSOR_ATTR(temp1_crit, S_IRUGO | S_IWUSR,
723 show_temp_crit, set_temp_crit, 0),
724 SENSOR_ATTR(temp2_crit, S_IRUGO | S_IWUSR,
725 show_temp_crit, set_temp_crit, 1),
726 SENSOR_ATTR(temp3_crit, S_IRUGO | S_IWUSR,
727 show_temp_crit, set_temp_crit, 2),
728};
647 729
648static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf) 730static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf)
649{ 731{
@@ -749,22 +831,24 @@ static int __init pc87360_find(int sioaddr, u8 *devid, unsigned short *addresses
749static int pc87360_detect(struct i2c_adapter *adapter) 831static int pc87360_detect(struct i2c_adapter *adapter)
750{ 832{
751 int i; 833 int i;
752 struct i2c_client *new_client; 834 struct i2c_client *client;
753 struct pc87360_data *data; 835 struct pc87360_data *data;
754 int err = 0; 836 int err = 0;
755 const char *name = "pc87360"; 837 const char *name = "pc87360";
756 int use_thermistors = 0; 838 int use_thermistors = 0;
839 struct device *dev;
757 840
758 if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL))) 841 if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL)))
759 return -ENOMEM; 842 return -ENOMEM;
760 843
761 new_client = &data->client; 844 client = &data->client;
762 i2c_set_clientdata(new_client, data); 845 dev = &client->dev;
763 new_client->addr = address; 846 i2c_set_clientdata(client, data);
847 client->addr = address;
764 init_MUTEX(&data->lock); 848 init_MUTEX(&data->lock);
765 new_client->adapter = adapter; 849 client->adapter = adapter;
766 new_client->driver = &pc87360_driver; 850 client->driver = &pc87360_driver;
767 new_client->flags = 0; 851 client->flags = 0;
768 852
769 data->fannr = 2; 853 data->fannr = 2;
770 data->innr = 0; 854 data->innr = 0;
@@ -792,7 +876,7 @@ static int pc87360_detect(struct i2c_adapter *adapter)
792 break; 876 break;
793 } 877 }
794 878
795 strcpy(new_client->name, name); 879 strlcpy(client->name, name, sizeof(client->name));
796 data->valid = 0; 880 data->valid = 0;
797 init_MUTEX(&data->update_lock); 881 init_MUTEX(&data->update_lock);
798 882
@@ -800,7 +884,7 @@ static int pc87360_detect(struct i2c_adapter *adapter)
800 if (((data->address[i] = extra_isa[i])) 884 if (((data->address[i] = extra_isa[i]))
801 && !request_region(extra_isa[i], PC87360_EXTENT, 885 && !request_region(extra_isa[i], PC87360_EXTENT,
802 pc87360_driver.driver.name)) { 886 pc87360_driver.driver.name)) {
803 dev_err(&new_client->dev, "Region 0x%x-0x%x already " 887 dev_err(&client->dev, "Region 0x%x-0x%x already "
804 "in use!\n", extra_isa[i], 888 "in use!\n", extra_isa[i],
805 extra_isa[i]+PC87360_EXTENT-1); 889 extra_isa[i]+PC87360_EXTENT-1);
806 for (i--; i >= 0; i--) 890 for (i--; i >= 0; i--)
@@ -814,7 +898,7 @@ static int pc87360_detect(struct i2c_adapter *adapter)
814 if (data->fannr) 898 if (data->fannr)
815 data->fan_conf = confreg[0] | (confreg[1] << 8); 899 data->fan_conf = confreg[0] | (confreg[1] << 8);
816 900
817 if ((err = i2c_attach_client(new_client))) 901 if ((err = i2c_attach_client(client)))
818 goto ERROR2; 902 goto ERROR2;
819 903
820 /* Use the correct reference voltage 904 /* Use the correct reference voltage
@@ -828,7 +912,7 @@ static int pc87360_detect(struct i2c_adapter *adapter)
828 PC87365_REG_TEMP_CONFIG); 912 PC87365_REG_TEMP_CONFIG);
829 } 913 }
830 data->in_vref = (i&0x02) ? 3025 : 2966; 914 data->in_vref = (i&0x02) ? 3025 : 2966;
831 dev_dbg(&new_client->dev, "Using %s reference voltage\n", 915 dev_dbg(&client->dev, "Using %s reference voltage\n",
832 (i&0x02) ? "external" : "internal"); 916 (i&0x02) ? "external" : "internal");
833 917
834 data->vid_conf = confreg[3]; 918 data->vid_conf = confreg[3];
@@ -847,154 +931,64 @@ static int pc87360_detect(struct i2c_adapter *adapter)
847 if (devid == 0xe9 && data->address[1]) /* PC87366 */ 931 if (devid == 0xe9 && data->address[1]) /* PC87366 */
848 use_thermistors = confreg[2] & 0x40; 932 use_thermistors = confreg[2] & 0x40;
849 933
850 pc87360_init_client(new_client, use_thermistors); 934 pc87360_init_client(client, use_thermistors);
851 } 935 }
852 936
853 /* Register sysfs hooks */ 937 /* Register sysfs hooks */
854 data->class_dev = hwmon_device_register(&new_client->dev); 938 data->class_dev = hwmon_device_register(&client->dev);
855 if (IS_ERR(data->class_dev)) { 939 if (IS_ERR(data->class_dev)) {
856 err = PTR_ERR(data->class_dev); 940 err = PTR_ERR(data->class_dev);
857 goto ERROR3; 941 goto ERROR3;
858 } 942 }
859 943
860 if (data->innr) { 944 if (data->innr) {
861 device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); 945 for (i = 0; i < 11; i++) {
862 device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr); 946 device_create_file(dev, &in_input[i].dev_attr);
863 device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr); 947 device_create_file(dev, &in_min[i].dev_attr);
864 device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr); 948 device_create_file(dev, &in_max[i].dev_attr);
865 device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr); 949 device_create_file(dev, &in_status[i].dev_attr);
866 device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr); 950 }
867 device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr); 951 device_create_file(dev, &dev_attr_cpu0_vid);
868 device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr); 952 device_create_file(dev, &dev_attr_vrm);
869 device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr); 953 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 } 954 }
910 955
911 if (data->tempnr) { 956 if (data->tempnr) {
912 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr); 957 for (i = 0; i < data->tempnr; i++) {
913 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr); 958 device_create_file(dev, &temp_input[i].dev_attr);
914 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr); 959 device_create_file(dev, &temp_min[i].dev_attr);
915 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr); 960 device_create_file(dev, &temp_max[i].dev_attr);
916 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr); 961 device_create_file(dev, &temp_crit[i].dev_attr);
917 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr); 962 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 } 963 }
964 device_create_file(dev, &dev_attr_alarms_temp);
965 }
961 966
962 if (FAN_CONFIG_MONITOR(data->fan_conf, 1)) { 967 if (data->innr == 14) {
963 device_create_file(&new_client->dev, 968 for (i = 0; i < 3; i++) {
964 &sensor_dev_attr_fan2_input.dev_attr); 969 device_create_file(dev, &therm_input[i].dev_attr);
965 device_create_file(&new_client->dev, 970 device_create_file(dev, &therm_min[i].dev_attr);
966 &sensor_dev_attr_fan2_min.dev_attr); 971 device_create_file(dev, &therm_max[i].dev_attr);
967 device_create_file(&new_client->dev, 972 device_create_file(dev, &therm_crit[i].dev_attr);
968 &sensor_dev_attr_fan2_div.dev_attr); 973 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 } 974 }
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 } 975 }
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 976
990 if (FAN_CONFIG_CONTROL(data->fan_conf, 2)) 977 for (i = 0; i < data->fannr; i++) {
991 device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr); 978 if (FAN_CONFIG_MONITOR(data->fan_conf, i)) {
979 device_create_file(dev, &fan_input[i].dev_attr);
980 device_create_file(dev, &fan_min[i].dev_attr);
981 device_create_file(dev, &fan_div[i].dev_attr);
982 device_create_file(dev, &fan_status[i].dev_attr);
983 }
984 if (FAN_CONFIG_CONTROL(data->fan_conf, i))
985 device_create_file(dev, &pwm[i].dev_attr);
992 } 986 }
993 987
994 return 0; 988 return 0;
995 989
996ERROR3: 990ERROR3:
997 i2c_detach_client(new_client); 991 i2c_detach_client(client);
998ERROR2: 992ERROR2:
999 for (i = 0; i < 3; i++) { 993 for (i = 0; i < 3; i++) {
1000 if (data->address[i]) { 994 if (data->address[i]) {
@@ -1071,7 +1065,7 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors)
1071 } 1065 }
1072 1066
1073 nr = data->innr < 11 ? data->innr : 11; 1067 nr = data->innr < 11 ? data->innr : 11;
1074 for (i=0; i<nr; i++) { 1068 for (i = 0; i < nr; i++) {
1075 if (init >= init_in[i]) { 1069 if (init >= init_in[i]) {
1076 /* Forcibly enable voltage channel */ 1070 /* Forcibly enable voltage channel */
1077 reg = pc87360_read_value(data, LD_IN, i, 1071 reg = pc87360_read_value(data, LD_IN, i,
@@ -1088,14 +1082,14 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors)
1088 1082
1089 /* We can't blindly trust the Super-I/O space configuration bit, 1083 /* We can't blindly trust the Super-I/O space configuration bit,
1090 most BIOS won't set it properly */ 1084 most BIOS won't set it properly */
1091 for (i=11; i<data->innr; i++) { 1085 for (i = 11; i < data->innr; i++) {
1092 reg = pc87360_read_value(data, LD_IN, i, 1086 reg = pc87360_read_value(data, LD_IN, i,
1093 PC87365_REG_TEMP_STATUS); 1087 PC87365_REG_TEMP_STATUS);
1094 use_thermistors = use_thermistors || (reg & 0x01); 1088 use_thermistors = use_thermistors || (reg & 0x01);
1095 } 1089 }
1096 1090
1097 i = use_thermistors ? 2 : 0; 1091 i = use_thermistors ? 2 : 0;
1098 for (; i<data->tempnr; i++) { 1092 for (; i < data->tempnr; i++) {
1099 if (init >= init_temp[i]) { 1093 if (init >= init_temp[i]) {
1100 /* Forcibly enable temperature channel */ 1094 /* Forcibly enable temperature channel */
1101 reg = pc87360_read_value(data, LD_TEMP, i, 1095 reg = pc87360_read_value(data, LD_TEMP, i,
@@ -1111,7 +1105,7 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors)
1111 } 1105 }
1112 1106
1113 if (use_thermistors) { 1107 if (use_thermistors) {
1114 for (i=11; i<data->innr; i++) { 1108 for (i = 11; i < data->innr; i++) {
1115 if (init >= init_in[i]) { 1109 if (init >= init_in[i]) {
1116 /* The pin may already be used by thermal 1110 /* The pin may already be used by thermal
1117 diodes */ 1111 diodes */