aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/Kconfig126
-rw-r--r--drivers/hwmon/Makefile2
-rw-r--r--drivers/hwmon/abituguru.c7
-rw-r--r--drivers/hwmon/abituguru3.c6
-rw-r--r--drivers/hwmon/ad7314.c24
-rw-r--r--drivers/hwmon/ad7414.c21
-rw-r--r--drivers/hwmon/ad7418.c21
-rw-r--r--drivers/hwmon/adcxx.c9
-rw-r--r--drivers/hwmon/adm1029.c21
-rw-r--r--drivers/hwmon/adm9240.c26
-rw-r--r--drivers/hwmon/ads1015.c12
-rw-r--r--drivers/hwmon/ads7828.c15
-rw-r--r--drivers/hwmon/ads7871.c30
-rw-r--r--drivers/hwmon/adt7410.c464
-rw-r--r--drivers/hwmon/adt7411.c9
-rw-r--r--drivers/hwmon/adt7462.c15
-rw-r--r--drivers/hwmon/adt7470.c15
-rw-r--r--drivers/hwmon/amc6821.c16
-rw-r--r--drivers/hwmon/applesmc.c4
-rw-r--r--drivers/hwmon/asb100.c17
-rw-r--r--drivers/hwmon/asus_atk0110.c7
-rw-r--r--drivers/hwmon/coretemp.c7
-rw-r--r--drivers/hwmon/dme1737.c45
-rw-r--r--drivers/hwmon/ds620.c16
-rw-r--r--drivers/hwmon/emc1403.c18
-rw-r--r--drivers/hwmon/emc2103.c10
-rw-r--r--drivers/hwmon/f71882fg.c48
-rw-r--r--drivers/hwmon/f75375s.c8
-rw-r--r--drivers/hwmon/fam15h_power.c40
-rw-r--r--drivers/hwmon/g760a.c10
-rw-r--r--drivers/hwmon/ina2xx.c181
-rw-r--r--drivers/hwmon/jz4740-hwmon.c53
-rw-r--r--drivers/hwmon/lm70.c42
-rw-r--r--drivers/hwmon/lm93.c2
-rw-r--r--drivers/hwmon/lm95241.c15
-rw-r--r--drivers/hwmon/lm95245.c15
-rw-r--r--drivers/hwmon/ltc4151.c15
-rw-r--r--drivers/hwmon/ltc4215.c15
-rw-r--r--drivers/hwmon/ltc4245.c14
-rw-r--r--drivers/hwmon/max1111.c74
-rw-r--r--drivers/hwmon/max1668.c8
-rw-r--r--drivers/hwmon/max197.c349
-rw-r--r--drivers/hwmon/mcp3021.c67
-rw-r--r--drivers/hwmon/s3c-hwmon.c2
-rw-r--r--drivers/hwmon/sch5627.c5
-rw-r--r--drivers/hwmon/sch5636.c6
-rw-r--r--drivers/hwmon/sch56xx-common.c28
-rw-r--r--drivers/hwmon/sht15.c154
-rw-r--r--drivers/hwmon/sht21.c13
-rw-r--r--drivers/hwmon/twl4030-madc-hwmon.c9
-rw-r--r--drivers/hwmon/via-cputemp.c28
-rw-r--r--drivers/hwmon/vt8231.c24
-rw-r--r--drivers/hwmon/w83627hf.c2
-rw-r--r--drivers/hwmon/w83791d.c7
-rw-r--r--drivers/hwmon/w83792d.c58
-rw-r--r--drivers/hwmon/w83793.c23
-rw-r--r--drivers/hwmon/w83l786ng.c13
57 files changed, 1409 insertions, 882 deletions
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 84e02b416a4a..c4633de64465 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -41,7 +41,7 @@ comment "Native drivers"
41 41
42config SENSORS_ABITUGURU 42config SENSORS_ABITUGURU
43 tristate "Abit uGuru (rev 1 & 2)" 43 tristate "Abit uGuru (rev 1 & 2)"
44 depends on X86 && DMI && EXPERIMENTAL 44 depends on X86 && DMI
45 help 45 help
46 If you say yes here you get support for the sensor part of the first 46 If you say yes here you get support for the sensor part of the first
47 and second revision of the Abit uGuru chip. The voltage and frequency 47 and second revision of the Abit uGuru chip. The voltage and frequency
@@ -56,7 +56,7 @@ config SENSORS_ABITUGURU
56 56
57config SENSORS_ABITUGURU3 57config SENSORS_ABITUGURU3
58 tristate "Abit uGuru (rev 3)" 58 tristate "Abit uGuru (rev 3)"
59 depends on X86 && DMI && EXPERIMENTAL 59 depends on X86 && DMI
60 help 60 help
61 If you say yes here you get support for the sensor part of the 61 If you say yes here you get support for the sensor part of the
62 third revision of the Abit uGuru chip. Only reading the sensors 62 third revision of the Abit uGuru chip. Only reading the sensors
@@ -70,7 +70,7 @@ config SENSORS_ABITUGURU3
70 70
71config SENSORS_AD7314 71config SENSORS_AD7314
72 tristate "Analog Devices AD7314 and compatibles" 72 tristate "Analog Devices AD7314 and compatibles"
73 depends on SPI && EXPERIMENTAL 73 depends on SPI
74 help 74 help
75 If you say yes here you get support for the Analog Devices 75 If you say yes here you get support for the Analog Devices
76 AD7314, ADT7301 and ADT7302 temperature sensors. 76 AD7314, ADT7301 and ADT7302 temperature sensors.
@@ -80,7 +80,7 @@ config SENSORS_AD7314
80 80
81config SENSORS_AD7414 81config SENSORS_AD7414
82 tristate "Analog Devices AD7414" 82 tristate "Analog Devices AD7414"
83 depends on I2C && EXPERIMENTAL 83 depends on I2C
84 help 84 help
85 If you say yes here you get support for the Analog Devices 85 If you say yes here you get support for the Analog Devices
86 AD7414 temperature monitoring chip. 86 AD7414 temperature monitoring chip.
@@ -90,7 +90,7 @@ config SENSORS_AD7414
90 90
91config SENSORS_AD7418 91config SENSORS_AD7418
92 tristate "Analog Devices AD7416, AD7417 and AD7418" 92 tristate "Analog Devices AD7416, AD7417 and AD7418"
93 depends on I2C && EXPERIMENTAL 93 depends on I2C
94 help 94 help
95 If you say yes here you get support for the Analog Devices 95 If you say yes here you get support for the Analog Devices
96 AD7416, AD7417 and AD7418 temperature monitoring chips. 96 AD7416, AD7417 and AD7418 temperature monitoring chips.
@@ -100,7 +100,7 @@ config SENSORS_AD7418
100 100
101config SENSORS_ADCXX 101config SENSORS_ADCXX
102 tristate "National Semiconductor ADCxxxSxxx" 102 tristate "National Semiconductor ADCxxxSxxx"
103 depends on SPI_MASTER && EXPERIMENTAL 103 depends on SPI_MASTER
104 help 104 help
105 If you say yes here you get support for the National Semiconductor 105 If you say yes here you get support for the National Semiconductor
106 ADC<bb><c>S<sss> chip family, where 106 ADC<bb><c>S<sss> chip family, where
@@ -179,9 +179,19 @@ config SENSORS_ADM9240
179 This driver can also be built as a module. If so, the module 179 This driver can also be built as a module. If so, the module
180 will be called adm9240. 180 will be called adm9240.
181 181
182config SENSORS_ADT7410
183 tristate "Analog Devices ADT7410"
184 depends on I2C
185 help
186 If you say yes here you get support for the Analog Devices
187 ADT7410 temperature monitoring chip.
188
189 This driver can also be built as a module. If so, the module
190 will be called adt7410.
191
182config SENSORS_ADT7411 192config SENSORS_ADT7411
183 tristate "Analog Devices ADT7411" 193 tristate "Analog Devices ADT7411"
184 depends on I2C && EXPERIMENTAL 194 depends on I2C
185 help 195 help
186 If you say yes here you get support for the Analog Devices 196 If you say yes here you get support for the Analog Devices
187 ADT7411 voltage and temperature monitoring chip. 197 ADT7411 voltage and temperature monitoring chip.
@@ -191,7 +201,7 @@ config SENSORS_ADT7411
191 201
192config SENSORS_ADT7462 202config SENSORS_ADT7462
193 tristate "Analog Devices ADT7462" 203 tristate "Analog Devices ADT7462"
194 depends on I2C && EXPERIMENTAL 204 depends on I2C
195 help 205 help
196 If you say yes here you get support for the Analog Devices 206 If you say yes here you get support for the Analog Devices
197 ADT7462 temperature monitoring chips. 207 ADT7462 temperature monitoring chips.
@@ -201,7 +211,7 @@ config SENSORS_ADT7462
201 211
202config SENSORS_ADT7470 212config SENSORS_ADT7470
203 tristate "Analog Devices ADT7470" 213 tristate "Analog Devices ADT7470"
204 depends on I2C && EXPERIMENTAL 214 depends on I2C
205 help 215 help
206 If you say yes here you get support for the Analog Devices 216 If you say yes here you get support for the Analog Devices
207 ADT7470 temperature monitoring chips. 217 ADT7470 temperature monitoring chips.
@@ -236,7 +246,7 @@ config SENSORS_ASC7621
236 246
237config SENSORS_K8TEMP 247config SENSORS_K8TEMP
238 tristate "AMD Athlon64/FX or Opteron temperature sensor" 248 tristate "AMD Athlon64/FX or Opteron temperature sensor"
239 depends on X86 && PCI && EXPERIMENTAL 249 depends on X86 && PCI
240 help 250 help
241 If you say yes here you get support for the temperature 251 If you say yes here you get support for the temperature
242 sensor(s) inside your CPU. Supported is whole AMD K8 252 sensor(s) inside your CPU. Supported is whole AMD K8
@@ -271,7 +281,7 @@ config SENSORS_FAM15H_POWER
271 281
272config SENSORS_ASB100 282config SENSORS_ASB100
273 tristate "Asus ASB100 Bach" 283 tristate "Asus ASB100 Bach"
274 depends on X86 && I2C && EXPERIMENTAL 284 depends on X86 && I2C
275 select HWMON_VID 285 select HWMON_VID
276 help 286 help
277 If you say yes here you get support for the ASB100 Bach sensor 287 If you say yes here you get support for the ASB100 Bach sensor
@@ -282,7 +292,7 @@ config SENSORS_ASB100
282 292
283config SENSORS_ATXP1 293config SENSORS_ATXP1
284 tristate "Attansic ATXP1 VID controller" 294 tristate "Attansic ATXP1 VID controller"
285 depends on I2C && EXPERIMENTAL 295 depends on I2C
286 select HWMON_VID 296 select HWMON_VID
287 help 297 help
288 If you say yes here you get support for the Attansic ATXP1 VID 298 If you say yes here you get support for the Attansic ATXP1 VID
@@ -326,7 +336,7 @@ config SENSORS_DA9052_ADC
326 336
327config SENSORS_I5K_AMB 337config SENSORS_I5K_AMB
328 tristate "FB-DIMM AMB temperature sensor on Intel 5000 series chipsets" 338 tristate "FB-DIMM AMB temperature sensor on Intel 5000 series chipsets"
329 depends on PCI && EXPERIMENTAL 339 depends on PCI
330 help 340 help
331 If you say yes here you get support for FB-DIMM AMB temperature 341 If you say yes here you get support for FB-DIMM AMB temperature
332 monitoring chips on systems with the Intel 5000 series chipset. 342 monitoring chips on systems with the Intel 5000 series chipset.
@@ -435,7 +445,7 @@ config SENSORS_GPIO_FAN
435 445
436config SENSORS_HIH6130 446config SENSORS_HIH6130
437 tristate "Honeywell Humidicon HIH-6130 humidity/temperature sensor" 447 tristate "Honeywell Humidicon HIH-6130 humidity/temperature sensor"
438 depends on I2C && EXPERIMENTAL 448 depends on I2C
439 help 449 help
440 If you say yes here you get support for Honeywell Humidicon 450 If you say yes here you get support for Honeywell Humidicon
441 HIH-6130 and HIH-6131 Humidicon humidity sensors. 451 HIH-6130 and HIH-6131 Humidicon humidity sensors.
@@ -445,7 +455,7 @@ config SENSORS_HIH6130
445 455
446config SENSORS_CORETEMP 456config SENSORS_CORETEMP
447 tristate "Intel Core/Core2/Atom temperature sensor" 457 tristate "Intel Core/Core2/Atom temperature sensor"
448 depends on X86 && PCI && EXPERIMENTAL 458 depends on X86 && PCI
449 help 459 help
450 If you say yes here you get support for the temperature 460 If you say yes here you get support for the temperature
451 sensor inside your CPU. Most of the family 6 CPUs 461 sensor inside your CPU. Most of the family 6 CPUs
@@ -485,8 +495,8 @@ config SENSORS_IT87
485 select HWMON_VID 495 select HWMON_VID
486 help 496 help
487 If you say yes here you get support for ITE IT8705F, IT8712F, 497 If you say yes here you get support for ITE IT8705F, IT8712F,
488 IT8716F, IT8718F, IT8720F, IT8721F, IT8726F, IT8728F and IT8758E 498 IT8716F, IT8718F, IT8720F, IT8721F, IT8726F, IT8728F, IT8758E,
489 sensor chips, and the SiS960 clone. 499 IT8782F, and IT8783E/F sensor chips, and the SiS950 clone.
490 500
491 This driver can also be built as a module. If so, the module 501 This driver can also be built as a module. If so, the module
492 will be called it87. 502 will be called it87.
@@ -517,7 +527,7 @@ config SENSORS_JC42
517 527
518config SENSORS_LINEAGE 528config SENSORS_LINEAGE
519 tristate "Lineage Compact Power Line Power Entry Module" 529 tristate "Lineage Compact Power Line Power Entry Module"
520 depends on I2C && EXPERIMENTAL 530 depends on I2C
521 help 531 help
522 If you say yes here you get support for the Lineage Compact Power Line 532 If you say yes here you get support for the Lineage Compact Power Line
523 series of DC/DC and AC/DC converters such as CP1800, CP2000AC, 533 series of DC/DC and AC/DC converters such as CP1800, CP2000AC,
@@ -540,12 +550,12 @@ config SENSORS_LM63
540 will be called lm63. 550 will be called lm63.
541 551
542config SENSORS_LM70 552config SENSORS_LM70
543 tristate "National Semiconductor LM70 / Texas Instruments TMP121" 553 tristate "National Semiconductor LM70 and compatibles"
544 depends on SPI_MASTER 554 depends on SPI_MASTER
545 help 555 help
546 If you say yes here you get support for the National Semiconductor 556 If you say yes here you get support for the National Semiconductor
547 LM70 and Texas Instruments TMP121/TMP123 digital temperature 557 LM70, LM71, LM74 and Texas Instruments TMP121/TMP123 digital tempera-
548 sensor chips. 558 ture sensor chips.
549 559
550 This driver can also be built as a module. If so, the module 560 This driver can also be built as a module. If so, the module
551 will be called lm70. 561 will be called lm70.
@@ -699,7 +709,7 @@ config SENSORS_LTC4151
699 709
700config SENSORS_LTC4215 710config SENSORS_LTC4215
701 tristate "Linear Technology LTC4215" 711 tristate "Linear Technology LTC4215"
702 depends on I2C && EXPERIMENTAL 712 depends on I2C
703 default n 713 default n
704 help 714 help
705 If you say yes here you get support for Linear Technology LTC4215 715 If you say yes here you get support for Linear Technology LTC4215
@@ -710,7 +720,7 @@ config SENSORS_LTC4215
710 720
711config SENSORS_LTC4245 721config SENSORS_LTC4245
712 tristate "Linear Technology LTC4245" 722 tristate "Linear Technology LTC4245"
713 depends on I2C && EXPERIMENTAL 723 depends on I2C
714 default n 724 default n
715 help 725 help
716 If you say yes here you get support for Linear Technology LTC4245 726 If you say yes here you get support for Linear Technology LTC4245
@@ -721,7 +731,7 @@ config SENSORS_LTC4245
721 731
722config SENSORS_LTC4261 732config SENSORS_LTC4261
723 tristate "Linear Technology LTC4261" 733 tristate "Linear Technology LTC4261"
724 depends on I2C && EXPERIMENTAL 734 depends on I2C
725 default n 735 default n
726 help 736 help
727 If you say yes here you get support for Linear Technology LTC4261 737 If you say yes here you get support for Linear Technology LTC4261
@@ -742,7 +752,7 @@ config SENSORS_LM95241
742 752
743config SENSORS_LM95245 753config SENSORS_LM95245
744 tristate "National Semiconductor LM95245 sensor chip" 754 tristate "National Semiconductor LM95245 sensor chip"
745 depends on I2C && EXPERIMENTAL 755 depends on I2C
746 help 756 help
747 If you say yes here you get support for LM95245 sensor chip. 757 If you say yes here you get support for LM95245 sensor chip.
748 758
@@ -750,10 +760,11 @@ config SENSORS_LM95245
750 will be called lm95245. 760 will be called lm95245.
751 761
752config SENSORS_MAX1111 762config SENSORS_MAX1111
753 tristate "Maxim MAX1111 Multichannel, Serial 8-bit ADC chip" 763 tristate "Maxim MAX1111 Serial 8-bit ADC chip and compatibles"
754 depends on SPI_MASTER 764 depends on SPI_MASTER
755 help 765 help
756 Say y here to support Maxim's MAX1111 ADC chips. 766 Say y here to support Maxim's MAX1110, MAX1111, MAX1112, and MAX1113
767 ADC chips.
757 768
758 This driver can also be built as a module. If so, the module 769 This driver can also be built as a module. If so, the module
759 will be called max1111. 770 will be called max1111.
@@ -785,7 +796,7 @@ config SENSORS_MAX1619
785 796
786config SENSORS_MAX1668 797config SENSORS_MAX1668
787 tristate "Maxim MAX1668 and compatibles" 798 tristate "Maxim MAX1668 and compatibles"
788 depends on I2C && EXPERIMENTAL 799 depends on I2C
789 help 800 help
790 If you say yes here you get support for MAX1668, MAX1989 and 801 If you say yes here you get support for MAX1668, MAX1989 and
791 MAX1805 chips. 802 MAX1805 chips.
@@ -793,9 +804,18 @@ config SENSORS_MAX1668
793 This driver can also be built as a module. If so, the module 804 This driver can also be built as a module. If so, the module
794 will be called max1668. 805 will be called max1668.
795 806
807config SENSORS_MAX197
808 tristate "Maxim MAX197 and compatibles"
809 help
810 Support for the Maxim MAX197 A/D converter.
811 Support will include, but not be limited to, MAX197, and MAX199.
812
813 This driver can also be built as a module. If so, the module
814 will be called max197.
815
796config SENSORS_MAX6639 816config SENSORS_MAX6639
797 tristate "Maxim MAX6639 sensor chip" 817 tristate "Maxim MAX6639 sensor chip"
798 depends on I2C && EXPERIMENTAL 818 depends on I2C
799 help 819 help
800 If you say yes here you get support for the MAX6639 820 If you say yes here you get support for the MAX6639
801 sensor chips. 821 sensor chips.
@@ -805,7 +825,7 @@ config SENSORS_MAX6639
805 825
806config SENSORS_MAX6642 826config SENSORS_MAX6642
807 tristate "Maxim MAX6642 sensor chip" 827 tristate "Maxim MAX6642 sensor chip"
808 depends on I2C && EXPERIMENTAL 828 depends on I2C
809 help 829 help
810 If you say yes here you get support for MAX6642 sensor chip. 830 If you say yes here you get support for MAX6642 sensor chip.
811 MAX6642 is a SMBus-Compatible Remote/Local Temperature Sensor 831 MAX6642 is a SMBus-Compatible Remote/Local Temperature Sensor
@@ -816,7 +836,7 @@ config SENSORS_MAX6642
816 836
817config SENSORS_MAX6650 837config SENSORS_MAX6650
818 tristate "Maxim MAX6650 sensor chip" 838 tristate "Maxim MAX6650 sensor chip"
819 depends on I2C && EXPERIMENTAL 839 depends on I2C
820 help 840 help
821 If you say yes here you get support for the MAX6650 / MAX6651 841 If you say yes here you get support for the MAX6650 / MAX6651
822 sensor chips. 842 sensor chips.
@@ -825,18 +845,18 @@ config SENSORS_MAX6650
825 will be called max6650. 845 will be called max6650.
826 846
827config SENSORS_MCP3021 847config SENSORS_MCP3021
828 tristate "Microchip MCP3021" 848 tristate "Microchip MCP3021 and compatibles"
829 depends on I2C && EXPERIMENTAL 849 depends on I2C
830 help 850 help
831 If you say yes here you get support for the MCP3021 chip 851 If you say yes here you get support for MCP3021 and MCP3221.
832 that is a A/D converter (ADC) with 10-bit resolution. 852 The MCP3021 is a A/D converter (ADC) with 10-bit and the MCP3221
853 with 12-bit resolution.
833 854
834 This driver can also be built as a module. If so, the module 855 This driver can also be built as a module. If so, the module
835 will be called mcp3021. 856 will be called mcp3021.
836 857
837config SENSORS_NTC_THERMISTOR 858config SENSORS_NTC_THERMISTOR
838 tristate "NTC thermistor support" 859 tristate "NTC thermistor support"
839 depends on EXPERIMENTAL
840 help 860 help
841 This driver supports NTC thermistors sensor reading and its 861 This driver supports NTC thermistors sensor reading and its
842 interpretation. The driver can also monitor the temperature and 862 interpretation. The driver can also monitor the temperature and
@@ -941,7 +961,7 @@ config SENSORS_SIS5595
941 961
942config SENSORS_SMM665 962config SENSORS_SMM665
943 tristate "Summit Microelectronics SMM665" 963 tristate "Summit Microelectronics SMM665"
944 depends on I2C && EXPERIMENTAL 964 depends on I2C
945 default n 965 default n
946 help 966 help
947 If you say yes here you get support for the hardware monitoring 967 If you say yes here you get support for the hardware monitoring
@@ -956,7 +976,7 @@ config SENSORS_SMM665
956 976
957config SENSORS_DME1737 977config SENSORS_DME1737
958 tristate "SMSC DME1737, SCH311x and compatibles" 978 tristate "SMSC DME1737, SCH311x and compatibles"
959 depends on I2C && EXPERIMENTAL && !PPC 979 depends on I2C && !PPC
960 select HWMON_VID 980 select HWMON_VID
961 help 981 help
962 If you say yes here you get support for the hardware monitoring 982 If you say yes here you get support for the hardware monitoring
@@ -1032,7 +1052,7 @@ config SENSORS_SMSC47M192
1032 1052
1033config SENSORS_SMSC47B397 1053config SENSORS_SMSC47B397
1034 tristate "SMSC LPC47B397-NC" 1054 tristate "SMSC LPC47B397-NC"
1035 depends on EXPERIMENTAL && !PPC 1055 depends on !PPC
1036 help 1056 help
1037 If you say yes here you get support for the SMSC LPC47B397-NC 1057 If you say yes here you get support for the SMSC LPC47B397-NC
1038 sensor chip. 1058 sensor chip.
@@ -1106,7 +1126,7 @@ config SENSORS_ADS7871
1106 1126
1107config SENSORS_AMC6821 1127config SENSORS_AMC6821
1108 tristate "Texas Instruments AMC6821" 1128 tristate "Texas Instruments AMC6821"
1109 depends on I2C && EXPERIMENTAL 1129 depends on I2C
1110 help 1130 help
1111 If you say yes here you get support for the Texas Instruments 1131 If you say yes here you get support for the Texas Instruments
1112 AMC6821 hardware monitoring chips. 1132 AMC6821 hardware monitoring chips.
@@ -1115,11 +1135,11 @@ config SENSORS_AMC6821
1115 will be called amc6821. 1135 will be called amc6821.
1116 1136
1117config SENSORS_INA2XX 1137config SENSORS_INA2XX
1118 tristate "Texas Instruments INA219, INA226" 1138 tristate "Texas Instruments INA219 and compatibles"
1119 depends on I2C && EXPERIMENTAL 1139 depends on I2C
1120 help 1140 help
1121 If you say yes here you get support for INA219 and INA226 power 1141 If you say yes here you get support for INA219, INA220, INA226, and
1122 monitor chips. 1142 INA230 power monitor chips.
1123 1143
1124 The INA2xx driver is configured for the default configuration of 1144 The INA2xx driver is configured for the default configuration of
1125 the part as described in the datasheet. 1145 the part as described in the datasheet.
@@ -1139,7 +1159,7 @@ config SENSORS_THMC50
1139 1159
1140config SENSORS_TMP102 1160config SENSORS_TMP102
1141 tristate "Texas Instruments TMP102" 1161 tristate "Texas Instruments TMP102"
1142 depends on I2C && EXPERIMENTAL 1162 depends on I2C
1143 help 1163 help
1144 If you say yes here you get support for Texas Instruments TMP102 1164 If you say yes here you get support for Texas Instruments TMP102
1145 sensor chips. 1165 sensor chips.
@@ -1149,7 +1169,7 @@ config SENSORS_TMP102
1149 1169
1150config SENSORS_TMP401 1170config SENSORS_TMP401
1151 tristate "Texas Instruments TMP401 and compatibles" 1171 tristate "Texas Instruments TMP401 and compatibles"
1152 depends on I2C && EXPERIMENTAL 1172 depends on I2C
1153 help 1173 help
1154 If you say yes here you get support for Texas Instruments TMP401 and 1174 If you say yes here you get support for Texas Instruments TMP401 and
1155 TMP411 temperature sensor chips. 1175 TMP411 temperature sensor chips.
@@ -1159,7 +1179,7 @@ config SENSORS_TMP401
1159 1179
1160config SENSORS_TMP421 1180config SENSORS_TMP421
1161 tristate "Texas Instruments TMP421 and compatible" 1181 tristate "Texas Instruments TMP421 and compatible"
1162 depends on I2C && EXPERIMENTAL 1182 depends on I2C
1163 help 1183 help
1164 If you say yes here you get support for Texas Instruments TMP421, 1184 If you say yes here you get support for Texas Instruments TMP421,
1165 TMP422 and TMP423 temperature sensor chips. 1185 TMP422 and TMP423 temperature sensor chips.
@@ -1251,7 +1271,7 @@ config SENSORS_W83792D
1251 1271
1252config SENSORS_W83793 1272config SENSORS_W83793
1253 tristate "Winbond W83793" 1273 tristate "Winbond W83793"
1254 depends on I2C && EXPERIMENTAL 1274 depends on I2C
1255 select HWMON_VID 1275 select HWMON_VID
1256 help 1276 help
1257 If you say yes here you get support for the Winbond W83793 1277 If you say yes here you get support for the Winbond W83793
@@ -1263,7 +1283,7 @@ config SENSORS_W83793
1263 1283
1264config SENSORS_W83795 1284config SENSORS_W83795
1265 tristate "Winbond/Nuvoton W83795G/ADG" 1285 tristate "Winbond/Nuvoton W83795G/ADG"
1266 depends on I2C && EXPERIMENTAL 1286 depends on I2C
1267 help 1287 help
1268 If you say yes here you get support for the Winbond W83795G and 1288 If you say yes here you get support for the Winbond W83795G and
1269 W83795ADG hardware monitoring chip, including manual fan speed 1289 W83795ADG hardware monitoring chip, including manual fan speed
@@ -1274,7 +1294,7 @@ config SENSORS_W83795
1274 1294
1275config SENSORS_W83795_FANCTRL 1295config SENSORS_W83795_FANCTRL
1276 boolean "Include automatic fan control support (DANGEROUS)" 1296 boolean "Include automatic fan control support (DANGEROUS)"
1277 depends on SENSORS_W83795 && EXPERIMENTAL 1297 depends on SENSORS_W83795
1278 default n 1298 default n
1279 help 1299 help
1280 If you say yes here, support for automatic fan speed control 1300 If you say yes here, support for automatic fan speed control
@@ -1291,7 +1311,7 @@ config SENSORS_W83795_FANCTRL
1291 1311
1292config SENSORS_W83L785TS 1312config SENSORS_W83L785TS
1293 tristate "Winbond W83L785TS-S" 1313 tristate "Winbond W83L785TS-S"
1294 depends on I2C && EXPERIMENTAL 1314 depends on I2C
1295 help 1315 help
1296 If you say yes here you get support for the Winbond W83L785TS-S 1316 If you say yes here you get support for the Winbond W83L785TS-S
1297 sensor chip, which is used on the Asus A7N8X, among other 1317 sensor chip, which is used on the Asus A7N8X, among other
@@ -1302,7 +1322,7 @@ config SENSORS_W83L785TS
1302 1322
1303config SENSORS_W83L786NG 1323config SENSORS_W83L786NG
1304 tristate "Winbond W83L786NG, W83L786NR" 1324 tristate "Winbond W83L786NG, W83L786NR"
1305 depends on I2C && EXPERIMENTAL 1325 depends on I2C
1306 help 1326 help
1307 If you say yes here you get support for the Winbond W83L786NG 1327 If you say yes here you get support for the Winbond W83L786NG
1308 and W83L786NR sensor chips. 1328 and W83L786NR sensor chips.
@@ -1417,7 +1437,7 @@ config SENSORS_ACPI_POWER
1417 1437
1418config SENSORS_ATK0110 1438config SENSORS_ATK0110
1419 tristate "ASUS ATK0110" 1439 tristate "ASUS ATK0110"
1420 depends on X86 && EXPERIMENTAL 1440 depends on X86
1421 help 1441 help
1422 If you say yes here you get support for the ACPI hardware 1442 If you say yes here you get support for the ACPI hardware
1423 monitoring interface found in many ASUS motherboards. This 1443 monitoring interface found in many ASUS motherboards. This
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 3eafe483f36a..8d5fcb5e8e9f 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o
34obj-$(CONFIG_SENSORS_ADS1015) += ads1015.o 34obj-$(CONFIG_SENSORS_ADS1015) += ads1015.o
35obj-$(CONFIG_SENSORS_ADS7828) += ads7828.o 35obj-$(CONFIG_SENSORS_ADS7828) += ads7828.o
36obj-$(CONFIG_SENSORS_ADS7871) += ads7871.o 36obj-$(CONFIG_SENSORS_ADS7871) += ads7871.o
37obj-$(CONFIG_SENSORS_ADT7410) += adt7410.o
37obj-$(CONFIG_SENSORS_ADT7411) += adt7411.o 38obj-$(CONFIG_SENSORS_ADT7411) += adt7411.o
38obj-$(CONFIG_SENSORS_ADT7462) += adt7462.o 39obj-$(CONFIG_SENSORS_ADT7462) += adt7462.o
39obj-$(CONFIG_SENSORS_ADT7470) += adt7470.o 40obj-$(CONFIG_SENSORS_ADT7470) += adt7470.o
@@ -93,6 +94,7 @@ obj-$(CONFIG_SENSORS_MAX1111) += max1111.o
93obj-$(CONFIG_SENSORS_MAX16065) += max16065.o 94obj-$(CONFIG_SENSORS_MAX16065) += max16065.o
94obj-$(CONFIG_SENSORS_MAX1619) += max1619.o 95obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
95obj-$(CONFIG_SENSORS_MAX1668) += max1668.o 96obj-$(CONFIG_SENSORS_MAX1668) += max1668.o
97obj-$(CONFIG_SENSORS_MAX197) += max197.o
96obj-$(CONFIG_SENSORS_MAX6639) += max6639.o 98obj-$(CONFIG_SENSORS_MAX6639) += max6639.o
97obj-$(CONFIG_SENSORS_MAX6642) += max6642.o 99obj-$(CONFIG_SENSORS_MAX6642) += max6642.o
98obj-$(CONFIG_SENSORS_MAX6650) += max6650.o 100obj-$(CONFIG_SENSORS_MAX6650) += max6650.o
diff --git a/drivers/hwmon/abituguru.c b/drivers/hwmon/abituguru.c
index d4419b47f3d4..78b81793ddd9 100644
--- a/drivers/hwmon/abituguru.c
+++ b/drivers/hwmon/abituguru.c
@@ -1278,7 +1278,8 @@ static int __devinit abituguru_probe(struct platform_device *pdev)
1278 0x00, 0x01, 0x03, 0x04, 0x0A, 0x08, 0x0E, 0x02, 1278 0x00, 0x01, 0x03, 0x04, 0x0A, 0x08, 0x0E, 0x02,
1279 0x09, 0x06, 0x05, 0x0B, 0x0F, 0x0D, 0x07, 0x0C }; 1279 0x09, 0x06, 0x05, 0x0B, 0x0F, 0x0D, 0x07, 0x0C };
1280 1280
1281 data = kzalloc(sizeof(struct abituguru_data), GFP_KERNEL); 1281 data = devm_kzalloc(&pdev->dev, sizeof(struct abituguru_data),
1282 GFP_KERNEL);
1282 if (!data) 1283 if (!data)
1283 return -ENOMEM; 1284 return -ENOMEM;
1284 1285
@@ -1430,8 +1431,6 @@ abituguru_probe_error:
1430 for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++) 1431 for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++)
1431 device_remove_file(&pdev->dev, 1432 device_remove_file(&pdev->dev,
1432 &abituguru_sysfs_attr[i].dev_attr); 1433 &abituguru_sysfs_attr[i].dev_attr);
1433 platform_set_drvdata(pdev, NULL);
1434 kfree(data);
1435 return res; 1434 return res;
1436} 1435}
1437 1436
@@ -1446,8 +1445,6 @@ static int __devexit abituguru_remove(struct platform_device *pdev)
1446 for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++) 1445 for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++)
1447 device_remove_file(&pdev->dev, 1446 device_remove_file(&pdev->dev,
1448 &abituguru_sysfs_attr[i].dev_attr); 1447 &abituguru_sysfs_attr[i].dev_attr);
1449 platform_set_drvdata(pdev, NULL);
1450 kfree(data);
1451 1448
1452 return 0; 1449 return 0;
1453} 1450}
diff --git a/drivers/hwmon/abituguru3.c b/drivers/hwmon/abituguru3.c
index 5d582aebff87..b174b8b2b4df 100644
--- a/drivers/hwmon/abituguru3.c
+++ b/drivers/hwmon/abituguru3.c
@@ -976,7 +976,8 @@ static int __devinit abituguru3_probe(struct platform_device *pdev)
976 u8 buf[2]; 976 u8 buf[2];
977 u16 id; 977 u16 id;
978 978
979 data = kzalloc(sizeof(struct abituguru3_data), GFP_KERNEL); 979 data = devm_kzalloc(&pdev->dev, sizeof(struct abituguru3_data),
980 GFP_KERNEL);
980 if (!data) 981 if (!data)
981 return -ENOMEM; 982 return -ENOMEM;
982 983
@@ -1068,7 +1069,6 @@ abituguru3_probe_error:
1068 for (i = 0; i < ARRAY_SIZE(abituguru3_sysfs_attr); i++) 1069 for (i = 0; i < ARRAY_SIZE(abituguru3_sysfs_attr); i++)
1069 device_remove_file(&pdev->dev, 1070 device_remove_file(&pdev->dev,
1070 &abituguru3_sysfs_attr[i].dev_attr); 1071 &abituguru3_sysfs_attr[i].dev_attr);
1071 kfree(data);
1072 return res; 1072 return res;
1073} 1073}
1074 1074
@@ -1084,8 +1084,6 @@ static int __devexit abituguru3_remove(struct platform_device *pdev)
1084 for (i = 0; i < ARRAY_SIZE(abituguru3_sysfs_attr); i++) 1084 for (i = 0; i < ARRAY_SIZE(abituguru3_sysfs_attr); i++)
1085 device_remove_file(&pdev->dev, 1085 device_remove_file(&pdev->dev,
1086 &abituguru3_sysfs_attr[i].dev_attr); 1086 &abituguru3_sysfs_attr[i].dev_attr);
1087 kfree(data);
1088
1089 return 0; 1087 return 0;
1090} 1088}
1091 1089
diff --git a/drivers/hwmon/ad7314.c b/drivers/hwmon/ad7314.c
index cfec802cf9ca..37c01e72d699 100644
--- a/drivers/hwmon/ad7314.c
+++ b/drivers/hwmon/ad7314.c
@@ -87,10 +87,18 @@ static ssize_t ad7314_show_temperature(struct device *dev,
87 } 87 }
88} 88}
89 89
90static ssize_t ad7314_show_name(struct device *dev,
91 struct device_attribute *devattr, char *buf)
92{
93 return sprintf(buf, "%s\n", to_spi_device(dev)->modalias);
94}
95
96static DEVICE_ATTR(name, S_IRUGO, ad7314_show_name, NULL);
90static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, 97static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO,
91 ad7314_show_temperature, NULL, 0); 98 ad7314_show_temperature, NULL, 0);
92 99
93static struct attribute *ad7314_attributes[] = { 100static struct attribute *ad7314_attributes[] = {
101 &dev_attr_name.attr,
94 &sensor_dev_attr_temp1_input.dev_attr.attr, 102 &sensor_dev_attr_temp1_input.dev_attr.attr,
95 NULL, 103 NULL,
96}; 104};
@@ -104,16 +112,16 @@ static int __devinit ad7314_probe(struct spi_device *spi_dev)
104 int ret; 112 int ret;
105 struct ad7314_data *chip; 113 struct ad7314_data *chip;
106 114
107 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 115 chip = devm_kzalloc(&spi_dev->dev, sizeof(*chip), GFP_KERNEL);
108 if (chip == NULL) { 116 if (chip == NULL)
109 ret = -ENOMEM; 117 return -ENOMEM;
110 goto error_ret; 118
111 }
112 dev_set_drvdata(&spi_dev->dev, chip); 119 dev_set_drvdata(&spi_dev->dev, chip);
113 120
114 ret = sysfs_create_group(&spi_dev->dev.kobj, &ad7314_group); 121 ret = sysfs_create_group(&spi_dev->dev.kobj, &ad7314_group);
115 if (ret < 0) 122 if (ret < 0)
116 goto error_free_chip; 123 return ret;
124
117 chip->hwmon_dev = hwmon_device_register(&spi_dev->dev); 125 chip->hwmon_dev = hwmon_device_register(&spi_dev->dev);
118 if (IS_ERR(chip->hwmon_dev)) { 126 if (IS_ERR(chip->hwmon_dev)) {
119 ret = PTR_ERR(chip->hwmon_dev); 127 ret = PTR_ERR(chip->hwmon_dev);
@@ -124,9 +132,6 @@ static int __devinit ad7314_probe(struct spi_device *spi_dev)
124 return 0; 132 return 0;
125error_remove_group: 133error_remove_group:
126 sysfs_remove_group(&spi_dev->dev.kobj, &ad7314_group); 134 sysfs_remove_group(&spi_dev->dev.kobj, &ad7314_group);
127error_free_chip:
128 kfree(chip);
129error_ret:
130 return ret; 135 return ret;
131} 136}
132 137
@@ -136,7 +141,6 @@ static int __devexit ad7314_remove(struct spi_device *spi_dev)
136 141
137 hwmon_device_unregister(chip->hwmon_dev); 142 hwmon_device_unregister(chip->hwmon_dev);
138 sysfs_remove_group(&spi_dev->dev.kobj, &ad7314_group); 143 sysfs_remove_group(&spi_dev->dev.kobj, &ad7314_group);
139 kfree(chip);
140 144
141 return 0; 145 return 0;
142} 146}
diff --git a/drivers/hwmon/ad7414.c b/drivers/hwmon/ad7414.c
index 06d2d60d1fd0..b420fb3f3a71 100644
--- a/drivers/hwmon/ad7414.c
+++ b/drivers/hwmon/ad7414.c
@@ -185,16 +185,13 @@ static int ad7414_probe(struct i2c_client *client,
185 int err; 185 int err;
186 186
187 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA | 187 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA |
188 I2C_FUNC_SMBUS_READ_WORD_DATA)) { 188 I2C_FUNC_SMBUS_READ_WORD_DATA))
189 err = -EOPNOTSUPP; 189 return -EOPNOTSUPP;
190 goto exit;
191 }
192 190
193 data = kzalloc(sizeof(struct ad7414_data), GFP_KERNEL); 191 data = devm_kzalloc(&client->dev, sizeof(struct ad7414_data),
194 if (!data) { 192 GFP_KERNEL);
195 err = -ENOMEM; 193 if (!data)
196 goto exit; 194 return -ENOMEM;
197 }
198 195
199 i2c_set_clientdata(client, data); 196 i2c_set_clientdata(client, data);
200 mutex_init(&data->lock); 197 mutex_init(&data->lock);
@@ -214,7 +211,7 @@ static int ad7414_probe(struct i2c_client *client,
214 /* Register sysfs hooks */ 211 /* Register sysfs hooks */
215 err = sysfs_create_group(&client->dev.kobj, &ad7414_group); 212 err = sysfs_create_group(&client->dev.kobj, &ad7414_group);
216 if (err) 213 if (err)
217 goto exit_free; 214 return err;
218 215
219 data->hwmon_dev = hwmon_device_register(&client->dev); 216 data->hwmon_dev = hwmon_device_register(&client->dev);
220 if (IS_ERR(data->hwmon_dev)) { 217 if (IS_ERR(data->hwmon_dev)) {
@@ -226,9 +223,6 @@ static int ad7414_probe(struct i2c_client *client,
226 223
227exit_remove: 224exit_remove:
228 sysfs_remove_group(&client->dev.kobj, &ad7414_group); 225 sysfs_remove_group(&client->dev.kobj, &ad7414_group);
229exit_free:
230 kfree(data);
231exit:
232 return err; 226 return err;
233} 227}
234 228
@@ -238,7 +232,6 @@ static int __devexit ad7414_remove(struct i2c_client *client)
238 232
239 hwmon_device_unregister(data->hwmon_dev); 233 hwmon_device_unregister(data->hwmon_dev);
240 sysfs_remove_group(&client->dev.kobj, &ad7414_group); 234 sysfs_remove_group(&client->dev.kobj, &ad7414_group);
241 kfree(data);
242 return 0; 235 return 0;
243} 236}
244 237
diff --git a/drivers/hwmon/ad7418.c b/drivers/hwmon/ad7418.c
index a50a6bef16c4..57d4a6295675 100644
--- a/drivers/hwmon/ad7418.c
+++ b/drivers/hwmon/ad7418.c
@@ -227,16 +227,13 @@ static int ad7418_probe(struct i2c_client *client,
227 int err; 227 int err;
228 228
229 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | 229 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
230 I2C_FUNC_SMBUS_WORD_DATA)) { 230 I2C_FUNC_SMBUS_WORD_DATA))
231 err = -EOPNOTSUPP; 231 return -EOPNOTSUPP;
232 goto exit;
233 }
234 232
235 data = kzalloc(sizeof(struct ad7418_data), GFP_KERNEL); 233 data = devm_kzalloc(&client->dev, sizeof(struct ad7418_data),
236 if (!data) { 234 GFP_KERNEL);
237 err = -ENOMEM; 235 if (!data)
238 goto exit; 236 return -ENOMEM;
239 }
240 237
241 i2c_set_clientdata(client, data); 238 i2c_set_clientdata(client, data);
242 239
@@ -268,7 +265,7 @@ static int ad7418_probe(struct i2c_client *client,
268 /* Register sysfs hooks */ 265 /* Register sysfs hooks */
269 err = sysfs_create_group(&client->dev.kobj, &data->attrs); 266 err = sysfs_create_group(&client->dev.kobj, &data->attrs);
270 if (err) 267 if (err)
271 goto exit_free; 268 return err;
272 269
273 data->hwmon_dev = hwmon_device_register(&client->dev); 270 data->hwmon_dev = hwmon_device_register(&client->dev);
274 if (IS_ERR(data->hwmon_dev)) { 271 if (IS_ERR(data->hwmon_dev)) {
@@ -280,9 +277,6 @@ static int ad7418_probe(struct i2c_client *client,
280 277
281exit_remove: 278exit_remove:
282 sysfs_remove_group(&client->dev.kobj, &data->attrs); 279 sysfs_remove_group(&client->dev.kobj, &data->attrs);
283exit_free:
284 kfree(data);
285exit:
286 return err; 280 return err;
287} 281}
288 282
@@ -291,7 +285,6 @@ static int ad7418_remove(struct i2c_client *client)
291 struct ad7418_data *data = i2c_get_clientdata(client); 285 struct ad7418_data *data = i2c_get_clientdata(client);
292 hwmon_device_unregister(data->hwmon_dev); 286 hwmon_device_unregister(data->hwmon_dev);
293 sysfs_remove_group(&client->dev.kobj, &data->attrs); 287 sysfs_remove_group(&client->dev.kobj, &data->attrs);
294 kfree(data);
295 return 0; 288 return 0;
296} 289}
297 290
diff --git a/drivers/hwmon/adcxx.c b/drivers/hwmon/adcxx.c
index a3d3183454ad..f4c5867170d6 100644
--- a/drivers/hwmon/adcxx.c
+++ b/drivers/hwmon/adcxx.c
@@ -141,10 +141,7 @@ static ssize_t adcxx_set_max(struct device *dev,
141static ssize_t adcxx_show_name(struct device *dev, struct device_attribute 141static ssize_t adcxx_show_name(struct device *dev, struct device_attribute
142 *devattr, char *buf) 142 *devattr, char *buf)
143{ 143{
144 struct spi_device *spi = to_spi_device(dev); 144 return sprintf(buf, "%s\n", to_spi_device(dev)->modalias);
145 struct adcxx *adc = spi_get_drvdata(spi);
146
147 return sprintf(buf, "adcxx%ds\n", adc->channels);
148} 145}
149 146
150static struct sensor_device_attribute ad_input[] = { 147static struct sensor_device_attribute ad_input[] = {
@@ -171,7 +168,7 @@ static int __devinit adcxx_probe(struct spi_device *spi)
171 int status; 168 int status;
172 int i; 169 int i;
173 170
174 adc = kzalloc(sizeof *adc, GFP_KERNEL); 171 adc = devm_kzalloc(&spi->dev, sizeof(*adc), GFP_KERNEL);
175 if (!adc) 172 if (!adc)
176 return -ENOMEM; 173 return -ENOMEM;
177 174
@@ -208,7 +205,6 @@ out_err:
208 205
209 spi_set_drvdata(spi, NULL); 206 spi_set_drvdata(spi, NULL);
210 mutex_unlock(&adc->lock); 207 mutex_unlock(&adc->lock);
211 kfree(adc);
212 return status; 208 return status;
213} 209}
214 210
@@ -224,7 +220,6 @@ static int __devexit adcxx_remove(struct spi_device *spi)
224 220
225 spi_set_drvdata(spi, NULL); 221 spi_set_drvdata(spi, NULL);
226 mutex_unlock(&adc->lock); 222 mutex_unlock(&adc->lock);
227 kfree(adc);
228 223
229 return 0; 224 return 0;
230} 225}
diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c
index 80cc465d8ac7..97f4718382f6 100644
--- a/drivers/hwmon/adm1029.c
+++ b/drivers/hwmon/adm1029.c
@@ -342,11 +342,10 @@ static int adm1029_probe(struct i2c_client *client,
342 struct adm1029_data *data; 342 struct adm1029_data *data;
343 int err; 343 int err;
344 344
345 data = kzalloc(sizeof(struct adm1029_data), GFP_KERNEL); 345 data = devm_kzalloc(&client->dev, sizeof(struct adm1029_data),
346 if (!data) { 346 GFP_KERNEL);
347 err = -ENOMEM; 347 if (!data)
348 goto exit; 348 return -ENOMEM;
349 }
350 349
351 i2c_set_clientdata(client, data); 350 i2c_set_clientdata(client, data);
352 mutex_init(&data->update_lock); 351 mutex_init(&data->update_lock);
@@ -355,15 +354,13 @@ static int adm1029_probe(struct i2c_client *client,
355 * Initialize the ADM1029 chip 354 * Initialize the ADM1029 chip
356 * Check config register 355 * Check config register
357 */ 356 */
358 if (adm1029_init_client(client) == 0) { 357 if (adm1029_init_client(client) == 0)
359 err = -ENODEV; 358 return -ENODEV;
360 goto exit_free;
361 }
362 359
363 /* Register sysfs hooks */ 360 /* Register sysfs hooks */
364 err = sysfs_create_group(&client->dev.kobj, &adm1029_group); 361 err = sysfs_create_group(&client->dev.kobj, &adm1029_group);
365 if (err) 362 if (err)
366 goto exit_free; 363 return err;
367 364
368 data->hwmon_dev = hwmon_device_register(&client->dev); 365 data->hwmon_dev = hwmon_device_register(&client->dev);
369 if (IS_ERR(data->hwmon_dev)) { 366 if (IS_ERR(data->hwmon_dev)) {
@@ -375,9 +372,6 @@ static int adm1029_probe(struct i2c_client *client,
375 372
376 exit_remove_files: 373 exit_remove_files:
377 sysfs_remove_group(&client->dev.kobj, &adm1029_group); 374 sysfs_remove_group(&client->dev.kobj, &adm1029_group);
378 exit_free:
379 kfree(data);
380 exit:
381 return err; 375 return err;
382} 376}
383 377
@@ -405,7 +399,6 @@ static int adm1029_remove(struct i2c_client *client)
405 hwmon_device_unregister(data->hwmon_dev); 399 hwmon_device_unregister(data->hwmon_dev);
406 sysfs_remove_group(&client->dev.kobj, &adm1029_group); 400 sysfs_remove_group(&client->dev.kobj, &adm1029_group);
407 401
408 kfree(data);
409 return 0; 402 return 0;
410} 403}
411 404
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
index 5a78d102a0fa..8b24d1a4a2b4 100644
--- a/drivers/hwmon/adm9240.c
+++ b/drivers/hwmon/adm9240.c
@@ -500,31 +500,6 @@ static ssize_t set_aout(struct device *dev,
500} 500}
501static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); 501static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);
502 502
503/* chassis_clear */
504static ssize_t chassis_clear_legacy(struct device *dev,
505 struct device_attribute *attr,
506 const char *buf, size_t count)
507{
508 struct i2c_client *client = to_i2c_client(dev);
509 long val;
510 int err;
511
512 err = kstrtol(buf, 10, &val);
513 if (err)
514 return err;
515
516 dev_warn(dev, "Attribute chassis_clear is deprecated, "
517 "use intrusion0_alarm instead\n");
518
519 if (val == 1) {
520 i2c_smbus_write_byte_data(client,
521 ADM9240_REG_CHASSIS_CLEAR, 0x80);
522 dev_dbg(&client->dev, "chassis intrusion latch cleared\n");
523 }
524 return count;
525}
526static DEVICE_ATTR(chassis_clear, S_IWUSR, NULL, chassis_clear_legacy);
527
528static ssize_t chassis_clear(struct device *dev, 503static ssize_t chassis_clear(struct device *dev,
529 struct device_attribute *attr, 504 struct device_attribute *attr,
530 const char *buf, size_t count) 505 const char *buf, size_t count)
@@ -586,7 +561,6 @@ static struct attribute *adm9240_attributes[] = {
586 &sensor_dev_attr_fan2_alarm.dev_attr.attr, 561 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
587 &dev_attr_alarms.attr, 562 &dev_attr_alarms.attr,
588 &dev_attr_aout_output.attr, 563 &dev_attr_aout_output.attr,
589 &dev_attr_chassis_clear.attr,
590 &sensor_dev_attr_intrusion0_alarm.dev_attr.attr, 564 &sensor_dev_attr_intrusion0_alarm.dev_attr.attr,
591 &dev_attr_cpu0_vid.attr, 565 &dev_attr_cpu0_vid.attr,
592 NULL 566 NULL
diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c
index 1958f03efd7a..2798246ad814 100644
--- a/drivers/hwmon/ads1015.c
+++ b/drivers/hwmon/ads1015.c
@@ -156,7 +156,6 @@ static int ads1015_remove(struct i2c_client *client)
156 hwmon_device_unregister(data->hwmon_dev); 156 hwmon_device_unregister(data->hwmon_dev);
157 for (k = 0; k < ADS1015_CHANNELS; ++k) 157 for (k = 0; k < ADS1015_CHANNELS; ++k)
158 device_remove_file(&client->dev, &ads1015_in[k].dev_attr); 158 device_remove_file(&client->dev, &ads1015_in[k].dev_attr);
159 kfree(data);
160 return 0; 159 return 0;
161} 160}
162 161
@@ -254,11 +253,10 @@ static int ads1015_probe(struct i2c_client *client,
254 int err; 253 int err;
255 unsigned int k; 254 unsigned int k;
256 255
257 data = kzalloc(sizeof(struct ads1015_data), GFP_KERNEL); 256 data = devm_kzalloc(&client->dev, sizeof(struct ads1015_data),
258 if (!data) { 257 GFP_KERNEL);
259 err = -ENOMEM; 258 if (!data)
260 goto exit; 259 return -ENOMEM;
261 }
262 260
263 i2c_set_clientdata(client, data); 261 i2c_set_clientdata(client, data);
264 mutex_init(&data->update_lock); 262 mutex_init(&data->update_lock);
@@ -284,8 +282,6 @@ static int ads1015_probe(struct i2c_client *client,
284exit_remove: 282exit_remove:
285 for (k = 0; k < ADS1015_CHANNELS; ++k) 283 for (k = 0; k < ADS1015_CHANNELS; ++k)
286 device_remove_file(&client->dev, &ads1015_in[k].dev_attr); 284 device_remove_file(&client->dev, &ads1015_in[k].dev_attr);
287 kfree(data);
288exit:
289 return err; 285 return err;
290} 286}
291 287
diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c
index bf3fdf495595..1f9e8af0f322 100644
--- a/drivers/hwmon/ads7828.c
+++ b/drivers/hwmon/ads7828.c
@@ -154,7 +154,6 @@ static int ads7828_remove(struct i2c_client *client)
154 struct ads7828_data *data = i2c_get_clientdata(client); 154 struct ads7828_data *data = i2c_get_clientdata(client);
155 hwmon_device_unregister(data->hwmon_dev); 155 hwmon_device_unregister(data->hwmon_dev);
156 sysfs_remove_group(&client->dev.kobj, &ads7828_group); 156 sysfs_remove_group(&client->dev.kobj, &ads7828_group);
157 kfree(i2c_get_clientdata(client));
158 return 0; 157 return 0;
159} 158}
160 159
@@ -217,11 +216,10 @@ static int ads7828_probe(struct i2c_client *client,
217 struct ads7828_data *data; 216 struct ads7828_data *data;
218 int err; 217 int err;
219 218
220 data = kzalloc(sizeof(struct ads7828_data), GFP_KERNEL); 219 data = devm_kzalloc(&client->dev, sizeof(struct ads7828_data),
221 if (!data) { 220 GFP_KERNEL);
222 err = -ENOMEM; 221 if (!data)
223 goto exit; 222 return -ENOMEM;
224 }
225 223
226 i2c_set_clientdata(client, data); 224 i2c_set_clientdata(client, data);
227 mutex_init(&data->update_lock); 225 mutex_init(&data->update_lock);
@@ -229,7 +227,7 @@ static int ads7828_probe(struct i2c_client *client,
229 /* Register sysfs hooks */ 227 /* Register sysfs hooks */
230 err = sysfs_create_group(&client->dev.kobj, &ads7828_group); 228 err = sysfs_create_group(&client->dev.kobj, &ads7828_group);
231 if (err) 229 if (err)
232 goto exit_free; 230 return err;
233 231
234 data->hwmon_dev = hwmon_device_register(&client->dev); 232 data->hwmon_dev = hwmon_device_register(&client->dev);
235 if (IS_ERR(data->hwmon_dev)) { 233 if (IS_ERR(data->hwmon_dev)) {
@@ -241,9 +239,6 @@ static int ads7828_probe(struct i2c_client *client,
241 239
242exit_remove: 240exit_remove:
243 sysfs_remove_group(&client->dev.kobj, &ads7828_group); 241 sysfs_remove_group(&client->dev.kobj, &ads7828_group);
244exit_free:
245 kfree(data);
246exit:
247 return err; 242 return err;
248} 243}
249 244
diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
index e65c6e45d36b..1b53aa42b6db 100644
--- a/drivers/hwmon/ads7871.c
+++ b/drivers/hwmon/ads7871.c
@@ -139,6 +139,12 @@ static ssize_t show_voltage(struct device *dev,
139 } 139 }
140} 140}
141 141
142static ssize_t ads7871_show_name(struct device *dev,
143 struct device_attribute *devattr, char *buf)
144{
145 return sprintf(buf, "%s\n", to_spi_device(dev)->modalias);
146}
147
142static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_voltage, NULL, 0); 148static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_voltage, NULL, 0);
143static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_voltage, NULL, 1); 149static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_voltage, NULL, 1);
144static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_voltage, NULL, 2); 150static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_voltage, NULL, 2);
@@ -148,6 +154,8 @@ static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_voltage, NULL, 5);
148static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_voltage, NULL, 6); 154static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_voltage, NULL, 6);
149static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_voltage, NULL, 7); 155static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_voltage, NULL, 7);
150 156
157static DEVICE_ATTR(name, S_IRUGO, ads7871_show_name, NULL);
158
151static struct attribute *ads7871_attributes[] = { 159static struct attribute *ads7871_attributes[] = {
152 &sensor_dev_attr_in0_input.dev_attr.attr, 160 &sensor_dev_attr_in0_input.dev_attr.attr,
153 &sensor_dev_attr_in1_input.dev_attr.attr, 161 &sensor_dev_attr_in1_input.dev_attr.attr,
@@ -157,6 +165,7 @@ static struct attribute *ads7871_attributes[] = {
157 &sensor_dev_attr_in5_input.dev_attr.attr, 165 &sensor_dev_attr_in5_input.dev_attr.attr,
158 &sensor_dev_attr_in6_input.dev_attr.attr, 166 &sensor_dev_attr_in6_input.dev_attr.attr,
159 &sensor_dev_attr_in7_input.dev_attr.attr, 167 &sensor_dev_attr_in7_input.dev_attr.attr,
168 &dev_attr_name.attr,
160 NULL 169 NULL
161}; 170};
162 171
@@ -189,20 +198,17 @@ static int __devinit ads7871_probe(struct spi_device *spi)
189 * because there is no other error checking on an SPI bus 198 * because there is no other error checking on an SPI bus
190 * we need to make sure we really have a chip 199 * we need to make sure we really have a chip
191 */ 200 */
192 if (val != ret) { 201 if (val != ret)
193 err = -ENODEV; 202 return -ENODEV;
194 goto exit;
195 }
196 203
197 pdata = kzalloc(sizeof(struct ads7871_data), GFP_KERNEL); 204 pdata = devm_kzalloc(&spi->dev, sizeof(struct ads7871_data),
198 if (!pdata) { 205 GFP_KERNEL);
199 err = -ENOMEM; 206 if (!pdata)
200 goto exit; 207 return -ENOMEM;
201 }
202 208
203 err = sysfs_create_group(&spi->dev.kobj, &ads7871_group); 209 err = sysfs_create_group(&spi->dev.kobj, &ads7871_group);
204 if (err < 0) 210 if (err < 0)
205 goto error_free; 211 return err;
206 212
207 spi_set_drvdata(spi, pdata); 213 spi_set_drvdata(spi, pdata);
208 214
@@ -216,9 +222,6 @@ static int __devinit ads7871_probe(struct spi_device *spi)
216 222
217error_remove: 223error_remove:
218 sysfs_remove_group(&spi->dev.kobj, &ads7871_group); 224 sysfs_remove_group(&spi->dev.kobj, &ads7871_group);
219error_free:
220 kfree(pdata);
221exit:
222 return err; 225 return err;
223} 226}
224 227
@@ -228,7 +231,6 @@ static int __devexit ads7871_remove(struct spi_device *spi)
228 231
229 hwmon_device_unregister(pdata->hwmon_dev); 232 hwmon_device_unregister(pdata->hwmon_dev);
230 sysfs_remove_group(&spi->dev.kobj, &ads7871_group); 233 sysfs_remove_group(&spi->dev.kobj, &ads7871_group);
231 kfree(pdata);
232 return 0; 234 return 0;
233} 235}
234 236
diff --git a/drivers/hwmon/adt7410.c b/drivers/hwmon/adt7410.c
new file mode 100644
index 000000000000..030c8d7c33a5
--- /dev/null
+++ b/drivers/hwmon/adt7410.c
@@ -0,0 +1,464 @@
1/*
2 * adt7410.c - Part of lm_sensors, Linux kernel modules for hardware
3 * monitoring
4 * This driver handles the ADT7410 and compatible digital temperature sensors.
5 * Hartmut Knaack <knaack.h@gmx.de> 2012-07-22
6 * based on lm75.c by Frodo Looijaard <frodol@dds.nl>
7 * and adt7410.c from iio-staging by Sonic Zhang <sonic.zhang@analog.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#include <linux/module.h>
25#include <linux/init.h>
26#include <linux/slab.h>
27#include <linux/jiffies.h>
28#include <linux/i2c.h>
29#include <linux/hwmon.h>
30#include <linux/hwmon-sysfs.h>
31#include <linux/err.h>
32#include <linux/mutex.h>
33#include <linux/delay.h>
34
35/*
36 * ADT7410 registers definition
37 */
38
39#define ADT7410_TEMPERATURE 0
40#define ADT7410_STATUS 2
41#define ADT7410_CONFIG 3
42#define ADT7410_T_ALARM_HIGH 4
43#define ADT7410_T_ALARM_LOW 6
44#define ADT7410_T_CRIT 8
45#define ADT7410_T_HYST 0xA
46
47/*
48 * ADT7410 status
49 */
50#define ADT7410_STAT_T_LOW (1 << 4)
51#define ADT7410_STAT_T_HIGH (1 << 5)
52#define ADT7410_STAT_T_CRIT (1 << 6)
53#define ADT7410_STAT_NOT_RDY (1 << 7)
54
55/*
56 * ADT7410 config
57 */
58#define ADT7410_FAULT_QUEUE_MASK (1 << 0 | 1 << 1)
59#define ADT7410_CT_POLARITY (1 << 2)
60#define ADT7410_INT_POLARITY (1 << 3)
61#define ADT7410_EVENT_MODE (1 << 4)
62#define ADT7410_MODE_MASK (1 << 5 | 1 << 6)
63#define ADT7410_FULL (0 << 5 | 0 << 6)
64#define ADT7410_PD (1 << 5 | 1 << 6)
65#define ADT7410_RESOLUTION (1 << 7)
66
67/*
68 * ADT7410 masks
69 */
70#define ADT7410_T13_VALUE_MASK 0xFFF8
71#define ADT7410_T_HYST_MASK 0xF
72
73/* straight from the datasheet */
74#define ADT7410_TEMP_MIN (-55000)
75#define ADT7410_TEMP_MAX 150000
76
77enum adt7410_type { /* keep sorted in alphabetical order */
78 adt7410,
79};
80
81/* Addresses scanned */
82static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b,
83 I2C_CLIENT_END };
84
85static const u8 ADT7410_REG_TEMP[4] = {
86 ADT7410_TEMPERATURE, /* input */
87 ADT7410_T_ALARM_HIGH, /* high */
88 ADT7410_T_ALARM_LOW, /* low */
89 ADT7410_T_CRIT, /* critical */
90};
91
92/* Each client has this additional data */
93struct adt7410_data {
94 struct device *hwmon_dev;
95 struct mutex update_lock;
96 u8 config;
97 u8 oldconfig;
98 bool valid; /* true if registers valid */
99 unsigned long last_updated; /* In jiffies */
100 s16 temp[4]; /* Register values,
101 0 = input
102 1 = high
103 2 = low
104 3 = critical */
105 u8 hyst; /* hysteresis offset */
106};
107
108/*
109 * adt7410 register access by I2C
110 */
111static int adt7410_temp_ready(struct i2c_client *client)
112{
113 int i, status;
114
115 for (i = 0; i < 6; i++) {
116 status = i2c_smbus_read_byte_data(client, ADT7410_STATUS);
117 if (status < 0)
118 return status;
119 if (!(status & ADT7410_STAT_NOT_RDY))
120 return 0;
121 msleep(60);
122 }
123 return -ETIMEDOUT;
124}
125
126static struct adt7410_data *adt7410_update_device(struct device *dev)
127{
128 struct i2c_client *client = to_i2c_client(dev);
129 struct adt7410_data *data = i2c_get_clientdata(client);
130 struct adt7410_data *ret = data;
131 mutex_lock(&data->update_lock);
132
133 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
134 || !data->valid) {
135 int i, status;
136
137 dev_dbg(&client->dev, "Starting update\n");
138
139 status = adt7410_temp_ready(client); /* check for new value */
140 if (unlikely(status)) {
141 ret = ERR_PTR(status);
142 goto abort;
143 }
144 for (i = 0; i < ARRAY_SIZE(data->temp); i++) {
145 status = i2c_smbus_read_word_swapped(client,
146 ADT7410_REG_TEMP[i]);
147 if (unlikely(status < 0)) {
148 dev_dbg(dev,
149 "Failed to read value: reg %d, error %d\n",
150 ADT7410_REG_TEMP[i], status);
151 ret = ERR_PTR(status);
152 goto abort;
153 }
154 data->temp[i] = status;
155 }
156 status = i2c_smbus_read_byte_data(client, ADT7410_T_HYST);
157 if (unlikely(status < 0)) {
158 dev_dbg(dev,
159 "Failed to read value: reg %d, error %d\n",
160 ADT7410_T_HYST, status);
161 ret = ERR_PTR(status);
162 goto abort;
163 }
164 data->hyst = status;
165 data->last_updated = jiffies;
166 data->valid = true;
167 }
168
169abort:
170 mutex_unlock(&data->update_lock);
171 return ret;
172}
173
174static s16 ADT7410_TEMP_TO_REG(long temp)
175{
176 return DIV_ROUND_CLOSEST(SENSORS_LIMIT(temp, ADT7410_TEMP_MIN,
177 ADT7410_TEMP_MAX) * 128, 1000);
178}
179
180static int ADT7410_REG_TO_TEMP(struct adt7410_data *data, s16 reg)
181{
182 /* in 13 bit mode, bits 0-2 are status flags - mask them out */
183 if (!(data->config & ADT7410_RESOLUTION))
184 reg &= ADT7410_T13_VALUE_MASK;
185 /*
186 * temperature is stored in twos complement format, in steps of
187 * 1/128°C
188 */
189 return DIV_ROUND_CLOSEST(reg * 1000, 128);
190}
191
192/*-----------------------------------------------------------------------*/
193
194/* sysfs attributes for hwmon */
195
196static ssize_t adt7410_show_temp(struct device *dev,
197 struct device_attribute *da, char *buf)
198{
199 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
200 struct adt7410_data *data = adt7410_update_device(dev);
201
202 if (IS_ERR(data))
203 return PTR_ERR(data);
204
205 return sprintf(buf, "%d\n", ADT7410_REG_TO_TEMP(data,
206 data->temp[attr->index]));
207}
208
209static ssize_t adt7410_set_temp(struct device *dev,
210 struct device_attribute *da,
211 const char *buf, size_t count)
212{
213 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
214 struct i2c_client *client = to_i2c_client(dev);
215 struct adt7410_data *data = i2c_get_clientdata(client);
216 int nr = attr->index;
217 long temp;
218 int ret;
219
220 ret = kstrtol(buf, 10, &temp);
221 if (ret)
222 return ret;
223
224 mutex_lock(&data->update_lock);
225 data->temp[nr] = ADT7410_TEMP_TO_REG(temp);
226 ret = i2c_smbus_write_word_swapped(client, ADT7410_REG_TEMP[nr],
227 data->temp[nr]);
228 if (ret)
229 count = ret;
230 mutex_unlock(&data->update_lock);
231 return count;
232}
233
234static ssize_t adt7410_show_t_hyst(struct device *dev,
235 struct device_attribute *da,
236 char *buf)
237{
238 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
239 struct adt7410_data *data;
240 int nr = attr->index;
241 int hyst;
242
243 data = adt7410_update_device(dev);
244 if (IS_ERR(data))
245 return PTR_ERR(data);
246 hyst = (data->hyst & ADT7410_T_HYST_MASK) * 1000;
247
248 /*
249 * hysteresis is stored as a 4 bit offset in the device, convert it
250 * to an absolute value
251 */
252 if (nr == 2) /* min has positive offset, others have negative */
253 hyst = -hyst;
254 return sprintf(buf, "%d\n",
255 ADT7410_REG_TO_TEMP(data, data->temp[nr]) - hyst);
256}
257
258static ssize_t adt7410_set_t_hyst(struct device *dev,
259 struct device_attribute *da,
260 const char *buf, size_t count)
261{
262 struct i2c_client *client = to_i2c_client(dev);
263 struct adt7410_data *data = i2c_get_clientdata(client);
264 int limit, ret;
265 long hyst;
266
267 ret = kstrtol(buf, 10, &hyst);
268 if (ret)
269 return ret;
270 /* convert absolute hysteresis value to a 4 bit delta value */
271 limit = ADT7410_REG_TO_TEMP(data, data->temp[1]);
272 hyst = SENSORS_LIMIT(hyst, ADT7410_TEMP_MIN, ADT7410_TEMP_MAX);
273 data->hyst = SENSORS_LIMIT(DIV_ROUND_CLOSEST(limit - hyst, 1000),
274 0, ADT7410_T_HYST_MASK);
275 ret = i2c_smbus_write_byte_data(client, ADT7410_T_HYST, data->hyst);
276 if (ret)
277 return ret;
278
279 return count;
280}
281
282static ssize_t adt7410_show_alarm(struct device *dev,
283 struct device_attribute *da,
284 char *buf)
285{
286 struct i2c_client *client = to_i2c_client(dev);
287 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
288 int ret;
289
290 ret = i2c_smbus_read_byte_data(client, ADT7410_STATUS);
291 if (ret < 0)
292 return ret;
293
294 return sprintf(buf, "%d\n", !!(ret & attr->index));
295}
296
297static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, adt7410_show_temp, NULL, 0);
298static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO,
299 adt7410_show_temp, adt7410_set_temp, 1);
300static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO,
301 adt7410_show_temp, adt7410_set_temp, 2);
302static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO,
303 adt7410_show_temp, adt7410_set_temp, 3);
304static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO,
305 adt7410_show_t_hyst, adt7410_set_t_hyst, 1);
306static SENSOR_DEVICE_ATTR(temp1_min_hyst, S_IRUGO,
307 adt7410_show_t_hyst, NULL, 2);
308static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO,
309 adt7410_show_t_hyst, NULL, 3);
310static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, adt7410_show_alarm,
311 NULL, ADT7410_STAT_T_LOW);
312static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, adt7410_show_alarm,
313 NULL, ADT7410_STAT_T_HIGH);
314static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, adt7410_show_alarm,
315 NULL, ADT7410_STAT_T_CRIT);
316
317static struct attribute *adt7410_attributes[] = {
318 &sensor_dev_attr_temp1_input.dev_attr.attr,
319 &sensor_dev_attr_temp1_max.dev_attr.attr,
320 &sensor_dev_attr_temp1_min.dev_attr.attr,
321 &sensor_dev_attr_temp1_crit.dev_attr.attr,
322 &sensor_dev_attr_temp1_max_hyst.dev_attr.attr,
323 &sensor_dev_attr_temp1_min_hyst.dev_attr.attr,
324 &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr,
325 &sensor_dev_attr_temp1_min_alarm.dev_attr.attr,
326 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
327 &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr,
328 NULL
329};
330
331static const struct attribute_group adt7410_group = {
332 .attrs = adt7410_attributes,
333};
334
335/*-----------------------------------------------------------------------*/
336
337/* device probe and removal */
338
339static int adt7410_probe(struct i2c_client *client,
340 const struct i2c_device_id *id)
341{
342 struct adt7410_data *data;
343 int ret;
344
345 if (!i2c_check_functionality(client->adapter,
346 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
347 return -ENODEV;
348
349 data = devm_kzalloc(&client->dev, sizeof(struct adt7410_data),
350 GFP_KERNEL);
351 if (!data)
352 return -ENOMEM;
353
354 i2c_set_clientdata(client, data);
355 mutex_init(&data->update_lock);
356
357 /* configure as specified */
358 ret = i2c_smbus_read_byte_data(client, ADT7410_CONFIG);
359 if (ret < 0) {
360 dev_dbg(&client->dev, "Can't read config? %d\n", ret);
361 return ret;
362 }
363 data->oldconfig = ret;
364 /*
365 * Set to 16 bit resolution, continous conversion and comparator mode.
366 */
367 data->config = ret | ADT7410_FULL | ADT7410_RESOLUTION |
368 ADT7410_EVENT_MODE;
369 if (data->config != data->oldconfig) {
370 ret = i2c_smbus_write_byte_data(client, ADT7410_CONFIG,
371 data->config);
372 if (ret)
373 return ret;
374 }
375 dev_dbg(&client->dev, "Config %02x\n", data->config);
376
377 /* Register sysfs hooks */
378 ret = sysfs_create_group(&client->dev.kobj, &adt7410_group);
379 if (ret)
380 goto exit_restore;
381
382 data->hwmon_dev = hwmon_device_register(&client->dev);
383 if (IS_ERR(data->hwmon_dev)) {
384 ret = PTR_ERR(data->hwmon_dev);
385 goto exit_remove;
386 }
387
388 dev_info(&client->dev, "sensor '%s'\n", client->name);
389
390 return 0;
391
392exit_remove:
393 sysfs_remove_group(&client->dev.kobj, &adt7410_group);
394exit_restore:
395 i2c_smbus_write_byte_data(client, ADT7410_CONFIG, data->oldconfig);
396 return ret;
397}
398
399static int adt7410_remove(struct i2c_client *client)
400{
401 struct adt7410_data *data = i2c_get_clientdata(client);
402
403 hwmon_device_unregister(data->hwmon_dev);
404 sysfs_remove_group(&client->dev.kobj, &adt7410_group);
405 if (data->oldconfig != data->config)
406 i2c_smbus_write_byte_data(client, ADT7410_CONFIG,
407 data->oldconfig);
408 return 0;
409}
410
411static const struct i2c_device_id adt7410_ids[] = {
412 { "adt7410", adt7410, },
413 { /* LIST END */ }
414};
415MODULE_DEVICE_TABLE(i2c, adt7410_ids);
416
417#ifdef CONFIG_PM
418static int adt7410_suspend(struct device *dev)
419{
420 int ret;
421 struct i2c_client *client = to_i2c_client(dev);
422 struct adt7410_data *data = i2c_get_clientdata(client);
423
424 ret = i2c_smbus_write_byte_data(client, ADT7410_CONFIG,
425 data->config | ADT7410_PD);
426 return ret;
427}
428
429static int adt7410_resume(struct device *dev)
430{
431 int ret;
432 struct i2c_client *client = to_i2c_client(dev);
433 struct adt7410_data *data = i2c_get_clientdata(client);
434
435 ret = i2c_smbus_write_byte_data(client, ADT7410_CONFIG, data->config);
436 return ret;
437}
438
439static const struct dev_pm_ops adt7410_dev_pm_ops = {
440 .suspend = adt7410_suspend,
441 .resume = adt7410_resume,
442};
443#define ADT7410_DEV_PM_OPS (&adt7410_dev_pm_ops)
444#else
445#define ADT7410_DEV_PM_OPS NULL
446#endif /* CONFIG_PM */
447
448static struct i2c_driver adt7410_driver = {
449 .class = I2C_CLASS_HWMON,
450 .driver = {
451 .name = "adt7410",
452 .pm = ADT7410_DEV_PM_OPS,
453 },
454 .probe = adt7410_probe,
455 .remove = adt7410_remove,
456 .id_table = adt7410_ids,
457 .address_list = normal_i2c,
458};
459
460module_i2c_driver(adt7410_driver);
461
462MODULE_AUTHOR("Hartmut Knaack");
463MODULE_DESCRIPTION("ADT7410 driver");
464MODULE_LICENSE("GPL");
diff --git a/drivers/hwmon/adt7411.c b/drivers/hwmon/adt7411.c
index 71bacc56e138..fe72c69a2d68 100644
--- a/drivers/hwmon/adt7411.c
+++ b/drivers/hwmon/adt7411.c
@@ -283,7 +283,7 @@ static int __devinit adt7411_probe(struct i2c_client *client,
283 struct adt7411_data *data; 283 struct adt7411_data *data;
284 int ret; 284 int ret;
285 285
286 data = kzalloc(sizeof(*data), GFP_KERNEL); 286 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
287 if (!data) 287 if (!data)
288 return -ENOMEM; 288 return -ENOMEM;
289 289
@@ -294,14 +294,14 @@ static int __devinit adt7411_probe(struct i2c_client *client,
294 ret = adt7411_modify_bit(client, ADT7411_REG_CFG1, 294 ret = adt7411_modify_bit(client, ADT7411_REG_CFG1,
295 ADT7411_CFG1_START_MONITOR, 1); 295 ADT7411_CFG1_START_MONITOR, 1);
296 if (ret < 0) 296 if (ret < 0)
297 goto exit_free; 297 return ret;
298 298
299 /* force update on first occasion */ 299 /* force update on first occasion */
300 data->next_update = jiffies; 300 data->next_update = jiffies;
301 301
302 ret = sysfs_create_group(&client->dev.kobj, &adt7411_attr_grp); 302 ret = sysfs_create_group(&client->dev.kobj, &adt7411_attr_grp);
303 if (ret) 303 if (ret)
304 goto exit_free; 304 return ret;
305 305
306 data->hwmon_dev = hwmon_device_register(&client->dev); 306 data->hwmon_dev = hwmon_device_register(&client->dev);
307 if (IS_ERR(data->hwmon_dev)) { 307 if (IS_ERR(data->hwmon_dev)) {
@@ -315,8 +315,6 @@ static int __devinit adt7411_probe(struct i2c_client *client,
315 315
316 exit_remove: 316 exit_remove:
317 sysfs_remove_group(&client->dev.kobj, &adt7411_attr_grp); 317 sysfs_remove_group(&client->dev.kobj, &adt7411_attr_grp);
318 exit_free:
319 kfree(data);
320 return ret; 318 return ret;
321} 319}
322 320
@@ -326,7 +324,6 @@ static int __devexit adt7411_remove(struct i2c_client *client)
326 324
327 hwmon_device_unregister(data->hwmon_dev); 325 hwmon_device_unregister(data->hwmon_dev);
328 sysfs_remove_group(&client->dev.kobj, &adt7411_attr_grp); 326 sysfs_remove_group(&client->dev.kobj, &adt7411_attr_grp);
329 kfree(data);
330 return 0; 327 return 0;
331} 328}
332 329
diff --git a/drivers/hwmon/adt7462.c b/drivers/hwmon/adt7462.c
index 339269f76e57..baee482aedfc 100644
--- a/drivers/hwmon/adt7462.c
+++ b/drivers/hwmon/adt7462.c
@@ -1931,11 +1931,10 @@ static int adt7462_probe(struct i2c_client *client,
1931 struct adt7462_data *data; 1931 struct adt7462_data *data;
1932 int err; 1932 int err;
1933 1933
1934 data = kzalloc(sizeof(struct adt7462_data), GFP_KERNEL); 1934 data = devm_kzalloc(&client->dev, sizeof(struct adt7462_data),
1935 if (!data) { 1935 GFP_KERNEL);
1936 err = -ENOMEM; 1936 if (!data)
1937 goto exit; 1937 return -ENOMEM;
1938 }
1939 1938
1940 i2c_set_clientdata(client, data); 1939 i2c_set_clientdata(client, data);
1941 mutex_init(&data->lock); 1940 mutex_init(&data->lock);
@@ -1946,7 +1945,7 @@ static int adt7462_probe(struct i2c_client *client,
1946 data->attrs.attrs = adt7462_attr; 1945 data->attrs.attrs = adt7462_attr;
1947 err = sysfs_create_group(&client->dev.kobj, &data->attrs); 1946 err = sysfs_create_group(&client->dev.kobj, &data->attrs);
1948 if (err) 1947 if (err)
1949 goto exit_free; 1948 return err;
1950 1949
1951 data->hwmon_dev = hwmon_device_register(&client->dev); 1950 data->hwmon_dev = hwmon_device_register(&client->dev);
1952 if (IS_ERR(data->hwmon_dev)) { 1951 if (IS_ERR(data->hwmon_dev)) {
@@ -1958,9 +1957,6 @@ static int adt7462_probe(struct i2c_client *client,
1958 1957
1959exit_remove: 1958exit_remove:
1960 sysfs_remove_group(&client->dev.kobj, &data->attrs); 1959 sysfs_remove_group(&client->dev.kobj, &data->attrs);
1961exit_free:
1962 kfree(data);
1963exit:
1964 return err; 1960 return err;
1965} 1961}
1966 1962
@@ -1970,7 +1966,6 @@ static int adt7462_remove(struct i2c_client *client)
1970 1966
1971 hwmon_device_unregister(data->hwmon_dev); 1967 hwmon_device_unregister(data->hwmon_dev);
1972 sysfs_remove_group(&client->dev.kobj, &data->attrs); 1968 sysfs_remove_group(&client->dev.kobj, &data->attrs);
1973 kfree(data);
1974 return 0; 1969 return 0;
1975} 1970}
1976 1971
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
index 54ec890521ff..39ecb1a3b9ef 100644
--- a/drivers/hwmon/adt7470.c
+++ b/drivers/hwmon/adt7470.c
@@ -1256,11 +1256,10 @@ static int adt7470_probe(struct i2c_client *client,
1256 struct adt7470_data *data; 1256 struct adt7470_data *data;
1257 int err; 1257 int err;
1258 1258
1259 data = kzalloc(sizeof(struct adt7470_data), GFP_KERNEL); 1259 data = devm_kzalloc(&client->dev, sizeof(struct adt7470_data),
1260 if (!data) { 1260 GFP_KERNEL);
1261 err = -ENOMEM; 1261 if (!data)
1262 goto exit; 1262 return -ENOMEM;
1263 }
1264 1263
1265 data->num_temp_sensors = -1; 1264 data->num_temp_sensors = -1;
1266 data->auto_update_interval = AUTO_UPDATE_INTERVAL; 1265 data->auto_update_interval = AUTO_UPDATE_INTERVAL;
@@ -1277,7 +1276,7 @@ static int adt7470_probe(struct i2c_client *client,
1277 data->attrs.attrs = adt7470_attr; 1276 data->attrs.attrs = adt7470_attr;
1278 err = sysfs_create_group(&client->dev.kobj, &data->attrs); 1277 err = sysfs_create_group(&client->dev.kobj, &data->attrs);
1279 if (err) 1278 if (err)
1280 goto exit_free; 1279 return err;
1281 1280
1282 data->hwmon_dev = hwmon_device_register(&client->dev); 1281 data->hwmon_dev = hwmon_device_register(&client->dev);
1283 if (IS_ERR(data->hwmon_dev)) { 1282 if (IS_ERR(data->hwmon_dev)) {
@@ -1299,9 +1298,6 @@ exit_unregister:
1299 hwmon_device_unregister(data->hwmon_dev); 1298 hwmon_device_unregister(data->hwmon_dev);
1300exit_remove: 1299exit_remove:
1301 sysfs_remove_group(&client->dev.kobj, &data->attrs); 1300 sysfs_remove_group(&client->dev.kobj, &data->attrs);
1302exit_free:
1303 kfree(data);
1304exit:
1305 return err; 1301 return err;
1306} 1302}
1307 1303
@@ -1313,7 +1309,6 @@ static int adt7470_remove(struct i2c_client *client)
1313 wait_for_completion(&data->auto_update_stop); 1309 wait_for_completion(&data->auto_update_stop);
1314 hwmon_device_unregister(data->hwmon_dev); 1310 hwmon_device_unregister(data->hwmon_dev);
1315 sysfs_remove_group(&client->dev.kobj, &data->attrs); 1311 sysfs_remove_group(&client->dev.kobj, &data->attrs);
1316 kfree(data);
1317 return 0; 1312 return 0;
1318} 1313}
1319 1314
diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c
index f600fa1f92e3..ae482e3afdac 100644
--- a/drivers/hwmon/amc6821.c
+++ b/drivers/hwmon/amc6821.c
@@ -862,12 +862,10 @@ static int amc6821_probe(
862 struct amc6821_data *data; 862 struct amc6821_data *data;
863 int err; 863 int err;
864 864
865 data = kzalloc(sizeof(struct amc6821_data), GFP_KERNEL); 865 data = devm_kzalloc(&client->dev, sizeof(struct amc6821_data),
866 if (!data) { 866 GFP_KERNEL);
867 dev_err(&client->dev, "out of memory.\n"); 867 if (!data)
868 return -ENOMEM; 868 return -ENOMEM;
869 }
870
871 869
872 i2c_set_clientdata(client, data); 870 i2c_set_clientdata(client, data);
873 mutex_init(&data->update_lock); 871 mutex_init(&data->update_lock);
@@ -877,11 +875,11 @@ static int amc6821_probe(
877 */ 875 */
878 err = amc6821_init_client(client); 876 err = amc6821_init_client(client);
879 if (err) 877 if (err)
880 goto err_free; 878 return err;
881 879
882 err = sysfs_create_group(&client->dev.kobj, &amc6821_attr_grp); 880 err = sysfs_create_group(&client->dev.kobj, &amc6821_attr_grp);
883 if (err) 881 if (err)
884 goto err_free; 882 return err;
885 883
886 data->hwmon_dev = hwmon_device_register(&client->dev); 884 data->hwmon_dev = hwmon_device_register(&client->dev);
887 if (!IS_ERR(data->hwmon_dev)) 885 if (!IS_ERR(data->hwmon_dev))
@@ -890,8 +888,6 @@ static int amc6821_probe(
890 err = PTR_ERR(data->hwmon_dev); 888 err = PTR_ERR(data->hwmon_dev);
891 dev_err(&client->dev, "error registering hwmon device.\n"); 889 dev_err(&client->dev, "error registering hwmon device.\n");
892 sysfs_remove_group(&client->dev.kobj, &amc6821_attr_grp); 890 sysfs_remove_group(&client->dev.kobj, &amc6821_attr_grp);
893err_free:
894 kfree(data);
895 return err; 891 return err;
896} 892}
897 893
@@ -902,8 +898,6 @@ static int amc6821_remove(struct i2c_client *client)
902 hwmon_device_unregister(data->hwmon_dev); 898 hwmon_device_unregister(data->hwmon_dev);
903 sysfs_remove_group(&client->dev.kobj, &amc6821_attr_grp); 899 sysfs_remove_group(&client->dev.kobj, &amc6821_attr_grp);
904 900
905 kfree(data);
906
907 return 0; 901 return 0;
908} 902}
909 903
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 282708860517..8f3f6f2c45fd 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -53,10 +53,10 @@
53 53
54#define APPLESMC_MAX_DATA_LENGTH 32 54#define APPLESMC_MAX_DATA_LENGTH 32
55 55
56/* wait up to 32 ms for a status change. */ 56/* wait up to 128 ms for a status change. */
57#define APPLESMC_MIN_WAIT 0x0010 57#define APPLESMC_MIN_WAIT 0x0010
58#define APPLESMC_RETRY_WAIT 0x0100 58#define APPLESMC_RETRY_WAIT 0x0100
59#define APPLESMC_MAX_WAIT 0x8000 59#define APPLESMC_MAX_WAIT 0x20000
60 60
61#define APPLESMC_READ_CMD 0x10 61#define APPLESMC_READ_CMD 0x10
62#define APPLESMC_WRITE_CMD 0x11 62#define APPLESMC_WRITE_CMD 0x11
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c
index 4b8814deabb1..a227be47149f 100644
--- a/drivers/hwmon/asb100.c
+++ b/drivers/hwmon/asb100.c
@@ -787,12 +787,10 @@ static int asb100_probe(struct i2c_client *client,
787 int err; 787 int err;
788 struct asb100_data *data; 788 struct asb100_data *data;
789 789
790 data = kzalloc(sizeof(struct asb100_data), GFP_KERNEL); 790 data = devm_kzalloc(&client->dev, sizeof(struct asb100_data),
791 if (!data) { 791 GFP_KERNEL);
792 pr_debug("probe failed, kzalloc failed!\n"); 792 if (!data)
793 err = -ENOMEM; 793 return -ENOMEM;
794 goto ERROR0;
795 }
796 794
797 i2c_set_clientdata(client, data); 795 i2c_set_clientdata(client, data);
798 mutex_init(&data->lock); 796 mutex_init(&data->lock);
@@ -801,7 +799,7 @@ static int asb100_probe(struct i2c_client *client,
801 /* Attach secondary lm75 clients */ 799 /* Attach secondary lm75 clients */
802 err = asb100_detect_subclients(client); 800 err = asb100_detect_subclients(client);
803 if (err) 801 if (err)
804 goto ERROR1; 802 return err;
805 803
806 /* Initialize the chip */ 804 /* Initialize the chip */
807 asb100_init_client(client); 805 asb100_init_client(client);
@@ -829,9 +827,6 @@ ERROR4:
829ERROR3: 827ERROR3:
830 i2c_unregister_device(data->lm75[1]); 828 i2c_unregister_device(data->lm75[1]);
831 i2c_unregister_device(data->lm75[0]); 829 i2c_unregister_device(data->lm75[0]);
832ERROR1:
833 kfree(data);
834ERROR0:
835 return err; 830 return err;
836} 831}
837 832
@@ -845,8 +840,6 @@ static int asb100_remove(struct i2c_client *client)
845 i2c_unregister_device(data->lm75[1]); 840 i2c_unregister_device(data->lm75[1]);
846 i2c_unregister_device(data->lm75[0]); 841 i2c_unregister_device(data->lm75[0]);
847 842
848 kfree(data);
849
850 return 0; 843 return 0;
851} 844}
852 845
diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
index 351d1f4593e7..cccb0e9d45b4 100644
--- a/drivers/hwmon/asus_atk0110.c
+++ b/drivers/hwmon/asus_atk0110.c
@@ -34,6 +34,12 @@ static const struct dmi_system_id __initconst atk_force_new_if[] = {
34 .matches = { 34 .matches = {
35 DMI_MATCH(DMI_BOARD_NAME, "SABERTOOTH X58") 35 DMI_MATCH(DMI_BOARD_NAME, "SABERTOOTH X58")
36 } 36 }
37 }, {
38 /* Old interface reads the same sensor for fan0 and fan1 */
39 .ident = "Asus M5A78L",
40 .matches = {
41 DMI_MATCH(DMI_BOARD_NAME, "M5A78L")
42 }
37 }, 43 },
38 { } 44 { }
39}; 45};
@@ -956,7 +962,6 @@ static int atk_add_sensor(struct atk_data *data, union acpi_object *obj)
956 962
957 return 1; 963 return 1;
958out: 964out:
959 kfree(sensor->acpi_name);
960 kfree(sensor); 965 kfree(sensor);
961 return err; 966 return err;
962} 967}
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index faa16f80db9c..984a3f13923b 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -196,7 +196,7 @@ struct tjmax {
196 int tjmax; 196 int tjmax;
197}; 197};
198 198
199static struct tjmax __cpuinitconst tjmax_table[] = { 199static const struct tjmax __cpuinitconst tjmax_table[] = {
200 { "CPU D410", 100000 }, 200 { "CPU D410", 100000 },
201 { "CPU D425", 100000 }, 201 { "CPU D425", 100000 },
202 { "CPU D510", 100000 }, 202 { "CPU D510", 100000 },
@@ -815,17 +815,20 @@ static int __init coretemp_init(void)
815 if (err) 815 if (err)
816 goto exit; 816 goto exit;
817 817
818 get_online_cpus();
818 for_each_online_cpu(i) 819 for_each_online_cpu(i)
819 get_core_online(i); 820 get_core_online(i);
820 821
821#ifndef CONFIG_HOTPLUG_CPU 822#ifndef CONFIG_HOTPLUG_CPU
822 if (list_empty(&pdev_list)) { 823 if (list_empty(&pdev_list)) {
824 put_online_cpus();
823 err = -ENODEV; 825 err = -ENODEV;
824 goto exit_driver_unreg; 826 goto exit_driver_unreg;
825 } 827 }
826#endif 828#endif
827 829
828 register_hotcpu_notifier(&coretemp_cpu_notifier); 830 register_hotcpu_notifier(&coretemp_cpu_notifier);
831 put_online_cpus();
829 return 0; 832 return 0;
830 833
831#ifndef CONFIG_HOTPLUG_CPU 834#ifndef CONFIG_HOTPLUG_CPU
@@ -840,6 +843,7 @@ static void __exit coretemp_exit(void)
840{ 843{
841 struct pdev_entry *p, *n; 844 struct pdev_entry *p, *n;
842 845
846 get_online_cpus();
843 unregister_hotcpu_notifier(&coretemp_cpu_notifier); 847 unregister_hotcpu_notifier(&coretemp_cpu_notifier);
844 mutex_lock(&pdev_list_mutex); 848 mutex_lock(&pdev_list_mutex);
845 list_for_each_entry_safe(p, n, &pdev_list, list) { 849 list_for_each_entry_safe(p, n, &pdev_list, list) {
@@ -848,6 +852,7 @@ static void __exit coretemp_exit(void)
848 kfree(p); 852 kfree(p);
849 } 853 }
850 mutex_unlock(&pdev_list_mutex); 854 mutex_unlock(&pdev_list_mutex);
855 put_online_cpus();
851 platform_driver_unregister(&coretemp_driver); 856 platform_driver_unregister(&coretemp_driver);
852} 857}
853 858
diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c
index e7c6a19f3b25..fe0eeec0b750 100644
--- a/drivers/hwmon/dme1737.c
+++ b/drivers/hwmon/dme1737.c
@@ -2475,11 +2475,9 @@ static int dme1737_i2c_probe(struct i2c_client *client,
2475 struct device *dev = &client->dev; 2475 struct device *dev = &client->dev;
2476 int err; 2476 int err;
2477 2477
2478 data = kzalloc(sizeof(struct dme1737_data), GFP_KERNEL); 2478 data = devm_kzalloc(dev, sizeof(struct dme1737_data), GFP_KERNEL);
2479 if (!data) { 2479 if (!data)
2480 err = -ENOMEM; 2480 return -ENOMEM;
2481 goto exit;
2482 }
2483 2481
2484 i2c_set_clientdata(client, data); 2482 i2c_set_clientdata(client, data);
2485 data->type = id->driver_data; 2483 data->type = id->driver_data;
@@ -2491,14 +2489,14 @@ static int dme1737_i2c_probe(struct i2c_client *client,
2491 err = dme1737_init_device(dev); 2489 err = dme1737_init_device(dev);
2492 if (err) { 2490 if (err) {
2493 dev_err(dev, "Failed to initialize device.\n"); 2491 dev_err(dev, "Failed to initialize device.\n");
2494 goto exit_kfree; 2492 return err;
2495 } 2493 }
2496 2494
2497 /* Create sysfs files */ 2495 /* Create sysfs files */
2498 err = dme1737_create_files(dev); 2496 err = dme1737_create_files(dev);
2499 if (err) { 2497 if (err) {
2500 dev_err(dev, "Failed to create sysfs files.\n"); 2498 dev_err(dev, "Failed to create sysfs files.\n");
2501 goto exit_kfree; 2499 return err;
2502 } 2500 }
2503 2501
2504 /* Register device */ 2502 /* Register device */
@@ -2513,9 +2511,6 @@ static int dme1737_i2c_probe(struct i2c_client *client,
2513 2511
2514exit_remove: 2512exit_remove:
2515 dme1737_remove_files(dev); 2513 dme1737_remove_files(dev);
2516exit_kfree:
2517 kfree(data);
2518exit:
2519 return err; 2514 return err;
2520} 2515}
2521 2516
@@ -2526,7 +2521,6 @@ static int dme1737_i2c_remove(struct i2c_client *client)
2526 hwmon_device_unregister(data->hwmon_dev); 2521 hwmon_device_unregister(data->hwmon_dev);
2527 dme1737_remove_files(&client->dev); 2522 dme1737_remove_files(&client->dev);
2528 2523
2529 kfree(data);
2530 return 0; 2524 return 0;
2531} 2525}
2532 2526
@@ -2645,19 +2639,16 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev)
2645 int err; 2639 int err;
2646 2640
2647 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 2641 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
2648 if (!request_region(res->start, DME1737_EXTENT, "dme1737")) { 2642 if (!devm_request_region(dev, res->start, DME1737_EXTENT, "dme1737")) {
2649 dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n", 2643 dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n",
2650 (unsigned short)res->start, 2644 (unsigned short)res->start,
2651 (unsigned short)res->start + DME1737_EXTENT - 1); 2645 (unsigned short)res->start + DME1737_EXTENT - 1);
2652 err = -EBUSY; 2646 return -EBUSY;
2653 goto exit;
2654 } 2647 }
2655 2648
2656 data = kzalloc(sizeof(struct dme1737_data), GFP_KERNEL); 2649 data = devm_kzalloc(dev, sizeof(struct dme1737_data), GFP_KERNEL);
2657 if (!data) { 2650 if (!data)
2658 err = -ENOMEM; 2651 return -ENOMEM;
2659 goto exit_release_region;
2660 }
2661 2652
2662 data->addr = res->start; 2653 data->addr = res->start;
2663 platform_set_drvdata(pdev, data); 2654 platform_set_drvdata(pdev, data);
@@ -2683,8 +2674,7 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev)
2683 (device == SCH5127_DEVICE)) { 2674 (device == SCH5127_DEVICE)) {
2684 data->type = sch5127; 2675 data->type = sch5127;
2685 } else { 2676 } else {
2686 err = -ENODEV; 2677 return -ENODEV;
2687 goto exit_kfree;
2688 } 2678 }
2689 } 2679 }
2690 2680
@@ -2703,14 +2693,14 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev)
2703 err = dme1737_init_device(dev); 2693 err = dme1737_init_device(dev);
2704 if (err) { 2694 if (err) {
2705 dev_err(dev, "Failed to initialize device.\n"); 2695 dev_err(dev, "Failed to initialize device.\n");
2706 goto exit_kfree; 2696 return err;
2707 } 2697 }
2708 2698
2709 /* Create sysfs files */ 2699 /* Create sysfs files */
2710 err = dme1737_create_files(dev); 2700 err = dme1737_create_files(dev);
2711 if (err) { 2701 if (err) {
2712 dev_err(dev, "Failed to create sysfs files.\n"); 2702 dev_err(dev, "Failed to create sysfs files.\n");
2713 goto exit_kfree; 2703 return err;
2714 } 2704 }
2715 2705
2716 /* Register device */ 2706 /* Register device */
@@ -2725,12 +2715,6 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev)
2725 2715
2726exit_remove_files: 2716exit_remove_files:
2727 dme1737_remove_files(dev); 2717 dme1737_remove_files(dev);
2728exit_kfree:
2729 platform_set_drvdata(pdev, NULL);
2730 kfree(data);
2731exit_release_region:
2732 release_region(res->start, DME1737_EXTENT);
2733exit:
2734 return err; 2718 return err;
2735} 2719}
2736 2720
@@ -2740,9 +2724,6 @@ static int __devexit dme1737_isa_remove(struct platform_device *pdev)
2740 2724
2741 hwmon_device_unregister(data->hwmon_dev); 2725 hwmon_device_unregister(data->hwmon_dev);
2742 dme1737_remove_files(&pdev->dev); 2726 dme1737_remove_files(&pdev->dev);
2743 release_region(data->addr, DME1737_EXTENT);
2744 platform_set_drvdata(pdev, NULL);
2745 kfree(data);
2746 2727
2747 return 0; 2728 return 0;
2748} 2729}
diff --git a/drivers/hwmon/ds620.c b/drivers/hwmon/ds620.c
index 50663efad412..f1d6b422cf06 100644
--- a/drivers/hwmon/ds620.c
+++ b/drivers/hwmon/ds620.c
@@ -232,11 +232,10 @@ static int ds620_probe(struct i2c_client *client,
232 struct ds620_data *data; 232 struct ds620_data *data;
233 int err; 233 int err;
234 234
235 data = kzalloc(sizeof(struct ds620_data), GFP_KERNEL); 235 data = devm_kzalloc(&client->dev, sizeof(struct ds620_data),
236 if (!data) { 236 GFP_KERNEL);
237 err = -ENOMEM; 237 if (!data)
238 goto exit; 238 return -ENOMEM;
239 }
240 239
241 i2c_set_clientdata(client, data); 240 i2c_set_clientdata(client, data);
242 mutex_init(&data->update_lock); 241 mutex_init(&data->update_lock);
@@ -247,7 +246,7 @@ static int ds620_probe(struct i2c_client *client,
247 /* Register sysfs hooks */ 246 /* Register sysfs hooks */
248 err = sysfs_create_group(&client->dev.kobj, &ds620_group); 247 err = sysfs_create_group(&client->dev.kobj, &ds620_group);
249 if (err) 248 if (err)
250 goto exit_free; 249 return err;
251 250
252 data->hwmon_dev = hwmon_device_register(&client->dev); 251 data->hwmon_dev = hwmon_device_register(&client->dev);
253 if (IS_ERR(data->hwmon_dev)) { 252 if (IS_ERR(data->hwmon_dev)) {
@@ -261,9 +260,6 @@ static int ds620_probe(struct i2c_client *client,
261 260
262exit_remove_files: 261exit_remove_files:
263 sysfs_remove_group(&client->dev.kobj, &ds620_group); 262 sysfs_remove_group(&client->dev.kobj, &ds620_group);
264exit_free:
265 kfree(data);
266exit:
267 return err; 263 return err;
268} 264}
269 265
@@ -274,8 +270,6 @@ static int ds620_remove(struct i2c_client *client)
274 hwmon_device_unregister(data->hwmon_dev); 270 hwmon_device_unregister(data->hwmon_dev);
275 sysfs_remove_group(&client->dev.kobj, &ds620_group); 271 sysfs_remove_group(&client->dev.kobj, &ds620_group);
276 272
277 kfree(data);
278
279 return 0; 273 return 0;
280} 274}
281 275
diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c
index 149dcb0e148f..68ab94bde3f1 100644
--- a/drivers/hwmon/emc1403.c
+++ b/drivers/hwmon/emc1403.c
@@ -306,11 +306,10 @@ static int emc1403_probe(struct i2c_client *client,
306 int res; 306 int res;
307 struct thermal_data *data; 307 struct thermal_data *data;
308 308
309 data = kzalloc(sizeof(struct thermal_data), GFP_KERNEL); 309 data = devm_kzalloc(&client->dev, sizeof(struct thermal_data),
310 if (data == NULL) { 310 GFP_KERNEL);
311 dev_warn(&client->dev, "out of memory"); 311 if (data == NULL)
312 return -ENOMEM; 312 return -ENOMEM;
313 }
314 313
315 i2c_set_clientdata(client, data); 314 i2c_set_clientdata(client, data);
316 mutex_init(&data->mutex); 315 mutex_init(&data->mutex);
@@ -319,21 +318,19 @@ static int emc1403_probe(struct i2c_client *client,
319 res = sysfs_create_group(&client->dev.kobj, &m_thermal_gr); 318 res = sysfs_create_group(&client->dev.kobj, &m_thermal_gr);
320 if (res) { 319 if (res) {
321 dev_warn(&client->dev, "create group failed\n"); 320 dev_warn(&client->dev, "create group failed\n");
322 goto thermal_error1; 321 return res;
323 } 322 }
324 data->hwmon_dev = hwmon_device_register(&client->dev); 323 data->hwmon_dev = hwmon_device_register(&client->dev);
325 if (IS_ERR(data->hwmon_dev)) { 324 if (IS_ERR(data->hwmon_dev)) {
326 res = PTR_ERR(data->hwmon_dev); 325 res = PTR_ERR(data->hwmon_dev);
327 dev_warn(&client->dev, "register hwmon dev failed\n"); 326 dev_warn(&client->dev, "register hwmon dev failed\n");
328 goto thermal_error2; 327 goto thermal_error;
329 } 328 }
330 dev_info(&client->dev, "EMC1403 Thermal chip found\n"); 329 dev_info(&client->dev, "EMC1403 Thermal chip found\n");
331 return res; 330 return 0;
332 331
333thermal_error2: 332thermal_error:
334 sysfs_remove_group(&client->dev.kobj, &m_thermal_gr); 333 sysfs_remove_group(&client->dev.kobj, &m_thermal_gr);
335thermal_error1:
336 kfree(data);
337 return res; 334 return res;
338} 335}
339 336
@@ -343,7 +340,6 @@ static int emc1403_remove(struct i2c_client *client)
343 340
344 hwmon_device_unregister(data->hwmon_dev); 341 hwmon_device_unregister(data->hwmon_dev);
345 sysfs_remove_group(&client->dev.kobj, &m_thermal_gr); 342 sysfs_remove_group(&client->dev.kobj, &m_thermal_gr);
346 kfree(data);
347 return 0; 343 return 0;
348} 344}
349 345
diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
index 7bb8e888692c..77f434c58236 100644
--- a/drivers/hwmon/emc2103.c
+++ b/drivers/hwmon/emc2103.c
@@ -590,7 +590,8 @@ emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id)
590 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 590 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
591 return -EIO; 591 return -EIO;
592 592
593 data = kzalloc(sizeof(struct emc2103_data), GFP_KERNEL); 593 data = devm_kzalloc(&client->dev, sizeof(struct emc2103_data),
594 GFP_KERNEL);
594 if (!data) 595 if (!data)
595 return -ENOMEM; 596 return -ENOMEM;
596 597
@@ -608,7 +609,7 @@ emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id)
608 if (status < 0) { 609 if (status < 0) {
609 dev_dbg(&client->dev, "reg 0x%02x, err %d\n", REG_CONF1, 610 dev_dbg(&client->dev, "reg 0x%02x, err %d\n", REG_CONF1,
610 status); 611 status);
611 goto exit_free; 612 return status;
612 } 613 }
613 614
614 /* detect current state of hardware */ 615 /* detect current state of hardware */
@@ -631,7 +632,7 @@ emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id)
631 /* Register sysfs hooks */ 632 /* Register sysfs hooks */
632 status = sysfs_create_group(&client->dev.kobj, &emc2103_group); 633 status = sysfs_create_group(&client->dev.kobj, &emc2103_group);
633 if (status) 634 if (status)
634 goto exit_free; 635 return status;
635 636
636 if (data->temp_count >= 3) { 637 if (data->temp_count >= 3) {
637 status = sysfs_create_group(&client->dev.kobj, 638 status = sysfs_create_group(&client->dev.kobj,
@@ -666,8 +667,6 @@ exit_remove_temp3:
666 sysfs_remove_group(&client->dev.kobj, &emc2103_temp3_group); 667 sysfs_remove_group(&client->dev.kobj, &emc2103_temp3_group);
667exit_remove: 668exit_remove:
668 sysfs_remove_group(&client->dev.kobj, &emc2103_group); 669 sysfs_remove_group(&client->dev.kobj, &emc2103_group);
669exit_free:
670 kfree(data);
671 return status; 670 return status;
672} 671}
673 672
@@ -685,7 +684,6 @@ static int emc2103_remove(struct i2c_client *client)
685 684
686 sysfs_remove_group(&client->dev.kobj, &emc2103_group); 685 sysfs_remove_group(&client->dev.kobj, &emc2103_group);
687 686
688 kfree(data);
689 return 0; 687 return 0;
690} 688}
691 689
diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c
index 6d1226365e30..50e4ce2d22d8 100644
--- a/drivers/hwmon/f71882fg.c
+++ b/drivers/hwmon/f71882fg.c
@@ -2274,7 +2274,8 @@ static int __devinit f71882fg_probe(struct platform_device *pdev)
2274 int err, i; 2274 int err, i;
2275 u8 start_reg, reg; 2275 u8 start_reg, reg;
2276 2276
2277 data = kzalloc(sizeof(struct f71882fg_data), GFP_KERNEL); 2277 data = devm_kzalloc(&pdev->dev, sizeof(struct f71882fg_data),
2278 GFP_KERNEL);
2278 if (!data) 2279 if (!data)
2279 return -ENOMEM; 2280 return -ENOMEM;
2280 2281
@@ -2288,13 +2289,11 @@ static int __devinit f71882fg_probe(struct platform_device *pdev)
2288 start_reg = f71882fg_read8(data, F71882FG_REG_START); 2289 start_reg = f71882fg_read8(data, F71882FG_REG_START);
2289 if (start_reg & 0x04) { 2290 if (start_reg & 0x04) {
2290 dev_warn(&pdev->dev, "Hardware monitor is powered down\n"); 2291 dev_warn(&pdev->dev, "Hardware monitor is powered down\n");
2291 err = -ENODEV; 2292 return -ENODEV;
2292 goto exit_free;
2293 } 2293 }
2294 if (!(start_reg & 0x03)) { 2294 if (!(start_reg & 0x03)) {
2295 dev_warn(&pdev->dev, "Hardware monitoring not activated\n"); 2295 dev_warn(&pdev->dev, "Hardware monitoring not activated\n");
2296 err = -ENODEV; 2296 return -ENODEV;
2297 goto exit_free;
2298 } 2297 }
2299 2298
2300 /* Register sysfs interface files */ 2299 /* Register sysfs interface files */
@@ -2422,8 +2421,6 @@ static int __devinit f71882fg_probe(struct platform_device *pdev)
2422exit_unregister_sysfs: 2421exit_unregister_sysfs:
2423 f71882fg_remove(pdev); /* Will unregister the sysfs files for us */ 2422 f71882fg_remove(pdev); /* Will unregister the sysfs files for us */
2424 return err; /* f71882fg_remove() also frees our data */ 2423 return err; /* f71882fg_remove() also frees our data */
2425exit_free:
2426 kfree(data);
2427 return err; 2424 return err;
2428} 2425}
2429 2426
@@ -2525,17 +2522,13 @@ static int f71882fg_remove(struct platform_device *pdev)
2525 ARRAY_SIZE(fxxxx_auto_pwm_attr[0]) * nr_fans); 2522 ARRAY_SIZE(fxxxx_auto_pwm_attr[0]) * nr_fans);
2526 } 2523 }
2527 } 2524 }
2528
2529 platform_set_drvdata(pdev, NULL);
2530 kfree(data);
2531
2532 return 0; 2525 return 0;
2533} 2526}
2534 2527
2535static int __init f71882fg_find(int sioaddr, unsigned short *address, 2528static int __init f71882fg_find(int sioaddr, struct f71882fg_sio_data *sio_data)
2536 struct f71882fg_sio_data *sio_data)
2537{ 2529{
2538 u16 devid; 2530 u16 devid;
2531 unsigned short address;
2539 int err = superio_enter(sioaddr); 2532 int err = superio_enter(sioaddr);
2540 if (err) 2533 if (err)
2541 return err; 2534 return err;
@@ -2603,25 +2596,25 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address,
2603 goto exit; 2596 goto exit;
2604 } 2597 }
2605 2598
2606 *address = superio_inw(sioaddr, SIO_REG_ADDR); 2599 address = superio_inw(sioaddr, SIO_REG_ADDR);
2607 if (*address == 0) { 2600 if (address == 0) {
2608 pr_warn("Base address not set\n"); 2601 pr_warn("Base address not set\n");
2609 err = -ENODEV; 2602 err = -ENODEV;
2610 goto exit; 2603 goto exit;
2611 } 2604 }
2612 *address &= ~(REGION_LENGTH - 1); /* Ignore 3 LSB */ 2605 address &= ~(REGION_LENGTH - 1); /* Ignore 3 LSB */
2613 2606
2614 err = 0; 2607 err = address;
2615 pr_info("Found %s chip at %#x, revision %d\n", 2608 pr_info("Found %s chip at %#x, revision %d\n",
2616 f71882fg_names[sio_data->type], (unsigned int)*address, 2609 f71882fg_names[sio_data->type], (unsigned int)address,
2617 (int)superio_inb(sioaddr, SIO_REG_DEVREV)); 2610 (int)superio_inb(sioaddr, SIO_REG_DEVREV));
2618exit: 2611exit:
2619 superio_exit(sioaddr); 2612 superio_exit(sioaddr);
2620 return err; 2613 return err;
2621} 2614}
2622 2615
2623static int __init f71882fg_device_add(unsigned short address, 2616static int __init f71882fg_device_add(int address,
2624 const struct f71882fg_sio_data *sio_data) 2617 const struct f71882fg_sio_data *sio_data)
2625{ 2618{
2626 struct resource res = { 2619 struct resource res = {
2627 .start = address, 2620 .start = address,
@@ -2668,19 +2661,21 @@ exit_device_put:
2668 2661
2669static int __init f71882fg_init(void) 2662static int __init f71882fg_init(void)
2670{ 2663{
2671 int err = -ENODEV; 2664 int err;
2672 unsigned short address; 2665 int address;
2673 struct f71882fg_sio_data sio_data; 2666 struct f71882fg_sio_data sio_data;
2674 2667
2675 memset(&sio_data, 0, sizeof(sio_data)); 2668 memset(&sio_data, 0, sizeof(sio_data));
2676 2669
2677 if (f71882fg_find(0x2e, &address, &sio_data) && 2670 address = f71882fg_find(0x2e, &sio_data);
2678 f71882fg_find(0x4e, &address, &sio_data)) 2671 if (address < 0)
2679 goto exit; 2672 address = f71882fg_find(0x4e, &sio_data);
2673 if (address < 0)
2674 return address;
2680 2675
2681 err = platform_driver_register(&f71882fg_driver); 2676 err = platform_driver_register(&f71882fg_driver);
2682 if (err) 2677 if (err)
2683 goto exit; 2678 return err;
2684 2679
2685 err = f71882fg_device_add(address, &sio_data); 2680 err = f71882fg_device_add(address, &sio_data);
2686 if (err) 2681 if (err)
@@ -2690,7 +2685,6 @@ static int __init f71882fg_init(void)
2690 2685
2691exit_driver: 2686exit_driver:
2692 platform_driver_unregister(&f71882fg_driver); 2687 platform_driver_unregister(&f71882fg_driver);
2693exit:
2694 return err; 2688 return err;
2695} 2689}
2696 2690
diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c
index ece4159bd453..f7dba229395f 100644
--- a/drivers/hwmon/f75375s.c
+++ b/drivers/hwmon/f75375s.c
@@ -838,7 +838,8 @@ static int f75375_probe(struct i2c_client *client,
838 if (!i2c_check_functionality(client->adapter, 838 if (!i2c_check_functionality(client->adapter,
839 I2C_FUNC_SMBUS_BYTE_DATA)) 839 I2C_FUNC_SMBUS_BYTE_DATA))
840 return -EIO; 840 return -EIO;
841 data = kzalloc(sizeof(struct f75375_data), GFP_KERNEL); 841 data = devm_kzalloc(&client->dev, sizeof(struct f75375_data),
842 GFP_KERNEL);
842 if (!data) 843 if (!data)
843 return -ENOMEM; 844 return -ENOMEM;
844 845
@@ -848,7 +849,7 @@ static int f75375_probe(struct i2c_client *client,
848 849
849 err = sysfs_create_group(&client->dev.kobj, &f75375_group); 850 err = sysfs_create_group(&client->dev.kobj, &f75375_group);
850 if (err) 851 if (err)
851 goto exit_free; 852 return err;
852 853
853 if (data->kind != f75373) { 854 if (data->kind != f75373) {
854 err = sysfs_chmod_file(&client->dev.kobj, 855 err = sysfs_chmod_file(&client->dev.kobj,
@@ -875,8 +876,6 @@ static int f75375_probe(struct i2c_client *client,
875 876
876exit_remove: 877exit_remove:
877 sysfs_remove_group(&client->dev.kobj, &f75375_group); 878 sysfs_remove_group(&client->dev.kobj, &f75375_group);
878exit_free:
879 kfree(data);
880 return err; 879 return err;
881} 880}
882 881
@@ -885,7 +884,6 @@ static int f75375_remove(struct i2c_client *client)
885 struct f75375_data *data = i2c_get_clientdata(client); 884 struct f75375_data *data = i2c_get_clientdata(client);
886 hwmon_device_unregister(data->hwmon_dev); 885 hwmon_device_unregister(data->hwmon_dev);
887 sysfs_remove_group(&client->dev.kobj, &f75375_group); 886 sysfs_remove_group(&client->dev.kobj, &f75375_group);
888 kfree(data);
889 return 0; 887 return 0;
890} 888}
891 889
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
index 2764b78a784b..68ad7d255512 100644
--- a/drivers/hwmon/fam15h_power.c
+++ b/drivers/hwmon/fam15h_power.c
@@ -129,12 +129,12 @@ static bool __devinit fam15h_power_is_internal_node0(struct pci_dev *f4)
129 * counter saturations resulting in bogus power readings. 129 * counter saturations resulting in bogus power readings.
130 * We correct this value ourselves to cope with older BIOSes. 130 * We correct this value ourselves to cope with older BIOSes.
131 */ 131 */
132static DEFINE_PCI_DEVICE_TABLE(affected_device) = { 132static const struct pci_device_id affected_device[] = {
133 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) }, 133 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) },
134 { 0 } 134 { 0 }
135}; 135};
136 136
137static void __devinit tweak_runavg_range(struct pci_dev *pdev) 137static void tweak_runavg_range(struct pci_dev *pdev)
138{ 138{
139 u32 val; 139 u32 val;
140 140
@@ -158,6 +158,16 @@ static void __devinit tweak_runavg_range(struct pci_dev *pdev)
158 REG_TDP_RUNNING_AVERAGE, val); 158 REG_TDP_RUNNING_AVERAGE, val);
159} 159}
160 160
161#ifdef CONFIG_PM
162static int fam15h_power_resume(struct pci_dev *pdev)
163{
164 tweak_runavg_range(pdev);
165 return 0;
166}
167#else
168#define fam15h_power_resume NULL
169#endif
170
161static void __devinit fam15h_power_init_data(struct pci_dev *f4, 171static void __devinit fam15h_power_init_data(struct pci_dev *f4,
162 struct fam15h_power_data *data) 172 struct fam15h_power_data *data)
163{ 173{
@@ -188,7 +198,7 @@ static int __devinit fam15h_power_probe(struct pci_dev *pdev,
188 const struct pci_device_id *id) 198 const struct pci_device_id *id)
189{ 199{
190 struct fam15h_power_data *data; 200 struct fam15h_power_data *data;
191 struct device *dev; 201 struct device *dev = &pdev->dev;
192 int err; 202 int err;
193 203
194 /* 204 /*
@@ -198,23 +208,19 @@ static int __devinit fam15h_power_probe(struct pci_dev *pdev,
198 */ 208 */
199 tweak_runavg_range(pdev); 209 tweak_runavg_range(pdev);
200 210
201 if (!fam15h_power_is_internal_node0(pdev)) { 211 if (!fam15h_power_is_internal_node0(pdev))
202 err = -ENODEV; 212 return -ENODEV;
203 goto exit; 213
204 } 214 data = devm_kzalloc(dev, sizeof(struct fam15h_power_data), GFP_KERNEL);
215 if (!data)
216 return -ENOMEM;
205 217
206 data = kzalloc(sizeof(struct fam15h_power_data), GFP_KERNEL);
207 if (!data) {
208 err = -ENOMEM;
209 goto exit;
210 }
211 fam15h_power_init_data(pdev, data); 218 fam15h_power_init_data(pdev, data);
212 dev = &pdev->dev;
213 219
214 dev_set_drvdata(dev, data); 220 dev_set_drvdata(dev, data);
215 err = sysfs_create_group(&dev->kobj, &fam15h_power_attr_group); 221 err = sysfs_create_group(&dev->kobj, &fam15h_power_attr_group);
216 if (err) 222 if (err)
217 goto exit_free_data; 223 return err;
218 224
219 data->hwmon_dev = hwmon_device_register(dev); 225 data->hwmon_dev = hwmon_device_register(dev);
220 if (IS_ERR(data->hwmon_dev)) { 226 if (IS_ERR(data->hwmon_dev)) {
@@ -226,9 +232,6 @@ static int __devinit fam15h_power_probe(struct pci_dev *pdev,
226 232
227exit_remove_group: 233exit_remove_group:
228 sysfs_remove_group(&dev->kobj, &fam15h_power_attr_group); 234 sysfs_remove_group(&dev->kobj, &fam15h_power_attr_group);
229exit_free_data:
230 kfree(data);
231exit:
232 return err; 235 return err;
233} 236}
234 237
@@ -241,8 +244,6 @@ static void __devexit fam15h_power_remove(struct pci_dev *pdev)
241 data = dev_get_drvdata(dev); 244 data = dev_get_drvdata(dev);
242 hwmon_device_unregister(data->hwmon_dev); 245 hwmon_device_unregister(data->hwmon_dev);
243 sysfs_remove_group(&dev->kobj, &fam15h_power_attr_group); 246 sysfs_remove_group(&dev->kobj, &fam15h_power_attr_group);
244 dev_set_drvdata(dev, NULL);
245 kfree(data);
246} 247}
247 248
248static DEFINE_PCI_DEVICE_TABLE(fam15h_power_id_table) = { 249static DEFINE_PCI_DEVICE_TABLE(fam15h_power_id_table) = {
@@ -256,6 +257,7 @@ static struct pci_driver fam15h_power_driver = {
256 .id_table = fam15h_power_id_table, 257 .id_table = fam15h_power_id_table,
257 .probe = fam15h_power_probe, 258 .probe = fam15h_power_probe,
258 .remove = __devexit_p(fam15h_power_remove), 259 .remove = __devexit_p(fam15h_power_remove),
260 .resume = fam15h_power_resume,
259}; 261};
260 262
261module_pci_driver(fam15h_power_driver); 263module_pci_driver(fam15h_power_driver);
diff --git a/drivers/hwmon/g760a.c b/drivers/hwmon/g760a.c
index ebcd2698e4dc..8b2106f60eda 100644
--- a/drivers/hwmon/g760a.c
+++ b/drivers/hwmon/g760a.c
@@ -207,7 +207,8 @@ static int g760a_probe(struct i2c_client *client,
207 I2C_FUNC_SMBUS_BYTE_DATA)) 207 I2C_FUNC_SMBUS_BYTE_DATA))
208 return -EIO; 208 return -EIO;
209 209
210 data = kzalloc(sizeof(struct g760a_data), GFP_KERNEL); 210 data = devm_kzalloc(&client->dev, sizeof(struct g760a_data),
211 GFP_KERNEL);
211 if (!data) 212 if (!data)
212 return -ENOMEM; 213 return -ENOMEM;
213 214
@@ -223,7 +224,7 @@ static int g760a_probe(struct i2c_client *client,
223 /* Register sysfs hooks */ 224 /* Register sysfs hooks */
224 err = sysfs_create_group(&client->dev.kobj, &g760a_group); 225 err = sysfs_create_group(&client->dev.kobj, &g760a_group);
225 if (err) 226 if (err)
226 goto error_sysfs_create_group; 227 return err;
227 228
228 data->hwmon_dev = hwmon_device_register(&client->dev); 229 data->hwmon_dev = hwmon_device_register(&client->dev);
229 if (IS_ERR(data->hwmon_dev)) { 230 if (IS_ERR(data->hwmon_dev)) {
@@ -235,9 +236,6 @@ static int g760a_probe(struct i2c_client *client,
235 236
236error_hwmon_device_register: 237error_hwmon_device_register:
237 sysfs_remove_group(&client->dev.kobj, &g760a_group); 238 sysfs_remove_group(&client->dev.kobj, &g760a_group);
238error_sysfs_create_group:
239 kfree(data);
240
241 return err; 239 return err;
242} 240}
243 241
@@ -246,8 +244,6 @@ static int g760a_remove(struct i2c_client *client)
246 struct g760a_data *data = i2c_get_clientdata(client); 244 struct g760a_data *data = i2c_get_clientdata(client);
247 hwmon_device_unregister(data->hwmon_dev); 245 hwmon_device_unregister(data->hwmon_dev);
248 sysfs_remove_group(&client->dev.kobj, &g760a_group); 246 sysfs_remove_group(&client->dev.kobj, &g760a_group);
249 kfree(data);
250
251 return 0; 247 return 0;
252} 248}
253 249
diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
index 7f3f4a385729..70717d4a5e89 100644
--- a/drivers/hwmon/ina2xx.c
+++ b/drivers/hwmon/ina2xx.c
@@ -5,10 +5,18 @@
5 * Zero Drift Bi-Directional Current/Power Monitor with I2C Interface 5 * Zero Drift Bi-Directional Current/Power Monitor with I2C Interface
6 * Datasheet: http://www.ti.com/product/ina219 6 * Datasheet: http://www.ti.com/product/ina219
7 * 7 *
8 * INA220:
9 * Bi-Directional Current/Power Monitor with I2C Interface
10 * Datasheet: http://www.ti.com/product/ina220
11 *
8 * INA226: 12 * INA226:
9 * Bi-Directional Current/Power Monitor with I2C Interface 13 * Bi-Directional Current/Power Monitor with I2C Interface
10 * Datasheet: http://www.ti.com/product/ina226 14 * Datasheet: http://www.ti.com/product/ina226
11 * 15 *
16 * INA230:
17 * Bi-directional Current/Power Monitor with I2C Interface
18 * Datasheet: http://www.ti.com/product/ina230
19 *
12 * Copyright (C) 2012 Lothar Felten <l-felten@ti.com> 20 * Copyright (C) 2012 Lothar Felten <l-felten@ti.com>
13 * Thanks to Jan Volkering 21 * Thanks to Jan Volkering
14 * 22 *
@@ -57,33 +65,48 @@
57 65
58enum ina2xx_ids { ina219, ina226 }; 66enum ina2xx_ids { ina219, ina226 };
59 67
68struct ina2xx_config {
69 u16 config_default;
70 int calibration_factor;
71 int registers;
72 int shunt_div;
73 int bus_voltage_shift;
74 int bus_voltage_lsb; /* uV */
75 int power_lsb; /* uW */
76};
77
60struct ina2xx_data { 78struct ina2xx_data {
61 struct device *hwmon_dev; 79 struct device *hwmon_dev;
80 const struct ina2xx_config *config;
62 81
63 struct mutex update_lock; 82 struct mutex update_lock;
64 bool valid; 83 bool valid;
65 unsigned long last_updated; 84 unsigned long last_updated;
66 85
67 int kind; 86 int kind;
68 int registers;
69 u16 regs[INA2XX_MAX_REGISTERS]; 87 u16 regs[INA2XX_MAX_REGISTERS];
70}; 88};
71 89
72int ina2xx_read_word(struct i2c_client *client, int reg) 90static const struct ina2xx_config ina2xx_config[] = {
73{ 91 [ina219] = {
74 int val = i2c_smbus_read_word_data(client, reg); 92 .config_default = INA219_CONFIG_DEFAULT,
75 if (unlikely(val < 0)) { 93 .calibration_factor = 40960000,
76 dev_dbg(&client->dev, 94 .registers = INA219_REGISTERS,
77 "Failed to read register: %d\n", reg); 95 .shunt_div = 100,
78 return val; 96 .bus_voltage_shift = 3,
79 } 97 .bus_voltage_lsb = 4000,
80 return be16_to_cpu(val); 98 .power_lsb = 20000,
81} 99 },
82 100 [ina226] = {
83void ina2xx_write_word(struct i2c_client *client, int reg, int data) 101 .config_default = INA226_CONFIG_DEFAULT,
84{ 102 .calibration_factor = 5120000,
85 i2c_smbus_write_word_data(client, reg, cpu_to_be16(data)); 103 .registers = INA226_REGISTERS,
86} 104 .shunt_div = 400,
105 .bus_voltage_shift = 0,
106 .bus_voltage_lsb = 1250,
107 .power_lsb = 25000,
108 },
109};
87 110
88static struct ina2xx_data *ina2xx_update_device(struct device *dev) 111static struct ina2xx_data *ina2xx_update_device(struct device *dev)
89{ 112{
@@ -101,8 +124,8 @@ static struct ina2xx_data *ina2xx_update_device(struct device *dev)
101 dev_dbg(&client->dev, "Starting ina2xx update\n"); 124 dev_dbg(&client->dev, "Starting ina2xx update\n");
102 125
103 /* Read all registers */ 126 /* Read all registers */
104 for (i = 0; i < data->registers; i++) { 127 for (i = 0; i < data->config->registers; i++) {
105 int rv = ina2xx_read_word(client, i); 128 int rv = i2c_smbus_read_word_swapped(client, i);
106 if (rv < 0) { 129 if (rv < 0) {
107 ret = ERR_PTR(rv); 130 ret = ERR_PTR(rv);
108 goto abort; 131 goto abort;
@@ -117,73 +140,26 @@ abort:
117 return ret; 140 return ret;
118} 141}
119 142
120static int ina219_get_value(struct ina2xx_data *data, u8 reg) 143static int ina2xx_get_value(struct ina2xx_data *data, u8 reg)
121{
122 /*
123 * calculate exact value for the given register
124 * we assume default power-on reset settings:
125 * bus voltage range 32V
126 * gain = /8
127 * adc 1 & 2 -> conversion time 532uS
128 * mode is continuous shunt and bus
129 * calibration value is INA219_CALIBRATION_VALUE
130 */
131 int val = data->regs[reg];
132
133 switch (reg) {
134 case INA2XX_SHUNT_VOLTAGE:
135 /* LSB=10uV. Convert to mV. */
136 val = DIV_ROUND_CLOSEST(val, 100);
137 break;
138 case INA2XX_BUS_VOLTAGE:
139 /* LSB=4mV. Register is not right aligned, convert to mV. */
140 val = (val >> 3) * 4;
141 break;
142 case INA2XX_POWER:
143 /* LSB=20mW. Convert to uW */
144 val = val * 20 * 1000;
145 break;
146 case INA2XX_CURRENT:
147 /* LSB=1mA (selected). Is in mA */
148 break;
149 default:
150 /* programmer goofed */
151 WARN_ON_ONCE(1);
152 val = 0;
153 break;
154 }
155
156 return val;
157}
158
159static int ina226_get_value(struct ina2xx_data *data, u8 reg)
160{ 144{
161 /* 145 int val;
162 * calculate exact value for the given register
163 * we assume default power-on reset settings:
164 * bus voltage range 32V
165 * gain = /8
166 * adc 1 & 2 -> conversion time 532uS
167 * mode is continuous shunt and bus
168 * calibration value is INA226_CALIBRATION_VALUE
169 */
170 int val = data->regs[reg];
171 146
172 switch (reg) { 147 switch (reg) {
173 case INA2XX_SHUNT_VOLTAGE: 148 case INA2XX_SHUNT_VOLTAGE:
174 /* LSB=2.5uV. Convert to mV. */ 149 val = DIV_ROUND_CLOSEST(data->regs[reg],
175 val = DIV_ROUND_CLOSEST(val, 400); 150 data->config->shunt_div);
176 break; 151 break;
177 case INA2XX_BUS_VOLTAGE: 152 case INA2XX_BUS_VOLTAGE:
178 /* LSB=1.25mV. Convert to mV. */ 153 val = (data->regs[reg] >> data->config->bus_voltage_shift)
179 val = val + DIV_ROUND_CLOSEST(val, 4); 154 * data->config->bus_voltage_lsb;
155 val = DIV_ROUND_CLOSEST(val, 1000);
180 break; 156 break;
181 case INA2XX_POWER: 157 case INA2XX_POWER:
182 /* LSB=25mW. Convert to uW */ 158 val = data->regs[reg] * data->config->power_lsb;
183 val = val * 25 * 1000;
184 break; 159 break;
185 case INA2XX_CURRENT: 160 case INA2XX_CURRENT:
186 /* LSB=1mA (selected). Is in mA */ 161 /* LSB=1mA (selected). Is in mA */
162 val = data->regs[reg];
187 break; 163 break;
188 default: 164 default:
189 /* programmer goofed */ 165 /* programmer goofed */
@@ -200,23 +176,12 @@ static ssize_t ina2xx_show_value(struct device *dev,
200{ 176{
201 struct sensor_device_attribute *attr = to_sensor_dev_attr(da); 177 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
202 struct ina2xx_data *data = ina2xx_update_device(dev); 178 struct ina2xx_data *data = ina2xx_update_device(dev);
203 int value = 0;
204 179
205 if (IS_ERR(data)) 180 if (IS_ERR(data))
206 return PTR_ERR(data); 181 return PTR_ERR(data);
207 182
208 switch (data->kind) { 183 return snprintf(buf, PAGE_SIZE, "%d\n",
209 case ina219: 184 ina2xx_get_value(data, attr->index));
210 value = ina219_get_value(data, attr->index);
211 break;
212 case ina226:
213 value = ina226_get_value(data, attr->index);
214 break;
215 default:
216 WARN_ON_ONCE(1);
217 break;
218 }
219 return snprintf(buf, PAGE_SIZE, "%d\n", value);
220} 185}
221 186
222/* shunt voltage */ 187/* shunt voltage */
@@ -254,7 +219,7 @@ static int ina2xx_probe(struct i2c_client *client,
254 struct i2c_adapter *adapter = client->adapter; 219 struct i2c_adapter *adapter = client->adapter;
255 struct ina2xx_data *data; 220 struct ina2xx_data *data;
256 struct ina2xx_platform_data *pdata; 221 struct ina2xx_platform_data *pdata;
257 int ret = 0; 222 int ret;
258 long shunt = 10000; /* default shunt value 10mOhms */ 223 long shunt = 10000; /* default shunt value 10mOhms */
259 224
260 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) 225 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA))
@@ -275,34 +240,15 @@ static int ina2xx_probe(struct i2c_client *client,
275 240
276 /* set the device type */ 241 /* set the device type */
277 data->kind = id->driver_data; 242 data->kind = id->driver_data;
243 data->config = &ina2xx_config[data->kind];
278 244
279 switch (data->kind) { 245 /* device configuration */
280 case ina219: 246 i2c_smbus_write_word_swapped(client, INA2XX_CONFIG,
281 /* device configuration */ 247 data->config->config_default);
282 ina2xx_write_word(client, INA2XX_CONFIG, INA219_CONFIG_DEFAULT); 248 /* set current LSB to 1mA, shunt is in uOhms */
283 249 /* (equation 13 in datasheet) */
284 /* set current LSB to 1mA, shunt is in uOhms */ 250 i2c_smbus_write_word_swapped(client, INA2XX_CALIBRATION,
285 /* (equation 13 in datasheet) */ 251 data->config->calibration_factor / shunt);
286 ina2xx_write_word(client, INA2XX_CALIBRATION, 40960000 / shunt);
287 dev_info(&client->dev,
288 "power monitor INA219 (Rshunt = %li uOhm)\n", shunt);
289 data->registers = INA219_REGISTERS;
290 break;
291 case ina226:
292 /* device configuration */
293 ina2xx_write_word(client, INA2XX_CONFIG, INA226_CONFIG_DEFAULT);
294
295 /* set current LSB to 1mA, shunt is in uOhms */
296 /* (equation 1 in datasheet)*/
297 ina2xx_write_word(client, INA2XX_CALIBRATION, 5120000 / shunt);
298 dev_info(&client->dev,
299 "power monitor INA226 (Rshunt = %li uOhm)\n", shunt);
300 data->registers = INA226_REGISTERS;
301 break;
302 default:
303 /* unknown device id */
304 return -ENODEV;
305 }
306 252
307 i2c_set_clientdata(client, data); 253 i2c_set_clientdata(client, data);
308 mutex_init(&data->update_lock); 254 mutex_init(&data->update_lock);
@@ -317,6 +263,9 @@ static int ina2xx_probe(struct i2c_client *client,
317 goto out_err_hwmon; 263 goto out_err_hwmon;
318 } 264 }
319 265
266 dev_info(&client->dev, "power monitor %s (Rshunt = %li uOhm)\n",
267 id->name, shunt);
268
320 return 0; 269 return 0;
321 270
322out_err_hwmon: 271out_err_hwmon:
@@ -336,7 +285,9 @@ static int ina2xx_remove(struct i2c_client *client)
336 285
337static const struct i2c_device_id ina2xx_id[] = { 286static const struct i2c_device_id ina2xx_id[] = {
338 { "ina219", ina219 }, 287 { "ina219", ina219 },
288 { "ina220", ina219 },
339 { "ina226", ina226 }, 289 { "ina226", ina226 },
290 { "ina230", ina226 },
340 { } 291 { }
341}; 292};
342MODULE_DEVICE_TABLE(i2c, ina2xx_id); 293MODULE_DEVICE_TABLE(i2c, ina2xx_id);
diff --git a/drivers/hwmon/jz4740-hwmon.c b/drivers/hwmon/jz4740-hwmon.c
index 5253d23361d9..dee9eec2036e 100644
--- a/drivers/hwmon/jz4740-hwmon.c
+++ b/drivers/hwmon/jz4740-hwmon.c
@@ -20,6 +20,7 @@
20#include <linux/mutex.h> 20#include <linux/mutex.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/io.h>
23 24
24#include <linux/completion.h> 25#include <linux/completion.h>
25#include <linux/mfd/core.h> 26#include <linux/mfd/core.h>
@@ -106,42 +107,37 @@ static int __devinit jz4740_hwmon_probe(struct platform_device *pdev)
106 int ret; 107 int ret;
107 struct jz4740_hwmon *hwmon; 108 struct jz4740_hwmon *hwmon;
108 109
109 hwmon = kmalloc(sizeof(*hwmon), GFP_KERNEL); 110 hwmon = devm_kzalloc(&pdev->dev, sizeof(*hwmon), GFP_KERNEL);
110 if (!hwmon) { 111 if (!hwmon)
111 dev_err(&pdev->dev, "Failed to allocate driver structure\n");
112 return -ENOMEM; 112 return -ENOMEM;
113 }
114 113
115 hwmon->cell = mfd_get_cell(pdev); 114 hwmon->cell = mfd_get_cell(pdev);
116 115
117 hwmon->irq = platform_get_irq(pdev, 0); 116 hwmon->irq = platform_get_irq(pdev, 0);
118 if (hwmon->irq < 0) { 117 if (hwmon->irq < 0) {
119 ret = hwmon->irq; 118 dev_err(&pdev->dev, "Failed to get platform irq: %d\n",
120 dev_err(&pdev->dev, "Failed to get platform irq: %d\n", ret); 119 hwmon->irq);
121 goto err_free; 120 return hwmon->irq;
122 } 121 }
123 122
124 hwmon->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 123 hwmon->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
125 if (!hwmon->mem) { 124 if (!hwmon->mem) {
126 ret = -ENOENT;
127 dev_err(&pdev->dev, "Failed to get platform mmio resource\n"); 125 dev_err(&pdev->dev, "Failed to get platform mmio resource\n");
128 goto err_free; 126 return -ENOENT;
129 } 127 }
130 128
131 hwmon->mem = request_mem_region(hwmon->mem->start, 129 hwmon->mem = devm_request_mem_region(&pdev->dev, hwmon->mem->start,
132 resource_size(hwmon->mem), pdev->name); 130 resource_size(hwmon->mem), pdev->name);
133 if (!hwmon->mem) { 131 if (!hwmon->mem) {
134 ret = -EBUSY;
135 dev_err(&pdev->dev, "Failed to request mmio memory region\n"); 132 dev_err(&pdev->dev, "Failed to request mmio memory region\n");
136 goto err_free; 133 return -EBUSY;
137 } 134 }
138 135
139 hwmon->base = ioremap_nocache(hwmon->mem->start, 136 hwmon->base = devm_ioremap_nocache(&pdev->dev, hwmon->mem->start,
140 resource_size(hwmon->mem)); 137 resource_size(hwmon->mem));
141 if (!hwmon->base) { 138 if (!hwmon->base) {
142 ret = -EBUSY;
143 dev_err(&pdev->dev, "Failed to ioremap mmio memory\n"); 139 dev_err(&pdev->dev, "Failed to ioremap mmio memory\n");
144 goto err_release_mem_region; 140 return -EBUSY;
145 } 141 }
146 142
147 init_completion(&hwmon->read_completion); 143 init_completion(&hwmon->read_completion);
@@ -149,17 +145,18 @@ static int __devinit jz4740_hwmon_probe(struct platform_device *pdev)
149 145
150 platform_set_drvdata(pdev, hwmon); 146 platform_set_drvdata(pdev, hwmon);
151 147
152 ret = request_irq(hwmon->irq, jz4740_hwmon_irq, 0, pdev->name, hwmon); 148 ret = devm_request_irq(&pdev->dev, hwmon->irq, jz4740_hwmon_irq, 0,
149 pdev->name, hwmon);
153 if (ret) { 150 if (ret) {
154 dev_err(&pdev->dev, "Failed to request irq: %d\n", ret); 151 dev_err(&pdev->dev, "Failed to request irq: %d\n", ret);
155 goto err_iounmap; 152 return ret;
156 } 153 }
157 disable_irq(hwmon->irq); 154 disable_irq(hwmon->irq);
158 155
159 ret = sysfs_create_group(&pdev->dev.kobj, &jz4740_hwmon_attr_group); 156 ret = sysfs_create_group(&pdev->dev.kobj, &jz4740_hwmon_attr_group);
160 if (ret) { 157 if (ret) {
161 dev_err(&pdev->dev, "Failed to create sysfs group: %d\n", ret); 158 dev_err(&pdev->dev, "Failed to create sysfs group: %d\n", ret);
162 goto err_free_irq; 159 return ret;
163 } 160 }
164 161
165 hwmon->hwmon = hwmon_device_register(&pdev->dev); 162 hwmon->hwmon = hwmon_device_register(&pdev->dev);
@@ -172,16 +169,6 @@ static int __devinit jz4740_hwmon_probe(struct platform_device *pdev)
172 169
173err_remove_file: 170err_remove_file:
174 sysfs_remove_group(&pdev->dev.kobj, &jz4740_hwmon_attr_group); 171 sysfs_remove_group(&pdev->dev.kobj, &jz4740_hwmon_attr_group);
175err_free_irq:
176 free_irq(hwmon->irq, hwmon);
177err_iounmap:
178 platform_set_drvdata(pdev, NULL);
179 iounmap(hwmon->base);
180err_release_mem_region:
181 release_mem_region(hwmon->mem->start, resource_size(hwmon->mem));
182err_free:
183 kfree(hwmon);
184
185 return ret; 172 return ret;
186} 173}
187 174
@@ -192,14 +179,6 @@ static int __devexit jz4740_hwmon_remove(struct platform_device *pdev)
192 hwmon_device_unregister(hwmon->hwmon); 179 hwmon_device_unregister(hwmon->hwmon);
193 sysfs_remove_group(&pdev->dev.kobj, &jz4740_hwmon_attr_group); 180 sysfs_remove_group(&pdev->dev.kobj, &jz4740_hwmon_attr_group);
194 181
195 free_irq(hwmon->irq, hwmon);
196
197 iounmap(hwmon->base);
198 release_mem_region(hwmon->mem->start, resource_size(hwmon->mem));
199
200 platform_set_drvdata(pdev, NULL);
201 kfree(hwmon);
202
203 return 0; 182 return 0;
204} 183}
205 184
diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c
index 472f79521a96..2d1777a03edb 100644
--- a/drivers/hwmon/lm70.c
+++ b/drivers/hwmon/lm70.c
@@ -43,6 +43,8 @@
43 43
44#define LM70_CHIP_LM70 0 /* original NS LM70 */ 44#define LM70_CHIP_LM70 0 /* original NS LM70 */
45#define LM70_CHIP_TMP121 1 /* TI TMP121/TMP123 */ 45#define LM70_CHIP_TMP121 1 /* TI TMP121/TMP123 */
46#define LM70_CHIP_LM71 2 /* NS LM71 */
47#define LM70_CHIP_LM74 3 /* NS LM74 */
46 48
47struct lm70 { 49struct lm70 {
48 struct device *hwmon_dev; 50 struct device *hwmon_dev;
@@ -88,9 +90,13 @@ static ssize_t lm70_sense_temp(struct device *dev,
88 * Celsius. 90 * Celsius.
89 * So it's equivalent to multiplying by 0.25 * 1000 = 250. 91 * So it's equivalent to multiplying by 0.25 * 1000 = 250.
90 * 92 *
91 * TMP121/TMP123: 93 * LM74 and TMP121/TMP123:
92 * 13 bits of 2's complement data, discard LSB 3 bits, 94 * 13 bits of 2's complement data, discard LSB 3 bits,
93 * resolution 0.0625 degrees celsius. 95 * resolution 0.0625 degrees celsius.
96 *
97 * LM71:
98 * 14 bits of 2's complement data, discard LSB 2 bits,
99 * resolution 0.0312 degrees celsius.
94 */ 100 */
95 switch (p_lm70->chip) { 101 switch (p_lm70->chip) {
96 case LM70_CHIP_LM70: 102 case LM70_CHIP_LM70:
@@ -98,8 +104,13 @@ static ssize_t lm70_sense_temp(struct device *dev,
98 break; 104 break;
99 105
100 case LM70_CHIP_TMP121: 106 case LM70_CHIP_TMP121:
107 case LM70_CHIP_LM74:
101 val = ((int)raw / 8) * 625 / 10; 108 val = ((int)raw / 8) * 625 / 10;
102 break; 109 break;
110
111 case LM70_CHIP_LM71:
112 val = ((int)raw / 4) * 3125 / 100;
113 break;
103 } 114 }
104 115
105 status = sprintf(buf, "%d\n", val); /* millidegrees Celsius */ 116 status = sprintf(buf, "%d\n", val); /* millidegrees Celsius */
@@ -113,20 +124,7 @@ static DEVICE_ATTR(temp1_input, S_IRUGO, lm70_sense_temp, NULL);
113static ssize_t lm70_show_name(struct device *dev, struct device_attribute 124static ssize_t lm70_show_name(struct device *dev, struct device_attribute
114 *devattr, char *buf) 125 *devattr, char *buf)
115{ 126{
116 struct lm70 *p_lm70 = dev_get_drvdata(dev); 127 return sprintf(buf, "%s\n", to_spi_device(dev)->modalias);
117 int ret;
118
119 switch (p_lm70->chip) {
120 case LM70_CHIP_LM70:
121 ret = sprintf(buf, "lm70\n");
122 break;
123 case LM70_CHIP_TMP121:
124 ret = sprintf(buf, "tmp121\n");
125 break;
126 default:
127 ret = -EINVAL;
128 }
129 return ret;
130} 128}
131 129
132static DEVICE_ATTR(name, S_IRUGO, lm70_show_name, NULL); 130static DEVICE_ATTR(name, S_IRUGO, lm70_show_name, NULL);
@@ -139,17 +137,13 @@ static int __devinit lm70_probe(struct spi_device *spi)
139 struct lm70 *p_lm70; 137 struct lm70 *p_lm70;
140 int status; 138 int status;
141 139
142 /* signaling is SPI_MODE_0 for both LM70 and TMP121 */ 140 /* signaling is SPI_MODE_0 */
143 if (spi->mode & (SPI_CPOL | SPI_CPHA)) 141 if (spi->mode & (SPI_CPOL | SPI_CPHA))
144 return -EINVAL; 142 return -EINVAL;
145 143
146 /* 3-wire link (shared SI/SO) for LM70 */
147 if (chip == LM70_CHIP_LM70 && !(spi->mode & SPI_3WIRE))
148 return -EINVAL;
149
150 /* NOTE: we assume 8-bit words, and convert to 16 bits manually */ 144 /* NOTE: we assume 8-bit words, and convert to 16 bits manually */
151 145
152 p_lm70 = kzalloc(sizeof *p_lm70, GFP_KERNEL); 146 p_lm70 = devm_kzalloc(&spi->dev, sizeof(*p_lm70), GFP_KERNEL);
153 if (!p_lm70) 147 if (!p_lm70)
154 return -ENOMEM; 148 return -ENOMEM;
155 149
@@ -181,7 +175,6 @@ out_dev_create_file_failed:
181 device_remove_file(&spi->dev, &dev_attr_temp1_input); 175 device_remove_file(&spi->dev, &dev_attr_temp1_input);
182out_dev_create_temp_file_failed: 176out_dev_create_temp_file_failed:
183 spi_set_drvdata(spi, NULL); 177 spi_set_drvdata(spi, NULL);
184 kfree(p_lm70);
185 return status; 178 return status;
186} 179}
187 180
@@ -193,7 +186,6 @@ static int __devexit lm70_remove(struct spi_device *spi)
193 device_remove_file(&spi->dev, &dev_attr_temp1_input); 186 device_remove_file(&spi->dev, &dev_attr_temp1_input);
194 device_remove_file(&spi->dev, &dev_attr_name); 187 device_remove_file(&spi->dev, &dev_attr_name);
195 spi_set_drvdata(spi, NULL); 188 spi_set_drvdata(spi, NULL);
196 kfree(p_lm70);
197 189
198 return 0; 190 return 0;
199} 191}
@@ -202,6 +194,8 @@ static int __devexit lm70_remove(struct spi_device *spi)
202static const struct spi_device_id lm70_ids[] = { 194static const struct spi_device_id lm70_ids[] = {
203 { "lm70", LM70_CHIP_LM70 }, 195 { "lm70", LM70_CHIP_LM70 },
204 { "tmp121", LM70_CHIP_TMP121 }, 196 { "tmp121", LM70_CHIP_TMP121 },
197 { "lm71", LM70_CHIP_LM71 },
198 { "lm74", LM70_CHIP_LM74 },
205 { }, 199 { },
206}; 200};
207MODULE_DEVICE_TABLE(spi, lm70_ids); 201MODULE_DEVICE_TABLE(spi, lm70_ids);
@@ -219,5 +213,5 @@ static struct spi_driver lm70_driver = {
219module_spi_driver(lm70_driver); 213module_spi_driver(lm70_driver);
220 214
221MODULE_AUTHOR("Kaiwan N Billimoria"); 215MODULE_AUTHOR("Kaiwan N Billimoria");
222MODULE_DESCRIPTION("NS LM70 / TI TMP121/TMP123 Linux driver"); 216MODULE_DESCRIPTION("NS LM70 and compatibles Linux driver");
223MODULE_LICENSE("GPL"); 217MODULE_LICENSE("GPL");
diff --git a/drivers/hwmon/lm93.c b/drivers/hwmon/lm93.c
index bf946187bd37..c3d4255ed154 100644
--- a/drivers/hwmon/lm93.c
+++ b/drivers/hwmon/lm93.c
@@ -1830,7 +1830,7 @@ static ssize_t store_fan_smart_tach(struct device *dev,
1830 1830
1831 mutex_lock(&data->update_lock); 1831 mutex_lock(&data->update_lock);
1832 /* sanity test, ignore the write otherwise */ 1832 /* sanity test, ignore the write otherwise */
1833 if (0 <= val && val <= 2) { 1833 if (val <= 2) {
1834 /* can't enable if pwm freq is 22.5KHz */ 1834 /* can't enable if pwm freq is 22.5KHz */
1835 if (val) { 1835 if (val) {
1836 u8 ctl4 = lm93_read_byte(client, 1836 u8 ctl4 = lm93_read_byte(client,
diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c
index bd8cdb7b96ed..4b68fb2a31d7 100644
--- a/drivers/hwmon/lm95241.c
+++ b/drivers/hwmon/lm95241.c
@@ -391,11 +391,10 @@ static int lm95241_probe(struct i2c_client *new_client,
391 struct lm95241_data *data; 391 struct lm95241_data *data;
392 int err; 392 int err;
393 393
394 data = kzalloc(sizeof(struct lm95241_data), GFP_KERNEL); 394 data = devm_kzalloc(&new_client->dev, sizeof(struct lm95241_data),
395 if (!data) { 395 GFP_KERNEL);
396 err = -ENOMEM; 396 if (!data)
397 goto exit; 397 return -ENOMEM;
398 }
399 398
400 i2c_set_clientdata(new_client, data); 399 i2c_set_clientdata(new_client, data);
401 mutex_init(&data->update_lock); 400 mutex_init(&data->update_lock);
@@ -406,7 +405,7 @@ static int lm95241_probe(struct i2c_client *new_client,
406 /* Register sysfs hooks */ 405 /* Register sysfs hooks */
407 err = sysfs_create_group(&new_client->dev.kobj, &lm95241_group); 406 err = sysfs_create_group(&new_client->dev.kobj, &lm95241_group);
408 if (err) 407 if (err)
409 goto exit_free; 408 return err;
410 409
411 data->hwmon_dev = hwmon_device_register(&new_client->dev); 410 data->hwmon_dev = hwmon_device_register(&new_client->dev);
412 if (IS_ERR(data->hwmon_dev)) { 411 if (IS_ERR(data->hwmon_dev)) {
@@ -418,9 +417,6 @@ static int lm95241_probe(struct i2c_client *new_client,
418 417
419exit_remove_files: 418exit_remove_files:
420 sysfs_remove_group(&new_client->dev.kobj, &lm95241_group); 419 sysfs_remove_group(&new_client->dev.kobj, &lm95241_group);
421exit_free:
422 kfree(data);
423exit:
424 return err; 420 return err;
425} 421}
426 422
@@ -431,7 +427,6 @@ static int lm95241_remove(struct i2c_client *client)
431 hwmon_device_unregister(data->hwmon_dev); 427 hwmon_device_unregister(data->hwmon_dev);
432 sysfs_remove_group(&client->dev.kobj, &lm95241_group); 428 sysfs_remove_group(&client->dev.kobj, &lm95241_group);
433 429
434 kfree(data);
435 return 0; 430 return 0;
436} 431}
437 432
diff --git a/drivers/hwmon/lm95245.c b/drivers/hwmon/lm95245.c
index 9a46c106a240..2915fd908364 100644
--- a/drivers/hwmon/lm95245.c
+++ b/drivers/hwmon/lm95245.c
@@ -462,11 +462,10 @@ static int lm95245_probe(struct i2c_client *new_client,
462 struct lm95245_data *data; 462 struct lm95245_data *data;
463 int err; 463 int err;
464 464
465 data = kzalloc(sizeof(struct lm95245_data), GFP_KERNEL); 465 data = devm_kzalloc(&new_client->dev, sizeof(struct lm95245_data),
466 if (!data) { 466 GFP_KERNEL);
467 err = -ENOMEM; 467 if (!data)
468 goto exit; 468 return -ENOMEM;
469 }
470 469
471 i2c_set_clientdata(new_client, data); 470 i2c_set_clientdata(new_client, data);
472 mutex_init(&data->update_lock); 471 mutex_init(&data->update_lock);
@@ -477,7 +476,7 @@ static int lm95245_probe(struct i2c_client *new_client,
477 /* Register sysfs hooks */ 476 /* Register sysfs hooks */
478 err = sysfs_create_group(&new_client->dev.kobj, &lm95245_group); 477 err = sysfs_create_group(&new_client->dev.kobj, &lm95245_group);
479 if (err) 478 if (err)
480 goto exit_free; 479 return err;
481 480
482 data->hwmon_dev = hwmon_device_register(&new_client->dev); 481 data->hwmon_dev = hwmon_device_register(&new_client->dev);
483 if (IS_ERR(data->hwmon_dev)) { 482 if (IS_ERR(data->hwmon_dev)) {
@@ -489,9 +488,6 @@ static int lm95245_probe(struct i2c_client *new_client,
489 488
490exit_remove_files: 489exit_remove_files:
491 sysfs_remove_group(&new_client->dev.kobj, &lm95245_group); 490 sysfs_remove_group(&new_client->dev.kobj, &lm95245_group);
492exit_free:
493 kfree(data);
494exit:
495 return err; 491 return err;
496} 492}
497 493
@@ -502,7 +498,6 @@ static int lm95245_remove(struct i2c_client *client)
502 hwmon_device_unregister(data->hwmon_dev); 498 hwmon_device_unregister(data->hwmon_dev);
503 sysfs_remove_group(&client->dev.kobj, &lm95245_group); 499 sysfs_remove_group(&client->dev.kobj, &lm95245_group);
504 500
505 kfree(data);
506 return 0; 501 return 0;
507} 502}
508 503
diff --git a/drivers/hwmon/ltc4151.c b/drivers/hwmon/ltc4151.c
index 4d005b219de2..8496baa08bc8 100644
--- a/drivers/hwmon/ltc4151.c
+++ b/drivers/hwmon/ltc4151.c
@@ -181,11 +181,9 @@ static int ltc4151_probe(struct i2c_client *client,
181 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 181 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
182 return -ENODEV; 182 return -ENODEV;
183 183
184 data = kzalloc(sizeof(*data), GFP_KERNEL); 184 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
185 if (!data) { 185 if (!data)
186 ret = -ENOMEM; 186 return -ENOMEM;
187 goto out_kzalloc;
188 }
189 187
190 i2c_set_clientdata(client, data); 188 i2c_set_clientdata(client, data);
191 mutex_init(&data->update_lock); 189 mutex_init(&data->update_lock);
@@ -193,7 +191,7 @@ static int ltc4151_probe(struct i2c_client *client,
193 /* Register sysfs hooks */ 191 /* Register sysfs hooks */
194 ret = sysfs_create_group(&client->dev.kobj, &ltc4151_group); 192 ret = sysfs_create_group(&client->dev.kobj, &ltc4151_group);
195 if (ret) 193 if (ret)
196 goto out_sysfs_create_group; 194 return ret;
197 195
198 data->hwmon_dev = hwmon_device_register(&client->dev); 196 data->hwmon_dev = hwmon_device_register(&client->dev);
199 if (IS_ERR(data->hwmon_dev)) { 197 if (IS_ERR(data->hwmon_dev)) {
@@ -205,9 +203,6 @@ static int ltc4151_probe(struct i2c_client *client,
205 203
206out_hwmon_device_register: 204out_hwmon_device_register:
207 sysfs_remove_group(&client->dev.kobj, &ltc4151_group); 205 sysfs_remove_group(&client->dev.kobj, &ltc4151_group);
208out_sysfs_create_group:
209 kfree(data);
210out_kzalloc:
211 return ret; 206 return ret;
212} 207}
213 208
@@ -218,8 +213,6 @@ static int ltc4151_remove(struct i2c_client *client)
218 hwmon_device_unregister(data->hwmon_dev); 213 hwmon_device_unregister(data->hwmon_dev);
219 sysfs_remove_group(&client->dev.kobj, &ltc4151_group); 214 sysfs_remove_group(&client->dev.kobj, &ltc4151_group);
220 215
221 kfree(data);
222
223 return 0; 216 return 0;
224} 217}
225 218
diff --git a/drivers/hwmon/ltc4215.c b/drivers/hwmon/ltc4215.c
index 429c5b2b66fd..98b3d04f98b7 100644
--- a/drivers/hwmon/ltc4215.c
+++ b/drivers/hwmon/ltc4215.c
@@ -253,11 +253,9 @@ static int ltc4215_probe(struct i2c_client *client,
253 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 253 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
254 return -ENODEV; 254 return -ENODEV;
255 255
256 data = kzalloc(sizeof(*data), GFP_KERNEL); 256 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
257 if (!data) { 257 if (!data)
258 ret = -ENOMEM; 258 return -ENOMEM;
259 goto out_kzalloc;
260 }
261 259
262 i2c_set_clientdata(client, data); 260 i2c_set_clientdata(client, data);
263 mutex_init(&data->update_lock); 261 mutex_init(&data->update_lock);
@@ -268,7 +266,7 @@ static int ltc4215_probe(struct i2c_client *client,
268 /* Register sysfs hooks */ 266 /* Register sysfs hooks */
269 ret = sysfs_create_group(&client->dev.kobj, &ltc4215_group); 267 ret = sysfs_create_group(&client->dev.kobj, &ltc4215_group);
270 if (ret) 268 if (ret)
271 goto out_sysfs_create_group; 269 return ret;
272 270
273 data->hwmon_dev = hwmon_device_register(&client->dev); 271 data->hwmon_dev = hwmon_device_register(&client->dev);
274 if (IS_ERR(data->hwmon_dev)) { 272 if (IS_ERR(data->hwmon_dev)) {
@@ -280,9 +278,6 @@ static int ltc4215_probe(struct i2c_client *client,
280 278
281out_hwmon_device_register: 279out_hwmon_device_register:
282 sysfs_remove_group(&client->dev.kobj, &ltc4215_group); 280 sysfs_remove_group(&client->dev.kobj, &ltc4215_group);
283out_sysfs_create_group:
284 kfree(data);
285out_kzalloc:
286 return ret; 281 return ret;
287} 282}
288 283
@@ -293,8 +288,6 @@ static int ltc4215_remove(struct i2c_client *client)
293 hwmon_device_unregister(data->hwmon_dev); 288 hwmon_device_unregister(data->hwmon_dev);
294 sysfs_remove_group(&client->dev.kobj, &ltc4215_group); 289 sysfs_remove_group(&client->dev.kobj, &ltc4215_group);
295 290
296 kfree(data);
297
298 return 0; 291 return 0;
299} 292}
300 293
diff --git a/drivers/hwmon/ltc4245.c b/drivers/hwmon/ltc4245.c
index b99b45bafdad..52075914eb0b 100644
--- a/drivers/hwmon/ltc4245.c
+++ b/drivers/hwmon/ltc4245.c
@@ -519,11 +519,9 @@ static int ltc4245_probe(struct i2c_client *client,
519 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 519 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
520 return -ENODEV; 520 return -ENODEV;
521 521
522 data = kzalloc(sizeof(*data), GFP_KERNEL); 522 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
523 if (!data) { 523 if (!data)
524 ret = -ENOMEM; 524 return -ENOMEM;
525 goto out_kzalloc;
526 }
527 525
528 i2c_set_clientdata(client, data); 526 i2c_set_clientdata(client, data);
529 mutex_init(&data->update_lock); 527 mutex_init(&data->update_lock);
@@ -536,7 +534,7 @@ static int ltc4245_probe(struct i2c_client *client,
536 /* Register sysfs hooks */ 534 /* Register sysfs hooks */
537 ret = ltc4245_sysfs_create_groups(client); 535 ret = ltc4245_sysfs_create_groups(client);
538 if (ret) 536 if (ret)
539 goto out_sysfs_create_groups; 537 return ret;
540 538
541 data->hwmon_dev = hwmon_device_register(&client->dev); 539 data->hwmon_dev = hwmon_device_register(&client->dev);
542 if (IS_ERR(data->hwmon_dev)) { 540 if (IS_ERR(data->hwmon_dev)) {
@@ -548,9 +546,6 @@ static int ltc4245_probe(struct i2c_client *client,
548 546
549out_hwmon_device_register: 547out_hwmon_device_register:
550 ltc4245_sysfs_remove_groups(client); 548 ltc4245_sysfs_remove_groups(client);
551out_sysfs_create_groups:
552 kfree(data);
553out_kzalloc:
554 return ret; 549 return ret;
555} 550}
556 551
@@ -560,7 +555,6 @@ static int ltc4245_remove(struct i2c_client *client)
560 555
561 hwmon_device_unregister(data->hwmon_dev); 556 hwmon_device_unregister(data->hwmon_dev);
562 ltc4245_sysfs_remove_groups(client); 557 ltc4245_sysfs_remove_groups(client);
563 kfree(data);
564 558
565 return 0; 559 return 0;
566} 560}
diff --git a/drivers/hwmon/max1111.c b/drivers/hwmon/max1111.c
index f3978a46e844..b4eb0889c465 100644
--- a/drivers/hwmon/max1111.c
+++ b/drivers/hwmon/max1111.c
@@ -22,6 +22,8 @@
22#include <linux/spi/spi.h> 22#include <linux/spi/spi.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24 24
25enum chips { max1110, max1111, max1112, max1113 };
26
25#define MAX1111_TX_BUF_SIZE 1 27#define MAX1111_TX_BUF_SIZE 1
26#define MAX1111_RX_BUF_SIZE 2 28#define MAX1111_RX_BUF_SIZE 2
27 29
@@ -30,6 +32,7 @@
30#define MAX1111_CTRL_PD1 (1u << 1) 32#define MAX1111_CTRL_PD1 (1u << 1)
31#define MAX1111_CTRL_SGL (1u << 2) 33#define MAX1111_CTRL_SGL (1u << 2)
32#define MAX1111_CTRL_UNI (1u << 3) 34#define MAX1111_CTRL_UNI (1u << 3)
35#define MAX1110_CTRL_SEL_SH (4)
33#define MAX1111_CTRL_SEL_SH (5) /* NOTE: bit 4 is ignored */ 36#define MAX1111_CTRL_SEL_SH (5) /* NOTE: bit 4 is ignored */
34#define MAX1111_CTRL_STR (1u << 7) 37#define MAX1111_CTRL_STR (1u << 7)
35 38
@@ -42,6 +45,8 @@ struct max1111_data {
42 uint8_t rx_buf[MAX1111_RX_BUF_SIZE]; 45 uint8_t rx_buf[MAX1111_RX_BUF_SIZE];
43 struct mutex drvdata_lock; 46 struct mutex drvdata_lock;
44 /* protect msg, xfer and buffers from multiple access */ 47 /* protect msg, xfer and buffers from multiple access */
48 int sel_sh;
49 int lsb;
45}; 50};
46 51
47static int max1111_read(struct device *dev, int channel) 52static int max1111_read(struct device *dev, int channel)
@@ -53,7 +58,7 @@ static int max1111_read(struct device *dev, int channel)
53 /* writing to drvdata struct is not thread safe, wait on mutex */ 58 /* writing to drvdata struct is not thread safe, wait on mutex */
54 mutex_lock(&data->drvdata_lock); 59 mutex_lock(&data->drvdata_lock);
55 60
56 data->tx_buf[0] = (channel << MAX1111_CTRL_SEL_SH) | 61 data->tx_buf[0] = (channel << data->sel_sh) |
57 MAX1111_CTRL_PD0 | MAX1111_CTRL_PD1 | 62 MAX1111_CTRL_PD0 | MAX1111_CTRL_PD1 |
58 MAX1111_CTRL_SGL | MAX1111_CTRL_UNI | MAX1111_CTRL_STR; 63 MAX1111_CTRL_SGL | MAX1111_CTRL_UNI | MAX1111_CTRL_STR;
59 64
@@ -93,12 +98,13 @@ EXPORT_SYMBOL(max1111_read_channel);
93static ssize_t show_name(struct device *dev, 98static ssize_t show_name(struct device *dev,
94 struct device_attribute *attr, char *buf) 99 struct device_attribute *attr, char *buf)
95{ 100{
96 return sprintf(buf, "max1111\n"); 101 return sprintf(buf, "%s\n", to_spi_device(dev)->modalias);
97} 102}
98 103
99static ssize_t show_adc(struct device *dev, 104static ssize_t show_adc(struct device *dev,
100 struct device_attribute *attr, char *buf) 105 struct device_attribute *attr, char *buf)
101{ 106{
107 struct max1111_data *data = dev_get_drvdata(dev);
102 int channel = to_sensor_dev_attr(attr)->index; 108 int channel = to_sensor_dev_attr(attr)->index;
103 int ret; 109 int ret;
104 110
@@ -107,10 +113,10 @@ static ssize_t show_adc(struct device *dev,
107 return ret; 113 return ret;
108 114
109 /* 115 /*
110 * assume the reference voltage to be 2.048V, with an 8-bit sample, 116 * Assume the reference voltage to be 2.048V or 4.096V, with an 8-bit
111 * the LSB weight is 8mV 117 * sample. The LSB weight is 8mV or 16mV depending on the chip type.
112 */ 118 */
113 return sprintf(buf, "%d\n", ret * 8); 119 return sprintf(buf, "%d\n", ret * data->lsb);
114} 120}
115 121
116#define MAX1111_ADC_ATTR(_id) \ 122#define MAX1111_ADC_ATTR(_id) \
@@ -121,6 +127,10 @@ static MAX1111_ADC_ATTR(0);
121static MAX1111_ADC_ATTR(1); 127static MAX1111_ADC_ATTR(1);
122static MAX1111_ADC_ATTR(2); 128static MAX1111_ADC_ATTR(2);
123static MAX1111_ADC_ATTR(3); 129static MAX1111_ADC_ATTR(3);
130static MAX1111_ADC_ATTR(4);
131static MAX1111_ADC_ATTR(5);
132static MAX1111_ADC_ATTR(6);
133static MAX1111_ADC_ATTR(7);
124 134
125static struct attribute *max1111_attributes[] = { 135static struct attribute *max1111_attributes[] = {
126 &dev_attr_name.attr, 136 &dev_attr_name.attr,
@@ -135,6 +145,18 @@ static const struct attribute_group max1111_attr_group = {
135 .attrs = max1111_attributes, 145 .attrs = max1111_attributes,
136}; 146};
137 147
148static struct attribute *max1110_attributes[] = {
149 &sensor_dev_attr_in4_input.dev_attr.attr,
150 &sensor_dev_attr_in5_input.dev_attr.attr,
151 &sensor_dev_attr_in6_input.dev_attr.attr,
152 &sensor_dev_attr_in7_input.dev_attr.attr,
153 NULL,
154};
155
156static const struct attribute_group max1110_attr_group = {
157 .attrs = max1110_attributes,
158};
159
138static int __devinit setup_transfer(struct max1111_data *data) 160static int __devinit setup_transfer(struct max1111_data *data)
139{ 161{
140 struct spi_message *m; 162 struct spi_message *m;
@@ -159,6 +181,7 @@ static int __devinit setup_transfer(struct max1111_data *data)
159 181
160static int __devinit max1111_probe(struct spi_device *spi) 182static int __devinit max1111_probe(struct spi_device *spi)
161{ 183{
184 enum chips chip = spi_get_device_id(spi)->driver_data;
162 struct max1111_data *data; 185 struct max1111_data *data;
163 int err; 186 int err;
164 187
@@ -174,6 +197,24 @@ static int __devinit max1111_probe(struct spi_device *spi)
174 return -ENOMEM; 197 return -ENOMEM;
175 } 198 }
176 199
200 switch (chip) {
201 case max1110:
202 data->lsb = 8;
203 data->sel_sh = MAX1110_CTRL_SEL_SH;
204 break;
205 case max1111:
206 data->lsb = 8;
207 data->sel_sh = MAX1111_CTRL_SEL_SH;
208 break;
209 case max1112:
210 data->lsb = 16;
211 data->sel_sh = MAX1110_CTRL_SEL_SH;
212 break;
213 case max1113:
214 data->lsb = 16;
215 data->sel_sh = MAX1111_CTRL_SEL_SH;
216 break;
217 }
177 err = setup_transfer(data); 218 err = setup_transfer(data);
178 if (err) 219 if (err)
179 return err; 220 return err;
@@ -188,6 +229,14 @@ static int __devinit max1111_probe(struct spi_device *spi)
188 dev_err(&spi->dev, "failed to create attribute group\n"); 229 dev_err(&spi->dev, "failed to create attribute group\n");
189 return err; 230 return err;
190 } 231 }
232 if (chip == max1110 || chip == max1112) {
233 err = sysfs_create_group(&spi->dev.kobj, &max1110_attr_group);
234 if (err) {
235 dev_err(&spi->dev,
236 "failed to create extended attribute group\n");
237 goto err_remove;
238 }
239 }
191 240
192 data->hwmon_dev = hwmon_device_register(&spi->dev); 241 data->hwmon_dev = hwmon_device_register(&spi->dev);
193 if (IS_ERR(data->hwmon_dev)) { 242 if (IS_ERR(data->hwmon_dev)) {
@@ -202,6 +251,7 @@ static int __devinit max1111_probe(struct spi_device *spi)
202 return 0; 251 return 0;
203 252
204err_remove: 253err_remove:
254 sysfs_remove_group(&spi->dev.kobj, &max1110_attr_group);
205 sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group); 255 sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group);
206 return err; 256 return err;
207} 257}
@@ -211,16 +261,27 @@ static int __devexit max1111_remove(struct spi_device *spi)
211 struct max1111_data *data = spi_get_drvdata(spi); 261 struct max1111_data *data = spi_get_drvdata(spi);
212 262
213 hwmon_device_unregister(data->hwmon_dev); 263 hwmon_device_unregister(data->hwmon_dev);
264 sysfs_remove_group(&spi->dev.kobj, &max1110_attr_group);
214 sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group); 265 sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group);
215 mutex_destroy(&data->drvdata_lock); 266 mutex_destroy(&data->drvdata_lock);
216 return 0; 267 return 0;
217} 268}
218 269
270static const struct spi_device_id max1111_ids[] = {
271 { "max1110", max1110 },
272 { "max1111", max1111 },
273 { "max1112", max1112 },
274 { "max1113", max1113 },
275 { },
276};
277MODULE_DEVICE_TABLE(spi, max1111_ids);
278
219static struct spi_driver max1111_driver = { 279static struct spi_driver max1111_driver = {
220 .driver = { 280 .driver = {
221 .name = "max1111", 281 .name = "max1111",
222 .owner = THIS_MODULE, 282 .owner = THIS_MODULE,
223 }, 283 },
284 .id_table = max1111_ids,
224 .probe = max1111_probe, 285 .probe = max1111_probe,
225 .remove = __devexit_p(max1111_remove), 286 .remove = __devexit_p(max1111_remove),
226}; 287};
@@ -228,6 +289,5 @@ static struct spi_driver max1111_driver = {
228module_spi_driver(max1111_driver); 289module_spi_driver(max1111_driver);
229 290
230MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>"); 291MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>");
231MODULE_DESCRIPTION("MAX1111 ADC Driver"); 292MODULE_DESCRIPTION("MAX1110/MAX1111/MAX1112/MAX1113 ADC Driver");
232MODULE_LICENSE("GPL"); 293MODULE_LICENSE("GPL");
233MODULE_ALIAS("spi:max1111");
diff --git a/drivers/hwmon/max1668.c b/drivers/hwmon/max1668.c
index 335b183d7c02..666d9f6263eb 100644
--- a/drivers/hwmon/max1668.c
+++ b/drivers/hwmon/max1668.c
@@ -411,7 +411,8 @@ static int max1668_probe(struct i2c_client *client,
411 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 411 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
412 return -ENODEV; 412 return -ENODEV;
413 413
414 data = kzalloc(sizeof(struct max1668_data), GFP_KERNEL); 414 data = devm_kzalloc(&client->dev, sizeof(struct max1668_data),
415 GFP_KERNEL);
415 if (!data) 416 if (!data)
416 return -ENOMEM; 417 return -ENOMEM;
417 418
@@ -422,7 +423,7 @@ static int max1668_probe(struct i2c_client *client,
422 /* Register sysfs hooks */ 423 /* Register sysfs hooks */
423 err = sysfs_create_group(&client->dev.kobj, &max1668_group_common); 424 err = sysfs_create_group(&client->dev.kobj, &max1668_group_common);
424 if (err) 425 if (err)
425 goto error_free; 426 return err;
426 427
427 if (data->type == max1668 || data->type == max1989) { 428 if (data->type == max1668 || data->type == max1989) {
428 err = sysfs_create_group(&client->dev.kobj, 429 err = sysfs_create_group(&client->dev.kobj,
@@ -444,8 +445,6 @@ error_sysrem1:
444 sysfs_remove_group(&client->dev.kobj, &max1668_group_unique); 445 sysfs_remove_group(&client->dev.kobj, &max1668_group_unique);
445error_sysrem0: 446error_sysrem0:
446 sysfs_remove_group(&client->dev.kobj, &max1668_group_common); 447 sysfs_remove_group(&client->dev.kobj, &max1668_group_common);
447error_free:
448 kfree(data);
449 return err; 448 return err;
450} 449}
451 450
@@ -459,7 +458,6 @@ static int max1668_remove(struct i2c_client *client)
459 458
460 sysfs_remove_group(&client->dev.kobj, &max1668_group_common); 459 sysfs_remove_group(&client->dev.kobj, &max1668_group_common);
461 460
462 kfree(data);
463 return 0; 461 return 0;
464} 462}
465 463
diff --git a/drivers/hwmon/max197.c b/drivers/hwmon/max197.c
new file mode 100644
index 000000000000..6304f2616fa7
--- /dev/null
+++ b/drivers/hwmon/max197.c
@@ -0,0 +1,349 @@
1/*
2 * Maxim MAX197 A/D Converter driver
3 *
4 * Copyright (c) 2012 Savoir-faire Linux Inc.
5 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * For further information, see the Documentation/hwmon/max197 file.
12 */
13
14#include <linux/kernel.h>
15#include <linux/module.h>
16#include <linux/init.h>
17#include <linux/err.h>
18#include <linux/slab.h>
19#include <linux/mutex.h>
20#include <linux/device.h>
21#include <linux/sysfs.h>
22#include <linux/hwmon.h>
23#include <linux/hwmon-sysfs.h>
24#include <linux/platform_device.h>
25#include <linux/platform_data/max197.h>
26
27#define MAX199_LIMIT 4000 /* 4V */
28#define MAX197_LIMIT 10000 /* 10V */
29
30#define MAX197_NUM_CH 8 /* 8 Analog Input Channels */
31
32/* Control byte format */
33#define MAX197_BIP (1 << 3) /* Bipolarity */
34#define MAX197_RNG (1 << 4) /* Full range */
35
36#define MAX197_SCALE 12207 /* Scale coefficient for raw data */
37
38/* List of supported chips */
39enum max197_chips { max197, max199 };
40
41/**
42 * struct max197_data - device instance specific data
43 * @pdata: Platform data.
44 * @hwmon_dev: The hwmon device.
45 * @lock: Read/Write mutex.
46 * @limit: Max range value (10V for MAX197, 4V for MAX199).
47 * @scale: Need to scale.
48 * @ctrl_bytes: Channels control byte.
49 */
50struct max197_data {
51 struct max197_platform_data *pdata;
52 struct device *hwmon_dev;
53 struct mutex lock;
54 int limit;
55 bool scale;
56 u8 ctrl_bytes[MAX197_NUM_CH];
57};
58
59static inline void max197_set_unipolarity(struct max197_data *data, int channel)
60{
61 data->ctrl_bytes[channel] &= ~MAX197_BIP;
62}
63
64static inline void max197_set_bipolarity(struct max197_data *data, int channel)
65{
66 data->ctrl_bytes[channel] |= MAX197_BIP;
67}
68
69static inline void max197_set_half_range(struct max197_data *data, int channel)
70{
71 data->ctrl_bytes[channel] &= ~MAX197_RNG;
72}
73
74static inline void max197_set_full_range(struct max197_data *data, int channel)
75{
76 data->ctrl_bytes[channel] |= MAX197_RNG;
77}
78
79static inline bool max197_is_bipolar(struct max197_data *data, int channel)
80{
81 return data->ctrl_bytes[channel] & MAX197_BIP;
82}
83
84static inline bool max197_is_full_range(struct max197_data *data, int channel)
85{
86 return data->ctrl_bytes[channel] & MAX197_RNG;
87}
88
89/* Function called on read access on in{0,1,2,3,4,5,6,7}_{min,max} */
90static ssize_t max197_show_range(struct device *dev,
91 struct device_attribute *devattr, char *buf)
92{
93 struct max197_data *data = dev_get_drvdata(dev);
94 struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
95 int channel = attr->index;
96 bool is_min = attr->nr;
97 int range;
98
99 if (mutex_lock_interruptible(&data->lock))
100 return -ERESTARTSYS;
101
102 range = max197_is_full_range(data, channel) ?
103 data->limit : data->limit / 2;
104 if (is_min) {
105 if (max197_is_bipolar(data, channel))
106 range = -range;
107 else
108 range = 0;
109 }
110
111 mutex_unlock(&data->lock);
112
113 return sprintf(buf, "%d\n", range);
114}
115
116/* Function called on write access on in{0,1,2,3,4,5,6,7}_{min,max} */
117static ssize_t max197_store_range(struct device *dev,
118 struct device_attribute *devattr,
119 const char *buf, size_t count)
120{
121 struct max197_data *data = dev_get_drvdata(dev);
122 struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
123 int channel = attr->index;
124 bool is_min = attr->nr;
125 long value;
126 int half = data->limit / 2;
127 int full = data->limit;
128
129 if (kstrtol(buf, 10, &value))
130 return -EINVAL;
131
132 if (is_min) {
133 if (value <= -full)
134 value = -full;
135 else if (value < 0)
136 value = -half;
137 else
138 value = 0;
139 } else {
140 if (value >= full)
141 value = full;
142 else
143 value = half;
144 }
145
146 if (mutex_lock_interruptible(&data->lock))
147 return -ERESTARTSYS;
148
149 if (value == 0) {
150 /* We can deduce only the polarity */
151 max197_set_unipolarity(data, channel);
152 } else if (value == -half) {
153 max197_set_bipolarity(data, channel);
154 max197_set_half_range(data, channel);
155 } else if (value == -full) {
156 max197_set_bipolarity(data, channel);
157 max197_set_full_range(data, channel);
158 } else if (value == half) {
159 /* We can deduce only the range */
160 max197_set_half_range(data, channel);
161 } else if (value == full) {
162 /* We can deduce only the range */
163 max197_set_full_range(data, channel);
164 }
165
166 mutex_unlock(&data->lock);
167
168 return count;
169}
170
171/* Function called on read access on in{0,1,2,3,4,5,6,7}_input */
172static ssize_t max197_show_input(struct device *dev,
173 struct device_attribute *devattr,
174 char *buf)
175{
176 struct max197_data *data = dev_get_drvdata(dev);
177 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
178 int channel = attr->index;
179 s32 value;
180 int ret;
181
182 if (mutex_lock_interruptible(&data->lock))
183 return -ERESTARTSYS;
184
185 ret = data->pdata->convert(data->ctrl_bytes[channel]);
186 if (ret < 0) {
187 dev_err(dev, "conversion failed\n");
188 goto unlock;
189 }
190 value = ret;
191
192 /*
193 * Coefficient to apply on raw value.
194 * See Table 1. Full Scale and Zero Scale in the MAX197 datasheet.
195 */
196 if (data->scale) {
197 value *= MAX197_SCALE;
198 if (max197_is_full_range(data, channel))
199 value *= 2;
200 value /= 10000;
201 }
202
203 ret = sprintf(buf, "%d\n", value);
204
205unlock:
206 mutex_unlock(&data->lock);
207 return ret;
208}
209
210static ssize_t max197_show_name(struct device *dev,
211 struct device_attribute *attr, char *buf)
212{
213 struct platform_device *pdev = to_platform_device(dev);
214 return sprintf(buf, "%s\n", pdev->name);
215}
216
217#define MAX197_SENSOR_DEVICE_ATTR_CH(chan) \
218 static SENSOR_DEVICE_ATTR(in##chan##_input, S_IRUGO, \
219 max197_show_input, NULL, chan); \
220 static SENSOR_DEVICE_ATTR_2(in##chan##_min, S_IRUGO | S_IWUSR, \
221 max197_show_range, \
222 max197_store_range, \
223 true, chan); \
224 static SENSOR_DEVICE_ATTR_2(in##chan##_max, S_IRUGO | S_IWUSR, \
225 max197_show_range, \
226 max197_store_range, \
227 false, chan)
228
229#define MAX197_SENSOR_DEV_ATTR_IN(chan) \
230 &sensor_dev_attr_in##chan##_input.dev_attr.attr, \
231 &sensor_dev_attr_in##chan##_max.dev_attr.attr, \
232 &sensor_dev_attr_in##chan##_min.dev_attr.attr
233
234static DEVICE_ATTR(name, S_IRUGO, max197_show_name, NULL);
235
236MAX197_SENSOR_DEVICE_ATTR_CH(0);
237MAX197_SENSOR_DEVICE_ATTR_CH(1);
238MAX197_SENSOR_DEVICE_ATTR_CH(2);
239MAX197_SENSOR_DEVICE_ATTR_CH(3);
240MAX197_SENSOR_DEVICE_ATTR_CH(4);
241MAX197_SENSOR_DEVICE_ATTR_CH(5);
242MAX197_SENSOR_DEVICE_ATTR_CH(6);
243MAX197_SENSOR_DEVICE_ATTR_CH(7);
244
245static const struct attribute_group max197_sysfs_group = {
246 .attrs = (struct attribute *[]) {
247 &dev_attr_name.attr,
248 MAX197_SENSOR_DEV_ATTR_IN(0),
249 MAX197_SENSOR_DEV_ATTR_IN(1),
250 MAX197_SENSOR_DEV_ATTR_IN(2),
251 MAX197_SENSOR_DEV_ATTR_IN(3),
252 MAX197_SENSOR_DEV_ATTR_IN(4),
253 MAX197_SENSOR_DEV_ATTR_IN(5),
254 MAX197_SENSOR_DEV_ATTR_IN(6),
255 MAX197_SENSOR_DEV_ATTR_IN(7),
256 NULL
257 },
258};
259
260static int __devinit max197_probe(struct platform_device *pdev)
261{
262 int ch, ret;
263 struct max197_data *data;
264 struct max197_platform_data *pdata = pdev->dev.platform_data;
265 enum max197_chips chip = platform_get_device_id(pdev)->driver_data;
266
267 if (pdata == NULL) {
268 dev_err(&pdev->dev, "no platform data supplied\n");
269 return -EINVAL;
270 }
271
272 if (pdata->convert == NULL) {
273 dev_err(&pdev->dev, "no convert function supplied\n");
274 return -EINVAL;
275 }
276
277 data = devm_kzalloc(&pdev->dev, sizeof(struct max197_data), GFP_KERNEL);
278 if (!data) {
279 dev_err(&pdev->dev, "devm_kzalloc failed\n");
280 return -ENOMEM;
281 }
282
283 data->pdata = pdata;
284 mutex_init(&data->lock);
285
286 if (chip == max197) {
287 data->limit = MAX197_LIMIT;
288 data->scale = true;
289 } else {
290 data->limit = MAX199_LIMIT;
291 data->scale = false;
292 }
293
294 for (ch = 0; ch < MAX197_NUM_CH; ch++)
295 data->ctrl_bytes[ch] = (u8) ch;
296
297 platform_set_drvdata(pdev, data);
298
299 ret = sysfs_create_group(&pdev->dev.kobj, &max197_sysfs_group);
300 if (ret) {
301 dev_err(&pdev->dev, "sysfs create group failed\n");
302 return ret;
303 }
304
305 data->hwmon_dev = hwmon_device_register(&pdev->dev);
306 if (IS_ERR(data->hwmon_dev)) {
307 ret = PTR_ERR(data->hwmon_dev);
308 dev_err(&pdev->dev, "hwmon device register failed\n");
309 goto error;
310 }
311
312 return 0;
313
314error:
315 sysfs_remove_group(&pdev->dev.kobj, &max197_sysfs_group);
316 return ret;
317}
318
319static int __devexit max197_remove(struct platform_device *pdev)
320{
321 struct max197_data *data = platform_get_drvdata(pdev);
322
323 hwmon_device_unregister(data->hwmon_dev);
324 sysfs_remove_group(&pdev->dev.kobj, &max197_sysfs_group);
325
326 return 0;
327}
328
329static struct platform_device_id max197_device_ids[] = {
330 { "max197", max197 },
331 { "max199", max199 },
332 { }
333};
334MODULE_DEVICE_TABLE(platform, max197_device_ids);
335
336static struct platform_driver max197_driver = {
337 .driver = {
338 .name = "max197",
339 .owner = THIS_MODULE,
340 },
341 .probe = max197_probe,
342 .remove = __devexit_p(max197_remove),
343 .id_table = max197_device_ids,
344};
345module_platform_driver(max197_driver);
346
347MODULE_LICENSE("GPL");
348MODULE_AUTHOR("Savoir-faire Linux Inc. <kernel@savoirfairelinux.com>");
349MODULE_DESCRIPTION("Maxim MAX197 A/D Converter driver");
diff --git a/drivers/hwmon/mcp3021.c b/drivers/hwmon/mcp3021.c
index d0afc0cd3ff4..eedb32292d6d 100644
--- a/drivers/hwmon/mcp3021.c
+++ b/drivers/hwmon/mcp3021.c
@@ -1,8 +1,9 @@
1/* 1/*
2 * mcp3021.c - driver for the Microchip MCP3021 chip 2 * mcp3021.c - driver for Microchip MCP3021 and MCP3221
3 * 3 *
4 * Copyright (C) 2008-2009, 2012 Freescale Semiconductor, Inc. 4 * Copyright (C) 2008-2009, 2012 Freescale Semiconductor, Inc.
5 * Author: Mingkai Hu <Mingkai.hu@freescale.com> 5 * Author: Mingkai Hu <Mingkai.hu@freescale.com>
6 * Reworked by Sven Schuchmann <schuchmann@schleissheimer.de>
6 * 7 *
7 * This driver export the value of analog input voltage to sysfs, the 8 * This driver export the value of analog input voltage to sysfs, the
8 * voltage unit is mV. Through the sysfs interface, lm-sensors tool 9 * voltage unit is mV. Through the sysfs interface, lm-sensors tool
@@ -34,16 +35,31 @@
34#define MCP3021_OUTPUT_RES 10 /* 10-bit resolution */ 35#define MCP3021_OUTPUT_RES 10 /* 10-bit resolution */
35#define MCP3021_OUTPUT_SCALE 4 36#define MCP3021_OUTPUT_SCALE 4
36 37
38#define MCP3221_SAR_SHIFT 0
39#define MCP3221_SAR_MASK 0xfff
40#define MCP3221_OUTPUT_RES 12 /* 12-bit resolution */
41#define MCP3221_OUTPUT_SCALE 1
42
43enum chips {
44 mcp3021,
45 mcp3221
46};
47
37/* 48/*
38 * Client data (each client gets its own) 49 * Client data (each client gets its own)
39 */ 50 */
40struct mcp3021_data { 51struct mcp3021_data {
41 struct device *hwmon_dev; 52 struct device *hwmon_dev;
42 u32 vdd; /* device power supply */ 53 u32 vdd; /* device power supply */
54 u16 sar_shift;
55 u16 sar_mask;
56 u8 output_res;
57 u8 output_scale;
43}; 58};
44 59
45static int mcp3021_read16(struct i2c_client *client) 60static int mcp3021_read16(struct i2c_client *client)
46{ 61{
62 struct mcp3021_data *data = i2c_get_clientdata(client);
47 int ret; 63 int ret;
48 u16 reg; 64 u16 reg;
49 __be16 buf; 65 __be16 buf;
@@ -61,20 +77,20 @@ static int mcp3021_read16(struct i2c_client *client)
61 * The ten-bit output code is composed of the lower 4-bit of the 77 * The ten-bit output code is composed of the lower 4-bit of the
62 * first byte and the upper 6-bit of the second byte. 78 * first byte and the upper 6-bit of the second byte.
63 */ 79 */
64 reg = (reg >> MCP3021_SAR_SHIFT) & MCP3021_SAR_MASK; 80 reg = (reg >> data->sar_shift) & data->sar_mask;
65 81
66 return reg; 82 return reg;
67} 83}
68 84
69static inline u16 volts_from_reg(u16 vdd, u16 val) 85static inline u16 volts_from_reg(struct mcp3021_data *data, u16 val)
70{ 86{
71 if (val == 0) 87 if (val == 0)
72 return 0; 88 return 0;
73 89
74 val = val * MCP3021_OUTPUT_SCALE - MCP3021_OUTPUT_SCALE / 2; 90 val = val * data->output_scale - data->output_scale / 2;
75 91
76 return val * DIV_ROUND_CLOSEST(vdd, 92 return val * DIV_ROUND_CLOSEST(data->vdd,
77 (1 << MCP3021_OUTPUT_RES) * MCP3021_OUTPUT_SCALE); 93 (1 << data->output_res) * data->output_scale);
78} 94}
79 95
80static ssize_t show_in_input(struct device *dev, struct device_attribute *attr, 96static ssize_t show_in_input(struct device *dev, struct device_attribute *attr,
@@ -88,7 +104,8 @@ static ssize_t show_in_input(struct device *dev, struct device_attribute *attr,
88 if (reg < 0) 104 if (reg < 0)
89 return reg; 105 return reg;
90 106
91 in_input = volts_from_reg(data->vdd, reg); 107 in_input = volts_from_reg(data, reg);
108
92 return sprintf(buf, "%d\n", in_input); 109 return sprintf(buf, "%d\n", in_input);
93} 110}
94 111
@@ -103,25 +120,39 @@ static int mcp3021_probe(struct i2c_client *client,
103 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) 120 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
104 return -ENODEV; 121 return -ENODEV;
105 122
106 data = kzalloc(sizeof(struct mcp3021_data), GFP_KERNEL); 123 data = devm_kzalloc(&client->dev, sizeof(struct mcp3021_data),
124 GFP_KERNEL);
107 if (!data) 125 if (!data)
108 return -ENOMEM; 126 return -ENOMEM;
109 127
110 i2c_set_clientdata(client, data); 128 i2c_set_clientdata(client, data);
111 129
130 switch (id->driver_data) {
131 case mcp3021:
132 data->sar_shift = MCP3021_SAR_SHIFT;
133 data->sar_mask = MCP3021_SAR_MASK;
134 data->output_res = MCP3021_OUTPUT_RES;
135 data->output_scale = MCP3021_OUTPUT_SCALE;
136 break;
137
138 case mcp3221:
139 data->sar_shift = MCP3221_SAR_SHIFT;
140 data->sar_mask = MCP3221_SAR_MASK;
141 data->output_res = MCP3221_OUTPUT_RES;
142 data->output_scale = MCP3221_OUTPUT_SCALE;
143 break;
144 }
145
112 if (client->dev.platform_data) { 146 if (client->dev.platform_data) {
113 data->vdd = *(u32 *)client->dev.platform_data; 147 data->vdd = *(u32 *)client->dev.platform_data;
114 if (data->vdd > MCP3021_VDD_MAX || 148 if (data->vdd > MCP3021_VDD_MAX || data->vdd < MCP3021_VDD_MIN)
115 data->vdd < MCP3021_VDD_MIN) { 149 return -EINVAL;
116 err = -EINVAL;
117 goto exit_free;
118 }
119 } else 150 } else
120 data->vdd = MCP3021_VDD_REF; 151 data->vdd = MCP3021_VDD_REF;
121 152
122 err = sysfs_create_file(&client->dev.kobj, &dev_attr_in0_input.attr); 153 err = sysfs_create_file(&client->dev.kobj, &dev_attr_in0_input.attr);
123 if (err) 154 if (err)
124 goto exit_free; 155 return err;
125 156
126 data->hwmon_dev = hwmon_device_register(&client->dev); 157 data->hwmon_dev = hwmon_device_register(&client->dev);
127 if (IS_ERR(data->hwmon_dev)) { 158 if (IS_ERR(data->hwmon_dev)) {
@@ -133,8 +164,6 @@ static int mcp3021_probe(struct i2c_client *client,
133 164
134exit_remove: 165exit_remove:
135 sysfs_remove_file(&client->dev.kobj, &dev_attr_in0_input.attr); 166 sysfs_remove_file(&client->dev.kobj, &dev_attr_in0_input.attr);
136exit_free:
137 kfree(data);
138 return err; 167 return err;
139} 168}
140 169
@@ -144,13 +173,13 @@ static int mcp3021_remove(struct i2c_client *client)
144 173
145 hwmon_device_unregister(data->hwmon_dev); 174 hwmon_device_unregister(data->hwmon_dev);
146 sysfs_remove_file(&client->dev.kobj, &dev_attr_in0_input.attr); 175 sysfs_remove_file(&client->dev.kobj, &dev_attr_in0_input.attr);
147 kfree(data);
148 176
149 return 0; 177 return 0;
150} 178}
151 179
152static const struct i2c_device_id mcp3021_id[] = { 180static const struct i2c_device_id mcp3021_id[] = {
153 { "mcp3021", 0 }, 181 { "mcp3021", mcp3021 },
182 { "mcp3221", mcp3221 },
154 { } 183 { }
155}; 184};
156MODULE_DEVICE_TABLE(i2c, mcp3021_id); 185MODULE_DEVICE_TABLE(i2c, mcp3021_id);
@@ -167,5 +196,5 @@ static struct i2c_driver mcp3021_driver = {
167module_i2c_driver(mcp3021_driver); 196module_i2c_driver(mcp3021_driver);
168 197
169MODULE_AUTHOR("Mingkai Hu <Mingkai.hu@freescale.com>"); 198MODULE_AUTHOR("Mingkai Hu <Mingkai.hu@freescale.com>");
170MODULE_DESCRIPTION("Microchip MCP3021 driver"); 199MODULE_DESCRIPTION("Microchip MCP3021/MCP3221 driver");
171MODULE_LICENSE("GPL"); 200MODULE_LICENSE("GPL");
diff --git a/drivers/hwmon/s3c-hwmon.c b/drivers/hwmon/s3c-hwmon.c
index b7975f858cff..fe11b95670bd 100644
--- a/drivers/hwmon/s3c-hwmon.c
+++ b/drivers/hwmon/s3c-hwmon.c
@@ -34,7 +34,7 @@
34#include <linux/hwmon-sysfs.h> 34#include <linux/hwmon-sysfs.h>
35 35
36#include <plat/adc.h> 36#include <plat/adc.h>
37#include <plat/hwmon.h> 37#include <linux/platform_data/hwmon-s3c.h>
38 38
39struct s3c_hwmon_attr { 39struct s3c_hwmon_attr {
40 struct sensor_device_attribute in; 40 struct sensor_device_attribute in;
diff --git a/drivers/hwmon/sch5627.c b/drivers/hwmon/sch5627.c
index 8342275378b8..49f6230bdcf1 100644
--- a/drivers/hwmon/sch5627.c
+++ b/drivers/hwmon/sch5627.c
@@ -461,8 +461,6 @@ static int sch5627_remove(struct platform_device *pdev)
461 hwmon_device_unregister(data->hwmon_dev); 461 hwmon_device_unregister(data->hwmon_dev);
462 462
463 sysfs_remove_group(&pdev->dev.kobj, &sch5627_group); 463 sysfs_remove_group(&pdev->dev.kobj, &sch5627_group);
464 platform_set_drvdata(pdev, NULL);
465 kfree(data);
466 464
467 return 0; 465 return 0;
468} 466}
@@ -472,7 +470,8 @@ static int __devinit sch5627_probe(struct platform_device *pdev)
472 struct sch5627_data *data; 470 struct sch5627_data *data;
473 int err, build_code, build_id, hwmon_rev, val; 471 int err, build_code, build_id, hwmon_rev, val;
474 472
475 data = kzalloc(sizeof(struct sch5627_data), GFP_KERNEL); 473 data = devm_kzalloc(&pdev->dev, sizeof(struct sch5627_data),
474 GFP_KERNEL);
476 if (!data) 475 if (!data)
477 return -ENOMEM; 476 return -ENOMEM;
478 477
diff --git a/drivers/hwmon/sch5636.c b/drivers/hwmon/sch5636.c
index 96a7e68718ca..517118016192 100644
--- a/drivers/hwmon/sch5636.c
+++ b/drivers/hwmon/sch5636.c
@@ -402,9 +402,6 @@ static int sch5636_remove(struct platform_device *pdev)
402 device_remove_file(&pdev->dev, 402 device_remove_file(&pdev->dev,
403 &sch5636_fan_attr[i].dev_attr); 403 &sch5636_fan_attr[i].dev_attr);
404 404
405 platform_set_drvdata(pdev, NULL);
406 kfree(data);
407
408 return 0; 405 return 0;
409} 406}
410 407
@@ -414,7 +411,8 @@ static int __devinit sch5636_probe(struct platform_device *pdev)
414 int i, err, val, revision[2]; 411 int i, err, val, revision[2];
415 char id[4]; 412 char id[4];
416 413
417 data = kzalloc(sizeof(struct sch5636_data), GFP_KERNEL); 414 data = devm_kzalloc(&pdev->dev, sizeof(struct sch5636_data),
415 GFP_KERNEL);
418 if (!data) 416 if (!data)
419 return -ENOMEM; 417 return -ENOMEM;
420 418
diff --git a/drivers/hwmon/sch56xx-common.c b/drivers/hwmon/sch56xx-common.c
index 4380f5d07be2..d00b30adc34b 100644
--- a/drivers/hwmon/sch56xx-common.c
+++ b/drivers/hwmon/sch56xx-common.c
@@ -503,10 +503,10 @@ EXPORT_SYMBOL(sch56xx_watchdog_unregister);
503 * platform dev find, add and remove functions 503 * platform dev find, add and remove functions
504 */ 504 */
505 505
506static int __init sch56xx_find(int sioaddr, unsigned short *address, 506static int __init sch56xx_find(int sioaddr, const char **name)
507 const char **name)
508{ 507{
509 u8 devid; 508 u8 devid;
509 unsigned short address;
510 int err; 510 int err;
511 511
512 err = superio_enter(sioaddr); 512 err = superio_enter(sioaddr);
@@ -540,20 +540,21 @@ static int __init sch56xx_find(int sioaddr, unsigned short *address,
540 * Warning the order of the low / high byte is the other way around 540 * Warning the order of the low / high byte is the other way around
541 * as on most other superio devices!! 541 * as on most other superio devices!!
542 */ 542 */
543 *address = superio_inb(sioaddr, SIO_REG_ADDR) | 543 address = superio_inb(sioaddr, SIO_REG_ADDR) |
544 superio_inb(sioaddr, SIO_REG_ADDR + 1) << 8; 544 superio_inb(sioaddr, SIO_REG_ADDR + 1) << 8;
545 if (*address == 0) { 545 if (address == 0) {
546 pr_warn("Base address not set\n"); 546 pr_warn("Base address not set\n");
547 err = -ENODEV; 547 err = -ENODEV;
548 goto exit; 548 goto exit;
549 } 549 }
550 err = address;
550 551
551exit: 552exit:
552 superio_exit(sioaddr); 553 superio_exit(sioaddr);
553 return err; 554 return err;
554} 555}
555 556
556static int __init sch56xx_device_add(unsigned short address, const char *name) 557static int __init sch56xx_device_add(int address, const char *name)
557{ 558{
558 struct resource res = { 559 struct resource res = {
559 .start = address, 560 .start = address,
@@ -593,15 +594,14 @@ exit_device_put:
593 594
594static int __init sch56xx_init(void) 595static int __init sch56xx_init(void)
595{ 596{
596 int err; 597 int address;
597 unsigned short address; 598 const char *name = NULL;
598 const char *name; 599
599 600 address = sch56xx_find(0x4e, &name);
600 err = sch56xx_find(0x4e, &address, &name); 601 if (address < 0)
601 if (err) 602 address = sch56xx_find(0x2e, &name);
602 err = sch56xx_find(0x2e, &address, &name); 603 if (address < 0)
603 if (err) 604 return address;
604 return err;
605 605
606 return sch56xx_device_add(address, name); 606 return sch56xx_device_add(address, name);
607} 607}
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
index 8b011d016621..07a0c1a0b84d 100644
--- a/drivers/hwmon/sht15.c
+++ b/drivers/hwmon/sht15.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * sht15.c - support for the SHT15 Temperature and Humidity Sensor 2 * sht15.c - support for the SHT15 Temperature and Humidity Sensor
3 * 3 *
4 * Portions Copyright (c) 2010-2011 Savoir-faire Linux Inc. 4 * Portions Copyright (c) 2010-2012 Savoir-faire Linux Inc.
5 * Jerome Oufella <jerome.oufella@savoirfairelinux.com> 5 * Jerome Oufella <jerome.oufella@savoirfairelinux.com>
6 * Vivien Didelot <vivien.didelot@savoirfairelinux.com> 6 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
7 * 7 *
@@ -24,12 +24,12 @@
24#include <linux/hwmon.h> 24#include <linux/hwmon.h>
25#include <linux/hwmon-sysfs.h> 25#include <linux/hwmon-sysfs.h>
26#include <linux/mutex.h> 26#include <linux/mutex.h>
27#include <linux/platform_data/sht15.h>
27#include <linux/platform_device.h> 28#include <linux/platform_device.h>
28#include <linux/sched.h> 29#include <linux/sched.h>
29#include <linux/delay.h> 30#include <linux/delay.h>
30#include <linux/jiffies.h> 31#include <linux/jiffies.h>
31#include <linux/err.h> 32#include <linux/err.h>
32#include <linux/sht15.h>
33#include <linux/regulator/consumer.h> 33#include <linux/regulator/consumer.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/atomic.h> 35#include <linux/atomic.h>
@@ -53,6 +53,9 @@
53#define SHT15_STATUS_HEATER 0x04 53#define SHT15_STATUS_HEATER 0x04
54#define SHT15_STATUS_LOW_BATTERY 0x40 54#define SHT15_STATUS_LOW_BATTERY 0x40
55 55
56/* List of supported chips */
57enum sht15_chips { sht10, sht11, sht15, sht71, sht75 };
58
56/* Actions the driver may be doing */ 59/* Actions the driver may be doing */
57enum sht15_state { 60enum sht15_state {
58 SHT15_READING_NOTHING, 61 SHT15_READING_NOTHING,
@@ -884,14 +887,12 @@ static int sht15_invalidate_voltage(struct notifier_block *nb,
884static int __devinit sht15_probe(struct platform_device *pdev) 887static int __devinit sht15_probe(struct platform_device *pdev)
885{ 888{
886 int ret; 889 int ret;
887 struct sht15_data *data = kzalloc(sizeof(*data), GFP_KERNEL); 890 struct sht15_data *data;
888 u8 status = 0; 891 u8 status = 0;
889 892
890 if (!data) { 893 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
891 ret = -ENOMEM; 894 if (!data)
892 dev_err(&pdev->dev, "kzalloc failed\n"); 895 return -ENOMEM;
893 goto error_ret;
894 }
895 896
896 INIT_WORK(&data->read_work, sht15_bh_read_data); 897 INIT_WORK(&data->read_work, sht15_bh_read_data);
897 INIT_WORK(&data->update_supply_work, sht15_update_voltage); 898 INIT_WORK(&data->update_supply_work, sht15_update_voltage);
@@ -901,9 +902,8 @@ static int __devinit sht15_probe(struct platform_device *pdev)
901 init_waitqueue_head(&data->wait_queue); 902 init_waitqueue_head(&data->wait_queue);
902 903
903 if (pdev->dev.platform_data == NULL) { 904 if (pdev->dev.platform_data == NULL) {
904 ret = -EINVAL;
905 dev_err(&pdev->dev, "no platform data supplied\n"); 905 dev_err(&pdev->dev, "no platform data supplied\n");
906 goto err_free_data; 906 return -EINVAL;
907 } 907 }
908 data->pdata = pdev->dev.platform_data; 908 data->pdata = pdev->dev.platform_data;
909 data->supply_uV = data->pdata->supply_mv * 1000; 909 data->supply_uV = data->pdata->supply_mv * 1000;
@@ -918,7 +918,7 @@ static int __devinit sht15_probe(struct platform_device *pdev)
918 * If a regulator is available, 918 * If a regulator is available,
919 * query what the supply voltage actually is! 919 * query what the supply voltage actually is!
920 */ 920 */
921 data->reg = regulator_get(data->dev, "vcc"); 921 data->reg = devm_regulator_get(data->dev, "vcc");
922 if (!IS_ERR(data->reg)) { 922 if (!IS_ERR(data->reg)) {
923 int voltage; 923 int voltage;
924 924
@@ -937,51 +937,51 @@ static int __devinit sht15_probe(struct platform_device *pdev)
937 dev_err(&pdev->dev, 937 dev_err(&pdev->dev,
938 "regulator notifier request failed\n"); 938 "regulator notifier request failed\n");
939 regulator_disable(data->reg); 939 regulator_disable(data->reg);
940 regulator_put(data->reg); 940 return ret;
941 goto err_free_data;
942 } 941 }
943 } 942 }
944 943
945 /* Try requesting the GPIOs */ 944 /* Try requesting the GPIOs */
946 ret = gpio_request(data->pdata->gpio_sck, "SHT15 sck"); 945 ret = devm_gpio_request(&pdev->dev, data->pdata->gpio_sck, "SHT15 sck");
947 if (ret) { 946 if (ret) {
948 dev_err(&pdev->dev, "gpio request failed\n"); 947 dev_err(&pdev->dev, "gpio request failed\n");
949 goto err_release_reg; 948 goto err_release_reg;
950 } 949 }
951 gpio_direction_output(data->pdata->gpio_sck, 0); 950 gpio_direction_output(data->pdata->gpio_sck, 0);
952 951
953 ret = gpio_request(data->pdata->gpio_data, "SHT15 data"); 952 ret = devm_gpio_request(&pdev->dev, data->pdata->gpio_data,
953 "SHT15 data");
954 if (ret) { 954 if (ret) {
955 dev_err(&pdev->dev, "gpio request failed\n"); 955 dev_err(&pdev->dev, "gpio request failed\n");
956 goto err_release_gpio_sck; 956 goto err_release_reg;
957 } 957 }
958 958
959 ret = request_irq(gpio_to_irq(data->pdata->gpio_data), 959 ret = devm_request_irq(&pdev->dev, gpio_to_irq(data->pdata->gpio_data),
960 sht15_interrupt_fired, 960 sht15_interrupt_fired,
961 IRQF_TRIGGER_FALLING, 961 IRQF_TRIGGER_FALLING,
962 "sht15 data", 962 "sht15 data",
963 data); 963 data);
964 if (ret) { 964 if (ret) {
965 dev_err(&pdev->dev, "failed to get irq for data line\n"); 965 dev_err(&pdev->dev, "failed to get irq for data line\n");
966 goto err_release_gpio_data; 966 goto err_release_reg;
967 } 967 }
968 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data)); 968 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
969 sht15_connection_reset(data); 969 sht15_connection_reset(data);
970 ret = sht15_soft_reset(data); 970 ret = sht15_soft_reset(data);
971 if (ret) 971 if (ret)
972 goto err_release_irq; 972 goto err_release_reg;
973 973
974 /* write status with platform data options */ 974 /* write status with platform data options */
975 if (status) { 975 if (status) {
976 ret = sht15_send_status(data, status); 976 ret = sht15_send_status(data, status);
977 if (ret) 977 if (ret)
978 goto err_release_irq; 978 goto err_release_reg;
979 } 979 }
980 980
981 ret = sysfs_create_group(&pdev->dev.kobj, &sht15_attr_group); 981 ret = sysfs_create_group(&pdev->dev.kobj, &sht15_attr_group);
982 if (ret) { 982 if (ret) {
983 dev_err(&pdev->dev, "sysfs create failed\n"); 983 dev_err(&pdev->dev, "sysfs create failed\n");
984 goto err_release_irq; 984 goto err_release_reg;
985 } 985 }
986 986
987 data->hwmon_dev = hwmon_device_register(data->dev); 987 data->hwmon_dev = hwmon_device_register(data->dev);
@@ -994,21 +994,11 @@ static int __devinit sht15_probe(struct platform_device *pdev)
994 994
995err_release_sysfs_group: 995err_release_sysfs_group:
996 sysfs_remove_group(&pdev->dev.kobj, &sht15_attr_group); 996 sysfs_remove_group(&pdev->dev.kobj, &sht15_attr_group);
997err_release_irq:
998 free_irq(gpio_to_irq(data->pdata->gpio_data), data);
999err_release_gpio_data:
1000 gpio_free(data->pdata->gpio_data);
1001err_release_gpio_sck:
1002 gpio_free(data->pdata->gpio_sck);
1003err_release_reg: 997err_release_reg:
1004 if (!IS_ERR(data->reg)) { 998 if (!IS_ERR(data->reg)) {
1005 regulator_unregister_notifier(data->reg, &data->nb); 999 regulator_unregister_notifier(data->reg, &data->nb);
1006 regulator_disable(data->reg); 1000 regulator_disable(data->reg);
1007 regulator_put(data->reg);
1008 } 1001 }
1009err_free_data:
1010 kfree(data);
1011error_ret:
1012 return ret; 1002 return ret;
1013} 1003}
1014 1004
@@ -1030,89 +1020,33 @@ static int __devexit sht15_remove(struct platform_device *pdev)
1030 if (!IS_ERR(data->reg)) { 1020 if (!IS_ERR(data->reg)) {
1031 regulator_unregister_notifier(data->reg, &data->nb); 1021 regulator_unregister_notifier(data->reg, &data->nb);
1032 regulator_disable(data->reg); 1022 regulator_disable(data->reg);
1033 regulator_put(data->reg);
1034 } 1023 }
1035 1024
1036 free_irq(gpio_to_irq(data->pdata->gpio_data), data);
1037 gpio_free(data->pdata->gpio_data);
1038 gpio_free(data->pdata->gpio_sck);
1039 mutex_unlock(&data->read_lock); 1025 mutex_unlock(&data->read_lock);
1040 kfree(data);
1041 1026
1042 return 0; 1027 return 0;
1043} 1028}
1044 1029
1045/* 1030static struct platform_device_id sht15_device_ids[] = {
1046 * sht_drivers simultaneously refers to __devinit and __devexit function 1031 { "sht10", sht10 },
1047 * which causes spurious section mismatch warning. So use __refdata to 1032 { "sht11", sht11 },
1048 * get rid from this. 1033 { "sht15", sht15 },
1049 */ 1034 { "sht71", sht71 },
1050static struct platform_driver __refdata sht_drivers[] = { 1035 { "sht75", sht75 },
1051 { 1036 { }
1052 .driver = {
1053 .name = "sht10",
1054 .owner = THIS_MODULE,
1055 },
1056 .probe = sht15_probe,
1057 .remove = __devexit_p(sht15_remove),
1058 }, {
1059 .driver = {
1060 .name = "sht11",
1061 .owner = THIS_MODULE,
1062 },
1063 .probe = sht15_probe,
1064 .remove = __devexit_p(sht15_remove),
1065 }, {
1066 .driver = {
1067 .name = "sht15",
1068 .owner = THIS_MODULE,
1069 },
1070 .probe = sht15_probe,
1071 .remove = __devexit_p(sht15_remove),
1072 }, {
1073 .driver = {
1074 .name = "sht71",
1075 .owner = THIS_MODULE,
1076 },
1077 .probe = sht15_probe,
1078 .remove = __devexit_p(sht15_remove),
1079 }, {
1080 .driver = {
1081 .name = "sht75",
1082 .owner = THIS_MODULE,
1083 },
1084 .probe = sht15_probe,
1085 .remove = __devexit_p(sht15_remove),
1086 },
1087}; 1037};
1038MODULE_DEVICE_TABLE(platform, sht15_device_ids);
1088 1039
1089static int __init sht15_init(void) 1040static struct platform_driver sht15_driver = {
1090{ 1041 .driver = {
1091 int ret; 1042 .name = "sht15",
1092 int i; 1043 .owner = THIS_MODULE,
1093 1044 },
1094 for (i = 0; i < ARRAY_SIZE(sht_drivers); i++) { 1045 .probe = sht15_probe,
1095 ret = platform_driver_register(&sht_drivers[i]); 1046 .remove = __devexit_p(sht15_remove),
1096 if (ret) 1047 .id_table = sht15_device_ids,
1097 goto error_unreg; 1048};
1098 } 1049module_platform_driver(sht15_driver);
1099
1100 return 0;
1101
1102error_unreg:
1103 while (--i >= 0)
1104 platform_driver_unregister(&sht_drivers[i]);
1105
1106 return ret;
1107}
1108module_init(sht15_init);
1109
1110static void __exit sht15_exit(void)
1111{
1112 int i;
1113 for (i = ARRAY_SIZE(sht_drivers) - 1; i >= 0; i--)
1114 platform_driver_unregister(&sht_drivers[i]);
1115}
1116module_exit(sht15_exit);
1117 1050
1118MODULE_LICENSE("GPL"); 1051MODULE_LICENSE("GPL");
1052MODULE_DESCRIPTION("Sensirion SHT15 temperature and humidity sensor driver");
diff --git a/drivers/hwmon/sht21.c b/drivers/hwmon/sht21.c
index 6c2dede4b8e7..c2565d04cd4a 100644
--- a/drivers/hwmon/sht21.c
+++ b/drivers/hwmon/sht21.c
@@ -199,11 +199,10 @@ static int __devinit sht21_probe(struct i2c_client *client,
199 return -ENODEV; 199 return -ENODEV;
200 } 200 }
201 201
202 sht21 = kzalloc(sizeof(*sht21), GFP_KERNEL); 202 sht21 = devm_kzalloc(&client->dev, sizeof(*sht21), GFP_KERNEL);
203 if (!sht21) { 203 if (!sht21)
204 dev_dbg(&client->dev, "kzalloc failed\n");
205 return -ENOMEM; 204 return -ENOMEM;
206 } 205
207 i2c_set_clientdata(client, sht21); 206 i2c_set_clientdata(client, sht21);
208 207
209 mutex_init(&sht21->lock); 208 mutex_init(&sht21->lock);
@@ -211,7 +210,7 @@ static int __devinit sht21_probe(struct i2c_client *client,
211 err = sysfs_create_group(&client->dev.kobj, &sht21_attr_group); 210 err = sysfs_create_group(&client->dev.kobj, &sht21_attr_group);
212 if (err) { 211 if (err) {
213 dev_dbg(&client->dev, "could not create sysfs files\n"); 212 dev_dbg(&client->dev, "could not create sysfs files\n");
214 goto fail_free; 213 return err;
215 } 214 }
216 sht21->hwmon_dev = hwmon_device_register(&client->dev); 215 sht21->hwmon_dev = hwmon_device_register(&client->dev);
217 if (IS_ERR(sht21->hwmon_dev)) { 216 if (IS_ERR(sht21->hwmon_dev)) {
@@ -226,9 +225,6 @@ static int __devinit sht21_probe(struct i2c_client *client,
226 225
227fail_remove_sysfs: 226fail_remove_sysfs:
228 sysfs_remove_group(&client->dev.kobj, &sht21_attr_group); 227 sysfs_remove_group(&client->dev.kobj, &sht21_attr_group);
229fail_free:
230 kfree(sht21);
231
232 return err; 228 return err;
233} 229}
234 230
@@ -242,7 +238,6 @@ static int __devexit sht21_remove(struct i2c_client *client)
242 238
243 hwmon_device_unregister(sht21->hwmon_dev); 239 hwmon_device_unregister(sht21->hwmon_dev);
244 sysfs_remove_group(&client->dev.kobj, &sht21_attr_group); 240 sysfs_remove_group(&client->dev.kobj, &sht21_attr_group);
245 kfree(sht21);
246 241
247 return 0; 242 return 0;
248} 243}
diff --git a/drivers/hwmon/twl4030-madc-hwmon.c b/drivers/hwmon/twl4030-madc-hwmon.c
index 0018c7dd0097..1a174f0a3cde 100644
--- a/drivers/hwmon/twl4030-madc-hwmon.c
+++ b/drivers/hwmon/twl4030-madc-hwmon.c
@@ -44,12 +44,13 @@ static ssize_t madc_read(struct device *dev,
44 struct device_attribute *devattr, char *buf) 44 struct device_attribute *devattr, char *buf)
45{ 45{
46 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 46 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
47 struct twl4030_madc_request req; 47 struct twl4030_madc_request req = {
48 .channels = 1 << attr->index,
49 .method = TWL4030_MADC_SW2,
50 .type = TWL4030_MADC_WAIT,
51 };
48 long val; 52 long val;
49 53
50 req.channels = (1 << attr->index);
51 req.method = TWL4030_MADC_SW2;
52 req.func_cb = NULL;
53 val = twl4030_madc_conversion(&req); 54 val = twl4030_madc_conversion(&req);
54 if (val < 0) 55 if (val < 0)
55 return val; 56 return val;
diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
index ee4ebc198a94..4cddee04f2e6 100644
--- a/drivers/hwmon/via-cputemp.c
+++ b/drivers/hwmon/via-cputemp.c
@@ -128,12 +128,10 @@ static int __devinit via_cputemp_probe(struct platform_device *pdev)
128 int err; 128 int err;
129 u32 eax, edx; 129 u32 eax, edx;
130 130
131 data = kzalloc(sizeof(struct via_cputemp_data), GFP_KERNEL); 131 data = devm_kzalloc(&pdev->dev, sizeof(struct via_cputemp_data),
132 if (!data) { 132 GFP_KERNEL);
133 err = -ENOMEM; 133 if (!data)
134 dev_err(&pdev->dev, "Out of memory\n"); 134 return -ENOMEM;
135 goto exit;
136 }
137 135
138 data->id = pdev->id; 136 data->id = pdev->id;
139 data->name = "via_cputemp"; 137 data->name = "via_cputemp";
@@ -151,8 +149,7 @@ static int __devinit via_cputemp_probe(struct platform_device *pdev)
151 data->msr_temp = 0x1423; 149 data->msr_temp = 0x1423;
152 break; 150 break;
153 default: 151 default:
154 err = -ENODEV; 152 return -ENODEV;
155 goto exit_free;
156 } 153 }
157 154
158 /* test if we can access the TEMPERATURE MSR */ 155 /* test if we can access the TEMPERATURE MSR */
@@ -160,14 +157,14 @@ static int __devinit via_cputemp_probe(struct platform_device *pdev)
160 if (err) { 157 if (err) {
161 dev_err(&pdev->dev, 158 dev_err(&pdev->dev,
162 "Unable to access TEMPERATURE MSR, giving up\n"); 159 "Unable to access TEMPERATURE MSR, giving up\n");
163 goto exit_free; 160 return err;
164 } 161 }
165 162
166 platform_set_drvdata(pdev, data); 163 platform_set_drvdata(pdev, data);
167 164
168 err = sysfs_create_group(&pdev->dev.kobj, &via_cputemp_group); 165 err = sysfs_create_group(&pdev->dev.kobj, &via_cputemp_group);
169 if (err) 166 if (err)
170 goto exit_free; 167 return err;
171 168
172 if (data->msr_vid) 169 if (data->msr_vid)
173 data->vrm = vid_which_vrm(); 170 data->vrm = vid_which_vrm();
@@ -192,10 +189,6 @@ exit_remove:
192 if (data->vrm) 189 if (data->vrm)
193 device_remove_file(&pdev->dev, &dev_attr_cpu0_vid); 190 device_remove_file(&pdev->dev, &dev_attr_cpu0_vid);
194 sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group); 191 sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group);
195exit_free:
196 platform_set_drvdata(pdev, NULL);
197 kfree(data);
198exit:
199 return err; 192 return err;
200} 193}
201 194
@@ -207,8 +200,6 @@ static int __devexit via_cputemp_remove(struct platform_device *pdev)
207 if (data->vrm) 200 if (data->vrm)
208 device_remove_file(&pdev->dev, &dev_attr_cpu0_vid); 201 device_remove_file(&pdev->dev, &dev_attr_cpu0_vid);
209 sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group); 202 sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group);
210 platform_set_drvdata(pdev, NULL);
211 kfree(data);
212 return 0; 203 return 0;
213} 204}
214 205
@@ -328,6 +319,7 @@ static int __init via_cputemp_init(void)
328 if (err) 319 if (err)
329 goto exit; 320 goto exit;
330 321
322 get_online_cpus();
331 for_each_online_cpu(i) { 323 for_each_online_cpu(i) {
332 struct cpuinfo_x86 *c = &cpu_data(i); 324 struct cpuinfo_x86 *c = &cpu_data(i);
333 325
@@ -347,12 +339,14 @@ static int __init via_cputemp_init(void)
347 339
348#ifndef CONFIG_HOTPLUG_CPU 340#ifndef CONFIG_HOTPLUG_CPU
349 if (list_empty(&pdev_list)) { 341 if (list_empty(&pdev_list)) {
342 put_online_cpus();
350 err = -ENODEV; 343 err = -ENODEV;
351 goto exit_driver_unreg; 344 goto exit_driver_unreg;
352 } 345 }
353#endif 346#endif
354 347
355 register_hotcpu_notifier(&via_cputemp_cpu_notifier); 348 register_hotcpu_notifier(&via_cputemp_cpu_notifier);
349 put_online_cpus();
356 return 0; 350 return 0;
357 351
358#ifndef CONFIG_HOTPLUG_CPU 352#ifndef CONFIG_HOTPLUG_CPU
@@ -367,6 +361,7 @@ static void __exit via_cputemp_exit(void)
367{ 361{
368 struct pdev_entry *p, *n; 362 struct pdev_entry *p, *n;
369 363
364 get_online_cpus();
370 unregister_hotcpu_notifier(&via_cputemp_cpu_notifier); 365 unregister_hotcpu_notifier(&via_cputemp_cpu_notifier);
371 mutex_lock(&pdev_list_mutex); 366 mutex_lock(&pdev_list_mutex);
372 list_for_each_entry_safe(p, n, &pdev_list, list) { 367 list_for_each_entry_safe(p, n, &pdev_list, list) {
@@ -375,6 +370,7 @@ static void __exit via_cputemp_exit(void)
375 kfree(p); 370 kfree(p);
376 } 371 }
377 mutex_unlock(&pdev_list_mutex); 372 mutex_unlock(&pdev_list_mutex);
373 put_online_cpus();
378 platform_driver_unregister(&via_cputemp_driver); 374 platform_driver_unregister(&via_cputemp_driver);
379} 375}
380 376
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
index 386a84538010..84e3dc5e3a83 100644
--- a/drivers/hwmon/vt8231.c
+++ b/drivers/hwmon/vt8231.c
@@ -789,18 +789,16 @@ static int vt8231_probe(struct platform_device *pdev)
789 789
790 /* Reserve the ISA region */ 790 /* Reserve the ISA region */
791 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 791 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
792 if (!request_region(res->start, VT8231_EXTENT, 792 if (!devm_request_region(&pdev->dev, res->start, VT8231_EXTENT,
793 vt8231_driver.driver.name)) { 793 vt8231_driver.driver.name)) {
794 dev_err(&pdev->dev, "Region 0x%lx-0x%lx already in use!\n", 794 dev_err(&pdev->dev, "Region 0x%lx-0x%lx already in use!\n",
795 (unsigned long)res->start, (unsigned long)res->end); 795 (unsigned long)res->start, (unsigned long)res->end);
796 return -ENODEV; 796 return -ENODEV;
797 } 797 }
798 798
799 data = kzalloc(sizeof(struct vt8231_data), GFP_KERNEL); 799 data = devm_kzalloc(&pdev->dev, sizeof(struct vt8231_data), GFP_KERNEL);
800 if (!data) { 800 if (!data)
801 err = -ENOMEM; 801 return -ENOMEM;
802 goto exit_release;
803 }
804 802
805 platform_set_drvdata(pdev, data); 803 platform_set_drvdata(pdev, data);
806 data->addr = res->start; 804 data->addr = res->start;
@@ -812,7 +810,7 @@ static int vt8231_probe(struct platform_device *pdev)
812 /* Register sysfs hooks */ 810 /* Register sysfs hooks */
813 err = sysfs_create_group(&pdev->dev.kobj, &vt8231_group); 811 err = sysfs_create_group(&pdev->dev.kobj, &vt8231_group);
814 if (err) 812 if (err)
815 goto exit_free; 813 return err;
816 814
817 /* Must update device information to find out the config field */ 815 /* Must update device information to find out the config field */
818 data->uch_config = vt8231_read_value(data, VT8231_REG_UCH_CONFIG); 816 data->uch_config = vt8231_read_value(data, VT8231_REG_UCH_CONFIG);
@@ -850,13 +848,6 @@ exit_remove_files:
850 sysfs_remove_group(&pdev->dev.kobj, &vt8231_group_temps[i]); 848 sysfs_remove_group(&pdev->dev.kobj, &vt8231_group_temps[i]);
851 849
852 sysfs_remove_group(&pdev->dev.kobj, &vt8231_group); 850 sysfs_remove_group(&pdev->dev.kobj, &vt8231_group);
853
854exit_free:
855 platform_set_drvdata(pdev, NULL);
856 kfree(data);
857
858exit_release:
859 release_region(res->start, VT8231_EXTENT);
860 return err; 851 return err;
861} 852}
862 853
@@ -875,9 +866,6 @@ static int __devexit vt8231_remove(struct platform_device *pdev)
875 866
876 sysfs_remove_group(&pdev->dev.kobj, &vt8231_group); 867 sysfs_remove_group(&pdev->dev.kobj, &vt8231_group);
877 868
878 release_region(data->addr, VT8231_EXTENT);
879 platform_set_drvdata(pdev, NULL);
880 kfree(data);
881 return 0; 869 return 0;
882} 870}
883 871
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index ab4825205a9d..5b1a6a666441 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -1206,7 +1206,7 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr,
1206 int err = -ENODEV; 1206 int err = -ENODEV;
1207 u16 val; 1207 u16 val;
1208 1208
1209 static const __initdata char *names[] = { 1209 static __initconst char *const names[] = {
1210 "W83627HF", 1210 "W83627HF",
1211 "W83627THF", 1211 "W83627THF",
1212 "W83697HF", 1212 "W83697HF",
diff --git a/drivers/hwmon/w83791d.c b/drivers/hwmon/w83791d.c
index 9ade4d4e2185..93ea81a4bf35 100644
--- a/drivers/hwmon/w83791d.c
+++ b/drivers/hwmon/w83791d.c
@@ -259,8 +259,7 @@ static u8 fan_to_reg(long rpm, int div)
259 ((val) + 500) / 1000) 259 ((val) + 500) / 1000)
260 260
261/* for thermal cruise temp tolerance, 4-bits, LSB = 1 degree Celsius */ 261/* for thermal cruise temp tolerance, 4-bits, LSB = 1 degree Celsius */
262#define TOL_TEMP_TO_REG(val) ((val) < 0 ? 0 : \ 262#define TOL_TEMP_TO_REG(val) ((val) >= 15000 ? 15 : \
263 (val) >= 15000 ? 15 : \
264 ((val) + 500) / 1000) 263 ((val) + 500) / 1000)
265 264
266#define BEEP_MASK_TO_REG(val) ((val) & 0xffffff) 265#define BEEP_MASK_TO_REG(val) ((val) & 0xffffff)
@@ -848,10 +847,10 @@ static ssize_t store_temp_target(struct device *dev,
848 struct i2c_client *client = to_i2c_client(dev); 847 struct i2c_client *client = to_i2c_client(dev);
849 struct w83791d_data *data = i2c_get_clientdata(client); 848 struct w83791d_data *data = i2c_get_clientdata(client);
850 int nr = sensor_attr->index; 849 int nr = sensor_attr->index;
851 unsigned long val; 850 long val;
852 u8 target_mask; 851 u8 target_mask;
853 852
854 if (kstrtoul(buf, 10, &val)) 853 if (kstrtol(buf, 10, &val))
855 return -EINVAL; 854 return -EINVAL;
856 855
857 mutex_lock(&data->update_lock); 856 mutex_lock(&data->update_lock);
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
index 0ba5a2bd562e..06d6f56d4f69 100644
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -296,7 +296,6 @@ struct w83792d_data {
296 u8 pwmenable[3]; 296 u8 pwmenable[3];
297 u32 alarms; /* realtime status register encoding,combined */ 297 u32 alarms; /* realtime status register encoding,combined */
298 u8 chassis; /* Chassis status */ 298 u8 chassis; /* Chassis status */
299 u8 chassis_clear; /* CLR_CHS, clear chassis intrusion detection */
300 u8 thermal_cruise[3]; /* Smart FanI: Fan1,2,3 target value */ 299 u8 thermal_cruise[3]; /* Smart FanI: Fan1,2,3 target value */
301 u8 tolerance[3]; /* Fan1,2,3 tolerance(Smart Fan I/II) */ 300 u8 tolerance[3]; /* Fan1,2,3 tolerance(Smart Fan I/II) */
302 u8 sf2_points[3][4]; /* Smart FanII: Fan1,2,3 temperature points */ 301 u8 sf2_points[3][4]; /* Smart FanII: Fan1,2,3 temperature points */
@@ -739,7 +738,7 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr,
739} 738}
740 739
741static ssize_t 740static ssize_t
742show_chassis(struct device *dev, struct device_attribute *attr, 741show_chassis_clear(struct device *dev, struct device_attribute *attr,
743 char *buf) 742 char *buf)
744{ 743{
745 struct w83792d_data *data = w83792d_update_device(dev); 744 struct w83792d_data *data = w83792d_update_device(dev);
@@ -747,52 +746,6 @@ show_chassis(struct device *dev, struct device_attribute *attr,
747} 746}
748 747
749static ssize_t 748static ssize_t
750show_regs_chassis(struct device *dev, struct device_attribute *attr,
751 char *buf)
752{
753 dev_warn(dev,
754 "Attribute %s is deprecated, use intrusion0_alarm instead\n",
755 "chassis");
756 return show_chassis(dev, attr, buf);
757}
758
759static ssize_t
760show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf)
761{
762 struct w83792d_data *data = w83792d_update_device(dev);
763 return sprintf(buf, "%d\n", data->chassis_clear);
764}
765
766static ssize_t
767store_chassis_clear_legacy(struct device *dev, struct device_attribute *attr,
768 const char *buf, size_t count)
769{
770 struct i2c_client *client = to_i2c_client(dev);
771 struct w83792d_data *data = i2c_get_clientdata(client);
772 unsigned long val;
773 int err;
774 u8 temp1 = 0, temp2 = 0;
775
776 dev_warn(dev,
777 "Attribute %s is deprecated, use intrusion0_alarm instead\n",
778 "chassis_clear");
779
780 err = kstrtoul(buf, 10, &val);
781 if (err)
782 return err;
783
784 mutex_lock(&data->update_lock);
785 data->chassis_clear = SENSORS_LIMIT(val, 0, 1);
786 temp1 = ((data->chassis_clear) << 7) & 0x80;
787 temp2 = w83792d_read_value(client,
788 W83792D_REG_CHASSIS_CLR) & 0x7f;
789 w83792d_write_value(client, W83792D_REG_CHASSIS_CLR, temp1 | temp2);
790 mutex_unlock(&data->update_lock);
791
792 return count;
793}
794
795static ssize_t
796store_chassis_clear(struct device *dev, struct device_attribute *attr, 749store_chassis_clear(struct device *dev, struct device_attribute *attr,
797 const char *buf, size_t count) 750 const char *buf, size_t count)
798{ 751{
@@ -1116,11 +1069,8 @@ static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 20);
1116static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, 21); 1069static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, 21);
1117static SENSOR_DEVICE_ATTR(fan5_alarm, S_IRUGO, show_alarm, NULL, 22); 1070static SENSOR_DEVICE_ATTR(fan5_alarm, S_IRUGO, show_alarm, NULL, 22);
1118static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO, show_alarm, NULL, 23); 1071static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO, show_alarm, NULL, 23);
1119static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL);
1120static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR,
1121 show_chassis_clear, store_chassis_clear_legacy);
1122static DEVICE_ATTR(intrusion0_alarm, S_IRUGO | S_IWUSR, 1072static DEVICE_ATTR(intrusion0_alarm, S_IRUGO | S_IWUSR,
1123 show_chassis, store_chassis_clear); 1073 show_chassis_clear, store_chassis_clear);
1124static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 0); 1074static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 0);
1125static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 1); 1075static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 1);
1126static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 2); 1076static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 2);
@@ -1320,8 +1270,6 @@ static struct attribute *w83792d_attributes[] = {
1320 &sensor_dev_attr_pwm3_mode.dev_attr.attr, 1270 &sensor_dev_attr_pwm3_mode.dev_attr.attr,
1321 &sensor_dev_attr_pwm3_enable.dev_attr.attr, 1271 &sensor_dev_attr_pwm3_enable.dev_attr.attr,
1322 &dev_attr_alarms.attr, 1272 &dev_attr_alarms.attr,
1323 &dev_attr_chassis.attr,
1324 &dev_attr_chassis_clear.attr,
1325 &dev_attr_intrusion0_alarm.attr, 1273 &dev_attr_intrusion0_alarm.attr,
1326 &sensor_dev_attr_tolerance1.dev_attr.attr, 1274 &sensor_dev_attr_tolerance1.dev_attr.attr,
1327 &sensor_dev_attr_thermal_cruise1.dev_attr.attr, 1275 &sensor_dev_attr_thermal_cruise1.dev_attr.attr,
@@ -1627,8 +1575,6 @@ static struct w83792d_data *w83792d_update_device(struct device *dev)
1627 /* Update CaseOpen status and it's CLR_CHS. */ 1575 /* Update CaseOpen status and it's CLR_CHS. */
1628 data->chassis = (w83792d_read_value(client, 1576 data->chassis = (w83792d_read_value(client,
1629 W83792D_REG_CHASSIS) >> 5) & 0x01; 1577 W83792D_REG_CHASSIS) >> 5) & 0x01;
1630 data->chassis_clear = (w83792d_read_value(client,
1631 W83792D_REG_CHASSIS_CLR) >> 7) & 0x01;
1632 1578
1633 /* Update Thermal Cruise/Smart Fan I target value */ 1579 /* Update Thermal Cruise/Smart Fan I target value */
1634 for (i = 0; i < 3; i++) { 1580 for (i = 0; i < 3; i++) {
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index d6b0bdd48651..4fc47e062071 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -442,27 +442,6 @@ store_beep_enable(struct device *dev, struct device_attribute *attr,
442 return count; 442 return count;
443} 443}
444 444
445/* Write any value to clear chassis alarm */
446static ssize_t
447store_chassis_clear_legacy(struct device *dev,
448 struct device_attribute *attr, const char *buf,
449 size_t count)
450{
451 struct i2c_client *client = to_i2c_client(dev);
452 struct w83793_data *data = i2c_get_clientdata(client);
453 u8 val;
454
455 dev_warn(dev, "Attribute chassis is deprecated, "
456 "use intrusion0_alarm instead\n");
457
458 mutex_lock(&data->update_lock);
459 val = w83793_read_value(client, W83793_REG_CLR_CHASSIS);
460 val |= 0x80;
461 w83793_write_value(client, W83793_REG_CLR_CHASSIS, val);
462 mutex_unlock(&data->update_lock);
463 return count;
464}
465
466/* Write 0 to clear chassis alarm */ 445/* Write 0 to clear chassis alarm */
467static ssize_t 446static ssize_t
468store_chassis_clear(struct device *dev, 447store_chassis_clear(struct device *dev,
@@ -1189,8 +1168,6 @@ static struct sensor_device_attribute_2 w83793_vid[] = {
1189static DEVICE_ATTR(vrm, S_IWUSR | S_IRUGO, show_vrm, store_vrm); 1168static DEVICE_ATTR(vrm, S_IWUSR | S_IRUGO, show_vrm, store_vrm);
1190 1169
1191static struct sensor_device_attribute_2 sda_single_files[] = { 1170static struct sensor_device_attribute_2 sda_single_files[] = {
1192 SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep,
1193 store_chassis_clear_legacy, ALARM_STATUS, 30),
1194 SENSOR_ATTR_2(intrusion0_alarm, S_IWUSR | S_IRUGO, show_alarm_beep, 1171 SENSOR_ATTR_2(intrusion0_alarm, S_IWUSR | S_IRUGO, show_alarm_beep,
1195 store_chassis_clear, ALARM_STATUS, 30), 1172 store_chassis_clear, ALARM_STATUS, 30),
1196 SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_beep_enable, 1173 SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_beep_enable,
diff --git a/drivers/hwmon/w83l786ng.c b/drivers/hwmon/w83l786ng.c
index 5850b7706088..c99c8a0473cf 100644
--- a/drivers/hwmon/w83l786ng.c
+++ b/drivers/hwmon/w83l786ng.c
@@ -668,11 +668,10 @@ w83l786ng_probe(struct i2c_client *client, const struct i2c_device_id *id)
668 int i, err = 0; 668 int i, err = 0;
669 u8 reg_tmp; 669 u8 reg_tmp;
670 670
671 data = kzalloc(sizeof(struct w83l786ng_data), GFP_KERNEL); 671 data = devm_kzalloc(&client->dev, sizeof(struct w83l786ng_data),
672 if (!data) { 672 GFP_KERNEL);
673 err = -ENOMEM; 673 if (!data)
674 goto exit; 674 return -ENOMEM;
675 }
676 675
677 i2c_set_clientdata(client, data); 676 i2c_set_clientdata(client, data);
678 mutex_init(&data->update_lock); 677 mutex_init(&data->update_lock);
@@ -708,8 +707,6 @@ w83l786ng_probe(struct i2c_client *client, const struct i2c_device_id *id)
708 707
709exit_remove: 708exit_remove:
710 sysfs_remove_group(&client->dev.kobj, &w83l786ng_group); 709 sysfs_remove_group(&client->dev.kobj, &w83l786ng_group);
711 kfree(data);
712exit:
713 return err; 710 return err;
714} 711}
715 712
@@ -721,8 +718,6 @@ w83l786ng_remove(struct i2c_client *client)
721 hwmon_device_unregister(data->hwmon_dev); 718 hwmon_device_unregister(data->hwmon_dev);
722 sysfs_remove_group(&client->dev.kobj, &w83l786ng_group); 719 sysfs_remove_group(&client->dev.kobj, &w83l786ng_group);
723 720
724 kfree(data);
725
726 return 0; 721 return 0;
727} 722}
728 723