diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-01-15 14:07:26 -0500 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-03-18 21:27:32 -0400 |
commit | 27b9de3c4ae302c51d99187047e6ebebb21fd29b (patch) | |
tree | a19c696ce7b16ce37cab1bee80ed3e520985e04a /drivers | |
parent | ca3ccad827175fa47f4b20ea4c7072e1ddc33128 (diff) |
hwmon: (w83627hf) Fix checkpatch issues
Fixed:
WARNING: simple_strtol is obsolete, use kstrtol instead
WARNING: simple_strtoul is obsolete, use kstrtoul instead
ERROR: do not use assignment in if condition
Modify multi-line comments to follow Documentation/CodingStyle.
Other checkpatch issues not fixed to reduce number of conflicts with pending
rewrite as mfd driver.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/w83627hf.c | 264 |
1 files changed, 174 insertions, 90 deletions
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index ca4d378c7623..5ce54a297249 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c | |||
@@ -1,43 +1,43 @@ | |||
1 | /* | 1 | /* |
2 | w83627hf.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | * w83627hf.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | monitoring | 3 | * monitoring |
4 | Copyright (c) 1998 - 2003 Frodo Looijaard <frodol@dds.nl>, | 4 | * Copyright (c) 1998 - 2003 Frodo Looijaard <frodol@dds.nl>, |
5 | Philip Edelbrock <phil@netroedge.com>, | 5 | * Philip Edelbrock <phil@netroedge.com>, |
6 | and Mark Studebaker <mdsxyz123@yahoo.com> | 6 | * and Mark Studebaker <mdsxyz123@yahoo.com> |
7 | Ported to 2.6 by Bernhard C. Schrenk <clemy@clemy.org> | 7 | * Ported to 2.6 by Bernhard C. Schrenk <clemy@clemy.org> |
8 | Copyright (c) 2007 Jean Delvare <khali@linux-fr.org> | 8 | * Copyright (c) 2007 Jean Delvare <khali@linux-fr.org> |
9 | 9 | * | |
10 | This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
11 | it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
12 | the Free Software Foundation; either version 2 of the License, or | 12 | * the Free Software Foundation; either version 2 of the License, or |
13 | (at your option) any later version. | 13 | * (at your option) any later version. |
14 | 14 | * | |
15 | This program is distributed in the hope that it will be useful, | 15 | * This program is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | GNU General Public License for more details. | 18 | * GNU General Public License for more details. |
19 | 19 | * | |
20 | You should have received a copy of the GNU General Public License | 20 | * You should have received a copy of the GNU General Public License |
21 | along with this program; if not, write to the Free Software | 21 | * along with this program; if not, write to the Free Software |
22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | /* | 25 | /* |
26 | Supports following chips: | 26 | * Supports following chips: |
27 | 27 | * | |
28 | Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA | 28 | * Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA |
29 | w83627hf 9 3 2 3 0x20 0x5ca3 no yes(LPC) | 29 | * w83627hf 9 3 2 3 0x20 0x5ca3 no yes(LPC) |
30 | w83627thf 7 3 3 3 0x90 0x5ca3 no yes(LPC) | 30 | * w83627thf 7 3 3 3 0x90 0x5ca3 no yes(LPC) |
31 | w83637hf 7 3 3 3 0x80 0x5ca3 no yes(LPC) | 31 | * w83637hf 7 3 3 3 0x80 0x5ca3 no yes(LPC) |
32 | w83687thf 7 3 3 3 0x90 0x5ca3 no yes(LPC) | 32 | * w83687thf 7 3 3 3 0x90 0x5ca3 no yes(LPC) |
33 | w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC) | 33 | * w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC) |
34 | 34 | * | |
35 | For other winbond chips, and for i2c support in the above chips, | 35 | * For other winbond chips, and for i2c support in the above chips, |
36 | use w83781d.c. | 36 | * use w83781d.c. |
37 | 37 | * | |
38 | Note: automatic ("cruise") fan control for 697, 637 & 627thf not | 38 | * Note: automatic ("cruise") fan control for 697, 637 & 627thf not |
39 | supported yet. | 39 | * supported yet. |
40 | */ | 40 | */ |
41 | 41 | ||
42 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 42 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
43 | 43 | ||
@@ -80,7 +80,7 @@ module_param(force_id, ushort, 0); | |||
80 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); | 80 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); |
81 | 81 | ||
82 | /* modified from kernel/include/traps.c */ | 82 | /* modified from kernel/include/traps.c */ |
83 | #define DEV 0x07 /* Register: Logical device select */ | 83 | #define DEV 0x07 /* Register: Logical device select */ |
84 | 84 | ||
85 | /* logical device numbers for superio_select (below) */ | 85 | /* logical device numbers for superio_select (below) */ |
86 | #define W83627HF_LD_FDC 0x00 | 86 | #define W83627HF_LD_FDC 0x00 |
@@ -99,7 +99,7 @@ MODULE_PARM_DESC(force_id, "Override the detected device ID"); | |||
99 | #define W83627HF_LD_ACPI 0x0a | 99 | #define W83627HF_LD_ACPI 0x0a |
100 | #define W83627HF_LD_HWM 0x0b | 100 | #define W83627HF_LD_HWM 0x0b |
101 | 101 | ||
102 | #define DEVID 0x20 /* Register: Device ID */ | 102 | #define DEVID 0x20 /* Register: Device ID */ |
103 | 103 | ||
104 | #define W83627THF_GPIO5_EN 0x30 /* w83627thf only */ | 104 | #define W83627THF_GPIO5_EN 0x30 /* w83627thf only */ |
105 | #define W83627THF_GPIO5_IOSR 0xf3 /* w83627thf only */ | 105 | #define W83627THF_GPIO5_IOSR 0xf3 /* w83627thf only */ |
@@ -248,10 +248,12 @@ static const u8 BIT_SCFG1[] = { 0x02, 0x04, 0x08 }; | |||
248 | static const u8 BIT_SCFG2[] = { 0x10, 0x20, 0x40 }; | 248 | static const u8 BIT_SCFG2[] = { 0x10, 0x20, 0x40 }; |
249 | #define W83781D_DEFAULT_BETA 3435 | 249 | #define W83781D_DEFAULT_BETA 3435 |
250 | 250 | ||
251 | /* Conversions. Limit checking is only done on the TO_REG | 251 | /* |
252 | variants. Note that you should be a bit careful with which arguments | 252 | * Conversions. Limit checking is only done on the TO_REG |
253 | these macros are called: arguments may be evaluated more than once. | 253 | * variants. Note that you should be a bit careful with which arguments |
254 | Fixing this is just not worth it. */ | 254 | * these macros are called: arguments may be evaluated more than once. |
255 | * Fixing this is just not worth it. | ||
256 | */ | ||
255 | #define IN_TO_REG(val) (SENSORS_LIMIT((((val) + 8)/16),0,255)) | 257 | #define IN_TO_REG(val) (SENSORS_LIMIT((((val) + 8)/16),0,255)) |
256 | #define IN_FROM_REG(val) ((val) * 16) | 258 | #define IN_FROM_REG(val) ((val) * 16) |
257 | 259 | ||
@@ -267,8 +269,10 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
267 | #define TEMP_MIN (-128000) | 269 | #define TEMP_MIN (-128000) |
268 | #define TEMP_MAX ( 127000) | 270 | #define TEMP_MAX ( 127000) |
269 | 271 | ||
270 | /* TEMP: 0.001C/bit (-128C to +127C) | 272 | /* |
271 | REG: 1C/bit, two's complement */ | 273 | * TEMP: 0.001C/bit (-128C to +127C) |
274 | * REG: 1C/bit, two's complement | ||
275 | */ | ||
272 | static u8 TEMP_TO_REG(long temp) | 276 | static u8 TEMP_TO_REG(long temp) |
273 | { | 277 | { |
274 | int ntemp = SENSORS_LIMIT(temp, TEMP_MIN, TEMP_MAX); | 278 | int ntemp = SENSORS_LIMIT(temp, TEMP_MIN, TEMP_MAX); |
@@ -294,8 +298,10 @@ static inline unsigned long pwm_freq_from_reg_627hf(u8 reg) | |||
294 | static inline u8 pwm_freq_to_reg_627hf(unsigned long val) | 298 | static inline u8 pwm_freq_to_reg_627hf(unsigned long val) |
295 | { | 299 | { |
296 | u8 i; | 300 | u8 i; |
297 | /* Only 5 dividers (1 2 4 8 16) | 301 | /* |
298 | Search for the nearest available frequency */ | 302 | * Only 5 dividers (1 2 4 8 16) |
303 | * Search for the nearest available frequency | ||
304 | */ | ||
299 | for (i = 0; i < 4; i++) { | 305 | for (i = 0; i < 4; i++) { |
300 | if (val > (((W83627HF_BASE_PWM_FREQ >> i) + | 306 | if (val > (((W83627HF_BASE_PWM_FREQ >> i) + |
301 | (W83627HF_BASE_PWM_FREQ >> (i+1))) / 2)) | 307 | (W83627HF_BASE_PWM_FREQ >> (i+1))) / 2)) |
@@ -345,8 +351,10 @@ static inline u8 DIV_TO_REG(long val) | |||
345 | return (u8)i; | 351 | return (u8)i; |
346 | } | 352 | } |
347 | 353 | ||
348 | /* For each registered chip, we need to keep some data in memory. | 354 | /* |
349 | The structure is dynamically allocated. */ | 355 | * For each registered chip, we need to keep some data in memory. |
356 | * The structure is dynamically allocated. | ||
357 | */ | ||
350 | struct w83627hf_data { | 358 | struct w83627hf_data { |
351 | unsigned short addr; | 359 | unsigned short addr; |
352 | const char *name; | 360 | const char *name; |
@@ -372,11 +380,13 @@ struct w83627hf_data { | |||
372 | u32 beep_mask; /* Register encoding, combined */ | 380 | u32 beep_mask; /* Register encoding, combined */ |
373 | u8 pwm[3]; /* Register value */ | 381 | u8 pwm[3]; /* Register value */ |
374 | u8 pwm_enable[3]; /* 1 = manual | 382 | u8 pwm_enable[3]; /* 1 = manual |
375 | 2 = thermal cruise (also called SmartFan I) | 383 | * 2 = thermal cruise (also called SmartFan I) |
376 | 3 = fan speed cruise */ | 384 | * 3 = fan speed cruise |
385 | */ | ||
377 | u8 pwm_freq[3]; /* Register value */ | 386 | u8 pwm_freq[3]; /* Register value */ |
378 | u16 sens[3]; /* 1 = pentium diode; 2 = 3904 diode; | 387 | u16 sens[3]; /* 1 = pentium diode; 2 = 3904 diode; |
379 | 4 = thermistor */ | 388 | * 4 = thermistor |
389 | */ | ||
380 | u8 vrm; | 390 | u8 vrm; |
381 | u8 vrm_ovt; /* Register value, 627THF/637HF/687THF only */ | 391 | u8 vrm_ovt; /* Register value, 627THF/637HF/687THF only */ |
382 | }; | 392 | }; |
@@ -427,7 +437,12 @@ store_in_min(struct device *dev, struct device_attribute *devattr, | |||
427 | { | 437 | { |
428 | int nr = to_sensor_dev_attr(devattr)->index; | 438 | int nr = to_sensor_dev_attr(devattr)->index; |
429 | struct w83627hf_data *data = dev_get_drvdata(dev); | 439 | struct w83627hf_data *data = dev_get_drvdata(dev); |
430 | long val = simple_strtol(buf, NULL, 10); | 440 | long val; |
441 | int err; | ||
442 | |||
443 | err = kstrtol(buf, 10, &val); | ||
444 | if (err) | ||
445 | return err; | ||
431 | 446 | ||
432 | mutex_lock(&data->update_lock); | 447 | mutex_lock(&data->update_lock); |
433 | data->in_min[nr] = IN_TO_REG(val); | 448 | data->in_min[nr] = IN_TO_REG(val); |
@@ -441,7 +456,12 @@ store_in_max(struct device *dev, struct device_attribute *devattr, | |||
441 | { | 456 | { |
442 | int nr = to_sensor_dev_attr(devattr)->index; | 457 | int nr = to_sensor_dev_attr(devattr)->index; |
443 | struct w83627hf_data *data = dev_get_drvdata(dev); | 458 | struct w83627hf_data *data = dev_get_drvdata(dev); |
444 | long val = simple_strtol(buf, NULL, 10); | 459 | long val; |
460 | int err; | ||
461 | |||
462 | err = kstrtol(buf, 10, &val); | ||
463 | if (err) | ||
464 | return err; | ||
445 | 465 | ||
446 | mutex_lock(&data->update_lock); | 466 | mutex_lock(&data->update_lock); |
447 | data->in_max[nr] = IN_TO_REG(val); | 467 | data->in_max[nr] = IN_TO_REG(val); |
@@ -506,9 +526,12 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a | |||
506 | const char *buf, size_t count) | 526 | const char *buf, size_t count) |
507 | { | 527 | { |
508 | struct w83627hf_data *data = dev_get_drvdata(dev); | 528 | struct w83627hf_data *data = dev_get_drvdata(dev); |
509 | u32 val; | 529 | unsigned long val; |
530 | int err; | ||
510 | 531 | ||
511 | val = simple_strtoul(buf, NULL, 10); | 532 | err = kstrtoul(buf, 10, &val); |
533 | if (err) | ||
534 | return err; | ||
512 | 535 | ||
513 | mutex_lock(&data->update_lock); | 536 | mutex_lock(&data->update_lock); |
514 | 537 | ||
@@ -533,9 +556,12 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a | |||
533 | const char *buf, size_t count) | 556 | const char *buf, size_t count) |
534 | { | 557 | { |
535 | struct w83627hf_data *data = dev_get_drvdata(dev); | 558 | struct w83627hf_data *data = dev_get_drvdata(dev); |
536 | u32 val; | 559 | unsigned long val; |
560 | int err; | ||
537 | 561 | ||
538 | val = simple_strtoul(buf, NULL, 10); | 562 | err = kstrtoul(buf, 10, &val); |
563 | if (err) | ||
564 | return err; | ||
539 | 565 | ||
540 | mutex_lock(&data->update_lock); | 566 | mutex_lock(&data->update_lock); |
541 | 567 | ||
@@ -584,7 +610,12 @@ store_fan_min(struct device *dev, struct device_attribute *devattr, | |||
584 | { | 610 | { |
585 | int nr = to_sensor_dev_attr(devattr)->index; | 611 | int nr = to_sensor_dev_attr(devattr)->index; |
586 | struct w83627hf_data *data = dev_get_drvdata(dev); | 612 | struct w83627hf_data *data = dev_get_drvdata(dev); |
587 | u32 val = simple_strtoul(buf, NULL, 10); | 613 | unsigned long val; |
614 | int err; | ||
615 | |||
616 | err = kstrtoul(buf, 10, &val); | ||
617 | if (err) | ||
618 | return err; | ||
588 | 619 | ||
589 | mutex_lock(&data->update_lock); | 620 | mutex_lock(&data->update_lock); |
590 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 621 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
@@ -645,9 +676,15 @@ store_temp_max(struct device *dev, struct device_attribute *devattr, | |||
645 | { | 676 | { |
646 | int nr = to_sensor_dev_attr(devattr)->index; | 677 | int nr = to_sensor_dev_attr(devattr)->index; |
647 | struct w83627hf_data *data = dev_get_drvdata(dev); | 678 | struct w83627hf_data *data = dev_get_drvdata(dev); |
648 | long val = simple_strtol(buf, NULL, 10); | 679 | u16 tmp; |
649 | u16 tmp = (nr) ? LM75_TEMP_TO_REG(val) : TEMP_TO_REG(val); | 680 | long val; |
681 | int err; | ||
650 | 682 | ||
683 | err = kstrtol(buf, 10, &val); | ||
684 | if (err) | ||
685 | return err; | ||
686 | |||
687 | tmp = (nr) ? LM75_TEMP_TO_REG(val) : TEMP_TO_REG(val); | ||
651 | mutex_lock(&data->update_lock); | 688 | mutex_lock(&data->update_lock); |
652 | data->temp_max[nr] = tmp; | 689 | data->temp_max[nr] = tmp; |
653 | w83627hf_write_value(data, w83627hf_reg_temp_over[nr], tmp); | 690 | w83627hf_write_value(data, w83627hf_reg_temp_over[nr], tmp); |
@@ -661,9 +698,15 @@ store_temp_max_hyst(struct device *dev, struct device_attribute *devattr, | |||
661 | { | 698 | { |
662 | int nr = to_sensor_dev_attr(devattr)->index; | 699 | int nr = to_sensor_dev_attr(devattr)->index; |
663 | struct w83627hf_data *data = dev_get_drvdata(dev); | 700 | struct w83627hf_data *data = dev_get_drvdata(dev); |
664 | long val = simple_strtol(buf, NULL, 10); | 701 | u16 tmp; |
665 | u16 tmp = (nr) ? LM75_TEMP_TO_REG(val) : TEMP_TO_REG(val); | 702 | long val; |
703 | int err; | ||
704 | |||
705 | err = kstrtol(buf, 10, &val); | ||
706 | if (err) | ||
707 | return err; | ||
666 | 708 | ||
709 | tmp = (nr) ? LM75_TEMP_TO_REG(val) : TEMP_TO_REG(val); | ||
667 | mutex_lock(&data->update_lock); | 710 | mutex_lock(&data->update_lock); |
668 | data->temp_max_hyst[nr] = tmp; | 711 | data->temp_max_hyst[nr] = tmp; |
669 | w83627hf_write_value(data, w83627hf_reg_temp_hyst[nr], tmp); | 712 | w83627hf_write_value(data, w83627hf_reg_temp_hyst[nr], tmp); |
@@ -701,9 +744,12 @@ static ssize_t | |||
701 | store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 744 | store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
702 | { | 745 | { |
703 | struct w83627hf_data *data = dev_get_drvdata(dev); | 746 | struct w83627hf_data *data = dev_get_drvdata(dev); |
704 | u32 val; | 747 | unsigned long val; |
748 | int err; | ||
705 | 749 | ||
706 | val = simple_strtoul(buf, NULL, 10); | 750 | err = kstrtoul(buf, 10, &val); |
751 | if (err) | ||
752 | return err; | ||
707 | data->vrm = val; | 753 | data->vrm = val; |
708 | 754 | ||
709 | return count; | 755 | return count; |
@@ -755,8 +801,11 @@ store_beep_mask(struct device *dev, struct device_attribute *attr, | |||
755 | { | 801 | { |
756 | struct w83627hf_data *data = dev_get_drvdata(dev); | 802 | struct w83627hf_data *data = dev_get_drvdata(dev); |
757 | unsigned long val; | 803 | unsigned long val; |
804 | int err; | ||
758 | 805 | ||
759 | val = simple_strtoul(buf, NULL, 10); | 806 | err = kstrtoul(buf, 10, &val); |
807 | if (err) | ||
808 | return err; | ||
760 | 809 | ||
761 | mutex_lock(&data->update_lock); | 810 | mutex_lock(&data->update_lock); |
762 | 811 | ||
@@ -791,10 +840,14 @@ store_beep(struct device *dev, struct device_attribute *attr, | |||
791 | { | 840 | { |
792 | struct w83627hf_data *data = dev_get_drvdata(dev); | 841 | struct w83627hf_data *data = dev_get_drvdata(dev); |
793 | int bitnr = to_sensor_dev_attr(attr)->index; | 842 | int bitnr = to_sensor_dev_attr(attr)->index; |
794 | unsigned long bit; | ||
795 | u8 reg; | 843 | u8 reg; |
844 | unsigned long bit; | ||
845 | int err; | ||
846 | |||
847 | err = kstrtoul(buf, 10, &bit); | ||
848 | if (err) | ||
849 | return err; | ||
796 | 850 | ||
797 | bit = simple_strtoul(buf, NULL, 10); | ||
798 | if (bit & ~1) | 851 | if (bit & ~1) |
799 | return -EINVAL; | 852 | return -EINVAL; |
800 | 853 | ||
@@ -872,10 +925,12 @@ show_fan_div(struct device *dev, struct device_attribute *devattr, char *buf) | |||
872 | return sprintf(buf, "%ld\n", | 925 | return sprintf(buf, "%ld\n", |
873 | (long) DIV_FROM_REG(data->fan_div[nr])); | 926 | (long) DIV_FROM_REG(data->fan_div[nr])); |
874 | } | 927 | } |
875 | /* Note: we save and restore the fan minimum here, because its value is | 928 | /* |
876 | determined in part by the fan divisor. This follows the principle of | 929 | * Note: we save and restore the fan minimum here, because its value is |
877 | least surprise; the user doesn't expect the fan minimum to change just | 930 | * determined in part by the fan divisor. This follows the principle of |
878 | because the divisor changed. */ | 931 | * least surprise; the user doesn't expect the fan minimum to change just |
932 | * because the divisor changed. | ||
933 | */ | ||
879 | static ssize_t | 934 | static ssize_t |
880 | store_fan_div(struct device *dev, struct device_attribute *devattr, | 935 | store_fan_div(struct device *dev, struct device_attribute *devattr, |
881 | const char *buf, size_t count) | 936 | const char *buf, size_t count) |
@@ -884,7 +939,12 @@ store_fan_div(struct device *dev, struct device_attribute *devattr, | |||
884 | struct w83627hf_data *data = dev_get_drvdata(dev); | 939 | struct w83627hf_data *data = dev_get_drvdata(dev); |
885 | unsigned long min; | 940 | unsigned long min; |
886 | u8 reg; | 941 | u8 reg; |
887 | unsigned long val = simple_strtoul(buf, NULL, 10); | 942 | unsigned long val; |
943 | int err; | ||
944 | |||
945 | err = kstrtoul(buf, 10, &val); | ||
946 | if (err) | ||
947 | return err; | ||
888 | 948 | ||
889 | mutex_lock(&data->update_lock); | 949 | mutex_lock(&data->update_lock); |
890 | 950 | ||
@@ -933,7 +993,12 @@ store_pwm(struct device *dev, struct device_attribute *devattr, | |||
933 | { | 993 | { |
934 | int nr = to_sensor_dev_attr(devattr)->index; | 994 | int nr = to_sensor_dev_attr(devattr)->index; |
935 | struct w83627hf_data *data = dev_get_drvdata(dev); | 995 | struct w83627hf_data *data = dev_get_drvdata(dev); |
936 | u32 val = simple_strtoul(buf, NULL, 10); | 996 | unsigned long val; |
997 | int err; | ||
998 | |||
999 | err = kstrtoul(buf, 10, &val); | ||
1000 | if (err) | ||
1001 | return err; | ||
937 | 1002 | ||
938 | mutex_lock(&data->update_lock); | 1003 | mutex_lock(&data->update_lock); |
939 | 1004 | ||
@@ -974,10 +1039,15 @@ store_pwm_enable(struct device *dev, struct device_attribute *devattr, | |||
974 | { | 1039 | { |
975 | int nr = to_sensor_dev_attr(devattr)->index; | 1040 | int nr = to_sensor_dev_attr(devattr)->index; |
976 | struct w83627hf_data *data = dev_get_drvdata(dev); | 1041 | struct w83627hf_data *data = dev_get_drvdata(dev); |
977 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
978 | u8 reg; | 1042 | u8 reg; |
1043 | unsigned long val; | ||
1044 | int err; | ||
1045 | |||
1046 | err = kstrtoul(buf, 10, &val); | ||
1047 | if (err) | ||
1048 | return err; | ||
979 | 1049 | ||
980 | if (!val || (val > 3)) /* modes 1, 2 and 3 are supported */ | 1050 | if (!val || val > 3) /* modes 1, 2 and 3 are supported */ |
981 | return -EINVAL; | 1051 | return -EINVAL; |
982 | mutex_lock(&data->update_lock); | 1052 | mutex_lock(&data->update_lock); |
983 | data->pwm_enable[nr] = val; | 1053 | data->pwm_enable[nr] = val; |
@@ -1016,9 +1086,12 @@ store_pwm_freq(struct device *dev, struct device_attribute *devattr, | |||
1016 | int nr = to_sensor_dev_attr(devattr)->index; | 1086 | int nr = to_sensor_dev_attr(devattr)->index; |
1017 | struct w83627hf_data *data = dev_get_drvdata(dev); | 1087 | struct w83627hf_data *data = dev_get_drvdata(dev); |
1018 | static const u8 mask[]={0xF8, 0x8F}; | 1088 | static const u8 mask[]={0xF8, 0x8F}; |
1019 | u32 val; | 1089 | unsigned long val; |
1090 | int err; | ||
1020 | 1091 | ||
1021 | val = simple_strtoul(buf, NULL, 10); | 1092 | err = kstrtoul(buf, 10, &val); |
1093 | if (err) | ||
1094 | return err; | ||
1022 | 1095 | ||
1023 | mutex_lock(&data->update_lock); | 1096 | mutex_lock(&data->update_lock); |
1024 | 1097 | ||
@@ -1060,9 +1133,13 @@ store_temp_type(struct device *dev, struct device_attribute *devattr, | |||
1060 | { | 1133 | { |
1061 | int nr = to_sensor_dev_attr(devattr)->index; | 1134 | int nr = to_sensor_dev_attr(devattr)->index; |
1062 | struct w83627hf_data *data = dev_get_drvdata(dev); | 1135 | struct w83627hf_data *data = dev_get_drvdata(dev); |
1063 | u32 val, tmp; | 1136 | unsigned long val; |
1137 | u32 tmp; | ||
1138 | int err; | ||
1064 | 1139 | ||
1065 | val = simple_strtoul(buf, NULL, 10); | 1140 | err = kstrtoul(buf, 10, &val); |
1141 | if (err) | ||
1142 | return err; | ||
1066 | 1143 | ||
1067 | mutex_lock(&data->update_lock); | 1144 | mutex_lock(&data->update_lock); |
1068 | 1145 | ||
@@ -1290,7 +1367,8 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1290 | goto ERROR0; | 1367 | goto ERROR0; |
1291 | } | 1368 | } |
1292 | 1369 | ||
1293 | if (!(data = kzalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) { | 1370 | data = kzalloc(sizeof(struct w83627hf_data), GFP_KERNEL); |
1371 | if (!data) { | ||
1294 | err = -ENOMEM; | 1372 | err = -ENOMEM; |
1295 | goto ERROR1; | 1373 | goto ERROR1; |
1296 | } | 1374 | } |
@@ -1311,7 +1389,8 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1311 | w83627hf_update_fan_div(data); | 1389 | w83627hf_update_fan_div(data); |
1312 | 1390 | ||
1313 | /* Register common device attributes */ | 1391 | /* Register common device attributes */ |
1314 | if ((err = sysfs_create_group(&dev->kobj, &w83627hf_group))) | 1392 | err = sysfs_create_group(&dev->kobj, &w83627hf_group); |
1393 | if (err) | ||
1315 | goto ERROR3; | 1394 | goto ERROR3; |
1316 | 1395 | ||
1317 | /* Register chip-specific device attributes */ | 1396 | /* Register chip-specific device attributes */ |
@@ -1387,10 +1466,11 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1387 | } | 1466 | } |
1388 | 1467 | ||
1389 | if (data->type == w83627thf || data->type == w83637hf | 1468 | if (data->type == w83627thf || data->type == w83637hf |
1390 | || data->type == w83687thf) | 1469 | || data->type == w83687thf) { |
1391 | if ((err = device_create_file(dev, | 1470 | err = device_create_file(dev, &sensor_dev_attr_pwm3.dev_attr); |
1392 | &sensor_dev_attr_pwm3.dev_attr))) | 1471 | if (err) |
1393 | goto ERROR4; | 1472 | goto ERROR4; |
1473 | } | ||
1394 | 1474 | ||
1395 | if (data->type == w83637hf || data->type == w83687thf) | 1475 | if (data->type == w83637hf || data->type == w83687thf) |
1396 | if ((err = device_create_file(dev, | 1476 | if ((err = device_create_file(dev, |
@@ -1409,10 +1489,12 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1409 | goto ERROR4; | 1489 | goto ERROR4; |
1410 | 1490 | ||
1411 | if (data->type == w83627thf || data->type == w83637hf | 1491 | if (data->type == w83627thf || data->type == w83637hf |
1412 | || data->type == w83687thf) | 1492 | || data->type == w83687thf) { |
1413 | if ((err = device_create_file(dev, | 1493 | err = device_create_file(dev, |
1414 | &sensor_dev_attr_pwm3_enable.dev_attr))) | 1494 | &sensor_dev_attr_pwm3_enable.dev_attr); |
1495 | if (err) | ||
1415 | goto ERROR4; | 1496 | goto ERROR4; |
1497 | } | ||
1416 | 1498 | ||
1417 | data->hwmon_dev = hwmon_device_register(dev); | 1499 | data->hwmon_dev = hwmon_device_register(dev); |
1418 | if (IS_ERR(data->hwmon_dev)) { | 1500 | if (IS_ERR(data->hwmon_dev)) { |
@@ -1510,8 +1592,10 @@ static int __devinit w83627thf_read_gpio5(struct platform_device *pdev) | |||
1510 | goto exit; | 1592 | goto exit; |
1511 | } | 1593 | } |
1512 | 1594 | ||
1513 | /* Make sure the pins are configured for input | 1595 | /* |
1514 | There must be at least five (VRM 9), and possibly 6 (VRM 10) */ | 1596 | * Make sure the pins are configured for input |
1597 | * There must be at least five (VRM 9), and possibly 6 (VRM 10) | ||
1598 | */ | ||
1515 | sel = superio_inb(sio_data, W83627THF_GPIO5_IOSR) & 0x3f; | 1599 | sel = superio_inb(sio_data, W83627THF_GPIO5_IOSR) & 0x3f; |
1516 | if ((sel & 0x1f) != 0x1f) { | 1600 | if ((sel & 0x1f) != 0x1f) { |
1517 | dev_dbg(&pdev->dev, "GPIO5 not configured for VID " | 1601 | dev_dbg(&pdev->dev, "GPIO5 not configured for VID " |