aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hwmon/w83627ehf.c149
1 files changed, 85 insertions, 64 deletions
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 66e6855f9397..1128eac7023b 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -1,10 +1,10 @@
1/* 1/*
2 w83627ehf - Driver for the hardware monitoring functionality of 2 w83627ehf - Driver for the hardware monitoring functionality of
3 the Winbond W83627EHF Super-I/O chip 3 the Winbond W83627EHF Super-I/O chip
4 Copyright (C) 2005 Jean Delvare <khali@linux-fr.org> 4 Copyright (C) 2005 Jean Delvare <khali@linux-fr.org>
5 Copyright (C) 2006 Yuan Mu (Winbond), 5 Copyright (C) 2006 Yuan Mu (Winbond),
6 Rudolf Marek <r.marek@assembler.cz> 6 Rudolf Marek <r.marek@assembler.cz>
7 David Hubbard <david.c.hubbard@gmail.com> 7 David Hubbard <david.c.hubbard@gmail.com>
8 Daniel J Blueman <daniel.blueman@gmail.com> 8 Daniel J Blueman <daniel.blueman@gmail.com>
9 9
10 Shamelessly ripped from the w83627hf driver 10 Shamelessly ripped from the w83627hf driver
@@ -35,7 +35,7 @@
35 35
36 Chip #vin #fan #pwm #temp chip IDs man ID 36 Chip #vin #fan #pwm #temp chip IDs man ID
37 w83627ehf 10 5 4 3 0x8850 0x88 0x5ca3 37 w83627ehf 10 5 4 3 0x8850 0x88 0x5ca3
38 0x8860 0xa1 38 0x8860 0xa1
39 w83627dhg 9 5 4 3 0xa020 0xc1 0x5ca3 39 w83627dhg 9 5 4 3 0xa020 0xc1 0x5ca3
40 w83627dhg-p 9 5 4 3 0xb070 0xc1 0x5ca3 40 w83627dhg-p 9 5 4 3 0xb070 0xc1 0x5ca3
41 w83667hg 9 5 3 3 0xa510 0xc1 0x5ca3 41 w83667hg 9 5 3 3 0xa510 0xc1 0x5ca3
@@ -61,7 +61,7 @@
61enum kinds { w83627ehf, w83627dhg, w83627dhg_p, w83667hg, w83667hg_b }; 61enum kinds { w83627ehf, w83627dhg, w83627dhg_p, w83667hg, w83667hg_b };
62 62
63/* used to set data->name = w83627ehf_device_names[data->sio_kind] */ 63/* used to set data->name = w83627ehf_device_names[data->sio_kind] */
64static const char * w83627ehf_device_names[] = { 64static const char * const w83627ehf_device_names[] = {
65 "w83627ehf", 65 "w83627ehf",
66 "w83627dhg", 66 "w83627dhg",
67 "w83627dhg", 67 "w83627dhg",
@@ -80,7 +80,7 @@ MODULE_PARM_DESC(force_id, "Override the detected device ID");
80 */ 80 */
81 81
82#define W83627EHF_LD_HWM 0x0b 82#define W83627EHF_LD_HWM 0x0b
83#define W83667HG_LD_VID 0x0d 83#define W83667HG_LD_VID 0x0d
84 84
85#define SIO_REG_LDSEL 0x07 /* Logical device select */ 85#define SIO_REG_LDSEL 0x07 /* Logical device select */
86#define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */ 86#define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */
@@ -94,7 +94,7 @@ MODULE_PARM_DESC(force_id, "Override the detected device ID");
94#define SIO_W83627EHG_ID 0x8860 94#define SIO_W83627EHG_ID 0x8860
95#define SIO_W83627DHG_ID 0xa020 95#define SIO_W83627DHG_ID 0xa020
96#define SIO_W83627DHG_P_ID 0xb070 96#define SIO_W83627DHG_P_ID 0xb070
97#define SIO_W83667HG_ID 0xa510 97#define SIO_W83667HG_ID 0xa510
98#define SIO_W83667HG_B_ID 0xb350 98#define SIO_W83667HG_B_ID 0xb350
99#define SIO_ID_MASK 0xFFF0 99#define SIO_ID_MASK 0xFFF0
100 100
@@ -138,7 +138,7 @@ superio_exit(int ioreg)
138 * ISA constants 138 * ISA constants
139 */ 139 */
140 140
141#define IOREGION_ALIGNMENT ~7 141#define IOREGION_ALIGNMENT (~7)
142#define IOREGION_OFFSET 5 142#define IOREGION_OFFSET 5
143#define IOREGION_LENGTH 2 143#define IOREGION_LENGTH 2
144#define ADDR_REG_OFFSET 0 144#define ADDR_REG_OFFSET 0
@@ -279,7 +279,8 @@ static inline long in_from_reg(u8 reg, u8 nr)
279 279
280static inline u8 in_to_reg(u32 val, u8 nr) 280static inline u8 in_to_reg(u32 val, u8 nr)
281{ 281{
282 return SENSORS_LIMIT(((val + (scale_in[nr] / 2)) / scale_in[nr]), 0, 255); 282 return SENSORS_LIMIT(((val + (scale_in[nr] / 2)) / scale_in[nr]), 0,
283 255);
283} 284}
284 285
285/* 286/*
@@ -321,7 +322,8 @@ struct w83627ehf_data {
321 u8 pwm_enable[4]; /* 1->manual 322 u8 pwm_enable[4]; /* 1->manual
322 2->thermal cruise mode (also called SmartFan I) 323 2->thermal cruise mode (also called SmartFan I)
323 3->fan speed cruise mode 324 3->fan speed cruise mode
324 4->variable thermal cruise (also called SmartFan III) */ 325 4->variable thermal cruise (also called
326 SmartFan III) */
325 u8 pwm_num; /* number of pwm */ 327 u8 pwm_num; /* number of pwm */
326 u8 pwm[4]; 328 u8 pwm[4];
327 u8 target_temp[4]; 329 u8 target_temp[4];
@@ -384,7 +386,8 @@ static u16 w83627ehf_read_value(struct w83627ehf_data *data, u16 reg)
384 return res; 386 return res;
385} 387}
386 388
387static int w83627ehf_write_value(struct w83627ehf_data *data, u16 reg, u16 value) 389static int w83627ehf_write_value(struct w83627ehf_data *data, u16 reg,
390 u16 value)
388{ 391{
389 int word_sized = is_word_sized(reg); 392 int word_sized = is_word_sized(reg);
390 393
@@ -518,7 +521,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
518 time */ 521 time */
519 if (data->fan[i] == 0xff 522 if (data->fan[i] == 0xff
520 && data->fan_div[i] < 0x07) { 523 && data->fan_div[i] < 0x07) {
521 dev_dbg(dev, "Increasing fan%d " 524 dev_dbg(dev, "Increasing fan%d "
522 "clock divider from %u to %u\n", 525 "clock divider from %u to %u\n",
523 i + 1, div_from_reg(data->fan_div[i]), 526 i + 1, div_from_reg(data->fan_div[i]),
524 div_from_reg(data->fan_div[i] + 1)); 527 div_from_reg(data->fan_div[i] + 1));
@@ -548,16 +551,16 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
548 ((pwmcfg >> W83627EHF_PWM_MODE_SHIFT[i]) & 1) 551 ((pwmcfg >> W83627EHF_PWM_MODE_SHIFT[i]) & 1)
549 ? 0 : 1; 552 ? 0 : 1;
550 data->pwm_enable[i] = 553 data->pwm_enable[i] =
551 ((pwmcfg >> W83627EHF_PWM_ENABLE_SHIFT[i]) 554 ((pwmcfg >> W83627EHF_PWM_ENABLE_SHIFT[i])
552 & 3) + 1; 555 & 3) + 1;
553 data->pwm[i] = w83627ehf_read_value(data, 556 data->pwm[i] = w83627ehf_read_value(data,
554 W83627EHF_REG_PWM[i]); 557 W83627EHF_REG_PWM[i]);
555 data->fan_start_output[i] = w83627ehf_read_value(data, 558 data->fan_start_output[i] = w83627ehf_read_value(data,
556 W83627EHF_REG_FAN_START_OUTPUT[i]); 559 W83627EHF_REG_FAN_START_OUTPUT[i]);
557 data->fan_stop_output[i] = w83627ehf_read_value(data, 560 data->fan_stop_output[i] = w83627ehf_read_value(data,
558 W83627EHF_REG_FAN_STOP_OUTPUT[i]); 561 W83627EHF_REG_FAN_STOP_OUTPUT[i]);
559 data->fan_stop_time[i] = w83627ehf_read_value(data, 562 data->fan_stop_time[i] = w83627ehf_read_value(data,
560 W83627EHF_REG_FAN_STOP_TIME[i]); 563 W83627EHF_REG_FAN_STOP_TIME[i]);
561 564
562 if (data->REG_FAN_MAX_OUTPUT[i] != 0xff) 565 if (data->REG_FAN_MAX_OUTPUT[i] != 0xff)
563 data->fan_max_output[i] = 566 data->fan_max_output[i] =
@@ -611,7 +614,8 @@ show_##reg(struct device *dev, struct device_attribute *attr, \
611 char *buf) \ 614 char *buf) \
612{ \ 615{ \
613 struct w83627ehf_data *data = w83627ehf_update_device(dev); \ 616 struct w83627ehf_data *data = w83627ehf_update_device(dev); \
614 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ 617 struct sensor_device_attribute *sensor_attr = \
618 to_sensor_dev_attr(attr); \
615 int nr = sensor_attr->index; \ 619 int nr = sensor_attr->index; \
616 return sprintf(buf, "%ld\n", in_from_reg(data->reg[nr], nr)); \ 620 return sprintf(buf, "%ld\n", in_from_reg(data->reg[nr], nr)); \
617} 621}
@@ -621,11 +625,12 @@ show_in_reg(in_max)
621 625
622#define store_in_reg(REG, reg) \ 626#define store_in_reg(REG, reg) \
623static ssize_t \ 627static ssize_t \
624store_in_##reg (struct device *dev, struct device_attribute *attr, \ 628store_in_##reg(struct device *dev, struct device_attribute *attr, \
625 const char *buf, size_t count) \ 629 const char *buf, size_t count) \
626{ \ 630{ \
627 struct w83627ehf_data *data = dev_get_drvdata(dev); \ 631 struct w83627ehf_data *data = dev_get_drvdata(dev); \
628 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ 632 struct sensor_device_attribute *sensor_attr = \
633 to_sensor_dev_attr(attr); \
629 int nr = sensor_attr->index; \ 634 int nr = sensor_attr->index; \
630 unsigned long val; \ 635 unsigned long val; \
631 int err; \ 636 int err; \
@@ -643,7 +648,8 @@ store_in_##reg (struct device *dev, struct device_attribute *attr, \
643store_in_reg(MIN, min) 648store_in_reg(MIN, min)
644store_in_reg(MAX, max) 649store_in_reg(MAX, max)
645 650
646static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, char *buf) 651static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
652 char *buf)
647{ 653{
648 struct w83627ehf_data *data = w83627ehf_update_device(dev); 654 struct w83627ehf_data *data = w83627ehf_update_device(dev);
649 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 655 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
@@ -678,29 +684,29 @@ static struct sensor_device_attribute sda_in_alarm[] = {
678}; 684};
679 685
680static struct sensor_device_attribute sda_in_min[] = { 686static struct sensor_device_attribute sda_in_min[] = {
681 SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 0), 687 SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 0),
682 SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 1), 688 SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 1),
683 SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 2), 689 SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 2),
684 SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 3), 690 SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 3),
685 SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 4), 691 SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 4),
686 SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 5), 692 SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 5),
687 SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 6), 693 SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 6),
688 SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 7), 694 SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 7),
689 SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 8), 695 SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 8),
690 SENSOR_ATTR(in9_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 9), 696 SENSOR_ATTR(in9_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 9),
691}; 697};
692 698
693static struct sensor_device_attribute sda_in_max[] = { 699static struct sensor_device_attribute sda_in_max[] = {
694 SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 0), 700 SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 0),
695 SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 1), 701 SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 1),
696 SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 2), 702 SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 2),
697 SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 3), 703 SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 3),
698 SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 4), 704 SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 4),
699 SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 5), 705 SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 5),
700 SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 6), 706 SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 6),
701 SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 7), 707 SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 7),
702 SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 8), 708 SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 8),
703 SENSOR_ATTR(in9_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 9), 709 SENSOR_ATTR(in9_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 9),
704}; 710};
705 711
706#define show_fan_reg(reg) \ 712#define show_fan_reg(reg) \
@@ -709,7 +715,8 @@ show_##reg(struct device *dev, struct device_attribute *attr, \
709 char *buf) \ 715 char *buf) \
710{ \ 716{ \
711 struct w83627ehf_data *data = w83627ehf_update_device(dev); \ 717 struct w83627ehf_data *data = w83627ehf_update_device(dev); \
712 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ 718 struct sensor_device_attribute *sensor_attr = \
719 to_sensor_dev_attr(attr); \
713 int nr = sensor_attr->index; \ 720 int nr = sensor_attr->index; \
714 return sprintf(buf, "%d\n", \ 721 return sprintf(buf, "%d\n", \
715 fan_from_reg(data->reg[nr], \ 722 fan_from_reg(data->reg[nr], \
@@ -847,7 +854,8 @@ show_##reg(struct device *dev, struct device_attribute *attr, \
847 char *buf) \ 854 char *buf) \
848{ \ 855{ \
849 struct w83627ehf_data *data = w83627ehf_update_device(dev); \ 856 struct w83627ehf_data *data = w83627ehf_update_device(dev); \
850 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ 857 struct sensor_device_attribute *sensor_attr = \
858 to_sensor_dev_attr(attr); \
851 int nr = sensor_attr->index; \ 859 int nr = sensor_attr->index; \
852 return sprintf(buf, "%d\n", \ 860 return sprintf(buf, "%d\n", \
853 temp_from_reg(W83627EHF_REG_##REG[nr], data->reg[nr])); \ 861 temp_from_reg(W83627EHF_REG_##REG[nr], data->reg[nr])); \
@@ -862,7 +870,8 @@ store_##reg(struct device *dev, struct device_attribute *attr, \
862 const char *buf, size_t count) \ 870 const char *buf, size_t count) \
863{ \ 871{ \
864 struct w83627ehf_data *data = dev_get_drvdata(dev); \ 872 struct w83627ehf_data *data = dev_get_drvdata(dev); \
865 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ 873 struct sensor_device_attribute *sensor_attr = \
874 to_sensor_dev_attr(attr); \
866 int nr = sensor_attr->index; \ 875 int nr = sensor_attr->index; \
867 int err; \ 876 int err; \
868 long val; \ 877 long val; \
@@ -925,11 +934,12 @@ static struct sensor_device_attribute sda_temp_type[] = {
925}; 934};
926 935
927#define show_pwm_reg(reg) \ 936#define show_pwm_reg(reg) \
928static ssize_t show_##reg (struct device *dev, struct device_attribute *attr, \ 937static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \
929 char *buf) \ 938 char *buf) \
930{ \ 939{ \
931 struct w83627ehf_data *data = w83627ehf_update_device(dev); \ 940 struct w83627ehf_data *data = w83627ehf_update_device(dev); \
932 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ 941 struct sensor_device_attribute *sensor_attr = \
942 to_sensor_dev_attr(attr); \
933 int nr = sensor_attr->index; \ 943 int nr = sensor_attr->index; \
934 return sprintf(buf, "%d\n", data->reg[nr]); \ 944 return sprintf(buf, "%d\n", data->reg[nr]); \
935} 945}
@@ -1022,7 +1032,8 @@ static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \
1022 char *buf) \ 1032 char *buf) \
1023{ \ 1033{ \
1024 struct w83627ehf_data *data = w83627ehf_update_device(dev); \ 1034 struct w83627ehf_data *data = w83627ehf_update_device(dev); \
1025 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ 1035 struct sensor_device_attribute *sensor_attr = \
1036 to_sensor_dev_attr(attr); \
1026 int nr = sensor_attr->index; \ 1037 int nr = sensor_attr->index; \
1027 return sprintf(buf, "%d\n", data->reg[nr] * 1000); \ 1038 return sprintf(buf, "%d\n", data->reg[nr] * 1000); \
1028} 1039}
@@ -1141,16 +1152,18 @@ static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \
1141 char *buf) \ 1152 char *buf) \
1142{ \ 1153{ \
1143 struct w83627ehf_data *data = w83627ehf_update_device(dev); \ 1154 struct w83627ehf_data *data = w83627ehf_update_device(dev); \
1144 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ 1155 struct sensor_device_attribute *sensor_attr = \
1156 to_sensor_dev_attr(attr); \
1145 int nr = sensor_attr->index; \ 1157 int nr = sensor_attr->index; \
1146 return sprintf(buf, "%d\n", data->reg[nr]); \ 1158 return sprintf(buf, "%d\n", data->reg[nr]); \
1147}\ 1159} \
1148static ssize_t \ 1160static ssize_t \
1149store_##reg(struct device *dev, struct device_attribute *attr, \ 1161store_##reg(struct device *dev, struct device_attribute *attr, \
1150 const char *buf, size_t count) \ 1162 const char *buf, size_t count) \
1151{\ 1163{ \
1152 struct w83627ehf_data *data = dev_get_drvdata(dev); \ 1164 struct w83627ehf_data *data = dev_get_drvdata(dev); \
1153 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ 1165 struct sensor_device_attribute *sensor_attr = \
1166 to_sensor_dev_attr(attr); \
1154 int nr = sensor_attr->index; \ 1167 int nr = sensor_attr->index; \
1155 unsigned long val; \ 1168 unsigned long val; \
1156 int err; \ 1169 int err; \
@@ -1175,10 +1188,12 @@ static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \
1175 char *buf) \ 1188 char *buf) \
1176{ \ 1189{ \
1177 struct w83627ehf_data *data = w83627ehf_update_device(dev); \ 1190 struct w83627ehf_data *data = w83627ehf_update_device(dev); \
1178 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ 1191 struct sensor_device_attribute *sensor_attr = \
1192 to_sensor_dev_attr(attr); \
1179 int nr = sensor_attr->index; \ 1193 int nr = sensor_attr->index; \
1180 return sprintf(buf, "%d\n", \ 1194 return sprintf(buf, "%d\n", \
1181 step_time_from_reg(data->reg[nr], data->pwm_mode[nr])); \ 1195 step_time_from_reg(data->reg[nr], \
1196 data->pwm_mode[nr])); \
1182} \ 1197} \
1183\ 1198\
1184static ssize_t \ 1199static ssize_t \
@@ -1186,7 +1201,8 @@ store_##reg(struct device *dev, struct device_attribute *attr, \
1186 const char *buf, size_t count) \ 1201 const char *buf, size_t count) \
1187{ \ 1202{ \
1188 struct w83627ehf_data *data = dev_get_drvdata(dev); \ 1203 struct w83627ehf_data *data = dev_get_drvdata(dev); \
1189 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ 1204 struct sensor_device_attribute *sensor_attr = \
1205 to_sensor_dev_attr(attr); \
1190 int nr = sensor_attr->index; \ 1206 int nr = sensor_attr->index; \
1191 unsigned long val; \ 1207 unsigned long val; \
1192 int err; \ 1208 int err; \
@@ -1387,7 +1403,8 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
1387 goto exit; 1403 goto exit;
1388 } 1404 }
1389 1405
1390 if (!(data = kzalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) { 1406 data = kzalloc(sizeof(struct w83627ehf_data), GFP_KERNEL);
1407 if (!data) {
1391 err = -ENOMEM; 1408 err = -ENOMEM;
1392 goto exit_release; 1409 goto exit_release;
1393 } 1410 }
@@ -1508,10 +1525,11 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
1508 w83627ehf_update_fan_div(data); 1525 w83627ehf_update_fan_div(data);
1509 1526
1510 /* Register sysfs hooks */ 1527 /* Register sysfs hooks */
1511 for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays); i++) 1528 for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays); i++) {
1512 if ((err = device_create_file(dev, 1529 err = device_create_file(dev, &sda_sf3_arrays[i].dev_attr);
1513 &sda_sf3_arrays[i].dev_attr))) 1530 if (err)
1514 goto exit_remove; 1531 goto exit_remove;
1532 }
1515 1533
1516 for (i = 0; i < ARRAY_SIZE(sda_sf3_max_step_arrays); i++) { 1534 for (i = 0; i < ARRAY_SIZE(sda_sf3_max_step_arrays); i++) {
1517 struct sensor_device_attribute *attr = 1535 struct sensor_device_attribute *attr =
@@ -1525,8 +1543,9 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
1525 /* if fan4 is enabled create the sf3 files for it */ 1543 /* if fan4 is enabled create the sf3 files for it */
1526 if ((data->has_fan & (1 << 3)) && data->pwm_num >= 4) 1544 if ((data->has_fan & (1 << 3)) && data->pwm_num >= 4)
1527 for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays_fan4); i++) { 1545 for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays_fan4); i++) {
1528 if ((err = device_create_file(dev, 1546 err = device_create_file(dev,
1529 &sda_sf3_arrays_fan4[i].dev_attr))) 1547 &sda_sf3_arrays_fan4[i].dev_attr);
1548 if (err)
1530 goto exit_remove; 1549 goto exit_remove;
1531 } 1550 }
1532 1551
@@ -1696,7 +1715,8 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr,
1696 /* Activate logical device if needed */ 1715 /* Activate logical device if needed */
1697 val = superio_inb(sioaddr, SIO_REG_ENABLE); 1716 val = superio_inb(sioaddr, SIO_REG_ENABLE);
1698 if (!(val & 0x01)) { 1717 if (!(val & 0x01)) {
1699 pr_warn("Forcibly enabling Super-I/O. Sensor is probably unusable.\n"); 1718 pr_warn("Forcibly enabling Super-I/O. "
1719 "Sensor is probably unusable.\n");
1700 superio_outb(sioaddr, SIO_REG_ENABLE, val | 0x01); 1720 superio_outb(sioaddr, SIO_REG_ENABLE, val | 0x01);
1701 } 1721 }
1702 1722
@@ -1733,7 +1753,8 @@ static int __init sensors_w83627ehf_init(void)
1733 if (err) 1753 if (err)
1734 goto exit; 1754 goto exit;
1735 1755
1736 if (!(pdev = platform_device_alloc(DRVNAME, address))) { 1756 pdev = platform_device_alloc(DRVNAME, address);
1757 if (!pdev) {
1737 err = -ENOMEM; 1758 err = -ENOMEM;
1738 pr_err("Device allocation failed\n"); 1759 pr_err("Device allocation failed\n");
1739 goto exit_unregister; 1760 goto exit_unregister;