diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-24 16:29:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-24 16:29:18 -0400 |
commit | 0cd5ff591ab6473355d5a6a47f7694def28e451d (patch) | |
tree | aed0ea4fbb724f13208ed76d438518ffc9130a17 | |
parent | 3539fc544f39017cf3403b9319fb4d74b5116135 (diff) | |
parent | e30bca12573fbf54e2470723aadc047549d147ce (diff) |
Merge tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon updates from Guenter Roeck:
"New drivers for DA9052/53 PMIC as well as HIH-6130/HIH-6131 humidity
and temperature sensors.
Convert drivers to use devm_ functions and to use dev_pm_ops. Address
a couple of Coverity errors/warnings as well as compile warnings.
Some functional improvements in applesmc driver."
* tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (72 commits)
hwmon: (applesmc) Ignore some temperature registers
hwmon: (applesmc) Allow negative temperature values
hwmon: (s3c-hwmon) Use devm_kzalloc instead of kzalloc
hwmon: (w83781d) Fix compile warning
hwmon: (applesmc) Shorten minimum wait time
hwmon: (exynos4_tmu) Use struct dev_pm_ops for power management
hwmon: (gpio-fan) Use struct dev_pm_ops for power management
hwmon: (abituguru3) Use struct dev_pm_ops for power management
hwmon: (abituguru) Use struct dev_pm_ops for power management
hwmon: (acpi_power_meter) Fix unintentional integer overflow
hwmon: (acpi_power_meter) Cleanup and optimizations
hwmon: Honeywell Humidicon HIH-6130/HIH-6131 humidity and temperature sensor driver
hwmon: (applesmc) Skip sensor mapping
hwmon: (ntc_thermistor) Ensure that data->name string is terminated
hwmon: (w83l785ts) Convert to use devm_ functions
hwmon: (w83l785ts) Simplify code and improve readability
hwmon: (smsc47m192) Convert to use devm_ functions
hwmon: (smsc47m1) Convert to use devm_ functions
hwmon: (smsc47b397) Convert to use devm_ functions
hwmon: (k8temp) Convert to use devm_ functions
...
68 files changed, 1220 insertions, 846 deletions
diff --git a/Documentation/hwmon/da9052 b/Documentation/hwmon/da9052 new file mode 100644 index 000000000000..ef898553638e --- /dev/null +++ b/Documentation/hwmon/da9052 | |||
@@ -0,0 +1,61 @@ | |||
1 | Supported chips: | ||
2 | * Dialog Semiconductors DA9052-BC and DA9053-AA/Bx PMICs | ||
3 | Prefix: 'da9052' | ||
4 | Datasheet: Datasheet is not publicly available. | ||
5 | |||
6 | Authors: David Dajun Chen <dchen@diasemi.com> | ||
7 | |||
8 | Description | ||
9 | ----------- | ||
10 | |||
11 | The DA9052/53 provides an Analogue to Digital Converter (ADC) with 10 bits | ||
12 | resolution and track and hold circuitry combined with an analogue input | ||
13 | multiplexer. The analogue input multiplexer will allow conversion of up to 10 | ||
14 | different inputs. The track and hold circuit ensures stable input voltages at | ||
15 | the input of the ADC during the conversion. | ||
16 | |||
17 | The ADC is used to measure the following inputs: | ||
18 | Channel 0: VDDOUT - measurement of the system voltage | ||
19 | Channel 1: ICH - internal battery charger current measurement | ||
20 | Channel 2: TBAT - output from the battery NTC | ||
21 | Channel 3: VBAT - measurement of the battery voltage | ||
22 | Channel 4: ADC_IN4 - high impedance input (0 - 2.5V) | ||
23 | Channel 5: ADC_IN5 - high impedance input (0 - 2.5V) | ||
24 | Channel 6: ADC_IN6 - high impedance input (0 - 2.5V) | ||
25 | Channel 7: XY - TSI interface to measure the X and Y voltage of the touch | ||
26 | screen resistive potentiometers | ||
27 | Channel 8: Internal Tjunc. - sense (internal temp. sensor) | ||
28 | Channel 9: VBBAT - measurement of the backup battery voltage | ||
29 | |||
30 | By using sysfs attributes we can measure the system voltage VDDOUT, the battery | ||
31 | charging current ICH, battery temperature TBAT, battery junction temperature | ||
32 | TJUNC, battery voltage VBAT and the back up battery voltage VBBAT. | ||
33 | |||
34 | Voltage Monitoring | ||
35 | ------------------ | ||
36 | |||
37 | Voltages are sampled by a 10 bit ADC. | ||
38 | |||
39 | The battery voltage is calculated as: | ||
40 | Milli volt = ((ADC value * 1000) / 512) + 2500 | ||
41 | |||
42 | The backup battery voltage is calculated as: | ||
43 | Milli volt = (ADC value * 2500) / 512; | ||
44 | |||
45 | The voltages on ADC channels 4, 5 and 6 are calculated as: | ||
46 | Milli volt = (ADC value * 2500) / 1023 | ||
47 | |||
48 | Temperature Monitoring | ||
49 | ---------------------- | ||
50 | |||
51 | Temperatures are sampled by a 10 bit ADC. Junction and battery temperatures | ||
52 | are monitored by the ADC channels. | ||
53 | |||
54 | The junction temperature is calculated: | ||
55 | Degrees celsius = 1.708 * (TJUNC_RES - T_OFFSET) - 108.8 | ||
56 | The junction temperature attribute is supported by the driver. | ||
57 | |||
58 | The battery temperature is calculated: | ||
59 | Degree Celcius = 1 / (t1 + 1/298)- 273 | ||
60 | where t1 = (1/B)* ln(( ADCval * 2.5)/(R25*ITBAT*255)) | ||
61 | Default values of R25, B, ITBAT are 10e3, 3380 and 50e-6 respectively. | ||
diff --git a/Documentation/hwmon/hih6130 b/Documentation/hwmon/hih6130 new file mode 100644 index 000000000000..73dae918ea7b --- /dev/null +++ b/Documentation/hwmon/hih6130 | |||
@@ -0,0 +1,37 @@ | |||
1 | Kernel driver hih6130 | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Honeywell HIH-6130 / HIH-6131 | ||
6 | Prefix: 'hih6130' | ||
7 | Addresses scanned: none | ||
8 | Datasheet: Publicly available at the Honeywell website | ||
9 | http://sensing.honeywell.com/index.php?ci_id=3106&la_id=1&defId=44872 | ||
10 | |||
11 | Author: | ||
12 | Iain Paton <ipaton0@gmail.com> | ||
13 | |||
14 | Description | ||
15 | ----------- | ||
16 | |||
17 | The HIH-6130 & HIH-6131 are humidity and temperature sensors in a SO8 package. | ||
18 | The difference between the two devices is that the HIH-6131 has a condensation | ||
19 | filter. | ||
20 | |||
21 | The devices communicate with the I2C protocol. All sensors are set to the same | ||
22 | I2C address 0x27 by default, so an entry with I2C_BOARD_INFO("hih6130", 0x27) | ||
23 | can be used in the board setup code. | ||
24 | |||
25 | Please see Documentation/i2c/instantiating-devices for details on how to | ||
26 | instantiate I2C devices. | ||
27 | |||
28 | sysfs-Interface | ||
29 | --------------- | ||
30 | |||
31 | temp1_input - temperature input | ||
32 | humidity1_input - humidity input | ||
33 | |||
34 | Notes | ||
35 | ----- | ||
36 | |||
37 | Command mode and alarms are not currently supported. | ||
diff --git a/Documentation/hwmon/submitting-patches b/Documentation/hwmon/submitting-patches index 86f42e8e9e49..790f774a3032 100644 --- a/Documentation/hwmon/submitting-patches +++ b/Documentation/hwmon/submitting-patches | |||
@@ -70,6 +70,9 @@ increase the chances of your change being accepted. | |||
70 | review more difficult. It may also result in code which is more complicated | 70 | review more difficult. It may also result in code which is more complicated |
71 | than necessary. Use inline functions or just regular functions instead. | 71 | than necessary. Use inline functions or just regular functions instead. |
72 | 72 | ||
73 | * Use devres functions whenever possible to allocate resources. For rationale | ||
74 | and supported functions, please see Documentation/driver-model/devres.txt. | ||
75 | |||
73 | * If the driver has a detect function, make sure it is silent. Debug messages | 76 | * If the driver has a detect function, make sure it is silent. Debug messages |
74 | and messages printed after a successful detection are acceptable, but it | 77 | and messages printed after a successful detection are acceptable, but it |
75 | must not print messages such as "Chip XXX not found/supported". | 78 | must not print messages such as "Chip XXX not found/supported". |
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 6f1d167cb1ea..b0a2e4c37e12 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -314,6 +314,16 @@ config SENSORS_DS1621 | |||
314 | This driver can also be built as a module. If so, the module | 314 | This driver can also be built as a module. If so, the module |
315 | will be called ds1621. | 315 | will be called ds1621. |
316 | 316 | ||
317 | config SENSORS_DA9052_ADC | ||
318 | tristate "Dialog DA9052/DA9053 ADC" | ||
319 | depends on PMIC_DA9052 | ||
320 | help | ||
321 | Say y here to support the ADC found on Dialog Semiconductor | ||
322 | DA9052-BC and DA9053-AA/Bx PMICs. | ||
323 | |||
324 | This driver can also be built as module. If so, the module | ||
325 | will be called da9052-hwmon. | ||
326 | |||
317 | config SENSORS_EXYNOS4_TMU | 327 | config SENSORS_EXYNOS4_TMU |
318 | tristate "Temperature sensor on Samsung EXYNOS4" | 328 | tristate "Temperature sensor on Samsung EXYNOS4" |
319 | depends on ARCH_EXYNOS4 | 329 | depends on ARCH_EXYNOS4 |
@@ -433,6 +443,16 @@ config SENSORS_GPIO_FAN | |||
433 | This driver can also be built as a module. If so, the module | 443 | This driver can also be built as a module. If so, the module |
434 | will be called gpio-fan. | 444 | will be called gpio-fan. |
435 | 445 | ||
446 | config SENSORS_HIH6130 | ||
447 | tristate "Honeywell Humidicon HIH-6130 humidity/temperature sensor" | ||
448 | depends on I2C && EXPERIMENTAL | ||
449 | help | ||
450 | If you say yes here you get support for Honeywell Humidicon | ||
451 | HIH-6130 and HIH-6131 Humidicon humidity sensors. | ||
452 | |||
453 | This driver can also be built as a module. If so, the module | ||
454 | will be called hih6130. | ||
455 | |||
436 | config SENSORS_CORETEMP | 456 | config SENSORS_CORETEMP |
437 | tristate "Intel Core/Core2/Atom temperature sensor" | 457 | tristate "Intel Core/Core2/Atom temperature sensor" |
438 | depends on X86 && PCI && EXPERIMENTAL | 458 | depends on X86 && PCI && EXPERIMENTAL |
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index e1eeac13b851..7aa98119c4ab 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile | |||
@@ -42,6 +42,7 @@ obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o | |||
42 | obj-$(CONFIG_SENSORS_ASC7621) += asc7621.o | 42 | obj-$(CONFIG_SENSORS_ASC7621) += asc7621.o |
43 | obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o | 43 | obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o |
44 | obj-$(CONFIG_SENSORS_CORETEMP) += coretemp.o | 44 | obj-$(CONFIG_SENSORS_CORETEMP) += coretemp.o |
45 | obj-$(CONFIG_SENSORS_DA9052_ADC)+= da9052-hwmon.o | ||
45 | obj-$(CONFIG_SENSORS_DME1737) += dme1737.o | 46 | obj-$(CONFIG_SENSORS_DME1737) += dme1737.o |
46 | obj-$(CONFIG_SENSORS_DS620) += ds620.o | 47 | obj-$(CONFIG_SENSORS_DS620) += ds620.o |
47 | obj-$(CONFIG_SENSORS_DS1621) += ds1621.o | 48 | obj-$(CONFIG_SENSORS_DS1621) += ds1621.o |
@@ -58,6 +59,7 @@ obj-$(CONFIG_SENSORS_G760A) += g760a.o | |||
58 | obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o | 59 | obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o |
59 | obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o | 60 | obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o |
60 | obj-$(CONFIG_SENSORS_GPIO_FAN) += gpio-fan.o | 61 | obj-$(CONFIG_SENSORS_GPIO_FAN) += gpio-fan.o |
62 | obj-$(CONFIG_SENSORS_HIH6130) += hih6130.o | ||
61 | obj-$(CONFIG_SENSORS_ULTRA45) += ultra45_env.o | 63 | obj-$(CONFIG_SENSORS_ULTRA45) += ultra45_env.o |
62 | obj-$(CONFIG_SENSORS_I5K_AMB) += i5k_amb.o | 64 | obj-$(CONFIG_SENSORS_I5K_AMB) += i5k_amb.o |
63 | obj-$(CONFIG_SENSORS_IBMAEM) += ibmaem.o | 65 | obj-$(CONFIG_SENSORS_IBMAEM) += ibmaem.o |
diff --git a/drivers/hwmon/abituguru.c b/drivers/hwmon/abituguru.c index a72bf25601a4..d4419b47f3d4 100644 --- a/drivers/hwmon/abituguru.c +++ b/drivers/hwmon/abituguru.c | |||
@@ -1513,10 +1513,10 @@ LEAVE_UPDATE: | |||
1513 | return NULL; | 1513 | return NULL; |
1514 | } | 1514 | } |
1515 | 1515 | ||
1516 | #ifdef CONFIG_PM | 1516 | #ifdef CONFIG_PM_SLEEP |
1517 | static int abituguru_suspend(struct platform_device *pdev, pm_message_t state) | 1517 | static int abituguru_suspend(struct device *dev) |
1518 | { | 1518 | { |
1519 | struct abituguru_data *data = platform_get_drvdata(pdev); | 1519 | struct abituguru_data *data = dev_get_drvdata(dev); |
1520 | /* | 1520 | /* |
1521 | * make sure all communications with the uguru are done and no new | 1521 | * make sure all communications with the uguru are done and no new |
1522 | * ones are started | 1522 | * ones are started |
@@ -1525,29 +1525,30 @@ static int abituguru_suspend(struct platform_device *pdev, pm_message_t state) | |||
1525 | return 0; | 1525 | return 0; |
1526 | } | 1526 | } |
1527 | 1527 | ||
1528 | static int abituguru_resume(struct platform_device *pdev) | 1528 | static int abituguru_resume(struct device *dev) |
1529 | { | 1529 | { |
1530 | struct abituguru_data *data = platform_get_drvdata(pdev); | 1530 | struct abituguru_data *data = dev_get_drvdata(dev); |
1531 | /* See if the uGuru is still ready */ | 1531 | /* See if the uGuru is still ready */ |
1532 | if (inb_p(data->addr + ABIT_UGURU_DATA) != ABIT_UGURU_STATUS_INPUT) | 1532 | if (inb_p(data->addr + ABIT_UGURU_DATA) != ABIT_UGURU_STATUS_INPUT) |
1533 | data->uguru_ready = 0; | 1533 | data->uguru_ready = 0; |
1534 | mutex_unlock(&data->update_lock); | 1534 | mutex_unlock(&data->update_lock); |
1535 | return 0; | 1535 | return 0; |
1536 | } | 1536 | } |
1537 | |||
1538 | static SIMPLE_DEV_PM_OPS(abituguru_pm, abituguru_suspend, abituguru_resume); | ||
1539 | #define ABIT_UGURU_PM &abituguru_pm | ||
1537 | #else | 1540 | #else |
1538 | #define abituguru_suspend NULL | 1541 | #define ABIT_UGURU_PM NULL |
1539 | #define abituguru_resume NULL | ||
1540 | #endif /* CONFIG_PM */ | 1542 | #endif /* CONFIG_PM */ |
1541 | 1543 | ||
1542 | static struct platform_driver abituguru_driver = { | 1544 | static struct platform_driver abituguru_driver = { |
1543 | .driver = { | 1545 | .driver = { |
1544 | .owner = THIS_MODULE, | 1546 | .owner = THIS_MODULE, |
1545 | .name = ABIT_UGURU_NAME, | 1547 | .name = ABIT_UGURU_NAME, |
1548 | .pm = ABIT_UGURU_PM, | ||
1546 | }, | 1549 | }, |
1547 | .probe = abituguru_probe, | 1550 | .probe = abituguru_probe, |
1548 | .remove = __devexit_p(abituguru_remove), | 1551 | .remove = __devexit_p(abituguru_remove), |
1549 | .suspend = abituguru_suspend, | ||
1550 | .resume = abituguru_resume, | ||
1551 | }; | 1552 | }; |
1552 | 1553 | ||
1553 | static int __init abituguru_detect(void) | 1554 | static int __init abituguru_detect(void) |
diff --git a/drivers/hwmon/abituguru3.c b/drivers/hwmon/abituguru3.c index a5bc4287daa6..5d582aebff87 100644 --- a/drivers/hwmon/abituguru3.c +++ b/drivers/hwmon/abituguru3.c | |||
@@ -1141,10 +1141,10 @@ LEAVE_UPDATE: | |||
1141 | return NULL; | 1141 | return NULL; |
1142 | } | 1142 | } |
1143 | 1143 | ||
1144 | #ifdef CONFIG_PM | 1144 | #ifdef CONFIG_PM_SLEEP |
1145 | static int abituguru3_suspend(struct platform_device *pdev, pm_message_t state) | 1145 | static int abituguru3_suspend(struct device *dev) |
1146 | { | 1146 | { |
1147 | struct abituguru3_data *data = platform_get_drvdata(pdev); | 1147 | struct abituguru3_data *data = dev_get_drvdata(dev); |
1148 | /* | 1148 | /* |
1149 | * make sure all communications with the uguru3 are done and no new | 1149 | * make sure all communications with the uguru3 are done and no new |
1150 | * ones are started | 1150 | * ones are started |
@@ -1153,26 +1153,27 @@ static int abituguru3_suspend(struct platform_device *pdev, pm_message_t state) | |||
1153 | return 0; | 1153 | return 0; |
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | static int abituguru3_resume(struct platform_device *pdev) | 1156 | static int abituguru3_resume(struct device *dev) |
1157 | { | 1157 | { |
1158 | struct abituguru3_data *data = platform_get_drvdata(pdev); | 1158 | struct abituguru3_data *data = dev_get_drvdata(dev); |
1159 | mutex_unlock(&data->update_lock); | 1159 | mutex_unlock(&data->update_lock); |
1160 | return 0; | 1160 | return 0; |
1161 | } | 1161 | } |
1162 | |||
1163 | static SIMPLE_DEV_PM_OPS(abituguru3_pm, abituguru3_suspend, abituguru3_resume); | ||
1164 | #define ABIT_UGURU3_PM &abituguru3_pm | ||
1162 | #else | 1165 | #else |
1163 | #define abituguru3_suspend NULL | 1166 | #define ABIT_UGURU3_PM NULL |
1164 | #define abituguru3_resume NULL | ||
1165 | #endif /* CONFIG_PM */ | 1167 | #endif /* CONFIG_PM */ |
1166 | 1168 | ||
1167 | static struct platform_driver abituguru3_driver = { | 1169 | static struct platform_driver abituguru3_driver = { |
1168 | .driver = { | 1170 | .driver = { |
1169 | .owner = THIS_MODULE, | 1171 | .owner = THIS_MODULE, |
1170 | .name = ABIT_UGURU3_NAME, | 1172 | .name = ABIT_UGURU3_NAME, |
1173 | .pm = ABIT_UGURU3_PM | ||
1171 | }, | 1174 | }, |
1172 | .probe = abituguru3_probe, | 1175 | .probe = abituguru3_probe, |
1173 | .remove = __devexit_p(abituguru3_remove), | 1176 | .remove = __devexit_p(abituguru3_remove), |
1174 | .suspend = abituguru3_suspend, | ||
1175 | .resume = abituguru3_resume | ||
1176 | }; | 1177 | }; |
1177 | 1178 | ||
1178 | static int __init abituguru3_dmi_detect(void) | 1179 | static int __init abituguru3_dmi_detect(void) |
diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c index e3fcf8146834..563c02904ddf 100644 --- a/drivers/hwmon/acpi_power_meter.c +++ b/drivers/hwmon/acpi_power_meter.c | |||
@@ -101,7 +101,7 @@ struct acpi_power_meter_resource { | |||
101 | unsigned long sensors_last_updated; | 101 | unsigned long sensors_last_updated; |
102 | struct sensor_device_attribute sensors[NUM_SENSORS]; | 102 | struct sensor_device_attribute sensors[NUM_SENSORS]; |
103 | int num_sensors; | 103 | int num_sensors; |
104 | int trip[2]; | 104 | s64 trip[2]; |
105 | int num_domain_devices; | 105 | int num_domain_devices; |
106 | struct acpi_device **domain_devices; | 106 | struct acpi_device **domain_devices; |
107 | struct kobject *holders_dir; | 107 | struct kobject *holders_dir; |
@@ -237,7 +237,7 @@ static ssize_t set_cap(struct device *dev, struct device_attribute *devattr, | |||
237 | if (res) | 237 | if (res) |
238 | return res; | 238 | return res; |
239 | 239 | ||
240 | temp /= 1000; | 240 | temp = DIV_ROUND_CLOSEST(temp, 1000); |
241 | if (temp > resource->caps.max_cap || temp < resource->caps.min_cap) | 241 | if (temp > resource->caps.max_cap || temp < resource->caps.min_cap) |
242 | return -EINVAL; | 242 | return -EINVAL; |
243 | arg0.integer.value = temp; | 243 | arg0.integer.value = temp; |
@@ -307,9 +307,7 @@ static ssize_t set_trip(struct device *dev, struct device_attribute *devattr, | |||
307 | if (res) | 307 | if (res) |
308 | return res; | 308 | return res; |
309 | 309 | ||
310 | temp /= 1000; | 310 | temp = DIV_ROUND_CLOSEST(temp, 1000); |
311 | if (temp < 0) | ||
312 | return -EINVAL; | ||
313 | 311 | ||
314 | mutex_lock(&resource->lock); | 312 | mutex_lock(&resource->lock); |
315 | resource->trip[attr->index - 7] = temp; | 313 | resource->trip[attr->index - 7] = temp; |
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index 4394e7e99c46..fd1d1b15854e 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c | |||
@@ -366,11 +366,11 @@ static int adm1021_probe(struct i2c_client *client, | |||
366 | struct adm1021_data *data; | 366 | struct adm1021_data *data; |
367 | int err; | 367 | int err; |
368 | 368 | ||
369 | data = kzalloc(sizeof(struct adm1021_data), GFP_KERNEL); | 369 | data = devm_kzalloc(&client->dev, sizeof(struct adm1021_data), |
370 | GFP_KERNEL); | ||
370 | if (!data) { | 371 | if (!data) { |
371 | pr_debug("adm1021: detect failed, kzalloc failed!\n"); | 372 | pr_debug("adm1021: detect failed, devm_kzalloc failed!\n"); |
372 | err = -ENOMEM; | 373 | return -ENOMEM; |
373 | goto error0; | ||
374 | } | 374 | } |
375 | 375 | ||
376 | i2c_set_clientdata(client, data); | 376 | i2c_set_clientdata(client, data); |
@@ -384,21 +384,18 @@ static int adm1021_probe(struct i2c_client *client, | |||
384 | /* Register sysfs hooks */ | 384 | /* Register sysfs hooks */ |
385 | err = sysfs_create_group(&client->dev.kobj, &adm1021_group); | 385 | err = sysfs_create_group(&client->dev.kobj, &adm1021_group); |
386 | if (err) | 386 | if (err) |
387 | goto error1; | 387 | return err; |
388 | 388 | ||
389 | data->hwmon_dev = hwmon_device_register(&client->dev); | 389 | data->hwmon_dev = hwmon_device_register(&client->dev); |
390 | if (IS_ERR(data->hwmon_dev)) { | 390 | if (IS_ERR(data->hwmon_dev)) { |
391 | err = PTR_ERR(data->hwmon_dev); | 391 | err = PTR_ERR(data->hwmon_dev); |
392 | goto error3; | 392 | goto error; |
393 | } | 393 | } |
394 | 394 | ||
395 | return 0; | 395 | return 0; |
396 | 396 | ||
397 | error3: | 397 | error: |
398 | sysfs_remove_group(&client->dev.kobj, &adm1021_group); | 398 | sysfs_remove_group(&client->dev.kobj, &adm1021_group); |
399 | error1: | ||
400 | kfree(data); | ||
401 | error0: | ||
402 | return err; | 399 | return err; |
403 | } | 400 | } |
404 | 401 | ||
@@ -418,7 +415,6 @@ static int adm1021_remove(struct i2c_client *client) | |||
418 | hwmon_device_unregister(data->hwmon_dev); | 415 | hwmon_device_unregister(data->hwmon_dev); |
419 | sysfs_remove_group(&client->dev.kobj, &adm1021_group); | 416 | sysfs_remove_group(&client->dev.kobj, &adm1021_group); |
420 | 417 | ||
421 | kfree(data); | ||
422 | return 0; | 418 | return 0; |
423 | } | 419 | } |
424 | 420 | ||
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index b8557f9857d2..7e16e5d07bc6 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c | |||
@@ -477,11 +477,10 @@ static int adm1025_probe(struct i2c_client *client, | |||
477 | int err; | 477 | int err; |
478 | u8 config; | 478 | u8 config; |
479 | 479 | ||
480 | data = kzalloc(sizeof(struct adm1025_data), GFP_KERNEL); | 480 | data = devm_kzalloc(&client->dev, sizeof(struct adm1025_data), |
481 | if (!data) { | 481 | GFP_KERNEL); |
482 | err = -ENOMEM; | 482 | if (!data) |
483 | goto exit; | 483 | return -ENOMEM; |
484 | } | ||
485 | 484 | ||
486 | i2c_set_clientdata(client, data); | 485 | i2c_set_clientdata(client, data); |
487 | mutex_init(&data->update_lock); | 486 | mutex_init(&data->update_lock); |
@@ -492,7 +491,7 @@ static int adm1025_probe(struct i2c_client *client, | |||
492 | /* Register sysfs hooks */ | 491 | /* Register sysfs hooks */ |
493 | err = sysfs_create_group(&client->dev.kobj, &adm1025_group); | 492 | err = sysfs_create_group(&client->dev.kobj, &adm1025_group); |
494 | if (err) | 493 | if (err) |
495 | goto exit_free; | 494 | return err; |
496 | 495 | ||
497 | /* Pin 11 is either in4 (+12V) or VID4 */ | 496 | /* Pin 11 is either in4 (+12V) or VID4 */ |
498 | config = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG); | 497 | config = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG); |
@@ -513,9 +512,6 @@ static int adm1025_probe(struct i2c_client *client, | |||
513 | exit_remove: | 512 | exit_remove: |
514 | sysfs_remove_group(&client->dev.kobj, &adm1025_group); | 513 | sysfs_remove_group(&client->dev.kobj, &adm1025_group); |
515 | sysfs_remove_group(&client->dev.kobj, &adm1025_group_in4); | 514 | sysfs_remove_group(&client->dev.kobj, &adm1025_group_in4); |
516 | exit_free: | ||
517 | kfree(data); | ||
518 | exit: | ||
519 | return err; | 515 | return err; |
520 | } | 516 | } |
521 | 517 | ||
@@ -569,7 +565,6 @@ static int adm1025_remove(struct i2c_client *client) | |||
569 | sysfs_remove_group(&client->dev.kobj, &adm1025_group); | 565 | sysfs_remove_group(&client->dev.kobj, &adm1025_group); |
570 | sysfs_remove_group(&client->dev.kobj, &adm1025_group_in4); | 566 | sysfs_remove_group(&client->dev.kobj, &adm1025_group_in4); |
571 | 567 | ||
572 | kfree(data); | ||
573 | return 0; | 568 | return 0; |
574 | } | 569 | } |
575 | 570 | ||
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index 1003219b9f90..0f068e7297ee 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c | |||
@@ -1834,11 +1834,10 @@ static int adm1026_probe(struct i2c_client *client, | |||
1834 | struct adm1026_data *data; | 1834 | struct adm1026_data *data; |
1835 | int err; | 1835 | int err; |
1836 | 1836 | ||
1837 | data = kzalloc(sizeof(struct adm1026_data), GFP_KERNEL); | 1837 | data = devm_kzalloc(&client->dev, sizeof(struct adm1026_data), |
1838 | if (!data) { | 1838 | GFP_KERNEL); |
1839 | err = -ENOMEM; | 1839 | if (!data) |
1840 | goto exit; | 1840 | return -ENOMEM; |
1841 | } | ||
1842 | 1841 | ||
1843 | i2c_set_clientdata(client, data); | 1842 | i2c_set_clientdata(client, data); |
1844 | mutex_init(&data->update_lock); | 1843 | mutex_init(&data->update_lock); |
@@ -1852,7 +1851,7 @@ static int adm1026_probe(struct i2c_client *client, | |||
1852 | /* Register sysfs hooks */ | 1851 | /* Register sysfs hooks */ |
1853 | err = sysfs_create_group(&client->dev.kobj, &adm1026_group); | 1852 | err = sysfs_create_group(&client->dev.kobj, &adm1026_group); |
1854 | if (err) | 1853 | if (err) |
1855 | goto exitfree; | 1854 | return err; |
1856 | if (data->config1 & CFG1_AIN8_9) | 1855 | if (data->config1 & CFG1_AIN8_9) |
1857 | err = sysfs_create_group(&client->dev.kobj, | 1856 | err = sysfs_create_group(&client->dev.kobj, |
1858 | &adm1026_group_in8_9); | 1857 | &adm1026_group_in8_9); |
@@ -1877,9 +1876,6 @@ exitremove: | |||
1877 | sysfs_remove_group(&client->dev.kobj, &adm1026_group_in8_9); | 1876 | sysfs_remove_group(&client->dev.kobj, &adm1026_group_in8_9); |
1878 | else | 1877 | else |
1879 | sysfs_remove_group(&client->dev.kobj, &adm1026_group_temp3); | 1878 | sysfs_remove_group(&client->dev.kobj, &adm1026_group_temp3); |
1880 | exitfree: | ||
1881 | kfree(data); | ||
1882 | exit: | ||
1883 | return err; | 1879 | return err; |
1884 | } | 1880 | } |
1885 | 1881 | ||
@@ -1892,7 +1888,6 @@ static int adm1026_remove(struct i2c_client *client) | |||
1892 | sysfs_remove_group(&client->dev.kobj, &adm1026_group_in8_9); | 1888 | sysfs_remove_group(&client->dev.kobj, &adm1026_group_in8_9); |
1893 | else | 1889 | else |
1894 | sysfs_remove_group(&client->dev.kobj, &adm1026_group_temp3); | 1890 | sysfs_remove_group(&client->dev.kobj, &adm1026_group_temp3); |
1895 | kfree(data); | ||
1896 | return 0; | 1891 | return 0; |
1897 | } | 1892 | } |
1898 | 1893 | ||
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index 44e1fd7f3d81..c6a4631e833f 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
@@ -954,11 +954,10 @@ static int adm1031_probe(struct i2c_client *client, | |||
954 | struct adm1031_data *data; | 954 | struct adm1031_data *data; |
955 | int err; | 955 | int err; |
956 | 956 | ||
957 | data = kzalloc(sizeof(struct adm1031_data), GFP_KERNEL); | 957 | data = devm_kzalloc(&client->dev, sizeof(struct adm1031_data), |
958 | if (!data) { | 958 | GFP_KERNEL); |
959 | err = -ENOMEM; | 959 | if (!data) |
960 | goto exit; | 960 | return -ENOMEM; |
961 | } | ||
962 | 961 | ||
963 | i2c_set_clientdata(client, data); | 962 | i2c_set_clientdata(client, data); |
964 | data->chip_type = id->driver_data; | 963 | data->chip_type = id->driver_data; |
@@ -975,7 +974,7 @@ static int adm1031_probe(struct i2c_client *client, | |||
975 | /* Register sysfs hooks */ | 974 | /* Register sysfs hooks */ |
976 | err = sysfs_create_group(&client->dev.kobj, &adm1031_group); | 975 | err = sysfs_create_group(&client->dev.kobj, &adm1031_group); |
977 | if (err) | 976 | if (err) |
978 | goto exit_free; | 977 | return err; |
979 | 978 | ||
980 | if (data->chip_type == adm1031) { | 979 | if (data->chip_type == adm1031) { |
981 | err = sysfs_create_group(&client->dev.kobj, &adm1031_group_opt); | 980 | err = sysfs_create_group(&client->dev.kobj, &adm1031_group_opt); |
@@ -994,9 +993,6 @@ static int adm1031_probe(struct i2c_client *client, | |||
994 | exit_remove: | 993 | exit_remove: |
995 | sysfs_remove_group(&client->dev.kobj, &adm1031_group); | 994 | sysfs_remove_group(&client->dev.kobj, &adm1031_group); |
996 | sysfs_remove_group(&client->dev.kobj, &adm1031_group_opt); | 995 | sysfs_remove_group(&client->dev.kobj, &adm1031_group_opt); |
997 | exit_free: | ||
998 | kfree(data); | ||
999 | exit: | ||
1000 | return err; | 996 | return err; |
1001 | } | 997 | } |
1002 | 998 | ||
@@ -1007,7 +1003,6 @@ static int adm1031_remove(struct i2c_client *client) | |||
1007 | hwmon_device_unregister(data->hwmon_dev); | 1003 | hwmon_device_unregister(data->hwmon_dev); |
1008 | sysfs_remove_group(&client->dev.kobj, &adm1031_group); | 1004 | sysfs_remove_group(&client->dev.kobj, &adm1031_group); |
1009 | sysfs_remove_group(&client->dev.kobj, &adm1031_group_opt); | 1005 | sysfs_remove_group(&client->dev.kobj, &adm1031_group_opt); |
1010 | kfree(data); | ||
1011 | return 0; | 1006 | return 0; |
1012 | } | 1007 | } |
1013 | 1008 | ||
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index c3c2865a8967..5a78d102a0fa 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c | |||
@@ -650,11 +650,9 @@ static int adm9240_probe(struct i2c_client *new_client, | |||
650 | struct adm9240_data *data; | 650 | struct adm9240_data *data; |
651 | int err; | 651 | int err; |
652 | 652 | ||
653 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 653 | data = devm_kzalloc(&new_client->dev, sizeof(*data), GFP_KERNEL); |
654 | if (!data) { | 654 | if (!data) |
655 | err = -ENOMEM; | 655 | return -ENOMEM; |
656 | goto exit; | ||
657 | } | ||
658 | 656 | ||
659 | i2c_set_clientdata(new_client, data); | 657 | i2c_set_clientdata(new_client, data); |
660 | mutex_init(&data->update_lock); | 658 | mutex_init(&data->update_lock); |
@@ -664,7 +662,7 @@ static int adm9240_probe(struct i2c_client *new_client, | |||
664 | /* populate sysfs filesystem */ | 662 | /* populate sysfs filesystem */ |
665 | err = sysfs_create_group(&new_client->dev.kobj, &adm9240_group); | 663 | err = sysfs_create_group(&new_client->dev.kobj, &adm9240_group); |
666 | if (err) | 664 | if (err) |
667 | goto exit_free; | 665 | return err; |
668 | 666 | ||
669 | data->hwmon_dev = hwmon_device_register(&new_client->dev); | 667 | data->hwmon_dev = hwmon_device_register(&new_client->dev); |
670 | if (IS_ERR(data->hwmon_dev)) { | 668 | if (IS_ERR(data->hwmon_dev)) { |
@@ -676,9 +674,6 @@ static int adm9240_probe(struct i2c_client *new_client, | |||
676 | 674 | ||
677 | exit_remove: | 675 | exit_remove: |
678 | sysfs_remove_group(&new_client->dev.kobj, &adm9240_group); | 676 | sysfs_remove_group(&new_client->dev.kobj, &adm9240_group); |
679 | exit_free: | ||
680 | kfree(data); | ||
681 | exit: | ||
682 | return err; | 677 | return err; |
683 | } | 678 | } |
684 | 679 | ||
@@ -689,7 +684,6 @@ static int adm9240_remove(struct i2c_client *client) | |||
689 | hwmon_device_unregister(data->hwmon_dev); | 684 | hwmon_device_unregister(data->hwmon_dev); |
690 | sysfs_remove_group(&client->dev.kobj, &adm9240_group); | 685 | sysfs_remove_group(&client->dev.kobj, &adm9240_group); |
691 | 686 | ||
692 | kfree(data); | ||
693 | return 0; | 687 | return 0; |
694 | } | 688 | } |
695 | 689 | ||
diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index df29d13a5349..861c756e9536 100644 --- a/drivers/hwmon/adt7475.c +++ b/drivers/hwmon/adt7475.c | |||
@@ -1260,7 +1260,7 @@ static int adt7475_probe(struct i2c_client *client, | |||
1260 | int i, ret = 0, revision; | 1260 | int i, ret = 0, revision; |
1261 | u8 config2, config3; | 1261 | u8 config2, config3; |
1262 | 1262 | ||
1263 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 1263 | data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); |
1264 | if (data == NULL) | 1264 | if (data == NULL) |
1265 | return -ENOMEM; | 1265 | return -ENOMEM; |
1266 | 1266 | ||
@@ -1344,7 +1344,7 @@ static int adt7475_probe(struct i2c_client *client, | |||
1344 | 1344 | ||
1345 | ret = sysfs_create_group(&client->dev.kobj, &adt7475_attr_group); | 1345 | ret = sysfs_create_group(&client->dev.kobj, &adt7475_attr_group); |
1346 | if (ret) | 1346 | if (ret) |
1347 | goto efree; | 1347 | return ret; |
1348 | 1348 | ||
1349 | /* Features that can be disabled individually */ | 1349 | /* Features that can be disabled individually */ |
1350 | if (data->has_fan4) { | 1350 | if (data->has_fan4) { |
@@ -1410,8 +1410,6 @@ static int adt7475_probe(struct i2c_client *client, | |||
1410 | 1410 | ||
1411 | eremove: | 1411 | eremove: |
1412 | adt7475_remove_files(client, data); | 1412 | adt7475_remove_files(client, data); |
1413 | efree: | ||
1414 | kfree(data); | ||
1415 | return ret; | 1413 | return ret; |
1416 | } | 1414 | } |
1417 | 1415 | ||
@@ -1421,7 +1419,6 @@ static int adt7475_remove(struct i2c_client *client) | |||
1421 | 1419 | ||
1422 | hwmon_device_unregister(data->hwmon_dev); | 1420 | hwmon_device_unregister(data->hwmon_dev); |
1423 | adt7475_remove_files(client, data); | 1421 | adt7475_remove_files(client, data); |
1424 | kfree(data); | ||
1425 | 1422 | ||
1426 | return 0; | 1423 | return 0; |
1427 | } | 1424 | } |
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c index 2cde9ecf7731..4d937a18fadb 100644 --- a/drivers/hwmon/applesmc.c +++ b/drivers/hwmon/applesmc.c | |||
@@ -54,7 +54,7 @@ | |||
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 32 ms for a status change. */ |
57 | #define APPLESMC_MIN_WAIT 0x0040 | 57 | #define APPLESMC_MIN_WAIT 0x0010 |
58 | #define APPLESMC_MAX_WAIT 0x8000 | 58 | #define APPLESMC_MAX_WAIT 0x8000 |
59 | 59 | ||
60 | #define APPLESMC_STATUS_MASK 0x0f | 60 | #define APPLESMC_STATUS_MASK 0x0f |
@@ -80,6 +80,8 @@ | |||
80 | #define FANS_MANUAL "FS! " /* r-w ui16 */ | 80 | #define FANS_MANUAL "FS! " /* r-w ui16 */ |
81 | #define FAN_ID_FMT "F%dID" /* r-o char[16] */ | 81 | #define FAN_ID_FMT "F%dID" /* r-o char[16] */ |
82 | 82 | ||
83 | #define TEMP_SENSOR_TYPE "sp78" | ||
84 | |||
83 | /* List of keys used to read/write fan speeds */ | 85 | /* List of keys used to read/write fan speeds */ |
84 | static const char *const fan_speed_fmt[] = { | 86 | static const char *const fan_speed_fmt[] = { |
85 | "F%dAc", /* actual speed */ | 87 | "F%dAc", /* actual speed */ |
@@ -96,10 +98,6 @@ static const char *const fan_speed_fmt[] = { | |||
96 | #define APPLESMC_INPUT_FUZZ 4 /* input event threshold */ | 98 | #define APPLESMC_INPUT_FUZZ 4 /* input event threshold */ |
97 | #define APPLESMC_INPUT_FLAT 4 | 99 | #define APPLESMC_INPUT_FLAT 4 |
98 | 100 | ||
99 | #define SENSOR_X 0 | ||
100 | #define SENSOR_Y 1 | ||
101 | #define SENSOR_Z 2 | ||
102 | |||
103 | #define to_index(attr) (to_sensor_dev_attr(attr)->index & 0xffff) | 101 | #define to_index(attr) (to_sensor_dev_attr(attr)->index & 0xffff) |
104 | #define to_option(attr) (to_sensor_dev_attr(attr)->index >> 16) | 102 | #define to_option(attr) (to_sensor_dev_attr(attr)->index >> 16) |
105 | 103 | ||
@@ -135,11 +133,13 @@ static struct applesmc_registers { | |||
135 | unsigned int temp_count; /* number of temperature registers */ | 133 | unsigned int temp_count; /* number of temperature registers */ |
136 | unsigned int temp_begin; /* temperature lower index bound */ | 134 | unsigned int temp_begin; /* temperature lower index bound */ |
137 | unsigned int temp_end; /* temperature upper index bound */ | 135 | unsigned int temp_end; /* temperature upper index bound */ |
136 | unsigned int index_count; /* size of temperature index array */ | ||
138 | int num_light_sensors; /* number of light sensors */ | 137 | int num_light_sensors; /* number of light sensors */ |
139 | bool has_accelerometer; /* has motion sensor */ | 138 | bool has_accelerometer; /* has motion sensor */ |
140 | bool has_key_backlight; /* has keyboard backlight */ | 139 | bool has_key_backlight; /* has keyboard backlight */ |
141 | bool init_complete; /* true when fully initialized */ | 140 | bool init_complete; /* true when fully initialized */ |
142 | struct applesmc_entry *cache; /* cached key entries */ | 141 | struct applesmc_entry *cache; /* cached key entries */ |
142 | const char **index; /* temperature key index */ | ||
143 | } smcreg = { | 143 | } smcreg = { |
144 | .mutex = __MUTEX_INITIALIZER(smcreg.mutex), | 144 | .mutex = __MUTEX_INITIALIZER(smcreg.mutex), |
145 | }; | 145 | }; |
@@ -432,30 +432,19 @@ static int applesmc_has_key(const char *key, bool *value) | |||
432 | } | 432 | } |
433 | 433 | ||
434 | /* | 434 | /* |
435 | * applesmc_read_motion_sensor - Read motion sensor (X, Y or Z). | 435 | * applesmc_read_s16 - Read 16-bit signed big endian register |
436 | */ | 436 | */ |
437 | static int applesmc_read_motion_sensor(int index, s16 *value) | 437 | static int applesmc_read_s16(const char *key, s16 *value) |
438 | { | 438 | { |
439 | u8 buffer[2]; | 439 | u8 buffer[2]; |
440 | int ret; | 440 | int ret; |
441 | 441 | ||
442 | switch (index) { | 442 | ret = applesmc_read_key(key, buffer, 2); |
443 | case SENSOR_X: | 443 | if (ret) |
444 | ret = applesmc_read_key(MOTION_SENSOR_X_KEY, buffer, 2); | 444 | return ret; |
445 | break; | ||
446 | case SENSOR_Y: | ||
447 | ret = applesmc_read_key(MOTION_SENSOR_Y_KEY, buffer, 2); | ||
448 | break; | ||
449 | case SENSOR_Z: | ||
450 | ret = applesmc_read_key(MOTION_SENSOR_Z_KEY, buffer, 2); | ||
451 | break; | ||
452 | default: | ||
453 | ret = -EINVAL; | ||
454 | } | ||
455 | 445 | ||
456 | *value = ((s16)buffer[0] << 8) | buffer[1]; | 446 | *value = ((s16)buffer[0] << 8) | buffer[1]; |
457 | 447 | return 0; | |
458 | return ret; | ||
459 | } | 448 | } |
460 | 449 | ||
461 | /* | 450 | /* |
@@ -482,6 +471,30 @@ static void applesmc_device_init(void) | |||
482 | pr_warn("failed to init the device\n"); | 471 | pr_warn("failed to init the device\n"); |
483 | } | 472 | } |
484 | 473 | ||
474 | static int applesmc_init_index(struct applesmc_registers *s) | ||
475 | { | ||
476 | const struct applesmc_entry *entry; | ||
477 | unsigned int i; | ||
478 | |||
479 | if (s->index) | ||
480 | return 0; | ||
481 | |||
482 | s->index = kcalloc(s->temp_count, sizeof(s->index[0]), GFP_KERNEL); | ||
483 | if (!s->index) | ||
484 | return -ENOMEM; | ||
485 | |||
486 | for (i = s->temp_begin; i < s->temp_end; i++) { | ||
487 | entry = applesmc_get_entry_by_index(i); | ||
488 | if (IS_ERR(entry)) | ||
489 | continue; | ||
490 | if (strcmp(entry->type, TEMP_SENSOR_TYPE)) | ||
491 | continue; | ||
492 | s->index[s->index_count++] = entry->key; | ||
493 | } | ||
494 | |||
495 | return 0; | ||
496 | } | ||
497 | |||
485 | /* | 498 | /* |
486 | * applesmc_init_smcreg_try - Try to initialize register cache. Idempotent. | 499 | * applesmc_init_smcreg_try - Try to initialize register cache. Idempotent. |
487 | */ | 500 | */ |
@@ -517,6 +530,10 @@ static int applesmc_init_smcreg_try(void) | |||
517 | return ret; | 530 | return ret; |
518 | s->temp_count = s->temp_end - s->temp_begin; | 531 | s->temp_count = s->temp_end - s->temp_begin; |
519 | 532 | ||
533 | ret = applesmc_init_index(s); | ||
534 | if (ret) | ||
535 | return ret; | ||
536 | |||
520 | ret = applesmc_has_key(LIGHT_SENSOR_LEFT_KEY, &left_light_sensor); | 537 | ret = applesmc_has_key(LIGHT_SENSOR_LEFT_KEY, &left_light_sensor); |
521 | if (ret) | 538 | if (ret) |
522 | return ret; | 539 | return ret; |
@@ -533,8 +550,8 @@ static int applesmc_init_smcreg_try(void) | |||
533 | s->num_light_sensors = left_light_sensor + right_light_sensor; | 550 | s->num_light_sensors = left_light_sensor + right_light_sensor; |
534 | s->init_complete = true; | 551 | s->init_complete = true; |
535 | 552 | ||
536 | pr_info("key=%d fan=%d temp=%d acc=%d lux=%d kbd=%d\n", | 553 | pr_info("key=%d fan=%d temp=%d index=%d acc=%d lux=%d kbd=%d\n", |
537 | s->key_count, s->fan_count, s->temp_count, | 554 | s->key_count, s->fan_count, s->temp_count, s->index_count, |
538 | s->has_accelerometer, | 555 | s->has_accelerometer, |
539 | s->num_light_sensors, | 556 | s->num_light_sensors, |
540 | s->has_key_backlight); | 557 | s->has_key_backlight); |
@@ -542,6 +559,15 @@ static int applesmc_init_smcreg_try(void) | |||
542 | return 0; | 559 | return 0; |
543 | } | 560 | } |
544 | 561 | ||
562 | static void applesmc_destroy_smcreg(void) | ||
563 | { | ||
564 | kfree(smcreg.index); | ||
565 | smcreg.index = NULL; | ||
566 | kfree(smcreg.cache); | ||
567 | smcreg.cache = NULL; | ||
568 | smcreg.init_complete = false; | ||
569 | } | ||
570 | |||
545 | /* | 571 | /* |
546 | * applesmc_init_smcreg - Initialize register cache. | 572 | * applesmc_init_smcreg - Initialize register cache. |
547 | * | 573 | * |
@@ -562,19 +588,11 @@ static int applesmc_init_smcreg(void) | |||
562 | msleep(INIT_WAIT_MSECS); | 588 | msleep(INIT_WAIT_MSECS); |
563 | } | 589 | } |
564 | 590 | ||
565 | kfree(smcreg.cache); | 591 | applesmc_destroy_smcreg(); |
566 | smcreg.cache = NULL; | ||
567 | 592 | ||
568 | return ret; | 593 | return ret; |
569 | } | 594 | } |
570 | 595 | ||
571 | static void applesmc_destroy_smcreg(void) | ||
572 | { | ||
573 | kfree(smcreg.cache); | ||
574 | smcreg.cache = NULL; | ||
575 | smcreg.init_complete = false; | ||
576 | } | ||
577 | |||
578 | /* Device model stuff */ | 596 | /* Device model stuff */ |
579 | static int applesmc_probe(struct platform_device *dev) | 597 | static int applesmc_probe(struct platform_device *dev) |
580 | { | 598 | { |
@@ -624,8 +642,8 @@ static struct platform_driver applesmc_driver = { | |||
624 | */ | 642 | */ |
625 | static void applesmc_calibrate(void) | 643 | static void applesmc_calibrate(void) |
626 | { | 644 | { |
627 | applesmc_read_motion_sensor(SENSOR_X, &rest_x); | 645 | applesmc_read_s16(MOTION_SENSOR_X_KEY, &rest_x); |
628 | applesmc_read_motion_sensor(SENSOR_Y, &rest_y); | 646 | applesmc_read_s16(MOTION_SENSOR_Y_KEY, &rest_y); |
629 | rest_x = -rest_x; | 647 | rest_x = -rest_x; |
630 | } | 648 | } |
631 | 649 | ||
@@ -634,9 +652,9 @@ static void applesmc_idev_poll(struct input_polled_dev *dev) | |||
634 | struct input_dev *idev = dev->input; | 652 | struct input_dev *idev = dev->input; |
635 | s16 x, y; | 653 | s16 x, y; |
636 | 654 | ||
637 | if (applesmc_read_motion_sensor(SENSOR_X, &x)) | 655 | if (applesmc_read_s16(MOTION_SENSOR_X_KEY, &x)) |
638 | return; | 656 | return; |
639 | if (applesmc_read_motion_sensor(SENSOR_Y, &y)) | 657 | if (applesmc_read_s16(MOTION_SENSOR_Y_KEY, &y)) |
640 | return; | 658 | return; |
641 | 659 | ||
642 | x = -x; | 660 | x = -x; |
@@ -659,13 +677,13 @@ static ssize_t applesmc_position_show(struct device *dev, | |||
659 | int ret; | 677 | int ret; |
660 | s16 x, y, z; | 678 | s16 x, y, z; |
661 | 679 | ||
662 | ret = applesmc_read_motion_sensor(SENSOR_X, &x); | 680 | ret = applesmc_read_s16(MOTION_SENSOR_X_KEY, &x); |
663 | if (ret) | 681 | if (ret) |
664 | goto out; | 682 | goto out; |
665 | ret = applesmc_read_motion_sensor(SENSOR_Y, &y); | 683 | ret = applesmc_read_s16(MOTION_SENSOR_Y_KEY, &y); |
666 | if (ret) | 684 | if (ret) |
667 | goto out; | 685 | goto out; |
668 | ret = applesmc_read_motion_sensor(SENSOR_Z, &z); | 686 | ret = applesmc_read_s16(MOTION_SENSOR_Z_KEY, &z); |
669 | if (ret) | 687 | if (ret) |
670 | goto out; | 688 | goto out; |
671 | 689 | ||
@@ -718,44 +736,27 @@ out: | |||
718 | static ssize_t applesmc_show_sensor_label(struct device *dev, | 736 | static ssize_t applesmc_show_sensor_label(struct device *dev, |
719 | struct device_attribute *devattr, char *sysfsbuf) | 737 | struct device_attribute *devattr, char *sysfsbuf) |
720 | { | 738 | { |
721 | int index = smcreg.temp_begin + to_index(devattr); | 739 | const char *key = smcreg.index[to_index(devattr)]; |
722 | const struct applesmc_entry *entry; | ||
723 | 740 | ||
724 | entry = applesmc_get_entry_by_index(index); | 741 | return snprintf(sysfsbuf, PAGE_SIZE, "%s\n", key); |
725 | if (IS_ERR(entry)) | ||
726 | return PTR_ERR(entry); | ||
727 | |||
728 | return snprintf(sysfsbuf, PAGE_SIZE, "%s\n", entry->key); | ||
729 | } | 742 | } |
730 | 743 | ||
731 | /* Displays degree Celsius * 1000 */ | 744 | /* Displays degree Celsius * 1000 */ |
732 | static ssize_t applesmc_show_temperature(struct device *dev, | 745 | static ssize_t applesmc_show_temperature(struct device *dev, |
733 | struct device_attribute *devattr, char *sysfsbuf) | 746 | struct device_attribute *devattr, char *sysfsbuf) |
734 | { | 747 | { |
735 | int index = smcreg.temp_begin + to_index(devattr); | 748 | const char *key = smcreg.index[to_index(devattr)]; |
736 | const struct applesmc_entry *entry; | ||
737 | int ret; | 749 | int ret; |
738 | u8 buffer[2]; | 750 | s16 value; |
739 | unsigned int temp; | 751 | int temp; |
740 | |||
741 | entry = applesmc_get_entry_by_index(index); | ||
742 | if (IS_ERR(entry)) | ||
743 | return PTR_ERR(entry); | ||
744 | if (entry->len > 2) | ||
745 | return -EINVAL; | ||
746 | 752 | ||
747 | ret = applesmc_read_entry(entry, buffer, entry->len); | 753 | ret = applesmc_read_s16(key, &value); |
748 | if (ret) | 754 | if (ret) |
749 | return ret; | 755 | return ret; |
750 | 756 | ||
751 | if (entry->len == 2) { | 757 | temp = 250 * (value >> 6); |
752 | temp = buffer[0] * 1000; | ||
753 | temp += (buffer[1] >> 6) * 250; | ||
754 | } else { | ||
755 | temp = buffer[0] * 4000; | ||
756 | } | ||
757 | 758 | ||
758 | return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", temp); | 759 | return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", temp); |
759 | } | 760 | } |
760 | 761 | ||
761 | static ssize_t applesmc_show_fan_speed(struct device *dev, | 762 | static ssize_t applesmc_show_fan_speed(struct device *dev, |
@@ -1265,7 +1266,7 @@ static int __init applesmc_init(void) | |||
1265 | if (ret) | 1266 | if (ret) |
1266 | goto out_info; | 1267 | goto out_info; |
1267 | 1268 | ||
1268 | ret = applesmc_create_nodes(temp_group, smcreg.temp_count); | 1269 | ret = applesmc_create_nodes(temp_group, smcreg.index_count); |
1269 | if (ret) | 1270 | if (ret) |
1270 | goto out_fans; | 1271 | goto out_fans; |
1271 | 1272 | ||
diff --git a/drivers/hwmon/asc7621.c b/drivers/hwmon/asc7621.c index 7caa242915a6..b867aab78049 100644 --- a/drivers/hwmon/asc7621.c +++ b/drivers/hwmon/asc7621.c | |||
@@ -1109,7 +1109,8 @@ asc7621_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1109 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 1109 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
1110 | return -EIO; | 1110 | return -EIO; |
1111 | 1111 | ||
1112 | data = kzalloc(sizeof(struct asc7621_data), GFP_KERNEL); | 1112 | data = devm_kzalloc(&client->dev, sizeof(struct asc7621_data), |
1113 | GFP_KERNEL); | ||
1113 | if (data == NULL) | 1114 | if (data == NULL) |
1114 | return -ENOMEM; | 1115 | return -ENOMEM; |
1115 | 1116 | ||
@@ -1143,7 +1144,6 @@ exit_remove: | |||
1143 | &(asc7621_params[i].sda.dev_attr)); | 1144 | &(asc7621_params[i].sda.dev_attr)); |
1144 | } | 1145 | } |
1145 | 1146 | ||
1146 | kfree(data); | ||
1147 | return err; | 1147 | return err; |
1148 | } | 1148 | } |
1149 | 1149 | ||
@@ -1192,7 +1192,6 @@ static int asc7621_remove(struct i2c_client *client) | |||
1192 | &(asc7621_params[i].sda.dev_attr)); | 1192 | &(asc7621_params[i].sda.dev_attr)); |
1193 | } | 1193 | } |
1194 | 1194 | ||
1195 | kfree(data); | ||
1196 | return 0; | 1195 | return 0; |
1197 | } | 1196 | } |
1198 | 1197 | ||
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index 58af6aa93530..aecb9ea7beb5 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c | |||
@@ -345,11 +345,10 @@ static int atxp1_probe(struct i2c_client *new_client, | |||
345 | struct atxp1_data *data; | 345 | struct atxp1_data *data; |
346 | int err; | 346 | int err; |
347 | 347 | ||
348 | data = kzalloc(sizeof(struct atxp1_data), GFP_KERNEL); | 348 | data = devm_kzalloc(&new_client->dev, sizeof(struct atxp1_data), |
349 | if (!data) { | 349 | GFP_KERNEL); |
350 | err = -ENOMEM; | 350 | if (!data) |
351 | goto exit; | 351 | return -ENOMEM; |
352 | } | ||
353 | 352 | ||
354 | /* Get VRM */ | 353 | /* Get VRM */ |
355 | data->vrm = vid_which_vrm(); | 354 | data->vrm = vid_which_vrm(); |
@@ -362,7 +361,7 @@ static int atxp1_probe(struct i2c_client *new_client, | |||
362 | /* Register sysfs hooks */ | 361 | /* Register sysfs hooks */ |
363 | err = sysfs_create_group(&new_client->dev.kobj, &atxp1_group); | 362 | err = sysfs_create_group(&new_client->dev.kobj, &atxp1_group); |
364 | if (err) | 363 | if (err) |
365 | goto exit_free; | 364 | return err; |
366 | 365 | ||
367 | data->hwmon_dev = hwmon_device_register(&new_client->dev); | 366 | data->hwmon_dev = hwmon_device_register(&new_client->dev); |
368 | if (IS_ERR(data->hwmon_dev)) { | 367 | if (IS_ERR(data->hwmon_dev)) { |
@@ -377,9 +376,6 @@ static int atxp1_probe(struct i2c_client *new_client, | |||
377 | 376 | ||
378 | exit_remove_files: | 377 | exit_remove_files: |
379 | sysfs_remove_group(&new_client->dev.kobj, &atxp1_group); | 378 | sysfs_remove_group(&new_client->dev.kobj, &atxp1_group); |
380 | exit_free: | ||
381 | kfree(data); | ||
382 | exit: | ||
383 | return err; | 379 | return err; |
384 | }; | 380 | }; |
385 | 381 | ||
@@ -390,8 +386,6 @@ static int atxp1_remove(struct i2c_client *client) | |||
390 | hwmon_device_unregister(data->hwmon_dev); | 386 | hwmon_device_unregister(data->hwmon_dev); |
391 | sysfs_remove_group(&client->dev.kobj, &atxp1_group); | 387 | sysfs_remove_group(&client->dev.kobj, &atxp1_group); |
392 | 388 | ||
393 | kfree(data); | ||
394 | |||
395 | return 0; | 389 | return 0; |
396 | }; | 390 | }; |
397 | 391 | ||
diff --git a/drivers/hwmon/da9052-hwmon.c b/drivers/hwmon/da9052-hwmon.c new file mode 100644 index 000000000000..fc65f2d3ec91 --- /dev/null +++ b/drivers/hwmon/da9052-hwmon.c | |||
@@ -0,0 +1,344 @@ | |||
1 | /* | ||
2 | * HWMON Driver for Dialog DA9052 | ||
3 | * | ||
4 | * Copyright(c) 2012 Dialog Semiconductor Ltd. | ||
5 | * | ||
6 | * Author: David Dajun Chen <dchen@diasemi.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/delay.h> | ||
16 | #include <linux/err.h> | ||
17 | #include <linux/hwmon.h> | ||
18 | #include <linux/hwmon-sysfs.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/slab.h> | ||
23 | #include <linux/platform_device.h> | ||
24 | |||
25 | #include <linux/mfd/da9052/da9052.h> | ||
26 | #include <linux/mfd/da9052/reg.h> | ||
27 | |||
28 | struct da9052_hwmon { | ||
29 | struct da9052 *da9052; | ||
30 | struct device *class_device; | ||
31 | struct mutex hwmon_lock; | ||
32 | }; | ||
33 | |||
34 | static const char * const input_names[] = { | ||
35 | [DA9052_ADC_VDDOUT] = "VDDOUT", | ||
36 | [DA9052_ADC_ICH] = "CHARGING CURRENT", | ||
37 | [DA9052_ADC_TBAT] = "BATTERY TEMP", | ||
38 | [DA9052_ADC_VBAT] = "BATTERY VOLTAGE", | ||
39 | [DA9052_ADC_IN4] = "ADC IN4", | ||
40 | [DA9052_ADC_IN5] = "ADC IN5", | ||
41 | [DA9052_ADC_IN6] = "ADC IN6", | ||
42 | [DA9052_ADC_TJUNC] = "BATTERY JUNCTION TEMP", | ||
43 | [DA9052_ADC_VBBAT] = "BACK-UP BATTERY VOLTAGE", | ||
44 | }; | ||
45 | |||
46 | /* Conversion function for VDDOUT and VBAT */ | ||
47 | static inline int volt_reg_to_mV(int value) | ||
48 | { | ||
49 | return DIV_ROUND_CLOSEST(value * 1000, 512) + 2500; | ||
50 | } | ||
51 | |||
52 | /* Conversion function for ADC channels 4, 5 and 6 */ | ||
53 | static inline int input_reg_to_mV(int value) | ||
54 | { | ||
55 | return DIV_ROUND_CLOSEST(value * 2500, 1023); | ||
56 | } | ||
57 | |||
58 | /* Conversion function for VBBAT */ | ||
59 | static inline int vbbat_reg_to_mV(int value) | ||
60 | { | ||
61 | return DIV_ROUND_CLOSEST(value * 2500, 512); | ||
62 | } | ||
63 | |||
64 | static int da9052_enable_vddout_channel(struct da9052 *da9052) | ||
65 | { | ||
66 | int ret; | ||
67 | |||
68 | ret = da9052_reg_read(da9052, DA9052_ADC_CONT_REG); | ||
69 | if (ret < 0) | ||
70 | return ret; | ||
71 | |||
72 | ret |= DA9052_ADCCONT_AUTOVDDEN; | ||
73 | |||
74 | return da9052_reg_write(da9052, DA9052_ADC_CONT_REG, ret); | ||
75 | } | ||
76 | |||
77 | static int da9052_disable_vddout_channel(struct da9052 *da9052) | ||
78 | { | ||
79 | int ret; | ||
80 | |||
81 | ret = da9052_reg_read(da9052, DA9052_ADC_CONT_REG); | ||
82 | if (ret < 0) | ||
83 | return ret; | ||
84 | |||
85 | ret &= ~DA9052_ADCCONT_AUTOVDDEN; | ||
86 | |||
87 | return da9052_reg_write(da9052, DA9052_ADC_CONT_REG, ret); | ||
88 | } | ||
89 | |||
90 | static ssize_t da9052_read_vddout(struct device *dev, | ||
91 | struct device_attribute *devattr, char *buf) | ||
92 | { | ||
93 | struct da9052_hwmon *hwmon = dev_get_drvdata(dev); | ||
94 | int ret, vdd; | ||
95 | |||
96 | mutex_lock(&hwmon->hwmon_lock); | ||
97 | |||
98 | ret = da9052_enable_vddout_channel(hwmon->da9052); | ||
99 | if (ret < 0) | ||
100 | goto hwmon_err; | ||
101 | |||
102 | vdd = da9052_reg_read(hwmon->da9052, DA9052_VDD_RES_REG); | ||
103 | if (vdd < 0) { | ||
104 | ret = vdd; | ||
105 | goto hwmon_err_release; | ||
106 | } | ||
107 | |||
108 | ret = da9052_disable_vddout_channel(hwmon->da9052); | ||
109 | if (ret < 0) | ||
110 | goto hwmon_err; | ||
111 | |||
112 | mutex_unlock(&hwmon->hwmon_lock); | ||
113 | return sprintf(buf, "%d\n", volt_reg_to_mV(vdd)); | ||
114 | |||
115 | hwmon_err_release: | ||
116 | da9052_disable_vddout_channel(hwmon->da9052); | ||
117 | hwmon_err: | ||
118 | mutex_unlock(&hwmon->hwmon_lock); | ||
119 | return ret; | ||
120 | } | ||
121 | |||
122 | static ssize_t da9052_read_ich(struct device *dev, | ||
123 | struct device_attribute *devattr, char *buf) | ||
124 | { | ||
125 | struct da9052_hwmon *hwmon = dev_get_drvdata(dev); | ||
126 | int ret; | ||
127 | |||
128 | ret = da9052_reg_read(hwmon->da9052, DA9052_ICHG_AV_REG); | ||
129 | if (ret < 0) | ||
130 | return ret; | ||
131 | |||
132 | /* Equivalent to 3.9mA/bit in register ICHG_AV */ | ||
133 | return sprintf(buf, "%d\n", DIV_ROUND_CLOSEST(ret * 39, 10)); | ||
134 | } | ||
135 | |||
136 | static ssize_t da9052_read_tbat(struct device *dev, | ||
137 | struct device_attribute *devattr, char *buf) | ||
138 | { | ||
139 | struct da9052_hwmon *hwmon = dev_get_drvdata(dev); | ||
140 | |||
141 | return sprintf(buf, "%d\n", da9052_adc_read_temp(hwmon->da9052)); | ||
142 | } | ||
143 | |||
144 | static ssize_t da9052_read_vbat(struct device *dev, | ||
145 | struct device_attribute *devattr, char *buf) | ||
146 | { | ||
147 | struct da9052_hwmon *hwmon = dev_get_drvdata(dev); | ||
148 | int ret; | ||
149 | |||
150 | ret = da9052_adc_manual_read(hwmon->da9052, DA9052_ADC_VBAT); | ||
151 | if (ret < 0) | ||
152 | return ret; | ||
153 | |||
154 | return sprintf(buf, "%d\n", volt_reg_to_mV(ret)); | ||
155 | } | ||
156 | |||
157 | static ssize_t da9052_read_misc_channel(struct device *dev, | ||
158 | struct device_attribute *devattr, | ||
159 | char *buf) | ||
160 | { | ||
161 | struct da9052_hwmon *hwmon = dev_get_drvdata(dev); | ||
162 | int channel = to_sensor_dev_attr(devattr)->index; | ||
163 | int ret; | ||
164 | |||
165 | ret = da9052_adc_manual_read(hwmon->da9052, channel); | ||
166 | if (ret < 0) | ||
167 | return ret; | ||
168 | |||
169 | return sprintf(buf, "%d\n", input_reg_to_mV(ret)); | ||
170 | } | ||
171 | |||
172 | static ssize_t da9052_read_tjunc(struct device *dev, | ||
173 | struct device_attribute *devattr, char *buf) | ||
174 | { | ||
175 | struct da9052_hwmon *hwmon = dev_get_drvdata(dev); | ||
176 | int tjunc; | ||
177 | int toffset; | ||
178 | |||
179 | tjunc = da9052_reg_read(hwmon->da9052, DA9052_TJUNC_RES_REG); | ||
180 | if (tjunc < 0) | ||
181 | return tjunc; | ||
182 | |||
183 | toffset = da9052_reg_read(hwmon->da9052, DA9052_T_OFFSET_REG); | ||
184 | if (toffset < 0) | ||
185 | return toffset; | ||
186 | |||
187 | /* | ||
188 | * Degrees celsius = 1.708 * (TJUNC_RES - T_OFFSET) - 108.8 | ||
189 | * T_OFFSET is a trim value used to improve accuracy of the result | ||
190 | */ | ||
191 | return sprintf(buf, "%d\n", 1708 * (tjunc - toffset) - 108800); | ||
192 | } | ||
193 | |||
194 | static ssize_t da9052_read_vbbat(struct device *dev, | ||
195 | struct device_attribute *devattr, char *buf) | ||
196 | { | ||
197 | struct da9052_hwmon *hwmon = dev_get_drvdata(dev); | ||
198 | int ret; | ||
199 | |||
200 | ret = da9052_adc_manual_read(hwmon->da9052, DA9052_ADC_VBBAT); | ||
201 | if (ret < 0) | ||
202 | return ret; | ||
203 | |||
204 | return sprintf(buf, "%d\n", vbbat_reg_to_mV(ret)); | ||
205 | } | ||
206 | |||
207 | static ssize_t da9052_hwmon_show_name(struct device *dev, | ||
208 | struct device_attribute *devattr, | ||
209 | char *buf) | ||
210 | { | ||
211 | return sprintf(buf, "da9052-hwmon\n"); | ||
212 | } | ||
213 | |||
214 | static ssize_t show_label(struct device *dev, | ||
215 | struct device_attribute *devattr, char *buf) | ||
216 | { | ||
217 | return sprintf(buf, "%s\n", | ||
218 | input_names[to_sensor_dev_attr(devattr)->index]); | ||
219 | } | ||
220 | |||
221 | static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, da9052_read_vddout, NULL, | ||
222 | DA9052_ADC_VDDOUT); | ||
223 | static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, show_label, NULL, | ||
224 | DA9052_ADC_VDDOUT); | ||
225 | static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, da9052_read_vbat, NULL, | ||
226 | DA9052_ADC_VBAT); | ||
227 | static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, | ||
228 | DA9052_ADC_VBAT); | ||
229 | static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, da9052_read_misc_channel, NULL, | ||
230 | DA9052_ADC_IN4); | ||
231 | static SENSOR_DEVICE_ATTR(in4_label, S_IRUGO, show_label, NULL, | ||
232 | DA9052_ADC_IN4); | ||
233 | static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, da9052_read_misc_channel, NULL, | ||
234 | DA9052_ADC_IN5); | ||
235 | static SENSOR_DEVICE_ATTR(in5_label, S_IRUGO, show_label, NULL, | ||
236 | DA9052_ADC_IN5); | ||
237 | static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, da9052_read_misc_channel, NULL, | ||
238 | DA9052_ADC_IN6); | ||
239 | static SENSOR_DEVICE_ATTR(in6_label, S_IRUGO, show_label, NULL, | ||
240 | DA9052_ADC_IN6); | ||
241 | static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, da9052_read_vbbat, NULL, | ||
242 | DA9052_ADC_VBBAT); | ||
243 | static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, show_label, NULL, | ||
244 | DA9052_ADC_VBBAT); | ||
245 | |||
246 | static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, da9052_read_ich, NULL, | ||
247 | DA9052_ADC_ICH); | ||
248 | static SENSOR_DEVICE_ATTR(curr1_label, S_IRUGO, show_label, NULL, | ||
249 | DA9052_ADC_ICH); | ||
250 | |||
251 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, da9052_read_tbat, NULL, | ||
252 | DA9052_ADC_TBAT); | ||
253 | static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, show_label, NULL, | ||
254 | DA9052_ADC_TBAT); | ||
255 | static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, da9052_read_tjunc, NULL, | ||
256 | DA9052_ADC_TJUNC); | ||
257 | static SENSOR_DEVICE_ATTR(temp8_label, S_IRUGO, show_label, NULL, | ||
258 | DA9052_ADC_TJUNC); | ||
259 | |||
260 | static DEVICE_ATTR(name, S_IRUGO, da9052_hwmon_show_name, NULL); | ||
261 | |||
262 | static struct attribute *da9052_attr[] = { | ||
263 | &dev_attr_name.attr, | ||
264 | &sensor_dev_attr_in0_input.dev_attr.attr, | ||
265 | &sensor_dev_attr_in0_label.dev_attr.attr, | ||
266 | &sensor_dev_attr_in3_input.dev_attr.attr, | ||
267 | &sensor_dev_attr_in3_label.dev_attr.attr, | ||
268 | &sensor_dev_attr_in4_input.dev_attr.attr, | ||
269 | &sensor_dev_attr_in4_label.dev_attr.attr, | ||
270 | &sensor_dev_attr_in5_input.dev_attr.attr, | ||
271 | &sensor_dev_attr_in5_label.dev_attr.attr, | ||
272 | &sensor_dev_attr_in6_input.dev_attr.attr, | ||
273 | &sensor_dev_attr_in6_label.dev_attr.attr, | ||
274 | &sensor_dev_attr_in9_input.dev_attr.attr, | ||
275 | &sensor_dev_attr_in9_label.dev_attr.attr, | ||
276 | &sensor_dev_attr_curr1_input.dev_attr.attr, | ||
277 | &sensor_dev_attr_curr1_label.dev_attr.attr, | ||
278 | &sensor_dev_attr_temp2_input.dev_attr.attr, | ||
279 | &sensor_dev_attr_temp2_label.dev_attr.attr, | ||
280 | &sensor_dev_attr_temp8_input.dev_attr.attr, | ||
281 | &sensor_dev_attr_temp8_label.dev_attr.attr, | ||
282 | NULL | ||
283 | }; | ||
284 | |||
285 | static const struct attribute_group da9052_attr_group = {.attrs = da9052_attr}; | ||
286 | |||
287 | static int __devinit da9052_hwmon_probe(struct platform_device *pdev) | ||
288 | { | ||
289 | struct da9052_hwmon *hwmon; | ||
290 | int ret; | ||
291 | |||
292 | hwmon = devm_kzalloc(&pdev->dev, sizeof(struct da9052_hwmon), | ||
293 | GFP_KERNEL); | ||
294 | if (!hwmon) | ||
295 | return -ENOMEM; | ||
296 | |||
297 | mutex_init(&hwmon->hwmon_lock); | ||
298 | hwmon->da9052 = dev_get_drvdata(pdev->dev.parent); | ||
299 | |||
300 | platform_set_drvdata(pdev, hwmon); | ||
301 | |||
302 | ret = sysfs_create_group(&pdev->dev.kobj, &da9052_attr_group); | ||
303 | if (ret) | ||
304 | goto err_mem; | ||
305 | |||
306 | hwmon->class_device = hwmon_device_register(&pdev->dev); | ||
307 | if (IS_ERR(hwmon->class_device)) { | ||
308 | ret = PTR_ERR(hwmon->class_device); | ||
309 | goto err_sysfs; | ||
310 | } | ||
311 | |||
312 | return 0; | ||
313 | |||
314 | err_sysfs: | ||
315 | sysfs_remove_group(&pdev->dev.kobj, &da9052_attr_group); | ||
316 | err_mem: | ||
317 | return ret; | ||
318 | } | ||
319 | |||
320 | static int __devexit da9052_hwmon_remove(struct platform_device *pdev) | ||
321 | { | ||
322 | struct da9052_hwmon *hwmon = platform_get_drvdata(pdev); | ||
323 | |||
324 | hwmon_device_unregister(hwmon->class_device); | ||
325 | sysfs_remove_group(&pdev->dev.kobj, &da9052_attr_group); | ||
326 | |||
327 | return 0; | ||
328 | } | ||
329 | |||
330 | static struct platform_driver da9052_hwmon_driver = { | ||
331 | .probe = da9052_hwmon_probe, | ||
332 | .remove = __devexit_p(da9052_hwmon_remove), | ||
333 | .driver = { | ||
334 | .name = "da9052-hwmon", | ||
335 | .owner = THIS_MODULE, | ||
336 | }, | ||
337 | }; | ||
338 | |||
339 | module_platform_driver(da9052_hwmon_driver); | ||
340 | |||
341 | MODULE_AUTHOR("David Dajun Chen <dchen@diasemi.com>"); | ||
342 | MODULE_DESCRIPTION("DA9052 HWMON driver"); | ||
343 | MODULE_LICENSE("GPL"); | ||
344 | MODULE_ALIAS("platform:da9052-hwmon"); | ||
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index f647a3307ebc..1c568736baff 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c | |||
@@ -249,11 +249,10 @@ static int ds1621_probe(struct i2c_client *client, | |||
249 | struct ds1621_data *data; | 249 | struct ds1621_data *data; |
250 | int err; | 250 | int err; |
251 | 251 | ||
252 | data = kzalloc(sizeof(struct ds1621_data), GFP_KERNEL); | 252 | data = devm_kzalloc(&client->dev, sizeof(struct ds1621_data), |
253 | if (!data) { | 253 | GFP_KERNEL); |
254 | err = -ENOMEM; | 254 | if (!data) |
255 | goto exit; | 255 | return -ENOMEM; |
256 | } | ||
257 | 256 | ||
258 | i2c_set_clientdata(client, data); | 257 | i2c_set_clientdata(client, data); |
259 | mutex_init(&data->update_lock); | 258 | mutex_init(&data->update_lock); |
@@ -264,7 +263,7 @@ static int ds1621_probe(struct i2c_client *client, | |||
264 | /* Register sysfs hooks */ | 263 | /* Register sysfs hooks */ |
265 | err = sysfs_create_group(&client->dev.kobj, &ds1621_group); | 264 | err = sysfs_create_group(&client->dev.kobj, &ds1621_group); |
266 | if (err) | 265 | if (err) |
267 | goto exit_free; | 266 | return err; |
268 | 267 | ||
269 | data->hwmon_dev = hwmon_device_register(&client->dev); | 268 | data->hwmon_dev = hwmon_device_register(&client->dev); |
270 | if (IS_ERR(data->hwmon_dev)) { | 269 | if (IS_ERR(data->hwmon_dev)) { |
@@ -276,9 +275,6 @@ static int ds1621_probe(struct i2c_client *client, | |||
276 | 275 | ||
277 | exit_remove_files: | 276 | exit_remove_files: |
278 | sysfs_remove_group(&client->dev.kobj, &ds1621_group); | 277 | sysfs_remove_group(&client->dev.kobj, &ds1621_group); |
279 | exit_free: | ||
280 | kfree(data); | ||
281 | exit: | ||
282 | return err; | 278 | return err; |
283 | } | 279 | } |
284 | 280 | ||
@@ -289,8 +285,6 @@ static int ds1621_remove(struct i2c_client *client) | |||
289 | hwmon_device_unregister(data->hwmon_dev); | 285 | hwmon_device_unregister(data->hwmon_dev); |
290 | sysfs_remove_group(&client->dev.kobj, &ds1621_group); | 286 | sysfs_remove_group(&client->dev.kobj, &ds1621_group); |
291 | 287 | ||
292 | kfree(data); | ||
293 | |||
294 | return 0; | 288 | return 0; |
295 | } | 289 | } |
296 | 290 | ||
diff --git a/drivers/hwmon/emc6w201.c b/drivers/hwmon/emc6w201.c index 840f5112e602..ada12a98a97c 100644 --- a/drivers/hwmon/emc6w201.c +++ b/drivers/hwmon/emc6w201.c | |||
@@ -492,11 +492,10 @@ static int emc6w201_probe(struct i2c_client *client, | |||
492 | struct emc6w201_data *data; | 492 | struct emc6w201_data *data; |
493 | int err; | 493 | int err; |
494 | 494 | ||
495 | data = kzalloc(sizeof(struct emc6w201_data), GFP_KERNEL); | 495 | data = devm_kzalloc(&client->dev, sizeof(struct emc6w201_data), |
496 | if (!data) { | 496 | GFP_KERNEL); |
497 | err = -ENOMEM; | 497 | if (!data) |
498 | goto exit; | 498 | return -ENOMEM; |
499 | } | ||
500 | 499 | ||
501 | i2c_set_clientdata(client, data); | 500 | i2c_set_clientdata(client, data); |
502 | mutex_init(&data->update_lock); | 501 | mutex_init(&data->update_lock); |
@@ -504,7 +503,7 @@ static int emc6w201_probe(struct i2c_client *client, | |||
504 | /* Create sysfs attribute */ | 503 | /* Create sysfs attribute */ |
505 | err = sysfs_create_group(&client->dev.kobj, &emc6w201_group); | 504 | err = sysfs_create_group(&client->dev.kobj, &emc6w201_group); |
506 | if (err) | 505 | if (err) |
507 | goto exit_free; | 506 | return err; |
508 | 507 | ||
509 | /* Expose as a hwmon device */ | 508 | /* Expose as a hwmon device */ |
510 | data->hwmon_dev = hwmon_device_register(&client->dev); | 509 | data->hwmon_dev = hwmon_device_register(&client->dev); |
@@ -517,9 +516,6 @@ static int emc6w201_probe(struct i2c_client *client, | |||
517 | 516 | ||
518 | exit_remove: | 517 | exit_remove: |
519 | sysfs_remove_group(&client->dev.kobj, &emc6w201_group); | 518 | sysfs_remove_group(&client->dev.kobj, &emc6w201_group); |
520 | exit_free: | ||
521 | kfree(data); | ||
522 | exit: | ||
523 | return err; | 519 | return err; |
524 | } | 520 | } |
525 | 521 | ||
@@ -529,7 +525,6 @@ static int emc6w201_remove(struct i2c_client *client) | |||
529 | 525 | ||
530 | hwmon_device_unregister(data->hwmon_dev); | 526 | hwmon_device_unregister(data->hwmon_dev); |
531 | sysfs_remove_group(&client->dev.kobj, &emc6w201_group); | 527 | sysfs_remove_group(&client->dev.kobj, &emc6w201_group); |
532 | kfree(data); | ||
533 | 528 | ||
534 | return 0; | 529 | return 0; |
535 | } | 530 | } |
diff --git a/drivers/hwmon/exynos4_tmu.c b/drivers/hwmon/exynos4_tmu.c index f2359a0093bd..e912059140cd 100644 --- a/drivers/hwmon/exynos4_tmu.c +++ b/drivers/hwmon/exynos4_tmu.c | |||
@@ -475,35 +475,39 @@ static int __devexit exynos4_tmu_remove(struct platform_device *pdev) | |||
475 | return 0; | 475 | return 0; |
476 | } | 476 | } |
477 | 477 | ||
478 | #ifdef CONFIG_PM | 478 | #ifdef CONFIG_PM_SLEEP |
479 | static int exynos4_tmu_suspend(struct platform_device *pdev, pm_message_t state) | 479 | static int exynos4_tmu_suspend(struct device *dev) |
480 | { | 480 | { |
481 | exynos4_tmu_control(pdev, false); | 481 | exynos4_tmu_control(to_platform_device(dev), false); |
482 | 482 | ||
483 | return 0; | 483 | return 0; |
484 | } | 484 | } |
485 | 485 | ||
486 | static int exynos4_tmu_resume(struct platform_device *pdev) | 486 | static int exynos4_tmu_resume(struct device *dev) |
487 | { | 487 | { |
488 | struct platform_device *pdev = to_platform_device(dev); | ||
489 | |||
488 | exynos4_tmu_initialize(pdev); | 490 | exynos4_tmu_initialize(pdev); |
489 | exynos4_tmu_control(pdev, true); | 491 | exynos4_tmu_control(pdev, true); |
490 | 492 | ||
491 | return 0; | 493 | return 0; |
492 | } | 494 | } |
495 | |||
496 | static SIMPLE_DEV_PM_OPS(exynos4_tmu_pm, | ||
497 | exynos4_tmu_suspend, exynos4_tmu_resume); | ||
498 | #define EXYNOS4_TMU_PM &exynos4_tmu_pm | ||
493 | #else | 499 | #else |
494 | #define exynos4_tmu_suspend NULL | 500 | #define EXYNOS4_TMU_PM NULL |
495 | #define exynos4_tmu_resume NULL | ||
496 | #endif | 501 | #endif |
497 | 502 | ||
498 | static struct platform_driver exynos4_tmu_driver = { | 503 | static struct platform_driver exynos4_tmu_driver = { |
499 | .driver = { | 504 | .driver = { |
500 | .name = "exynos4-tmu", | 505 | .name = "exynos4-tmu", |
501 | .owner = THIS_MODULE, | 506 | .owner = THIS_MODULE, |
507 | .pm = EXYNOS4_TMU_PM, | ||
502 | }, | 508 | }, |
503 | .probe = exynos4_tmu_probe, | 509 | .probe = exynos4_tmu_probe, |
504 | .remove = __devexit_p(exynos4_tmu_remove), | 510 | .remove = __devexit_p(exynos4_tmu_remove), |
505 | .suspend = exynos4_tmu_suspend, | ||
506 | .resume = exynos4_tmu_resume, | ||
507 | }; | 511 | }; |
508 | 512 | ||
509 | module_platform_driver(exynos4_tmu_driver); | 513 | module_platform_driver(exynos4_tmu_driver); |
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c index 3e4da620e9c7..4dd7723d257f 100644 --- a/drivers/hwmon/f71805f.c +++ b/drivers/hwmon/f71805f.c | |||
@@ -1386,20 +1386,20 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
1386 | "f71872f", | 1386 | "f71872f", |
1387 | }; | 1387 | }; |
1388 | 1388 | ||
1389 | data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL); | 1389 | data = devm_kzalloc(&pdev->dev, sizeof(struct f71805f_data), |
1390 | GFP_KERNEL); | ||
1390 | if (!data) { | 1391 | if (!data) { |
1391 | err = -ENOMEM; | ||
1392 | pr_err("Out of memory\n"); | 1392 | pr_err("Out of memory\n"); |
1393 | goto exit; | 1393 | return -ENOMEM; |
1394 | } | 1394 | } |
1395 | 1395 | ||
1396 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 1396 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
1397 | if (!request_region(res->start + ADDR_REG_OFFSET, 2, DRVNAME)) { | 1397 | if (!devm_request_region(&pdev->dev, res->start + ADDR_REG_OFFSET, 2, |
1398 | err = -EBUSY; | 1398 | DRVNAME)) { |
1399 | dev_err(&pdev->dev, "Failed to request region 0x%lx-0x%lx\n", | 1399 | dev_err(&pdev->dev, "Failed to request region 0x%lx-0x%lx\n", |
1400 | (unsigned long)(res->start + ADDR_REG_OFFSET), | 1400 | (unsigned long)(res->start + ADDR_REG_OFFSET), |
1401 | (unsigned long)(res->start + ADDR_REG_OFFSET + 1)); | 1401 | (unsigned long)(res->start + ADDR_REG_OFFSET + 1)); |
1402 | goto exit_free; | 1402 | return -EBUSY; |
1403 | } | 1403 | } |
1404 | data->addr = res->start; | 1404 | data->addr = res->start; |
1405 | data->name = names[sio_data->kind]; | 1405 | data->name = names[sio_data->kind]; |
@@ -1427,7 +1427,7 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
1427 | /* Register sysfs interface files */ | 1427 | /* Register sysfs interface files */ |
1428 | err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group); | 1428 | err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group); |
1429 | if (err) | 1429 | if (err) |
1430 | goto exit_release_region; | 1430 | return err; |
1431 | if (data->has_in & (1 << 4)) { /* in4 */ | 1431 | if (data->has_in & (1 << 4)) { /* in4 */ |
1432 | err = sysfs_create_group(&pdev->dev.kobj, | 1432 | err = sysfs_create_group(&pdev->dev.kobj, |
1433 | &f71805f_group_optin[0]); | 1433 | &f71805f_group_optin[0]); |
@@ -1487,19 +1487,12 @@ exit_remove_files: | |||
1487 | for (i = 0; i < 4; i++) | 1487 | for (i = 0; i < 4; i++) |
1488 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]); | 1488 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]); |
1489 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq); | 1489 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq); |
1490 | exit_release_region: | ||
1491 | release_region(res->start + ADDR_REG_OFFSET, 2); | ||
1492 | exit_free: | ||
1493 | platform_set_drvdata(pdev, NULL); | ||
1494 | kfree(data); | ||
1495 | exit: | ||
1496 | return err; | 1490 | return err; |
1497 | } | 1491 | } |
1498 | 1492 | ||
1499 | static int __devexit f71805f_remove(struct platform_device *pdev) | 1493 | static int __devexit f71805f_remove(struct platform_device *pdev) |
1500 | { | 1494 | { |
1501 | struct f71805f_data *data = platform_get_drvdata(pdev); | 1495 | struct f71805f_data *data = platform_get_drvdata(pdev); |
1502 | struct resource *res; | ||
1503 | int i; | 1496 | int i; |
1504 | 1497 | ||
1505 | hwmon_device_unregister(data->hwmon_dev); | 1498 | hwmon_device_unregister(data->hwmon_dev); |
@@ -1507,11 +1500,6 @@ static int __devexit f71805f_remove(struct platform_device *pdev) | |||
1507 | for (i = 0; i < 4; i++) | 1500 | for (i = 0; i < 4; i++) |
1508 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]); | 1501 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]); |
1509 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq); | 1502 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq); |
1510 | platform_set_drvdata(pdev, NULL); | ||
1511 | kfree(data); | ||
1512 | |||
1513 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
1514 | release_region(res->start + ADDR_REG_OFFSET, 2); | ||
1515 | 1503 | ||
1516 | return 0; | 1504 | return 0; |
1517 | } | 1505 | } |
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c index 6b13f1a4dc27..2764b78a784b 100644 --- a/drivers/hwmon/fam15h_power.c +++ b/drivers/hwmon/fam15h_power.c | |||
@@ -67,7 +67,8 @@ static ssize_t show_power(struct device *dev, | |||
67 | REG_TDP_LIMIT3, &val); | 67 | REG_TDP_LIMIT3, &val); |
68 | 68 | ||
69 | tdp_limit = val >> 16; | 69 | tdp_limit = val >> 16; |
70 | curr_pwr_watts = (tdp_limit + data->base_tdp) << running_avg_range; | 70 | curr_pwr_watts = ((u64)(tdp_limit + |
71 | data->base_tdp)) << running_avg_range; | ||
71 | curr_pwr_watts -= running_avg_capture; | 72 | curr_pwr_watts -= running_avg_capture; |
72 | curr_pwr_watts *= data->tdp_to_watts; | 73 | curr_pwr_watts *= data->tdp_to_watts; |
73 | 74 | ||
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 764a083ac7a7..2c74673f48e5 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c | |||
@@ -544,11 +544,10 @@ static int gl518_probe(struct i2c_client *client, | |||
544 | struct gl518_data *data; | 544 | struct gl518_data *data; |
545 | int err, revision; | 545 | int err, revision; |
546 | 546 | ||
547 | data = kzalloc(sizeof(struct gl518_data), GFP_KERNEL); | 547 | data = devm_kzalloc(&client->dev, sizeof(struct gl518_data), |
548 | if (!data) { | 548 | GFP_KERNEL); |
549 | err = -ENOMEM; | 549 | if (!data) |
550 | goto exit; | 550 | return -ENOMEM; |
551 | } | ||
552 | 551 | ||
553 | i2c_set_clientdata(client, data); | 552 | i2c_set_clientdata(client, data); |
554 | revision = gl518_read_value(client, GL518_REG_REVISION); | 553 | revision = gl518_read_value(client, GL518_REG_REVISION); |
@@ -562,7 +561,7 @@ static int gl518_probe(struct i2c_client *client, | |||
562 | /* Register sysfs hooks */ | 561 | /* Register sysfs hooks */ |
563 | err = sysfs_create_group(&client->dev.kobj, &gl518_group); | 562 | err = sysfs_create_group(&client->dev.kobj, &gl518_group); |
564 | if (err) | 563 | if (err) |
565 | goto exit_free; | 564 | return err; |
566 | if (data->type == gl518sm_r80) { | 565 | if (data->type == gl518sm_r80) { |
567 | err = sysfs_create_group(&client->dev.kobj, &gl518_group_r80); | 566 | err = sysfs_create_group(&client->dev.kobj, &gl518_group_r80); |
568 | if (err) | 567 | if (err) |
@@ -581,9 +580,6 @@ exit_remove_files: | |||
581 | sysfs_remove_group(&client->dev.kobj, &gl518_group); | 580 | sysfs_remove_group(&client->dev.kobj, &gl518_group); |
582 | if (data->type == gl518sm_r80) | 581 | if (data->type == gl518sm_r80) |
583 | sysfs_remove_group(&client->dev.kobj, &gl518_group_r80); | 582 | sysfs_remove_group(&client->dev.kobj, &gl518_group_r80); |
584 | exit_free: | ||
585 | kfree(data); | ||
586 | exit: | ||
587 | return err; | 583 | return err; |
588 | } | 584 | } |
589 | 585 | ||
@@ -617,7 +613,6 @@ static int gl518_remove(struct i2c_client *client) | |||
617 | if (data->type == gl518sm_r80) | 613 | if (data->type == gl518sm_r80) |
618 | sysfs_remove_group(&client->dev.kobj, &gl518_group_r80); | 614 | sysfs_remove_group(&client->dev.kobj, &gl518_group_r80); |
619 | 615 | ||
620 | kfree(data); | ||
621 | return 0; | 616 | return 0; |
622 | } | 617 | } |
623 | 618 | ||
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index 5ff452b6a4d0..a21ff252f2f1 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c | |||
@@ -779,11 +779,10 @@ static int gl520_probe(struct i2c_client *client, | |||
779 | struct gl520_data *data; | 779 | struct gl520_data *data; |
780 | int err; | 780 | int err; |
781 | 781 | ||
782 | data = kzalloc(sizeof(struct gl520_data), GFP_KERNEL); | 782 | data = devm_kzalloc(&client->dev, sizeof(struct gl520_data), |
783 | if (!data) { | 783 | GFP_KERNEL); |
784 | err = -ENOMEM; | 784 | if (!data) |
785 | goto exit; | 785 | return -ENOMEM; |
786 | } | ||
787 | 786 | ||
788 | i2c_set_clientdata(client, data); | 787 | i2c_set_clientdata(client, data); |
789 | mutex_init(&data->update_lock); | 788 | mutex_init(&data->update_lock); |
@@ -794,7 +793,7 @@ static int gl520_probe(struct i2c_client *client, | |||
794 | /* Register sysfs hooks */ | 793 | /* Register sysfs hooks */ |
795 | err = sysfs_create_group(&client->dev.kobj, &gl520_group); | 794 | err = sysfs_create_group(&client->dev.kobj, &gl520_group); |
796 | if (err) | 795 | if (err) |
797 | goto exit_free; | 796 | return err; |
798 | 797 | ||
799 | if (data->two_temps) | 798 | if (data->two_temps) |
800 | err = sysfs_create_group(&client->dev.kobj, &gl520_group_temp2); | 799 | err = sysfs_create_group(&client->dev.kobj, &gl520_group_temp2); |
@@ -816,9 +815,6 @@ exit_remove_files: | |||
816 | sysfs_remove_group(&client->dev.kobj, &gl520_group); | 815 | sysfs_remove_group(&client->dev.kobj, &gl520_group); |
817 | sysfs_remove_group(&client->dev.kobj, &gl520_group_in4); | 816 | sysfs_remove_group(&client->dev.kobj, &gl520_group_in4); |
818 | sysfs_remove_group(&client->dev.kobj, &gl520_group_temp2); | 817 | sysfs_remove_group(&client->dev.kobj, &gl520_group_temp2); |
819 | exit_free: | ||
820 | kfree(data); | ||
821 | exit: | ||
822 | return err; | 818 | return err; |
823 | } | 819 | } |
824 | 820 | ||
@@ -870,7 +866,6 @@ static int gl520_remove(struct i2c_client *client) | |||
870 | sysfs_remove_group(&client->dev.kobj, &gl520_group_in4); | 866 | sysfs_remove_group(&client->dev.kobj, &gl520_group_in4); |
871 | sysfs_remove_group(&client->dev.kobj, &gl520_group_temp2); | 867 | sysfs_remove_group(&client->dev.kobj, &gl520_group_temp2); |
872 | 868 | ||
873 | kfree(data); | ||
874 | return 0; | 869 | return 0; |
875 | } | 870 | } |
876 | 871 | ||
diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c index 2ce8c44a0e07..2f4b01bda87c 100644 --- a/drivers/hwmon/gpio-fan.c +++ b/drivers/hwmon/gpio-fan.c | |||
@@ -41,7 +41,7 @@ struct gpio_fan_data { | |||
41 | int num_speed; | 41 | int num_speed; |
42 | struct gpio_fan_speed *speed; | 42 | struct gpio_fan_speed *speed; |
43 | int speed_index; | 43 | int speed_index; |
44 | #ifdef CONFIG_PM | 44 | #ifdef CONFIG_PM_SLEEP |
45 | int resume_speed; | 45 | int resume_speed; |
46 | #endif | 46 | #endif |
47 | bool pwm_enable; | 47 | bool pwm_enable; |
@@ -95,17 +95,17 @@ static int fan_alarm_init(struct gpio_fan_data *fan_data, | |||
95 | 95 | ||
96 | fan_data->alarm = alarm; | 96 | fan_data->alarm = alarm; |
97 | 97 | ||
98 | err = gpio_request(alarm->gpio, "GPIO fan alarm"); | 98 | err = devm_gpio_request(&pdev->dev, alarm->gpio, "GPIO fan alarm"); |
99 | if (err) | 99 | if (err) |
100 | return err; | 100 | return err; |
101 | 101 | ||
102 | err = gpio_direction_input(alarm->gpio); | 102 | err = gpio_direction_input(alarm->gpio); |
103 | if (err) | 103 | if (err) |
104 | goto err_free_gpio; | 104 | return err; |
105 | 105 | ||
106 | err = device_create_file(&pdev->dev, &dev_attr_fan1_alarm); | 106 | err = device_create_file(&pdev->dev, &dev_attr_fan1_alarm); |
107 | if (err) | 107 | if (err) |
108 | goto err_free_gpio; | 108 | return err; |
109 | 109 | ||
110 | /* | 110 | /* |
111 | * If the alarm GPIO don't support interrupts, just leave | 111 | * If the alarm GPIO don't support interrupts, just leave |
@@ -117,8 +117,8 @@ static int fan_alarm_init(struct gpio_fan_data *fan_data, | |||
117 | 117 | ||
118 | INIT_WORK(&fan_data->alarm_work, fan_alarm_notify); | 118 | INIT_WORK(&fan_data->alarm_work, fan_alarm_notify); |
119 | irq_set_irq_type(alarm_irq, IRQ_TYPE_EDGE_BOTH); | 119 | irq_set_irq_type(alarm_irq, IRQ_TYPE_EDGE_BOTH); |
120 | err = request_irq(alarm_irq, fan_alarm_irq_handler, IRQF_SHARED, | 120 | err = devm_request_irq(&pdev->dev, alarm_irq, fan_alarm_irq_handler, |
121 | "GPIO fan alarm", fan_data); | 121 | IRQF_SHARED, "GPIO fan alarm", fan_data); |
122 | if (err) | 122 | if (err) |
123 | goto err_free_sysfs; | 123 | goto err_free_sysfs; |
124 | 124 | ||
@@ -126,21 +126,14 @@ static int fan_alarm_init(struct gpio_fan_data *fan_data, | |||
126 | 126 | ||
127 | err_free_sysfs: | 127 | err_free_sysfs: |
128 | device_remove_file(&pdev->dev, &dev_attr_fan1_alarm); | 128 | device_remove_file(&pdev->dev, &dev_attr_fan1_alarm); |
129 | err_free_gpio: | ||
130 | gpio_free(alarm->gpio); | ||
131 | |||
132 | return err; | 129 | return err; |
133 | } | 130 | } |
134 | 131 | ||
135 | static void fan_alarm_free(struct gpio_fan_data *fan_data) | 132 | static void fan_alarm_free(struct gpio_fan_data *fan_data) |
136 | { | 133 | { |
137 | struct platform_device *pdev = fan_data->pdev; | 134 | struct platform_device *pdev = fan_data->pdev; |
138 | int alarm_irq = gpio_to_irq(fan_data->alarm->gpio); | ||
139 | 135 | ||
140 | if (alarm_irq >= 0) | ||
141 | free_irq(alarm_irq, fan_data); | ||
142 | device_remove_file(&pdev->dev, &dev_attr_fan1_alarm); | 136 | device_remove_file(&pdev->dev, &dev_attr_fan1_alarm); |
143 | gpio_free(fan_data->alarm->gpio); | ||
144 | } | 137 | } |
145 | 138 | ||
146 | /* | 139 | /* |
@@ -365,15 +358,14 @@ static int fan_ctrl_init(struct gpio_fan_data *fan_data, | |||
365 | int i, err; | 358 | int i, err; |
366 | 359 | ||
367 | for (i = 0; i < num_ctrl; i++) { | 360 | for (i = 0; i < num_ctrl; i++) { |
368 | err = gpio_request(ctrl[i], "GPIO fan control"); | 361 | err = devm_gpio_request(&pdev->dev, ctrl[i], |
362 | "GPIO fan control"); | ||
369 | if (err) | 363 | if (err) |
370 | goto err_free_gpio; | 364 | return err; |
371 | 365 | ||
372 | err = gpio_direction_output(ctrl[i], gpio_get_value(ctrl[i])); | 366 | err = gpio_direction_output(ctrl[i], gpio_get_value(ctrl[i])); |
373 | if (err) { | 367 | if (err) |
374 | gpio_free(ctrl[i]); | 368 | return err; |
375 | goto err_free_gpio; | ||
376 | } | ||
377 | } | 369 | } |
378 | 370 | ||
379 | fan_data->num_ctrl = num_ctrl; | 371 | fan_data->num_ctrl = num_ctrl; |
@@ -382,32 +374,18 @@ static int fan_ctrl_init(struct gpio_fan_data *fan_data, | |||
382 | fan_data->speed = pdata->speed; | 374 | fan_data->speed = pdata->speed; |
383 | fan_data->pwm_enable = true; /* Enable manual fan speed control. */ | 375 | fan_data->pwm_enable = true; /* Enable manual fan speed control. */ |
384 | fan_data->speed_index = get_fan_speed_index(fan_data); | 376 | fan_data->speed_index = get_fan_speed_index(fan_data); |
385 | if (fan_data->speed_index < 0) { | 377 | if (fan_data->speed_index < 0) |
386 | err = -ENODEV; | 378 | return -ENODEV; |
387 | goto err_free_gpio; | ||
388 | } | ||
389 | 379 | ||
390 | err = sysfs_create_group(&pdev->dev.kobj, &gpio_fan_ctrl_group); | 380 | err = sysfs_create_group(&pdev->dev.kobj, &gpio_fan_ctrl_group); |
391 | if (err) | ||
392 | goto err_free_gpio; | ||
393 | |||
394 | return 0; | ||
395 | |||
396 | err_free_gpio: | ||
397 | for (i = i - 1; i >= 0; i--) | ||
398 | gpio_free(ctrl[i]); | ||
399 | |||
400 | return err; | 381 | return err; |
401 | } | 382 | } |
402 | 383 | ||
403 | static void fan_ctrl_free(struct gpio_fan_data *fan_data) | 384 | static void fan_ctrl_free(struct gpio_fan_data *fan_data) |
404 | { | 385 | { |
405 | struct platform_device *pdev = fan_data->pdev; | 386 | struct platform_device *pdev = fan_data->pdev; |
406 | int i; | ||
407 | 387 | ||
408 | sysfs_remove_group(&pdev->dev.kobj, &gpio_fan_ctrl_group); | 388 | sysfs_remove_group(&pdev->dev.kobj, &gpio_fan_ctrl_group); |
409 | for (i = 0; i < fan_data->num_ctrl; i++) | ||
410 | gpio_free(fan_data->ctrl[i]); | ||
411 | } | 389 | } |
412 | 390 | ||
413 | /* | 391 | /* |
@@ -431,7 +409,8 @@ static int __devinit gpio_fan_probe(struct platform_device *pdev) | |||
431 | if (!pdata) | 409 | if (!pdata) |
432 | return -EINVAL; | 410 | return -EINVAL; |
433 | 411 | ||
434 | fan_data = kzalloc(sizeof(struct gpio_fan_data), GFP_KERNEL); | 412 | fan_data = devm_kzalloc(&pdev->dev, sizeof(struct gpio_fan_data), |
413 | GFP_KERNEL); | ||
435 | if (!fan_data) | 414 | if (!fan_data) |
436 | return -ENOMEM; | 415 | return -ENOMEM; |
437 | 416 | ||
@@ -443,7 +422,7 @@ static int __devinit gpio_fan_probe(struct platform_device *pdev) | |||
443 | if (pdata->alarm) { | 422 | if (pdata->alarm) { |
444 | err = fan_alarm_init(fan_data, pdata->alarm); | 423 | err = fan_alarm_init(fan_data, pdata->alarm); |
445 | if (err) | 424 | if (err) |
446 | goto err_free_data; | 425 | return err; |
447 | } | 426 | } |
448 | 427 | ||
449 | /* Configure control GPIOs if available. */ | 428 | /* Configure control GPIOs if available. */ |
@@ -480,10 +459,6 @@ err_free_ctrl: | |||
480 | err_free_alarm: | 459 | err_free_alarm: |
481 | if (fan_data->alarm) | 460 | if (fan_data->alarm) |
482 | fan_alarm_free(fan_data); | 461 | fan_alarm_free(fan_data); |
483 | err_free_data: | ||
484 | platform_set_drvdata(pdev, NULL); | ||
485 | kfree(fan_data); | ||
486 | |||
487 | return err; | 462 | return err; |
488 | } | 463 | } |
489 | 464 | ||
@@ -497,15 +472,14 @@ static int __devexit gpio_fan_remove(struct platform_device *pdev) | |||
497 | fan_alarm_free(fan_data); | 472 | fan_alarm_free(fan_data); |
498 | if (fan_data->ctrl) | 473 | if (fan_data->ctrl) |
499 | fan_ctrl_free(fan_data); | 474 | fan_ctrl_free(fan_data); |
500 | kfree(fan_data); | ||
501 | 475 | ||
502 | return 0; | 476 | return 0; |
503 | } | 477 | } |
504 | 478 | ||
505 | #ifdef CONFIG_PM | 479 | #ifdef CONFIG_PM_SLEEP |
506 | static int gpio_fan_suspend(struct platform_device *pdev, pm_message_t state) | 480 | static int gpio_fan_suspend(struct device *dev) |
507 | { | 481 | { |
508 | struct gpio_fan_data *fan_data = platform_get_drvdata(pdev); | 482 | struct gpio_fan_data *fan_data = dev_get_drvdata(dev); |
509 | 483 | ||
510 | if (fan_data->ctrl) { | 484 | if (fan_data->ctrl) { |
511 | fan_data->resume_speed = fan_data->speed_index; | 485 | fan_data->resume_speed = fan_data->speed_index; |
@@ -515,27 +489,28 @@ static int gpio_fan_suspend(struct platform_device *pdev, pm_message_t state) | |||
515 | return 0; | 489 | return 0; |
516 | } | 490 | } |
517 | 491 | ||
518 | static int gpio_fan_resume(struct platform_device *pdev) | 492 | static int gpio_fan_resume(struct device *dev) |
519 | { | 493 | { |
520 | struct gpio_fan_data *fan_data = platform_get_drvdata(pdev); | 494 | struct gpio_fan_data *fan_data = dev_get_drvdata(dev); |
521 | 495 | ||
522 | if (fan_data->ctrl) | 496 | if (fan_data->ctrl) |
523 | set_fan_speed(fan_data, fan_data->resume_speed); | 497 | set_fan_speed(fan_data, fan_data->resume_speed); |
524 | 498 | ||
525 | return 0; | 499 | return 0; |
526 | } | 500 | } |
501 | |||
502 | static SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume); | ||
503 | #define GPIO_FAN_PM &gpio_fan_pm | ||
527 | #else | 504 | #else |
528 | #define gpio_fan_suspend NULL | 505 | #define GPIO_FAN_PM NULL |
529 | #define gpio_fan_resume NULL | ||
530 | #endif | 506 | #endif |
531 | 507 | ||
532 | static struct platform_driver gpio_fan_driver = { | 508 | static struct platform_driver gpio_fan_driver = { |
533 | .probe = gpio_fan_probe, | 509 | .probe = gpio_fan_probe, |
534 | .remove = __devexit_p(gpio_fan_remove), | 510 | .remove = __devexit_p(gpio_fan_remove), |
535 | .suspend = gpio_fan_suspend, | ||
536 | .resume = gpio_fan_resume, | ||
537 | .driver = { | 511 | .driver = { |
538 | .name = "gpio-fan", | 512 | .name = "gpio-fan", |
513 | .pm = GPIO_FAN_PM, | ||
539 | }, | 514 | }, |
540 | }; | 515 | }; |
541 | 516 | ||
diff --git a/drivers/hwmon/hih6130.c b/drivers/hwmon/hih6130.c new file mode 100644 index 000000000000..e8ee75f55472 --- /dev/null +++ b/drivers/hwmon/hih6130.c | |||
@@ -0,0 +1,293 @@ | |||
1 | /* Honeywell HIH-6130/HIH-6131 humidity and temperature sensor driver | ||
2 | * | ||
3 | * Copyright (C) 2012 Iain Paton <ipaton0@gmail.com> | ||
4 | * | ||
5 | * heavily based on the sht21 driver | ||
6 | * Copyright (C) 2010 Urs Fleisch <urs.fleisch@sensirion.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | * | ||
22 | * Data sheets available (2012-06-22) at | ||
23 | * http://sensing.honeywell.com/index.php?ci_id=3106&la_id=1&defId=44872 | ||
24 | */ | ||
25 | |||
26 | #include <linux/module.h> | ||
27 | #include <linux/init.h> | ||
28 | #include <linux/slab.h> | ||
29 | #include <linux/i2c.h> | ||
30 | #include <linux/hwmon.h> | ||
31 | #include <linux/hwmon-sysfs.h> | ||
32 | #include <linux/err.h> | ||
33 | #include <linux/mutex.h> | ||
34 | #include <linux/device.h> | ||
35 | #include <linux/delay.h> | ||
36 | |||
37 | /** | ||
38 | * struct hih6130 - HIH-6130 device specific data | ||
39 | * @hwmon_dev: device registered with hwmon | ||
40 | * @lock: mutex to protect measurement values | ||
41 | * @valid: only false before first measurement is taken | ||
42 | * @last_update: time of last update (jiffies) | ||
43 | * @temperature: cached temperature measurement value | ||
44 | * @humidity: cached humidity measurement value | ||
45 | */ | ||
46 | struct hih6130 { | ||
47 | struct device *hwmon_dev; | ||
48 | struct mutex lock; | ||
49 | bool valid; | ||
50 | unsigned long last_update; | ||
51 | int temperature; | ||
52 | int humidity; | ||
53 | }; | ||
54 | |||
55 | /** | ||
56 | * hih6130_temp_ticks_to_millicelsius() - convert raw temperature ticks to | ||
57 | * milli celsius | ||
58 | * @ticks: temperature ticks value received from sensor | ||
59 | */ | ||
60 | static inline int hih6130_temp_ticks_to_millicelsius(int ticks) | ||
61 | { | ||
62 | |||
63 | ticks = ticks >> 2; | ||
64 | /* | ||
65 | * from data sheet section 5.0 | ||
66 | * Formula T = ( ticks / ( 2^14 - 2 ) ) * 165 -40 | ||
67 | */ | ||
68 | return (DIV_ROUND_CLOSEST(ticks * 1650, 16382) - 400) * 100; | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * hih6130_rh_ticks_to_per_cent_mille() - convert raw humidity ticks to | ||
73 | * one-thousandths of a percent relative humidity | ||
74 | * @ticks: humidity ticks value received from sensor | ||
75 | */ | ||
76 | static inline int hih6130_rh_ticks_to_per_cent_mille(int ticks) | ||
77 | { | ||
78 | |||
79 | ticks &= ~0xC000; /* clear status bits */ | ||
80 | /* | ||
81 | * from data sheet section 4.0 | ||
82 | * Formula RH = ( ticks / ( 2^14 -2 ) ) * 100 | ||
83 | */ | ||
84 | return DIV_ROUND_CLOSEST(ticks * 1000, 16382) * 100; | ||
85 | } | ||
86 | |||
87 | /** | ||
88 | * hih6130_update_measurements() - get updated measurements from device | ||
89 | * @client: I2C client device | ||
90 | * | ||
91 | * Returns 0 on success, else negative errno. | ||
92 | */ | ||
93 | static int hih6130_update_measurements(struct i2c_client *client) | ||
94 | { | ||
95 | int ret = 0; | ||
96 | int t; | ||
97 | struct hih6130 *hih6130 = i2c_get_clientdata(client); | ||
98 | unsigned char tmp[4]; | ||
99 | struct i2c_msg msgs[1] = { | ||
100 | { | ||
101 | .addr = client->addr, | ||
102 | .flags = I2C_M_RD, | ||
103 | .len = 4, | ||
104 | .buf = tmp, | ||
105 | } | ||
106 | }; | ||
107 | |||
108 | mutex_lock(&hih6130->lock); | ||
109 | |||
110 | /* | ||
111 | * While the measurement can be completed in ~40ms the sensor takes | ||
112 | * much longer to react to a change in external conditions. How quickly | ||
113 | * it reacts depends on airflow and other factors outwith our control. | ||
114 | * The datasheet specifies maximum 'Response time' for humidity at 8s | ||
115 | * and temperature at 30s under specified conditions. | ||
116 | * We therefore choose to only read the sensor at most once per second. | ||
117 | * This trades off pointless activity polling the sensor much faster | ||
118 | * than it can react against better response times in conditions more | ||
119 | * favourable than specified in the datasheet. | ||
120 | */ | ||
121 | if (time_after(jiffies, hih6130->last_update + HZ) || !hih6130->valid) { | ||
122 | |||
123 | /* write to slave address, no data, to request a measurement */ | ||
124 | ret = i2c_master_send(client, tmp, 0); | ||
125 | if (ret < 0) | ||
126 | goto out; | ||
127 | |||
128 | /* measurement cycle time is ~36.65msec */ | ||
129 | msleep(40); | ||
130 | |||
131 | ret = i2c_transfer(client->adapter, msgs, 1); | ||
132 | if (ret < 0) | ||
133 | goto out; | ||
134 | |||
135 | if ((tmp[0] & 0xC0) != 0) { | ||
136 | dev_err(&client->dev, "Error while reading measurement result\n"); | ||
137 | ret = -EIO; | ||
138 | goto out; | ||
139 | } | ||
140 | |||
141 | t = (tmp[0] << 8) + tmp[1]; | ||
142 | hih6130->humidity = hih6130_rh_ticks_to_per_cent_mille(t); | ||
143 | |||
144 | t = (tmp[2] << 8) + tmp[3]; | ||
145 | hih6130->temperature = hih6130_temp_ticks_to_millicelsius(t); | ||
146 | |||
147 | hih6130->last_update = jiffies; | ||
148 | hih6130->valid = true; | ||
149 | } | ||
150 | out: | ||
151 | mutex_unlock(&hih6130->lock); | ||
152 | |||
153 | return ret >= 0 ? 0 : ret; | ||
154 | } | ||
155 | |||
156 | /** | ||
157 | * hih6130_show_temperature() - show temperature measurement value in sysfs | ||
158 | * @dev: device | ||
159 | * @attr: device attribute | ||
160 | * @buf: sysfs buffer (PAGE_SIZE) where measurement values are written to | ||
161 | * | ||
162 | * Will be called on read access to temp1_input sysfs attribute. | ||
163 | * Returns number of bytes written into buffer, negative errno on error. | ||
164 | */ | ||
165 | static ssize_t hih6130_show_temperature(struct device *dev, | ||
166 | struct device_attribute *attr, | ||
167 | char *buf) | ||
168 | { | ||
169 | struct i2c_client *client = to_i2c_client(dev); | ||
170 | struct hih6130 *hih6130 = i2c_get_clientdata(client); | ||
171 | int ret = hih6130_update_measurements(client); | ||
172 | if (ret < 0) | ||
173 | return ret; | ||
174 | return sprintf(buf, "%d\n", hih6130->temperature); | ||
175 | } | ||
176 | |||
177 | /** | ||
178 | * hih6130_show_humidity() - show humidity measurement value in sysfs | ||
179 | * @dev: device | ||
180 | * @attr: device attribute | ||
181 | * @buf: sysfs buffer (PAGE_SIZE) where measurement values are written to | ||
182 | * | ||
183 | * Will be called on read access to humidity1_input sysfs attribute. | ||
184 | * Returns number of bytes written into buffer, negative errno on error. | ||
185 | */ | ||
186 | static ssize_t hih6130_show_humidity(struct device *dev, | ||
187 | struct device_attribute *attr, char *buf) | ||
188 | { | ||
189 | struct i2c_client *client = to_i2c_client(dev); | ||
190 | struct hih6130 *hih6130 = i2c_get_clientdata(client); | ||
191 | int ret = hih6130_update_measurements(client); | ||
192 | if (ret < 0) | ||
193 | return ret; | ||
194 | return sprintf(buf, "%d\n", hih6130->humidity); | ||
195 | } | ||
196 | |||
197 | /* sysfs attributes */ | ||
198 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, hih6130_show_temperature, | ||
199 | NULL, 0); | ||
200 | static SENSOR_DEVICE_ATTR(humidity1_input, S_IRUGO, hih6130_show_humidity, | ||
201 | NULL, 0); | ||
202 | |||
203 | static struct attribute *hih6130_attributes[] = { | ||
204 | &sensor_dev_attr_temp1_input.dev_attr.attr, | ||
205 | &sensor_dev_attr_humidity1_input.dev_attr.attr, | ||
206 | NULL | ||
207 | }; | ||
208 | |||
209 | static const struct attribute_group hih6130_attr_group = { | ||
210 | .attrs = hih6130_attributes, | ||
211 | }; | ||
212 | |||
213 | /** | ||
214 | * hih6130_probe() - probe device | ||
215 | * @client: I2C client device | ||
216 | * @id: device ID | ||
217 | * | ||
218 | * Called by the I2C core when an entry in the ID table matches a | ||
219 | * device's name. | ||
220 | * Returns 0 on success. | ||
221 | */ | ||
222 | static int __devinit hih6130_probe(struct i2c_client *client, | ||
223 | const struct i2c_device_id *id) | ||
224 | { | ||
225 | struct hih6130 *hih6130; | ||
226 | int err; | ||
227 | |||
228 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { | ||
229 | dev_err(&client->dev, "adapter does not support true I2C\n"); | ||
230 | return -ENODEV; | ||
231 | } | ||
232 | |||
233 | hih6130 = devm_kzalloc(&client->dev, sizeof(*hih6130), GFP_KERNEL); | ||
234 | if (!hih6130) | ||
235 | return -ENOMEM; | ||
236 | |||
237 | i2c_set_clientdata(client, hih6130); | ||
238 | |||
239 | mutex_init(&hih6130->lock); | ||
240 | |||
241 | err = sysfs_create_group(&client->dev.kobj, &hih6130_attr_group); | ||
242 | if (err) { | ||
243 | dev_dbg(&client->dev, "could not create sysfs files\n"); | ||
244 | return err; | ||
245 | } | ||
246 | |||
247 | hih6130->hwmon_dev = hwmon_device_register(&client->dev); | ||
248 | if (IS_ERR(hih6130->hwmon_dev)) { | ||
249 | dev_dbg(&client->dev, "unable to register hwmon device\n"); | ||
250 | err = PTR_ERR(hih6130->hwmon_dev); | ||
251 | goto fail_remove_sysfs; | ||
252 | } | ||
253 | |||
254 | return 0; | ||
255 | |||
256 | fail_remove_sysfs: | ||
257 | sysfs_remove_group(&client->dev.kobj, &hih6130_attr_group); | ||
258 | return err; | ||
259 | } | ||
260 | |||
261 | /** | ||
262 | * hih6130_remove() - remove device | ||
263 | * @client: I2C client device | ||
264 | */ | ||
265 | static int __devexit hih6130_remove(struct i2c_client *client) | ||
266 | { | ||
267 | struct hih6130 *hih6130 = i2c_get_clientdata(client); | ||
268 | |||
269 | hwmon_device_unregister(hih6130->hwmon_dev); | ||
270 | sysfs_remove_group(&client->dev.kobj, &hih6130_attr_group); | ||
271 | |||
272 | return 0; | ||
273 | } | ||
274 | |||
275 | /* Device ID table */ | ||
276 | static const struct i2c_device_id hih6130_id[] = { | ||
277 | { "hih6130", 0 }, | ||
278 | { } | ||
279 | }; | ||
280 | MODULE_DEVICE_TABLE(i2c, hih6130_id); | ||
281 | |||
282 | static struct i2c_driver hih6130_driver = { | ||
283 | .driver.name = "hih6130", | ||
284 | .probe = hih6130_probe, | ||
285 | .remove = __devexit_p(hih6130_remove), | ||
286 | .id_table = hih6130_id, | ||
287 | }; | ||
288 | |||
289 | module_i2c_driver(hih6130_driver); | ||
290 | |||
291 | MODULE_AUTHOR("Iain Paton <ipaton0@gmail.com>"); | ||
292 | MODULE_DESCRIPTION("Honeywell HIH-6130 humidity and temperature sensor driver"); | ||
293 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c index 35aac82ee8eb..49a69c5b3b8d 100644 --- a/drivers/hwmon/k8temp.c +++ b/drivers/hwmon/k8temp.c | |||
@@ -183,21 +183,17 @@ static int __devinit k8temp_probe(struct pci_dev *pdev, | |||
183 | u8 model, stepping; | 183 | u8 model, stepping; |
184 | struct k8temp_data *data; | 184 | struct k8temp_data *data; |
185 | 185 | ||
186 | data = kzalloc(sizeof(struct k8temp_data), GFP_KERNEL); | 186 | data = devm_kzalloc(&pdev->dev, sizeof(struct k8temp_data), GFP_KERNEL); |
187 | if (!data) { | 187 | if (!data) |
188 | err = -ENOMEM; | 188 | return -ENOMEM; |
189 | goto exit; | ||
190 | } | ||
191 | 189 | ||
192 | model = boot_cpu_data.x86_model; | 190 | model = boot_cpu_data.x86_model; |
193 | stepping = boot_cpu_data.x86_mask; | 191 | stepping = boot_cpu_data.x86_mask; |
194 | 192 | ||
195 | /* feature available since SH-C0, exclude older revisions */ | 193 | /* feature available since SH-C0, exclude older revisions */ |
196 | if (((model == 4) && (stepping == 0)) || | 194 | if ((model == 4 && stepping == 0) || |
197 | ((model == 5) && (stepping <= 1))) { | 195 | (model == 5 && stepping <= 1)) |
198 | err = -ENODEV; | 196 | return -ENODEV; |
199 | goto exit_free; | ||
200 | } | ||
201 | 197 | ||
202 | /* | 198 | /* |
203 | * AMD NPT family 0fh, i.e. RevF and RevG: | 199 | * AMD NPT family 0fh, i.e. RevF and RevG: |
@@ -224,8 +220,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev, | |||
224 | 220 | ||
225 | if (scfg & (SEL_PLACE | SEL_CORE)) { | 221 | if (scfg & (SEL_PLACE | SEL_CORE)) { |
226 | dev_err(&pdev->dev, "Configuration bit(s) stuck at 1!\n"); | 222 | dev_err(&pdev->dev, "Configuration bit(s) stuck at 1!\n"); |
227 | err = -ENODEV; | 223 | return -ENODEV; |
228 | goto exit_free; | ||
229 | } | 224 | } |
230 | 225 | ||
231 | scfg |= (SEL_PLACE | SEL_CORE); | 226 | scfg |= (SEL_PLACE | SEL_CORE); |
@@ -307,10 +302,6 @@ exit_remove: | |||
307 | device_remove_file(&pdev->dev, | 302 | device_remove_file(&pdev->dev, |
308 | &sensor_dev_attr_temp4_input.dev_attr); | 303 | &sensor_dev_attr_temp4_input.dev_attr); |
309 | device_remove_file(&pdev->dev, &dev_attr_name); | 304 | device_remove_file(&pdev->dev, &dev_attr_name); |
310 | exit_free: | ||
311 | pci_set_drvdata(pdev, NULL); | ||
312 | kfree(data); | ||
313 | exit: | ||
314 | return err; | 305 | return err; |
315 | } | 306 | } |
316 | 307 | ||
@@ -328,8 +319,6 @@ static void __devexit k8temp_remove(struct pci_dev *pdev) | |||
328 | device_remove_file(&pdev->dev, | 319 | device_remove_file(&pdev->dev, |
329 | &sensor_dev_attr_temp4_input.dev_attr); | 320 | &sensor_dev_attr_temp4_input.dev_attr); |
330 | device_remove_file(&pdev->dev, &dev_attr_name); | 321 | device_remove_file(&pdev->dev, &dev_attr_name); |
331 | pci_set_drvdata(pdev, NULL); | ||
332 | kfree(data); | ||
333 | } | 322 | } |
334 | 323 | ||
335 | static struct pci_driver k8temp_driver = { | 324 | static struct pci_driver k8temp_driver = { |
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 602a0f0b0de8..eed4d9401788 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c | |||
@@ -1108,11 +1108,9 @@ static int lm63_probe(struct i2c_client *client, | |||
1108 | struct lm63_data *data; | 1108 | struct lm63_data *data; |
1109 | int err; | 1109 | int err; |
1110 | 1110 | ||
1111 | data = kzalloc(sizeof(struct lm63_data), GFP_KERNEL); | 1111 | data = devm_kzalloc(&client->dev, sizeof(struct lm63_data), GFP_KERNEL); |
1112 | if (!data) { | 1112 | if (!data) |
1113 | err = -ENOMEM; | 1113 | return -ENOMEM; |
1114 | goto exit; | ||
1115 | } | ||
1116 | 1114 | ||
1117 | i2c_set_clientdata(client, data); | 1115 | i2c_set_clientdata(client, data); |
1118 | data->valid = 0; | 1116 | data->valid = 0; |
@@ -1129,7 +1127,7 @@ static int lm63_probe(struct i2c_client *client, | |||
1129 | /* Register sysfs hooks */ | 1127 | /* Register sysfs hooks */ |
1130 | err = sysfs_create_group(&client->dev.kobj, &lm63_group); | 1128 | err = sysfs_create_group(&client->dev.kobj, &lm63_group); |
1131 | if (err) | 1129 | if (err) |
1132 | goto exit_free; | 1130 | return err; |
1133 | if (data->config & 0x04) { /* tachometer enabled */ | 1131 | if (data->config & 0x04) { /* tachometer enabled */ |
1134 | err = sysfs_create_group(&client->dev.kobj, &lm63_group_fan1); | 1132 | err = sysfs_create_group(&client->dev.kobj, &lm63_group_fan1); |
1135 | if (err) | 1133 | if (err) |
@@ -1161,9 +1159,6 @@ exit_remove_files: | |||
1161 | device_remove_file(&client->dev, &dev_attr_temp2_type); | 1159 | device_remove_file(&client->dev, &dev_attr_temp2_type); |
1162 | sysfs_remove_group(&client->dev.kobj, &lm63_group_extra_lut); | 1160 | sysfs_remove_group(&client->dev.kobj, &lm63_group_extra_lut); |
1163 | } | 1161 | } |
1164 | exit_free: | ||
1165 | kfree(data); | ||
1166 | exit: | ||
1167 | return err; | 1162 | return err; |
1168 | } | 1163 | } |
1169 | 1164 | ||
@@ -1179,7 +1174,6 @@ static int lm63_remove(struct i2c_client *client) | |||
1179 | sysfs_remove_group(&client->dev.kobj, &lm63_group_extra_lut); | 1174 | sysfs_remove_group(&client->dev.kobj, &lm63_group_extra_lut); |
1180 | } | 1175 | } |
1181 | 1176 | ||
1182 | kfree(data); | ||
1183 | return 0; | 1177 | return 0; |
1184 | } | 1178 | } |
1185 | 1179 | ||
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index a83f206af244..291edfff55bf 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -156,7 +156,7 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
156 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) | 156 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) |
157 | return -EIO; | 157 | return -EIO; |
158 | 158 | ||
159 | data = kzalloc(sizeof(struct lm75_data), GFP_KERNEL); | 159 | data = devm_kzalloc(&client->dev, sizeof(struct lm75_data), GFP_KERNEL); |
160 | if (!data) | 160 | if (!data) |
161 | return -ENOMEM; | 161 | return -ENOMEM; |
162 | 162 | ||
@@ -174,7 +174,7 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
174 | status = lm75_read_value(client, LM75_REG_CONF); | 174 | status = lm75_read_value(client, LM75_REG_CONF); |
175 | if (status < 0) { | 175 | if (status < 0) { |
176 | dev_dbg(&client->dev, "Can't read config? %d\n", status); | 176 | dev_dbg(&client->dev, "Can't read config? %d\n", status); |
177 | goto exit_free; | 177 | return status; |
178 | } | 178 | } |
179 | data->orig_conf = status; | 179 | data->orig_conf = status; |
180 | new = status & ~clr_mask; | 180 | new = status & ~clr_mask; |
@@ -186,7 +186,7 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
186 | /* Register sysfs hooks */ | 186 | /* Register sysfs hooks */ |
187 | status = sysfs_create_group(&client->dev.kobj, &lm75_group); | 187 | status = sysfs_create_group(&client->dev.kobj, &lm75_group); |
188 | if (status) | 188 | if (status) |
189 | goto exit_free; | 189 | return status; |
190 | 190 | ||
191 | data->hwmon_dev = hwmon_device_register(&client->dev); | 191 | data->hwmon_dev = hwmon_device_register(&client->dev); |
192 | if (IS_ERR(data->hwmon_dev)) { | 192 | if (IS_ERR(data->hwmon_dev)) { |
@@ -201,8 +201,6 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
201 | 201 | ||
202 | exit_remove: | 202 | exit_remove: |
203 | sysfs_remove_group(&client->dev.kobj, &lm75_group); | 203 | sysfs_remove_group(&client->dev.kobj, &lm75_group); |
204 | exit_free: | ||
205 | kfree(data); | ||
206 | return status; | 204 | return status; |
207 | } | 205 | } |
208 | 206 | ||
@@ -213,7 +211,6 @@ static int lm75_remove(struct i2c_client *client) | |||
213 | hwmon_device_unregister(data->hwmon_dev); | 211 | hwmon_device_unregister(data->hwmon_dev); |
214 | sysfs_remove_group(&client->dev.kobj, &lm75_group); | 212 | sysfs_remove_group(&client->dev.kobj, &lm75_group); |
215 | lm75_write_value(client, LM75_REG_CONF, data->orig_conf); | 213 | lm75_write_value(client, LM75_REG_CONF, data->orig_conf); |
216 | kfree(data); | ||
217 | return 0; | 214 | return 0; |
218 | } | 215 | } |
219 | 216 | ||
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index 0fca8613e7d8..f82acf67acf5 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c | |||
@@ -267,10 +267,9 @@ static const struct attribute_group lm77_group = { | |||
267 | }; | 267 | }; |
268 | 268 | ||
269 | /* Return 0 if detection is successful, -ENODEV otherwise */ | 269 | /* Return 0 if detection is successful, -ENODEV otherwise */ |
270 | static int lm77_detect(struct i2c_client *new_client, | 270 | static int lm77_detect(struct i2c_client *client, struct i2c_board_info *info) |
271 | struct i2c_board_info *info) | ||
272 | { | 271 | { |
273 | struct i2c_adapter *adapter = new_client->adapter; | 272 | struct i2c_adapter *adapter = client->adapter; |
274 | int i, cur, conf, hyst, crit, min, max; | 273 | int i, cur, conf, hyst, crit, min, max; |
275 | 274 | ||
276 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | | 275 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | |
@@ -292,18 +291,18 @@ static int lm77_detect(struct i2c_client *new_client, | |||
292 | */ | 291 | */ |
293 | 292 | ||
294 | /* addresses cycling */ | 293 | /* addresses cycling */ |
295 | cur = i2c_smbus_read_word_data(new_client, 0); | 294 | cur = i2c_smbus_read_word_data(client, 0); |
296 | conf = i2c_smbus_read_byte_data(new_client, 1); | 295 | conf = i2c_smbus_read_byte_data(client, 1); |
297 | hyst = i2c_smbus_read_word_data(new_client, 2); | 296 | hyst = i2c_smbus_read_word_data(client, 2); |
298 | crit = i2c_smbus_read_word_data(new_client, 3); | 297 | crit = i2c_smbus_read_word_data(client, 3); |
299 | min = i2c_smbus_read_word_data(new_client, 4); | 298 | min = i2c_smbus_read_word_data(client, 4); |
300 | max = i2c_smbus_read_word_data(new_client, 5); | 299 | max = i2c_smbus_read_word_data(client, 5); |
301 | for (i = 8; i <= 0xff; i += 8) { | 300 | for (i = 8; i <= 0xff; i += 8) { |
302 | if (i2c_smbus_read_byte_data(new_client, i + 1) != conf | 301 | if (i2c_smbus_read_byte_data(client, i + 1) != conf |
303 | || i2c_smbus_read_word_data(new_client, i + 2) != hyst | 302 | || i2c_smbus_read_word_data(client, i + 2) != hyst |
304 | || i2c_smbus_read_word_data(new_client, i + 3) != crit | 303 | || i2c_smbus_read_word_data(client, i + 3) != crit |
305 | || i2c_smbus_read_word_data(new_client, i + 4) != min | 304 | || i2c_smbus_read_word_data(client, i + 4) != min |
306 | || i2c_smbus_read_word_data(new_client, i + 5) != max) | 305 | || i2c_smbus_read_word_data(client, i + 5) != max) |
307 | return -ENODEV; | 306 | return -ENODEV; |
308 | } | 307 | } |
309 | 308 | ||
@@ -320,17 +319,17 @@ static int lm77_detect(struct i2c_client *new_client, | |||
320 | return -ENODEV; | 319 | return -ENODEV; |
321 | 320 | ||
322 | /* 0x06 and 0x07 return the last read value */ | 321 | /* 0x06 and 0x07 return the last read value */ |
323 | cur = i2c_smbus_read_word_data(new_client, 0); | 322 | cur = i2c_smbus_read_word_data(client, 0); |
324 | if (i2c_smbus_read_word_data(new_client, 6) != cur | 323 | if (i2c_smbus_read_word_data(client, 6) != cur |
325 | || i2c_smbus_read_word_data(new_client, 7) != cur) | 324 | || i2c_smbus_read_word_data(client, 7) != cur) |
326 | return -ENODEV; | 325 | return -ENODEV; |
327 | hyst = i2c_smbus_read_word_data(new_client, 2); | 326 | hyst = i2c_smbus_read_word_data(client, 2); |
328 | if (i2c_smbus_read_word_data(new_client, 6) != hyst | 327 | if (i2c_smbus_read_word_data(client, 6) != hyst |
329 | || i2c_smbus_read_word_data(new_client, 7) != hyst) | 328 | || i2c_smbus_read_word_data(client, 7) != hyst) |
330 | return -ENODEV; | 329 | return -ENODEV; |
331 | min = i2c_smbus_read_word_data(new_client, 4); | 330 | min = i2c_smbus_read_word_data(client, 4); |
332 | if (i2c_smbus_read_word_data(new_client, 6) != min | 331 | if (i2c_smbus_read_word_data(client, 6) != min |
333 | || i2c_smbus_read_word_data(new_client, 7) != min) | 332 | || i2c_smbus_read_word_data(client, 7) != min) |
334 | return -ENODEV; | 333 | return -ENODEV; |
335 | 334 | ||
336 | strlcpy(info->type, "lm77", I2C_NAME_SIZE); | 335 | strlcpy(info->type, "lm77", I2C_NAME_SIZE); |
@@ -338,31 +337,29 @@ static int lm77_detect(struct i2c_client *new_client, | |||
338 | return 0; | 337 | return 0; |
339 | } | 338 | } |
340 | 339 | ||
341 | static int lm77_probe(struct i2c_client *new_client, | 340 | static int lm77_probe(struct i2c_client *client, const struct i2c_device_id *id) |
342 | const struct i2c_device_id *id) | ||
343 | { | 341 | { |
342 | struct device *dev = &client->dev; | ||
344 | struct lm77_data *data; | 343 | struct lm77_data *data; |
345 | int err; | 344 | int err; |
346 | 345 | ||
347 | data = kzalloc(sizeof(struct lm77_data), GFP_KERNEL); | 346 | data = devm_kzalloc(dev, sizeof(struct lm77_data), GFP_KERNEL); |
348 | if (!data) { | 347 | if (!data) |
349 | err = -ENOMEM; | 348 | return -ENOMEM; |
350 | goto exit; | ||
351 | } | ||
352 | 349 | ||
353 | i2c_set_clientdata(new_client, data); | 350 | i2c_set_clientdata(client, data); |
354 | data->valid = 0; | 351 | data->valid = 0; |
355 | mutex_init(&data->update_lock); | 352 | mutex_init(&data->update_lock); |
356 | 353 | ||
357 | /* Initialize the LM77 chip */ | 354 | /* Initialize the LM77 chip */ |
358 | lm77_init_client(new_client); | 355 | lm77_init_client(client); |
359 | 356 | ||
360 | /* Register sysfs hooks */ | 357 | /* Register sysfs hooks */ |
361 | err = sysfs_create_group(&new_client->dev.kobj, &lm77_group); | 358 | err = sysfs_create_group(&dev->kobj, &lm77_group); |
362 | if (err) | 359 | if (err) |
363 | goto exit_free; | 360 | return err; |
364 | 361 | ||
365 | data->hwmon_dev = hwmon_device_register(&new_client->dev); | 362 | data->hwmon_dev = hwmon_device_register(dev); |
366 | if (IS_ERR(data->hwmon_dev)) { | 363 | if (IS_ERR(data->hwmon_dev)) { |
367 | err = PTR_ERR(data->hwmon_dev); | 364 | err = PTR_ERR(data->hwmon_dev); |
368 | goto exit_remove; | 365 | goto exit_remove; |
@@ -371,10 +368,7 @@ static int lm77_probe(struct i2c_client *new_client, | |||
371 | return 0; | 368 | return 0; |
372 | 369 | ||
373 | exit_remove: | 370 | exit_remove: |
374 | sysfs_remove_group(&new_client->dev.kobj, &lm77_group); | 371 | sysfs_remove_group(&dev->kobj, &lm77_group); |
375 | exit_free: | ||
376 | kfree(data); | ||
377 | exit: | ||
378 | return err; | 372 | return err; |
379 | } | 373 | } |
380 | 374 | ||
@@ -383,7 +377,6 @@ static int lm77_remove(struct i2c_client *client) | |||
383 | struct lm77_data *data = i2c_get_clientdata(client); | 377 | struct lm77_data *data = i2c_get_clientdata(client); |
384 | hwmon_device_unregister(data->hwmon_dev); | 378 | hwmon_device_unregister(data->hwmon_dev); |
385 | sysfs_remove_group(&client->dev.kobj, &lm77_group); | 379 | sysfs_remove_group(&client->dev.kobj, &lm77_group); |
386 | kfree(data); | ||
387 | return 0; | 380 | return 0; |
388 | } | 381 | } |
389 | 382 | ||
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index f6bc414e1e91..c6ffafe600ad 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c | |||
@@ -660,7 +660,7 @@ static int lm78_i2c_probe(struct i2c_client *client, | |||
660 | struct lm78_data *data; | 660 | struct lm78_data *data; |
661 | int err; | 661 | int err; |
662 | 662 | ||
663 | data = kzalloc(sizeof(struct lm78_data), GFP_KERNEL); | 663 | data = devm_kzalloc(&client->dev, sizeof(struct lm78_data), GFP_KERNEL); |
664 | if (!data) | 664 | if (!data) |
665 | return -ENOMEM; | 665 | return -ENOMEM; |
666 | 666 | ||
@@ -674,20 +674,18 @@ static int lm78_i2c_probe(struct i2c_client *client, | |||
674 | /* Register sysfs hooks */ | 674 | /* Register sysfs hooks */ |
675 | err = sysfs_create_group(&client->dev.kobj, &lm78_group); | 675 | err = sysfs_create_group(&client->dev.kobj, &lm78_group); |
676 | if (err) | 676 | if (err) |
677 | goto ERROR3; | 677 | return err; |
678 | 678 | ||
679 | data->hwmon_dev = hwmon_device_register(&client->dev); | 679 | data->hwmon_dev = hwmon_device_register(&client->dev); |
680 | if (IS_ERR(data->hwmon_dev)) { | 680 | if (IS_ERR(data->hwmon_dev)) { |
681 | err = PTR_ERR(data->hwmon_dev); | 681 | err = PTR_ERR(data->hwmon_dev); |
682 | goto ERROR4; | 682 | goto error; |
683 | } | 683 | } |
684 | 684 | ||
685 | return 0; | 685 | return 0; |
686 | 686 | ||
687 | ERROR4: | 687 | error: |
688 | sysfs_remove_group(&client->dev.kobj, &lm78_group); | 688 | sysfs_remove_group(&client->dev.kobj, &lm78_group); |
689 | ERROR3: | ||
690 | kfree(data); | ||
691 | return err; | 689 | return err; |
692 | } | 690 | } |
693 | 691 | ||
@@ -697,7 +695,6 @@ static int lm78_i2c_remove(struct i2c_client *client) | |||
697 | 695 | ||
698 | hwmon_device_unregister(data->hwmon_dev); | 696 | hwmon_device_unregister(data->hwmon_dev); |
699 | sysfs_remove_group(&client->dev.kobj, &lm78_group); | 697 | sysfs_remove_group(&client->dev.kobj, &lm78_group); |
700 | kfree(data); | ||
701 | 698 | ||
702 | return 0; | 699 | return 0; |
703 | } | 700 | } |
@@ -844,16 +841,14 @@ static int __devinit lm78_isa_probe(struct platform_device *pdev) | |||
844 | 841 | ||
845 | /* Reserve the ISA region */ | 842 | /* Reserve the ISA region */ |
846 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 843 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
847 | if (!request_region(res->start + LM78_ADDR_REG_OFFSET, 2, "lm78")) { | 844 | if (!devm_request_region(&pdev->dev, res->start + LM78_ADDR_REG_OFFSET, |
848 | err = -EBUSY; | 845 | 2, "lm78")) |
849 | goto exit; | 846 | return -EBUSY; |
850 | } | 847 | |
848 | data = devm_kzalloc(&pdev->dev, sizeof(struct lm78_data), GFP_KERNEL); | ||
849 | if (!data) | ||
850 | return -ENOMEM; | ||
851 | 851 | ||
852 | data = kzalloc(sizeof(struct lm78_data), GFP_KERNEL); | ||
853 | if (!data) { | ||
854 | err = -ENOMEM; | ||
855 | goto exit_release_region; | ||
856 | } | ||
857 | mutex_init(&data->lock); | 852 | mutex_init(&data->lock); |
858 | data->isa_addr = res->start; | 853 | data->isa_addr = res->start; |
859 | platform_set_drvdata(pdev, data); | 854 | platform_set_drvdata(pdev, data); |
@@ -888,25 +883,16 @@ static int __devinit lm78_isa_probe(struct platform_device *pdev) | |||
888 | exit_remove_files: | 883 | exit_remove_files: |
889 | sysfs_remove_group(&pdev->dev.kobj, &lm78_group); | 884 | sysfs_remove_group(&pdev->dev.kobj, &lm78_group); |
890 | device_remove_file(&pdev->dev, &dev_attr_name); | 885 | device_remove_file(&pdev->dev, &dev_attr_name); |
891 | kfree(data); | ||
892 | exit_release_region: | ||
893 | release_region(res->start + LM78_ADDR_REG_OFFSET, 2); | ||
894 | exit: | ||
895 | return err; | 886 | return err; |
896 | } | 887 | } |
897 | 888 | ||
898 | static int __devexit lm78_isa_remove(struct platform_device *pdev) | 889 | static int __devexit lm78_isa_remove(struct platform_device *pdev) |
899 | { | 890 | { |
900 | struct lm78_data *data = platform_get_drvdata(pdev); | 891 | struct lm78_data *data = platform_get_drvdata(pdev); |
901 | struct resource *res; | ||
902 | 892 | ||
903 | hwmon_device_unregister(data->hwmon_dev); | 893 | hwmon_device_unregister(data->hwmon_dev); |
904 | sysfs_remove_group(&pdev->dev.kobj, &lm78_group); | 894 | sysfs_remove_group(&pdev->dev.kobj, &lm78_group); |
905 | device_remove_file(&pdev->dev, &dev_attr_name); | 895 | device_remove_file(&pdev->dev, &dev_attr_name); |
906 | kfree(data); | ||
907 | |||
908 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
909 | release_region(res->start + LM78_ADDR_REG_OFFSET, 2); | ||
910 | 896 | ||
911 | return 0; | 897 | return 0; |
912 | } | 898 | } |
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index e2c43e1774be..28a8b71f4571 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c | |||
@@ -543,11 +543,9 @@ static int lm80_probe(struct i2c_client *client, | |||
543 | struct lm80_data *data; | 543 | struct lm80_data *data; |
544 | int err; | 544 | int err; |
545 | 545 | ||
546 | data = kzalloc(sizeof(struct lm80_data), GFP_KERNEL); | 546 | data = devm_kzalloc(&client->dev, sizeof(struct lm80_data), GFP_KERNEL); |
547 | if (!data) { | 547 | if (!data) |
548 | err = -ENOMEM; | 548 | return -ENOMEM; |
549 | goto exit; | ||
550 | } | ||
551 | 549 | ||
552 | i2c_set_clientdata(client, data); | 550 | i2c_set_clientdata(client, data); |
553 | mutex_init(&data->update_lock); | 551 | mutex_init(&data->update_lock); |
@@ -562,7 +560,7 @@ static int lm80_probe(struct i2c_client *client, | |||
562 | /* Register sysfs hooks */ | 560 | /* Register sysfs hooks */ |
563 | err = sysfs_create_group(&client->dev.kobj, &lm80_group); | 561 | err = sysfs_create_group(&client->dev.kobj, &lm80_group); |
564 | if (err) | 562 | if (err) |
565 | goto error_free; | 563 | return err; |
566 | 564 | ||
567 | data->hwmon_dev = hwmon_device_register(&client->dev); | 565 | data->hwmon_dev = hwmon_device_register(&client->dev); |
568 | if (IS_ERR(data->hwmon_dev)) { | 566 | if (IS_ERR(data->hwmon_dev)) { |
@@ -574,9 +572,6 @@ static int lm80_probe(struct i2c_client *client, | |||
574 | 572 | ||
575 | error_remove: | 573 | error_remove: |
576 | sysfs_remove_group(&client->dev.kobj, &lm80_group); | 574 | sysfs_remove_group(&client->dev.kobj, &lm80_group); |
577 | error_free: | ||
578 | kfree(data); | ||
579 | exit: | ||
580 | return err; | 575 | return err; |
581 | } | 576 | } |
582 | 577 | ||
@@ -587,7 +582,6 @@ static int lm80_remove(struct i2c_client *client) | |||
587 | hwmon_device_unregister(data->hwmon_dev); | 582 | hwmon_device_unregister(data->hwmon_dev); |
588 | sysfs_remove_group(&client->dev.kobj, &lm80_group); | 583 | sysfs_remove_group(&client->dev.kobj, &lm80_group); |
589 | 584 | ||
590 | kfree(data); | ||
591 | return 0; | 585 | return 0; |
592 | } | 586 | } |
593 | 587 | ||
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index cd45b9d85584..e998034f1f11 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c | |||
@@ -343,11 +343,10 @@ static int lm83_probe(struct i2c_client *new_client, | |||
343 | struct lm83_data *data; | 343 | struct lm83_data *data; |
344 | int err; | 344 | int err; |
345 | 345 | ||
346 | data = kzalloc(sizeof(struct lm83_data), GFP_KERNEL); | 346 | data = devm_kzalloc(&new_client->dev, sizeof(struct lm83_data), |
347 | if (!data) { | 347 | GFP_KERNEL); |
348 | err = -ENOMEM; | 348 | if (!data) |
349 | goto exit; | 349 | return -ENOMEM; |
350 | } | ||
351 | 350 | ||
352 | i2c_set_clientdata(new_client, data); | 351 | i2c_set_clientdata(new_client, data); |
353 | data->valid = 0; | 352 | data->valid = 0; |
@@ -362,7 +361,7 @@ static int lm83_probe(struct i2c_client *new_client, | |||
362 | 361 | ||
363 | err = sysfs_create_group(&new_client->dev.kobj, &lm83_group); | 362 | err = sysfs_create_group(&new_client->dev.kobj, &lm83_group); |
364 | if (err) | 363 | if (err) |
365 | goto exit_free; | 364 | return err; |
366 | 365 | ||
367 | if (id->driver_data == lm83) { | 366 | if (id->driver_data == lm83) { |
368 | err = sysfs_create_group(&new_client->dev.kobj, | 367 | err = sysfs_create_group(&new_client->dev.kobj, |
@@ -382,9 +381,6 @@ static int lm83_probe(struct i2c_client *new_client, | |||
382 | exit_remove_files: | 381 | exit_remove_files: |
383 | sysfs_remove_group(&new_client->dev.kobj, &lm83_group); | 382 | sysfs_remove_group(&new_client->dev.kobj, &lm83_group); |
384 | sysfs_remove_group(&new_client->dev.kobj, &lm83_group_opt); | 383 | sysfs_remove_group(&new_client->dev.kobj, &lm83_group_opt); |
385 | exit_free: | ||
386 | kfree(data); | ||
387 | exit: | ||
388 | return err; | 384 | return err; |
389 | } | 385 | } |
390 | 386 | ||
@@ -396,7 +392,6 @@ static int lm83_remove(struct i2c_client *client) | |||
396 | sysfs_remove_group(&client->dev.kobj, &lm83_group); | 392 | sysfs_remove_group(&client->dev.kobj, &lm83_group); |
397 | sysfs_remove_group(&client->dev.kobj, &lm83_group_opt); | 393 | sysfs_remove_group(&client->dev.kobj, &lm83_group_opt); |
398 | 394 | ||
399 | kfree(data); | ||
400 | return 0; | 395 | return 0; |
401 | } | 396 | } |
402 | 397 | ||
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 864c7d999e0c..9f2dd77e1e0e 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -1387,7 +1387,7 @@ static int lm85_probe(struct i2c_client *client, | |||
1387 | struct lm85_data *data; | 1387 | struct lm85_data *data; |
1388 | int err; | 1388 | int err; |
1389 | 1389 | ||
1390 | data = kzalloc(sizeof(struct lm85_data), GFP_KERNEL); | 1390 | data = devm_kzalloc(&client->dev, sizeof(struct lm85_data), GFP_KERNEL); |
1391 | if (!data) | 1391 | if (!data) |
1392 | return -ENOMEM; | 1392 | return -ENOMEM; |
1393 | 1393 | ||
@@ -1419,7 +1419,7 @@ static int lm85_probe(struct i2c_client *client, | |||
1419 | /* Register sysfs hooks */ | 1419 | /* Register sysfs hooks */ |
1420 | err = sysfs_create_group(&client->dev.kobj, &lm85_group); | 1420 | err = sysfs_create_group(&client->dev.kobj, &lm85_group); |
1421 | if (err) | 1421 | if (err) |
1422 | goto err_kfree; | 1422 | return err; |
1423 | 1423 | ||
1424 | /* minctl and temp_off exist on all chips except emc6d103s */ | 1424 | /* minctl and temp_off exist on all chips except emc6d103s */ |
1425 | if (data->type != emc6d103s) { | 1425 | if (data->type != emc6d103s) { |
@@ -1466,8 +1466,6 @@ static int lm85_probe(struct i2c_client *client, | |||
1466 | /* Error out and cleanup code */ | 1466 | /* Error out and cleanup code */ |
1467 | err_remove_files: | 1467 | err_remove_files: |
1468 | lm85_remove_files(client, data); | 1468 | lm85_remove_files(client, data); |
1469 | err_kfree: | ||
1470 | kfree(data); | ||
1471 | return err; | 1469 | return err; |
1472 | } | 1470 | } |
1473 | 1471 | ||
@@ -1476,7 +1474,6 @@ static int lm85_remove(struct i2c_client *client) | |||
1476 | struct lm85_data *data = i2c_get_clientdata(client); | 1474 | struct lm85_data *data = i2c_get_clientdata(client); |
1477 | hwmon_device_unregister(data->hwmon_dev); | 1475 | hwmon_device_unregister(data->hwmon_dev); |
1478 | lm85_remove_files(client, data); | 1476 | lm85_remove_files(client, data); |
1479 | kfree(data); | ||
1480 | return 0; | 1477 | return 0; |
1481 | } | 1478 | } |
1482 | 1479 | ||
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 314d147bf1ac..16e45d702152 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c | |||
@@ -898,11 +898,9 @@ static int lm87_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
898 | struct lm87_data *data; | 898 | struct lm87_data *data; |
899 | int err; | 899 | int err; |
900 | 900 | ||
901 | data = kzalloc(sizeof(struct lm87_data), GFP_KERNEL); | 901 | data = devm_kzalloc(&client->dev, sizeof(struct lm87_data), GFP_KERNEL); |
902 | if (!data) { | 902 | if (!data) |
903 | err = -ENOMEM; | 903 | return -ENOMEM; |
904 | goto exit; | ||
905 | } | ||
906 | 904 | ||
907 | i2c_set_clientdata(client, data); | 905 | i2c_set_clientdata(client, data); |
908 | data->valid = 0; | 906 | data->valid = 0; |
@@ -923,7 +921,7 @@ static int lm87_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
923 | /* Register sysfs hooks */ | 921 | /* Register sysfs hooks */ |
924 | err = sysfs_create_group(&client->dev.kobj, &lm87_group); | 922 | err = sysfs_create_group(&client->dev.kobj, &lm87_group); |
925 | if (err) | 923 | if (err) |
926 | goto exit_free; | 924 | goto exit_stop; |
927 | 925 | ||
928 | if (data->channel & CHAN_NO_FAN(0)) { | 926 | if (data->channel & CHAN_NO_FAN(0)) { |
929 | err = sysfs_create_group(&client->dev.kobj, &lm87_group_in6); | 927 | err = sysfs_create_group(&client->dev.kobj, &lm87_group_in6); |
@@ -972,10 +970,8 @@ static int lm87_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
972 | 970 | ||
973 | exit_remove: | 971 | exit_remove: |
974 | lm87_remove_files(client); | 972 | lm87_remove_files(client); |
975 | exit_free: | 973 | exit_stop: |
976 | lm87_write_value(client, LM87_REG_CONFIG, data->config); | 974 | lm87_write_value(client, LM87_REG_CONFIG, data->config); |
977 | kfree(data); | ||
978 | exit: | ||
979 | return err; | 975 | return err; |
980 | } | 976 | } |
981 | 977 | ||
@@ -987,7 +983,6 @@ static int lm87_remove(struct i2c_client *client) | |||
987 | lm87_remove_files(client); | 983 | lm87_remove_files(client); |
988 | 984 | ||
989 | lm87_write_value(client, LM87_REG_CONFIG, data->config); | 985 | lm87_write_value(client, LM87_REG_CONFIG, data->config); |
990 | kfree(data); | ||
991 | return 0; | 986 | return 0; |
992 | } | 987 | } |
993 | 988 | ||
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 22b14a68e35e..863412a02bdd 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
@@ -1399,11 +1399,10 @@ static int lm90_probe(struct i2c_client *client, | |||
1399 | struct lm90_data *data; | 1399 | struct lm90_data *data; |
1400 | int err; | 1400 | int err; |
1401 | 1401 | ||
1402 | data = kzalloc(sizeof(struct lm90_data), GFP_KERNEL); | 1402 | data = devm_kzalloc(&client->dev, sizeof(struct lm90_data), GFP_KERNEL); |
1403 | if (!data) { | 1403 | if (!data) |
1404 | err = -ENOMEM; | 1404 | return -ENOMEM; |
1405 | goto exit; | 1405 | |
1406 | } | ||
1407 | i2c_set_clientdata(client, data); | 1406 | i2c_set_clientdata(client, data); |
1408 | mutex_init(&data->update_lock); | 1407 | mutex_init(&data->update_lock); |
1409 | 1408 | ||
@@ -1474,8 +1473,6 @@ exit_remove_files: | |||
1474 | lm90_remove_files(client, data); | 1473 | lm90_remove_files(client, data); |
1475 | exit_restore: | 1474 | exit_restore: |
1476 | lm90_restore_conf(client, data); | 1475 | lm90_restore_conf(client, data); |
1477 | kfree(data); | ||
1478 | exit: | ||
1479 | return err; | 1476 | return err; |
1480 | } | 1477 | } |
1481 | 1478 | ||
@@ -1487,7 +1484,6 @@ static int lm90_remove(struct i2c_client *client) | |||
1487 | lm90_remove_files(client, data); | 1484 | lm90_remove_files(client, data); |
1488 | lm90_restore_conf(client, data); | 1485 | lm90_restore_conf(client, data); |
1489 | 1486 | ||
1490 | kfree(data); | ||
1491 | return 0; | 1487 | return 0; |
1492 | } | 1488 | } |
1493 | 1489 | ||
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index fdc691a4028f..2282d77e83e8 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c | |||
@@ -373,11 +373,10 @@ static int lm92_probe(struct i2c_client *new_client, | |||
373 | struct lm92_data *data; | 373 | struct lm92_data *data; |
374 | int err; | 374 | int err; |
375 | 375 | ||
376 | data = kzalloc(sizeof(struct lm92_data), GFP_KERNEL); | 376 | data = devm_kzalloc(&new_client->dev, sizeof(struct lm92_data), |
377 | if (!data) { | 377 | GFP_KERNEL); |
378 | err = -ENOMEM; | 378 | if (!data) |
379 | goto exit; | 379 | return -ENOMEM; |
380 | } | ||
381 | 380 | ||
382 | i2c_set_clientdata(new_client, data); | 381 | i2c_set_clientdata(new_client, data); |
383 | data->valid = 0; | 382 | data->valid = 0; |
@@ -389,7 +388,7 @@ static int lm92_probe(struct i2c_client *new_client, | |||
389 | /* Register sysfs hooks */ | 388 | /* Register sysfs hooks */ |
390 | err = sysfs_create_group(&new_client->dev.kobj, &lm92_group); | 389 | err = sysfs_create_group(&new_client->dev.kobj, &lm92_group); |
391 | if (err) | 390 | if (err) |
392 | goto exit_free; | 391 | return err; |
393 | 392 | ||
394 | data->hwmon_dev = hwmon_device_register(&new_client->dev); | 393 | data->hwmon_dev = hwmon_device_register(&new_client->dev); |
395 | if (IS_ERR(data->hwmon_dev)) { | 394 | if (IS_ERR(data->hwmon_dev)) { |
@@ -401,9 +400,6 @@ static int lm92_probe(struct i2c_client *new_client, | |||
401 | 400 | ||
402 | exit_remove: | 401 | exit_remove: |
403 | sysfs_remove_group(&new_client->dev.kobj, &lm92_group); | 402 | sysfs_remove_group(&new_client->dev.kobj, &lm92_group); |
404 | exit_free: | ||
405 | kfree(data); | ||
406 | exit: | ||
407 | return err; | 403 | return err; |
408 | } | 404 | } |
409 | 405 | ||
@@ -414,7 +410,6 @@ static int lm92_remove(struct i2c_client *client) | |||
414 | hwmon_device_unregister(data->hwmon_dev); | 410 | hwmon_device_unregister(data->hwmon_dev); |
415 | sysfs_remove_group(&client->dev.kobj, &lm92_group); | 411 | sysfs_remove_group(&client->dev.kobj, &lm92_group); |
416 | 412 | ||
417 | kfree(data); | ||
418 | return 0; | 413 | return 0; |
419 | } | 414 | } |
420 | 415 | ||
diff --git a/drivers/hwmon/lm93.c b/drivers/hwmon/lm93.c index 67e8fe256e02..bf946187bd37 100644 --- a/drivers/hwmon/lm93.c +++ b/drivers/hwmon/lm93.c | |||
@@ -2738,15 +2738,13 @@ static int lm93_probe(struct i2c_client *client, | |||
2738 | } else { | 2738 | } else { |
2739 | dev_dbg(&client->dev, "detect failed, " | 2739 | dev_dbg(&client->dev, "detect failed, " |
2740 | "smbus byte and/or word data not supported!\n"); | 2740 | "smbus byte and/or word data not supported!\n"); |
2741 | err = -ENODEV; | 2741 | return -ENODEV; |
2742 | goto err_out; | ||
2743 | } | 2742 | } |
2744 | 2743 | ||
2745 | data = kzalloc(sizeof(struct lm93_data), GFP_KERNEL); | 2744 | data = devm_kzalloc(&client->dev, sizeof(struct lm93_data), GFP_KERNEL); |
2746 | if (!data) { | 2745 | if (!data) { |
2747 | dev_dbg(&client->dev, "out of memory!\n"); | 2746 | dev_dbg(&client->dev, "out of memory!\n"); |
2748 | err = -ENOMEM; | 2747 | return -ENOMEM; |
2749 | goto err_out; | ||
2750 | } | 2748 | } |
2751 | i2c_set_clientdata(client, data); | 2749 | i2c_set_clientdata(client, data); |
2752 | 2750 | ||
@@ -2760,7 +2758,7 @@ static int lm93_probe(struct i2c_client *client, | |||
2760 | 2758 | ||
2761 | err = sysfs_create_group(&client->dev.kobj, &lm93_attr_grp); | 2759 | err = sysfs_create_group(&client->dev.kobj, &lm93_attr_grp); |
2762 | if (err) | 2760 | if (err) |
2763 | goto err_free; | 2761 | return err; |
2764 | 2762 | ||
2765 | /* Register hwmon driver class */ | 2763 | /* Register hwmon driver class */ |
2766 | data->hwmon_dev = hwmon_device_register(&client->dev); | 2764 | data->hwmon_dev = hwmon_device_register(&client->dev); |
@@ -2770,9 +2768,6 @@ static int lm93_probe(struct i2c_client *client, | |||
2770 | err = PTR_ERR(data->hwmon_dev); | 2768 | err = PTR_ERR(data->hwmon_dev); |
2771 | dev_err(&client->dev, "error registering hwmon device.\n"); | 2769 | dev_err(&client->dev, "error registering hwmon device.\n"); |
2772 | sysfs_remove_group(&client->dev.kobj, &lm93_attr_grp); | 2770 | sysfs_remove_group(&client->dev.kobj, &lm93_attr_grp); |
2773 | err_free: | ||
2774 | kfree(data); | ||
2775 | err_out: | ||
2776 | return err; | 2771 | return err; |
2777 | } | 2772 | } |
2778 | 2773 | ||
@@ -2783,7 +2778,6 @@ static int lm93_remove(struct i2c_client *client) | |||
2783 | hwmon_device_unregister(data->hwmon_dev); | 2778 | hwmon_device_unregister(data->hwmon_dev); |
2784 | sysfs_remove_group(&client->dev.kobj, &lm93_attr_grp); | 2779 | sysfs_remove_group(&client->dev.kobj, &lm93_attr_grp); |
2785 | 2780 | ||
2786 | kfree(data); | ||
2787 | return 0; | 2781 | return 0; |
2788 | } | 2782 | } |
2789 | 2783 | ||
diff --git a/drivers/hwmon/max1111.c b/drivers/hwmon/max1111.c index 362a40eb6129..f3978a46e844 100644 --- a/drivers/hwmon/max1111.c +++ b/drivers/hwmon/max1111.c | |||
@@ -168,7 +168,7 @@ static int __devinit max1111_probe(struct spi_device *spi) | |||
168 | if (err < 0) | 168 | if (err < 0) |
169 | return err; | 169 | return err; |
170 | 170 | ||
171 | data = kzalloc(sizeof(struct max1111_data), GFP_KERNEL); | 171 | data = devm_kzalloc(&spi->dev, sizeof(struct max1111_data), GFP_KERNEL); |
172 | if (data == NULL) { | 172 | if (data == NULL) { |
173 | dev_err(&spi->dev, "failed to allocate memory\n"); | 173 | dev_err(&spi->dev, "failed to allocate memory\n"); |
174 | return -ENOMEM; | 174 | return -ENOMEM; |
@@ -176,7 +176,7 @@ static int __devinit max1111_probe(struct spi_device *spi) | |||
176 | 176 | ||
177 | err = setup_transfer(data); | 177 | err = setup_transfer(data); |
178 | if (err) | 178 | if (err) |
179 | goto err_free_data; | 179 | return err; |
180 | 180 | ||
181 | mutex_init(&data->drvdata_lock); | 181 | mutex_init(&data->drvdata_lock); |
182 | 182 | ||
@@ -186,7 +186,7 @@ static int __devinit max1111_probe(struct spi_device *spi) | |||
186 | err = sysfs_create_group(&spi->dev.kobj, &max1111_attr_group); | 186 | err = sysfs_create_group(&spi->dev.kobj, &max1111_attr_group); |
187 | if (err) { | 187 | if (err) { |
188 | dev_err(&spi->dev, "failed to create attribute group\n"); | 188 | dev_err(&spi->dev, "failed to create attribute group\n"); |
189 | goto err_free_data; | 189 | return err; |
190 | } | 190 | } |
191 | 191 | ||
192 | data->hwmon_dev = hwmon_device_register(&spi->dev); | 192 | data->hwmon_dev = hwmon_device_register(&spi->dev); |
@@ -203,8 +203,6 @@ static int __devinit max1111_probe(struct spi_device *spi) | |||
203 | 203 | ||
204 | err_remove: | 204 | err_remove: |
205 | sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group); | 205 | sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group); |
206 | err_free_data: | ||
207 | kfree(data); | ||
208 | return err; | 206 | return err; |
209 | } | 207 | } |
210 | 208 | ||
@@ -215,7 +213,6 @@ static int __devexit max1111_remove(struct spi_device *spi) | |||
215 | hwmon_device_unregister(data->hwmon_dev); | 213 | hwmon_device_unregister(data->hwmon_dev); |
216 | sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group); | 214 | sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group); |
217 | mutex_destroy(&data->drvdata_lock); | 215 | mutex_destroy(&data->drvdata_lock); |
218 | kfree(data); | ||
219 | return 0; | 216 | return 0; |
220 | } | 217 | } |
221 | 218 | ||
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index ecac04a7b7d6..6c11ec214071 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c | |||
@@ -267,11 +267,10 @@ static int max1619_probe(struct i2c_client *new_client, | |||
267 | struct max1619_data *data; | 267 | struct max1619_data *data; |
268 | int err; | 268 | int err; |
269 | 269 | ||
270 | data = kzalloc(sizeof(struct max1619_data), GFP_KERNEL); | 270 | data = devm_kzalloc(&new_client->dev, sizeof(struct max1619_data), |
271 | if (!data) { | 271 | GFP_KERNEL); |
272 | err = -ENOMEM; | 272 | if (!data) |
273 | goto exit; | 273 | return -ENOMEM; |
274 | } | ||
275 | 274 | ||
276 | i2c_set_clientdata(new_client, data); | 275 | i2c_set_clientdata(new_client, data); |
277 | data->valid = 0; | 276 | data->valid = 0; |
@@ -283,7 +282,7 @@ static int max1619_probe(struct i2c_client *new_client, | |||
283 | /* Register sysfs hooks */ | 282 | /* Register sysfs hooks */ |
284 | err = sysfs_create_group(&new_client->dev.kobj, &max1619_group); | 283 | err = sysfs_create_group(&new_client->dev.kobj, &max1619_group); |
285 | if (err) | 284 | if (err) |
286 | goto exit_free; | 285 | return err; |
287 | 286 | ||
288 | data->hwmon_dev = hwmon_device_register(&new_client->dev); | 287 | data->hwmon_dev = hwmon_device_register(&new_client->dev); |
289 | if (IS_ERR(data->hwmon_dev)) { | 288 | if (IS_ERR(data->hwmon_dev)) { |
@@ -295,9 +294,6 @@ static int max1619_probe(struct i2c_client *new_client, | |||
295 | 294 | ||
296 | exit_remove_files: | 295 | exit_remove_files: |
297 | sysfs_remove_group(&new_client->dev.kobj, &max1619_group); | 296 | sysfs_remove_group(&new_client->dev.kobj, &max1619_group); |
298 | exit_free: | ||
299 | kfree(data); | ||
300 | exit: | ||
301 | return err; | 297 | return err; |
302 | } | 298 | } |
303 | 299 | ||
@@ -323,7 +319,6 @@ static int max1619_remove(struct i2c_client *client) | |||
323 | hwmon_device_unregister(data->hwmon_dev); | 319 | hwmon_device_unregister(data->hwmon_dev); |
324 | sysfs_remove_group(&client->dev.kobj, &max1619_group); | 320 | sysfs_remove_group(&client->dev.kobj, &max1619_group); |
325 | 321 | ||
326 | kfree(data); | ||
327 | return 0; | 322 | return 0; |
328 | } | 323 | } |
329 | 324 | ||
diff --git a/drivers/hwmon/max6639.c b/drivers/hwmon/max6639.c index de8f7adaccbd..6e60036abfa7 100644 --- a/drivers/hwmon/max6639.c +++ b/drivers/hwmon/max6639.c | |||
@@ -548,11 +548,10 @@ static int max6639_probe(struct i2c_client *client, | |||
548 | struct max6639_data *data; | 548 | struct max6639_data *data; |
549 | int err; | 549 | int err; |
550 | 550 | ||
551 | data = kzalloc(sizeof(struct max6639_data), GFP_KERNEL); | 551 | data = devm_kzalloc(&client->dev, sizeof(struct max6639_data), |
552 | if (!data) { | 552 | GFP_KERNEL); |
553 | err = -ENOMEM; | 553 | if (!data) |
554 | goto exit; | 554 | return -ENOMEM; |
555 | } | ||
556 | 555 | ||
557 | i2c_set_clientdata(client, data); | 556 | i2c_set_clientdata(client, data); |
558 | mutex_init(&data->update_lock); | 557 | mutex_init(&data->update_lock); |
@@ -560,12 +559,12 @@ static int max6639_probe(struct i2c_client *client, | |||
560 | /* Initialize the max6639 chip */ | 559 | /* Initialize the max6639 chip */ |
561 | err = max6639_init_client(client); | 560 | err = max6639_init_client(client); |
562 | if (err < 0) | 561 | if (err < 0) |
563 | goto error_free; | 562 | return err; |
564 | 563 | ||
565 | /* Register sysfs hooks */ | 564 | /* Register sysfs hooks */ |
566 | err = sysfs_create_group(&client->dev.kobj, &max6639_group); | 565 | err = sysfs_create_group(&client->dev.kobj, &max6639_group); |
567 | if (err) | 566 | if (err) |
568 | goto error_free; | 567 | return err; |
569 | 568 | ||
570 | data->hwmon_dev = hwmon_device_register(&client->dev); | 569 | data->hwmon_dev = hwmon_device_register(&client->dev); |
571 | if (IS_ERR(data->hwmon_dev)) { | 570 | if (IS_ERR(data->hwmon_dev)) { |
@@ -579,9 +578,6 @@ static int max6639_probe(struct i2c_client *client, | |||
579 | 578 | ||
580 | error_remove: | 579 | error_remove: |
581 | sysfs_remove_group(&client->dev.kobj, &max6639_group); | 580 | sysfs_remove_group(&client->dev.kobj, &max6639_group); |
582 | error_free: | ||
583 | kfree(data); | ||
584 | exit: | ||
585 | return err; | 581 | return err; |
586 | } | 582 | } |
587 | 583 | ||
@@ -592,7 +588,6 @@ static int max6639_remove(struct i2c_client *client) | |||
592 | hwmon_device_unregister(data->hwmon_dev); | 588 | hwmon_device_unregister(data->hwmon_dev); |
593 | sysfs_remove_group(&client->dev.kobj, &max6639_group); | 589 | sysfs_remove_group(&client->dev.kobj, &max6639_group); |
594 | 590 | ||
595 | kfree(data); | ||
596 | return 0; | 591 | return 0; |
597 | } | 592 | } |
598 | 593 | ||
diff --git a/drivers/hwmon/max6642.c b/drivers/hwmon/max6642.c index 4298909a41fd..bf236c0782b7 100644 --- a/drivers/hwmon/max6642.c +++ b/drivers/hwmon/max6642.c | |||
@@ -286,11 +286,10 @@ static int max6642_probe(struct i2c_client *new_client, | |||
286 | struct max6642_data *data; | 286 | struct max6642_data *data; |
287 | int err; | 287 | int err; |
288 | 288 | ||
289 | data = kzalloc(sizeof(struct max6642_data), GFP_KERNEL); | 289 | data = devm_kzalloc(&new_client->dev, sizeof(struct max6642_data), |
290 | if (!data) { | 290 | GFP_KERNEL); |
291 | err = -ENOMEM; | 291 | if (!data) |
292 | goto exit; | 292 | return -ENOMEM; |
293 | } | ||
294 | 293 | ||
295 | i2c_set_clientdata(new_client, data); | 294 | i2c_set_clientdata(new_client, data); |
296 | mutex_init(&data->update_lock); | 295 | mutex_init(&data->update_lock); |
@@ -301,7 +300,7 @@ static int max6642_probe(struct i2c_client *new_client, | |||
301 | /* Register sysfs hooks */ | 300 | /* Register sysfs hooks */ |
302 | err = sysfs_create_group(&new_client->dev.kobj, &max6642_group); | 301 | err = sysfs_create_group(&new_client->dev.kobj, &max6642_group); |
303 | if (err) | 302 | if (err) |
304 | goto exit_free; | 303 | return err; |
305 | 304 | ||
306 | data->hwmon_dev = hwmon_device_register(&new_client->dev); | 305 | data->hwmon_dev = hwmon_device_register(&new_client->dev); |
307 | if (IS_ERR(data->hwmon_dev)) { | 306 | if (IS_ERR(data->hwmon_dev)) { |
@@ -313,9 +312,6 @@ static int max6642_probe(struct i2c_client *new_client, | |||
313 | 312 | ||
314 | exit_remove_files: | 313 | exit_remove_files: |
315 | sysfs_remove_group(&new_client->dev.kobj, &max6642_group); | 314 | sysfs_remove_group(&new_client->dev.kobj, &max6642_group); |
316 | exit_free: | ||
317 | kfree(data); | ||
318 | exit: | ||
319 | return err; | 315 | return err; |
320 | } | 316 | } |
321 | 317 | ||
@@ -326,7 +322,6 @@ static int max6642_remove(struct i2c_client *client) | |||
326 | hwmon_device_unregister(data->hwmon_dev); | 322 | hwmon_device_unregister(data->hwmon_dev); |
327 | sysfs_remove_group(&client->dev.kobj, &max6642_group); | 323 | sysfs_remove_group(&client->dev.kobj, &max6642_group); |
328 | 324 | ||
329 | kfree(data); | ||
330 | return 0; | 325 | return 0; |
331 | } | 326 | } |
332 | 327 | ||
diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c index 33a8a7f15e18..f739f83bafb9 100644 --- a/drivers/hwmon/max6650.c +++ b/drivers/hwmon/max6650.c | |||
@@ -545,7 +545,8 @@ static int max6650_probe(struct i2c_client *client, | |||
545 | struct max6650_data *data; | 545 | struct max6650_data *data; |
546 | int err; | 546 | int err; |
547 | 547 | ||
548 | data = kzalloc(sizeof(struct max6650_data), GFP_KERNEL); | 548 | data = devm_kzalloc(&client->dev, sizeof(struct max6650_data), |
549 | GFP_KERNEL); | ||
549 | if (!data) { | 550 | if (!data) { |
550 | dev_err(&client->dev, "out of memory.\n"); | 551 | dev_err(&client->dev, "out of memory.\n"); |
551 | return -ENOMEM; | 552 | return -ENOMEM; |
@@ -560,11 +561,11 @@ static int max6650_probe(struct i2c_client *client, | |||
560 | */ | 561 | */ |
561 | err = max6650_init_client(client); | 562 | err = max6650_init_client(client); |
562 | if (err) | 563 | if (err) |
563 | goto err_free; | 564 | return err; |
564 | 565 | ||
565 | err = sysfs_create_group(&client->dev.kobj, &max6650_attr_grp); | 566 | err = sysfs_create_group(&client->dev.kobj, &max6650_attr_grp); |
566 | if (err) | 567 | if (err) |
567 | goto err_free; | 568 | return err; |
568 | /* 3 additional fan inputs for the MAX6651 */ | 569 | /* 3 additional fan inputs for the MAX6651 */ |
569 | if (data->nr_fans == 4) { | 570 | if (data->nr_fans == 4) { |
570 | err = sysfs_create_group(&client->dev.kobj, &max6651_attr_grp); | 571 | err = sysfs_create_group(&client->dev.kobj, &max6651_attr_grp); |
@@ -582,8 +583,6 @@ static int max6650_probe(struct i2c_client *client, | |||
582 | sysfs_remove_group(&client->dev.kobj, &max6651_attr_grp); | 583 | sysfs_remove_group(&client->dev.kobj, &max6651_attr_grp); |
583 | err_remove: | 584 | err_remove: |
584 | sysfs_remove_group(&client->dev.kobj, &max6650_attr_grp); | 585 | sysfs_remove_group(&client->dev.kobj, &max6650_attr_grp); |
585 | err_free: | ||
586 | kfree(data); | ||
587 | return err; | 586 | return err; |
588 | } | 587 | } |
589 | 588 | ||
@@ -595,7 +594,6 @@ static int max6650_remove(struct i2c_client *client) | |||
595 | if (data->nr_fans == 4) | 594 | if (data->nr_fans == 4) |
596 | sysfs_remove_group(&client->dev.kobj, &max6651_attr_grp); | 595 | sysfs_remove_group(&client->dev.kobj, &max6651_attr_grp); |
597 | sysfs_remove_group(&client->dev.kobj, &max6650_attr_grp); | 596 | sysfs_remove_group(&client->dev.kobj, &max6650_attr_grp); |
598 | kfree(data); | ||
599 | return 0; | 597 | return 0; |
600 | } | 598 | } |
601 | 599 | ||
diff --git a/drivers/hwmon/mc13783-adc.c b/drivers/hwmon/mc13783-adc.c index ce86c5e3c2c2..cf47a59657a9 100644 --- a/drivers/hwmon/mc13783-adc.c +++ b/drivers/hwmon/mc13783-adc.c | |||
@@ -179,7 +179,7 @@ static int __init mc13783_adc_probe(struct platform_device *pdev) | |||
179 | const struct platform_device_id *id = platform_get_device_id(pdev); | 179 | const struct platform_device_id *id = platform_get_device_id(pdev); |
180 | char *dash; | 180 | char *dash; |
181 | 181 | ||
182 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 182 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); |
183 | if (!priv) | 183 | if (!priv) |
184 | return -ENOMEM; | 184 | return -ENOMEM; |
185 | 185 | ||
@@ -194,7 +194,7 @@ static int __init mc13783_adc_probe(struct platform_device *pdev) | |||
194 | /* Register sysfs hooks */ | 194 | /* Register sysfs hooks */ |
195 | ret = sysfs_create_group(&pdev->dev.kobj, &mc13783_group_base); | 195 | ret = sysfs_create_group(&pdev->dev.kobj, &mc13783_group_base); |
196 | if (ret) | 196 | if (ret) |
197 | goto out_err_create_base; | 197 | return ret; |
198 | 198 | ||
199 | if (id->driver_data & MC13783_ADC_16CHANS) { | 199 | if (id->driver_data & MC13783_ADC_16CHANS) { |
200 | ret = sysfs_create_group(&pdev->dev.kobj, | 200 | ret = sysfs_create_group(&pdev->dev.kobj, |
@@ -230,11 +230,6 @@ out_err_create_ts: | |||
230 | out_err_create_16chans: | 230 | out_err_create_16chans: |
231 | 231 | ||
232 | sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_base); | 232 | sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_base); |
233 | out_err_create_base: | ||
234 | |||
235 | platform_set_drvdata(pdev, NULL); | ||
236 | kfree(priv); | ||
237 | |||
238 | return ret; | 233 | return ret; |
239 | } | 234 | } |
240 | 235 | ||
@@ -253,9 +248,6 @@ static int __devexit mc13783_adc_remove(struct platform_device *pdev) | |||
253 | 248 | ||
254 | sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_base); | 249 | sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_base); |
255 | 250 | ||
256 | platform_set_drvdata(pdev, NULL); | ||
257 | kfree(priv); | ||
258 | |||
259 | return 0; | 251 | return 0; |
260 | } | 252 | } |
261 | 253 | ||
diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c index 6da9696e1827..74a6c58d0218 100644 --- a/drivers/hwmon/ntc_thermistor.c +++ b/drivers/hwmon/ntc_thermistor.c | |||
@@ -351,7 +351,7 @@ static int __devinit ntc_thermistor_probe(struct platform_device *pdev) | |||
351 | 351 | ||
352 | data->dev = &pdev->dev; | 352 | data->dev = &pdev->dev; |
353 | data->pdata = pdata; | 353 | data->pdata = pdata; |
354 | strncpy(data->name, pdev->id_entry->name, PLATFORM_NAME_SIZE); | 354 | strlcpy(data->name, pdev->id_entry->name, sizeof(data->name)); |
355 | 355 | ||
356 | switch (pdev->id_entry->driver_data) { | 356 | switch (pdev->id_entry->driver_data) { |
357 | case TYPE_NCPXXWB473: | 357 | case TYPE_NCPXXWB473: |
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index 79ba48c8c116..91d5b2a21dd9 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c | |||
@@ -1230,7 +1230,7 @@ static int __devinit pc87360_probe(struct platform_device *pdev) | |||
1230 | int use_thermistors = 0; | 1230 | int use_thermistors = 0; |
1231 | struct device *dev = &pdev->dev; | 1231 | struct device *dev = &pdev->dev; |
1232 | 1232 | ||
1233 | data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL); | 1233 | data = devm_kzalloc(dev, sizeof(struct pc87360_data), GFP_KERNEL); |
1234 | if (!data) | 1234 | if (!data) |
1235 | return -ENOMEM; | 1235 | return -ENOMEM; |
1236 | 1236 | ||
@@ -1269,15 +1269,12 @@ static int __devinit pc87360_probe(struct platform_device *pdev) | |||
1269 | for (i = 0; i < LDNI_MAX; i++) { | 1269 | for (i = 0; i < LDNI_MAX; i++) { |
1270 | data->address[i] = extra_isa[i]; | 1270 | data->address[i] = extra_isa[i]; |
1271 | if (data->address[i] | 1271 | if (data->address[i] |
1272 | && !request_region(extra_isa[i], PC87360_EXTENT, | 1272 | && !devm_request_region(dev, extra_isa[i], PC87360_EXTENT, |
1273 | pc87360_driver.driver.name)) { | 1273 | pc87360_driver.driver.name)) { |
1274 | dev_err(dev, "Region 0x%x-0x%x already " | 1274 | dev_err(dev, "Region 0x%x-0x%x already " |
1275 | "in use!\n", extra_isa[i], | 1275 | "in use!\n", extra_isa[i], |
1276 | extra_isa[i]+PC87360_EXTENT-1); | 1276 | extra_isa[i]+PC87360_EXTENT-1); |
1277 | for (i--; i >= 0; i--) | 1277 | return -EBUSY; |
1278 | release_region(extra_isa[i], PC87360_EXTENT); | ||
1279 | err = -EBUSY; | ||
1280 | goto ERROR1; | ||
1281 | } | 1278 | } |
1282 | } | 1279 | } |
1283 | 1280 | ||
@@ -1325,13 +1322,13 @@ static int __devinit pc87360_probe(struct platform_device *pdev) | |||
1325 | if (data->innr) { | 1322 | if (data->innr) { |
1326 | err = sysfs_create_group(&dev->kobj, &pc8736x_vin_group); | 1323 | err = sysfs_create_group(&dev->kobj, &pc8736x_vin_group); |
1327 | if (err) | 1324 | if (err) |
1328 | goto ERROR3; | 1325 | goto error; |
1329 | } | 1326 | } |
1330 | 1327 | ||
1331 | if (data->innr == 14) { | 1328 | if (data->innr == 14) { |
1332 | err = sysfs_create_group(&dev->kobj, &pc8736x_therm_group); | 1329 | err = sysfs_create_group(&dev->kobj, &pc8736x_therm_group); |
1333 | if (err) | 1330 | if (err) |
1334 | goto ERROR3; | 1331 | goto error; |
1335 | } | 1332 | } |
1336 | 1333 | ||
1337 | /* create device attr-files for varying sysfs groups */ | 1334 | /* create device attr-files for varying sysfs groups */ |
@@ -1341,11 +1338,11 @@ static int __devinit pc87360_probe(struct platform_device *pdev) | |||
1341 | err = sysfs_create_group(&dev->kobj, | 1338 | err = sysfs_create_group(&dev->kobj, |
1342 | &pc8736x_temp_attr_group[i]); | 1339 | &pc8736x_temp_attr_group[i]); |
1343 | if (err) | 1340 | if (err) |
1344 | goto ERROR3; | 1341 | goto error; |
1345 | } | 1342 | } |
1346 | err = device_create_file(dev, &dev_attr_alarms_temp); | 1343 | err = device_create_file(dev, &dev_attr_alarms_temp); |
1347 | if (err) | 1344 | if (err) |
1348 | goto ERROR3; | 1345 | goto error; |
1349 | } | 1346 | } |
1350 | 1347 | ||
1351 | for (i = 0; i < data->fannr; i++) { | 1348 | for (i = 0; i < data->fannr; i++) { |
@@ -1353,49 +1350,37 @@ static int __devinit pc87360_probe(struct platform_device *pdev) | |||
1353 | err = sysfs_create_group(&dev->kobj, | 1350 | err = sysfs_create_group(&dev->kobj, |
1354 | &pc8736x_fan_attr_group[i]); | 1351 | &pc8736x_fan_attr_group[i]); |
1355 | if (err) | 1352 | if (err) |
1356 | goto ERROR3; | 1353 | goto error; |
1357 | } | 1354 | } |
1358 | if (FAN_CONFIG_CONTROL(data->fan_conf, i)) { | 1355 | if (FAN_CONFIG_CONTROL(data->fan_conf, i)) { |
1359 | err = device_create_file(dev, &pwm[i].dev_attr); | 1356 | err = device_create_file(dev, &pwm[i].dev_attr); |
1360 | if (err) | 1357 | if (err) |
1361 | goto ERROR3; | 1358 | goto error; |
1362 | } | 1359 | } |
1363 | } | 1360 | } |
1364 | 1361 | ||
1365 | err = device_create_file(dev, &dev_attr_name); | 1362 | err = device_create_file(dev, &dev_attr_name); |
1366 | if (err) | 1363 | if (err) |
1367 | goto ERROR3; | 1364 | goto error; |
1368 | 1365 | ||
1369 | data->hwmon_dev = hwmon_device_register(dev); | 1366 | data->hwmon_dev = hwmon_device_register(dev); |
1370 | if (IS_ERR(data->hwmon_dev)) { | 1367 | if (IS_ERR(data->hwmon_dev)) { |
1371 | err = PTR_ERR(data->hwmon_dev); | 1368 | err = PTR_ERR(data->hwmon_dev); |
1372 | goto ERROR3; | 1369 | goto error; |
1373 | } | 1370 | } |
1374 | return 0; | 1371 | return 0; |
1375 | 1372 | ||
1376 | ERROR3: | 1373 | error: |
1377 | pc87360_remove_files(dev); | 1374 | pc87360_remove_files(dev); |
1378 | for (i = 0; i < 3; i++) { | ||
1379 | if (data->address[i]) | ||
1380 | release_region(data->address[i], PC87360_EXTENT); | ||
1381 | } | ||
1382 | ERROR1: | ||
1383 | kfree(data); | ||
1384 | return err; | 1375 | return err; |
1385 | } | 1376 | } |
1386 | 1377 | ||
1387 | static int __devexit pc87360_remove(struct platform_device *pdev) | 1378 | static int __devexit pc87360_remove(struct platform_device *pdev) |
1388 | { | 1379 | { |
1389 | struct pc87360_data *data = platform_get_drvdata(pdev); | 1380 | struct pc87360_data *data = platform_get_drvdata(pdev); |
1390 | int i; | ||
1391 | 1381 | ||
1392 | hwmon_device_unregister(data->hwmon_dev); | 1382 | hwmon_device_unregister(data->hwmon_dev); |
1393 | pc87360_remove_files(&pdev->dev); | 1383 | pc87360_remove_files(&pdev->dev); |
1394 | for (i = 0; i < 3; i++) { | ||
1395 | if (data->address[i]) | ||
1396 | release_region(data->address[i], PC87360_EXTENT); | ||
1397 | } | ||
1398 | kfree(data); | ||
1399 | 1384 | ||
1400 | return 0; | 1385 | return 0; |
1401 | } | 1386 | } |
diff --git a/drivers/hwmon/pc87427.c b/drivers/hwmon/pc87427.c index 37059a3755e9..f185b1fa53e5 100644 --- a/drivers/hwmon/pc87427.c +++ b/drivers/hwmon/pc87427.c | |||
@@ -956,44 +956,28 @@ static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | |||
956 | * Device detection, attach and detach | 956 | * Device detection, attach and detach |
957 | */ | 957 | */ |
958 | 958 | ||
959 | static void pc87427_release_regions(struct platform_device *pdev, int count) | ||
960 | { | ||
961 | struct resource *res; | ||
962 | int i; | ||
963 | |||
964 | for (i = 0; i < count; i++) { | ||
965 | res = platform_get_resource(pdev, IORESOURCE_IO, i); | ||
966 | release_region(res->start, resource_size(res)); | ||
967 | } | ||
968 | } | ||
969 | |||
970 | static int __devinit pc87427_request_regions(struct platform_device *pdev, | 959 | static int __devinit pc87427_request_regions(struct platform_device *pdev, |
971 | int count) | 960 | int count) |
972 | { | 961 | { |
973 | struct resource *res; | 962 | struct resource *res; |
974 | int i, err = 0; | 963 | int i; |
975 | 964 | ||
976 | for (i = 0; i < count; i++) { | 965 | for (i = 0; i < count; i++) { |
977 | res = platform_get_resource(pdev, IORESOURCE_IO, i); | 966 | res = platform_get_resource(pdev, IORESOURCE_IO, i); |
978 | if (!res) { | 967 | if (!res) { |
979 | err = -ENOENT; | ||
980 | dev_err(&pdev->dev, "Missing resource #%d\n", i); | 968 | dev_err(&pdev->dev, "Missing resource #%d\n", i); |
981 | break; | 969 | return -ENOENT; |
982 | } | 970 | } |
983 | if (!request_region(res->start, resource_size(res), DRVNAME)) { | 971 | if (!devm_request_region(&pdev->dev, res->start, |
984 | err = -EBUSY; | 972 | resource_size(res), DRVNAME)) { |
985 | dev_err(&pdev->dev, | 973 | dev_err(&pdev->dev, |
986 | "Failed to request region 0x%lx-0x%lx\n", | 974 | "Failed to request region 0x%lx-0x%lx\n", |
987 | (unsigned long)res->start, | 975 | (unsigned long)res->start, |
988 | (unsigned long)res->end); | 976 | (unsigned long)res->end); |
989 | break; | 977 | return -EBUSY; |
990 | } | 978 | } |
991 | } | 979 | } |
992 | 980 | return 0; | |
993 | if (err && i) | ||
994 | pc87427_release_regions(pdev, i); | ||
995 | |||
996 | return err; | ||
997 | } | 981 | } |
998 | 982 | ||
999 | static void __devinit pc87427_init_device(struct device *dev) | 983 | static void __devinit pc87427_init_device(struct device *dev) |
@@ -1094,11 +1078,11 @@ static int __devinit pc87427_probe(struct platform_device *pdev) | |||
1094 | struct pc87427_data *data; | 1078 | struct pc87427_data *data; |
1095 | int i, err, res_count; | 1079 | int i, err, res_count; |
1096 | 1080 | ||
1097 | data = kzalloc(sizeof(struct pc87427_data), GFP_KERNEL); | 1081 | data = devm_kzalloc(&pdev->dev, sizeof(struct pc87427_data), |
1082 | GFP_KERNEL); | ||
1098 | if (!data) { | 1083 | if (!data) { |
1099 | err = -ENOMEM; | ||
1100 | pr_err("Out of memory\n"); | 1084 | pr_err("Out of memory\n"); |
1101 | goto exit; | 1085 | return -ENOMEM; |
1102 | } | 1086 | } |
1103 | 1087 | ||
1104 | data->address[0] = sio_data->address[0]; | 1088 | data->address[0] = sio_data->address[0]; |
@@ -1107,7 +1091,7 @@ static int __devinit pc87427_probe(struct platform_device *pdev) | |||
1107 | 1091 | ||
1108 | err = pc87427_request_regions(pdev, res_count); | 1092 | err = pc87427_request_regions(pdev, res_count); |
1109 | if (err) | 1093 | if (err) |
1110 | goto exit_kfree; | 1094 | return err; |
1111 | 1095 | ||
1112 | mutex_init(&data->lock); | 1096 | mutex_init(&data->lock); |
1113 | data->name = "pc87427"; | 1097 | data->name = "pc87427"; |
@@ -1117,7 +1101,7 @@ static int __devinit pc87427_probe(struct platform_device *pdev) | |||
1117 | /* Register sysfs hooks */ | 1101 | /* Register sysfs hooks */ |
1118 | err = device_create_file(&pdev->dev, &dev_attr_name); | 1102 | err = device_create_file(&pdev->dev, &dev_attr_name); |
1119 | if (err) | 1103 | if (err) |
1120 | goto exit_release_region; | 1104 | return err; |
1121 | for (i = 0; i < 8; i++) { | 1105 | for (i = 0; i < 8; i++) { |
1122 | if (!(data->fan_enabled & (1 << i))) | 1106 | if (!(data->fan_enabled & (1 << i))) |
1123 | continue; | 1107 | continue; |
@@ -1154,28 +1138,15 @@ static int __devinit pc87427_probe(struct platform_device *pdev) | |||
1154 | 1138 | ||
1155 | exit_remove_files: | 1139 | exit_remove_files: |
1156 | pc87427_remove_files(&pdev->dev); | 1140 | pc87427_remove_files(&pdev->dev); |
1157 | exit_release_region: | ||
1158 | pc87427_release_regions(pdev, res_count); | ||
1159 | exit_kfree: | ||
1160 | platform_set_drvdata(pdev, NULL); | ||
1161 | kfree(data); | ||
1162 | exit: | ||
1163 | return err; | 1141 | return err; |
1164 | } | 1142 | } |
1165 | 1143 | ||
1166 | static int __devexit pc87427_remove(struct platform_device *pdev) | 1144 | static int __devexit pc87427_remove(struct platform_device *pdev) |
1167 | { | 1145 | { |
1168 | struct pc87427_data *data = platform_get_drvdata(pdev); | 1146 | struct pc87427_data *data = platform_get_drvdata(pdev); |
1169 | int res_count; | ||
1170 | |||
1171 | res_count = (data->address[0] != 0) + (data->address[1] != 0); | ||
1172 | 1147 | ||
1173 | hwmon_device_unregister(data->hwmon_dev); | 1148 | hwmon_device_unregister(data->hwmon_dev); |
1174 | pc87427_remove_files(&pdev->dev); | 1149 | pc87427_remove_files(&pdev->dev); |
1175 | platform_set_drvdata(pdev, NULL); | ||
1176 | kfree(data); | ||
1177 | |||
1178 | pc87427_release_regions(pdev, res_count); | ||
1179 | 1150 | ||
1180 | return 0; | 1151 | return 0; |
1181 | } | 1152 | } |
diff --git a/drivers/hwmon/pcf8591.c b/drivers/hwmon/pcf8591.c index 4174c7463d70..825883d29002 100644 --- a/drivers/hwmon/pcf8591.c +++ b/drivers/hwmon/pcf8591.c | |||
@@ -200,11 +200,10 @@ static int pcf8591_probe(struct i2c_client *client, | |||
200 | struct pcf8591_data *data; | 200 | struct pcf8591_data *data; |
201 | int err; | 201 | int err; |
202 | 202 | ||
203 | data = kzalloc(sizeof(struct pcf8591_data), GFP_KERNEL); | 203 | data = devm_kzalloc(&client->dev, sizeof(struct pcf8591_data), |
204 | if (!data) { | 204 | GFP_KERNEL); |
205 | err = -ENOMEM; | 205 | if (!data) |
206 | goto exit; | 206 | return -ENOMEM; |
207 | } | ||
208 | 207 | ||
209 | i2c_set_clientdata(client, data); | 208 | i2c_set_clientdata(client, data); |
210 | mutex_init(&data->update_lock); | 209 | mutex_init(&data->update_lock); |
@@ -215,7 +214,7 @@ static int pcf8591_probe(struct i2c_client *client, | |||
215 | /* Register sysfs hooks */ | 214 | /* Register sysfs hooks */ |
216 | err = sysfs_create_group(&client->dev.kobj, &pcf8591_attr_group); | 215 | err = sysfs_create_group(&client->dev.kobj, &pcf8591_attr_group); |
217 | if (err) | 216 | if (err) |
218 | goto exit_kfree; | 217 | return err; |
219 | 218 | ||
220 | /* Register input2 if not in "two differential inputs" mode */ | 219 | /* Register input2 if not in "two differential inputs" mode */ |
221 | if (input_mode != 3) { | 220 | if (input_mode != 3) { |
@@ -242,9 +241,6 @@ static int pcf8591_probe(struct i2c_client *client, | |||
242 | exit_sysfs_remove: | 241 | exit_sysfs_remove: |
243 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt); | 242 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt); |
244 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group); | 243 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group); |
245 | exit_kfree: | ||
246 | kfree(data); | ||
247 | exit: | ||
248 | return err; | 244 | return err; |
249 | } | 245 | } |
250 | 246 | ||
@@ -255,7 +251,6 @@ static int pcf8591_remove(struct i2c_client *client) | |||
255 | hwmon_device_unregister(data->hwmon_dev); | 251 | hwmon_device_unregister(data->hwmon_dev); |
256 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt); | 252 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt); |
257 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group); | 253 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group); |
258 | kfree(i2c_get_clientdata(client)); | ||
259 | return 0; | 254 | return 0; |
260 | } | 255 | } |
261 | 256 | ||
diff --git a/drivers/hwmon/s3c-hwmon.c b/drivers/hwmon/s3c-hwmon.c index f6c26d19f521..b7975f858cff 100644 --- a/drivers/hwmon/s3c-hwmon.c +++ b/drivers/hwmon/s3c-hwmon.c | |||
@@ -288,7 +288,7 @@ static int __devinit s3c_hwmon_probe(struct platform_device *dev) | |||
288 | return -EINVAL; | 288 | return -EINVAL; |
289 | } | 289 | } |
290 | 290 | ||
291 | hwmon = kzalloc(sizeof(struct s3c_hwmon), GFP_KERNEL); | 291 | hwmon = devm_kzalloc(&dev->dev, sizeof(struct s3c_hwmon), GFP_KERNEL); |
292 | if (hwmon == NULL) { | 292 | if (hwmon == NULL) { |
293 | dev_err(&dev->dev, "no memory\n"); | 293 | dev_err(&dev->dev, "no memory\n"); |
294 | return -ENOMEM; | 294 | return -ENOMEM; |
@@ -303,8 +303,7 @@ static int __devinit s3c_hwmon_probe(struct platform_device *dev) | |||
303 | hwmon->client = s3c_adc_register(dev, NULL, NULL, 0); | 303 | hwmon->client = s3c_adc_register(dev, NULL, NULL, 0); |
304 | if (IS_ERR(hwmon->client)) { | 304 | if (IS_ERR(hwmon->client)) { |
305 | dev_err(&dev->dev, "cannot register adc\n"); | 305 | dev_err(&dev->dev, "cannot register adc\n"); |
306 | ret = PTR_ERR(hwmon->client); | 306 | return PTR_ERR(hwmon->client); |
307 | goto err_mem; | ||
308 | } | 307 | } |
309 | 308 | ||
310 | /* add attributes for our adc devices. */ | 309 | /* add attributes for our adc devices. */ |
@@ -363,8 +362,6 @@ static int __devinit s3c_hwmon_probe(struct platform_device *dev) | |||
363 | err_registered: | 362 | err_registered: |
364 | s3c_adc_release(hwmon->client); | 363 | s3c_adc_release(hwmon->client); |
365 | 364 | ||
366 | err_mem: | ||
367 | kfree(hwmon); | ||
368 | return ret; | 365 | return ret; |
369 | } | 366 | } |
370 | 367 | ||
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 6c4d8eb9b7ca..8275f0e14eb7 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c | |||
@@ -593,17 +593,14 @@ static int __devinit sis5595_probe(struct platform_device *pdev) | |||
593 | 593 | ||
594 | /* Reserve the ISA region */ | 594 | /* Reserve the ISA region */ |
595 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 595 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
596 | if (!request_region(res->start, SIS5595_EXTENT, | 596 | if (!devm_request_region(&pdev->dev, res->start, SIS5595_EXTENT, |
597 | sis5595_driver.driver.name)) { | 597 | sis5595_driver.driver.name)) |
598 | err = -EBUSY; | 598 | return -EBUSY; |
599 | goto exit; | ||
600 | } | ||
601 | 599 | ||
602 | data = kzalloc(sizeof(struct sis5595_data), GFP_KERNEL); | 600 | data = devm_kzalloc(&pdev->dev, sizeof(struct sis5595_data), |
603 | if (!data) { | 601 | GFP_KERNEL); |
604 | err = -ENOMEM; | 602 | if (!data) |
605 | goto exit_release; | 603 | return -ENOMEM; |
606 | } | ||
607 | 604 | ||
608 | mutex_init(&data->lock); | 605 | mutex_init(&data->lock); |
609 | mutex_init(&data->update_lock); | 606 | mutex_init(&data->update_lock); |
@@ -636,7 +633,7 @@ static int __devinit sis5595_probe(struct platform_device *pdev) | |||
636 | /* Register sysfs hooks */ | 633 | /* Register sysfs hooks */ |
637 | err = sysfs_create_group(&pdev->dev.kobj, &sis5595_group); | 634 | err = sysfs_create_group(&pdev->dev.kobj, &sis5595_group); |
638 | if (err) | 635 | if (err) |
639 | goto exit_free; | 636 | return err; |
640 | if (data->maxins == 4) { | 637 | if (data->maxins == 4) { |
641 | err = sysfs_create_group(&pdev->dev.kobj, &sis5595_group_in4); | 638 | err = sysfs_create_group(&pdev->dev.kobj, &sis5595_group_in4); |
642 | if (err) | 639 | if (err) |
@@ -659,11 +656,6 @@ exit_remove_files: | |||
659 | sysfs_remove_group(&pdev->dev.kobj, &sis5595_group); | 656 | sysfs_remove_group(&pdev->dev.kobj, &sis5595_group); |
660 | sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_in4); | 657 | sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_in4); |
661 | sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_temp1); | 658 | sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_temp1); |
662 | exit_free: | ||
663 | kfree(data); | ||
664 | exit_release: | ||
665 | release_region(res->start, SIS5595_EXTENT); | ||
666 | exit: | ||
667 | return err; | 659 | return err; |
668 | } | 660 | } |
669 | 661 | ||
@@ -676,10 +668,6 @@ static int __devexit sis5595_remove(struct platform_device *pdev) | |||
676 | sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_in4); | 668 | sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_in4); |
677 | sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_temp1); | 669 | sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_temp1); |
678 | 670 | ||
679 | release_region(data->addr, SIS5595_EXTENT); | ||
680 | platform_set_drvdata(pdev, NULL); | ||
681 | kfree(data); | ||
682 | |||
683 | return 0; | 671 | return 0; |
684 | } | 672 | } |
685 | 673 | ||
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index c5f6be478bad..65b07de11a0f 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c | |||
@@ -231,13 +231,9 @@ static const struct attribute_group smsc47b397_group = { | |||
231 | static int __devexit smsc47b397_remove(struct platform_device *pdev) | 231 | static int __devexit smsc47b397_remove(struct platform_device *pdev) |
232 | { | 232 | { |
233 | struct smsc47b397_data *data = platform_get_drvdata(pdev); | 233 | struct smsc47b397_data *data = platform_get_drvdata(pdev); |
234 | struct resource *res; | ||
235 | 234 | ||
236 | hwmon_device_unregister(data->hwmon_dev); | 235 | hwmon_device_unregister(data->hwmon_dev); |
237 | sysfs_remove_group(&pdev->dev.kobj, &smsc47b397_group); | 236 | sysfs_remove_group(&pdev->dev.kobj, &smsc47b397_group); |
238 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
239 | release_region(res->start, SMSC_EXTENT); | ||
240 | kfree(data); | ||
241 | 237 | ||
242 | return 0; | 238 | return 0; |
243 | } | 239 | } |
@@ -261,19 +257,17 @@ static int __devinit smsc47b397_probe(struct platform_device *pdev) | |||
261 | int err = 0; | 257 | int err = 0; |
262 | 258 | ||
263 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 259 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
264 | if (!request_region(res->start, SMSC_EXTENT, | 260 | if (!devm_request_region(dev, res->start, SMSC_EXTENT, |
265 | smsc47b397_driver.driver.name)) { | 261 | smsc47b397_driver.driver.name)) { |
266 | dev_err(dev, "Region 0x%lx-0x%lx already in use!\n", | 262 | dev_err(dev, "Region 0x%lx-0x%lx already in use!\n", |
267 | (unsigned long)res->start, | 263 | (unsigned long)res->start, |
268 | (unsigned long)res->start + SMSC_EXTENT - 1); | 264 | (unsigned long)res->start + SMSC_EXTENT - 1); |
269 | return -EBUSY; | 265 | return -EBUSY; |
270 | } | 266 | } |
271 | 267 | ||
272 | data = kzalloc(sizeof(struct smsc47b397_data), GFP_KERNEL); | 268 | data = devm_kzalloc(dev, sizeof(struct smsc47b397_data), GFP_KERNEL); |
273 | if (!data) { | 269 | if (!data) |
274 | err = -ENOMEM; | 270 | return -ENOMEM; |
275 | goto error_release; | ||
276 | } | ||
277 | 271 | ||
278 | data->addr = res->start; | 272 | data->addr = res->start; |
279 | data->name = "smsc47b397"; | 273 | data->name = "smsc47b397"; |
@@ -283,7 +277,7 @@ static int __devinit smsc47b397_probe(struct platform_device *pdev) | |||
283 | 277 | ||
284 | err = sysfs_create_group(&dev->kobj, &smsc47b397_group); | 278 | err = sysfs_create_group(&dev->kobj, &smsc47b397_group); |
285 | if (err) | 279 | if (err) |
286 | goto error_free; | 280 | return err; |
287 | 281 | ||
288 | data->hwmon_dev = hwmon_device_register(dev); | 282 | data->hwmon_dev = hwmon_device_register(dev); |
289 | if (IS_ERR(data->hwmon_dev)) { | 283 | if (IS_ERR(data->hwmon_dev)) { |
@@ -295,10 +289,6 @@ static int __devinit smsc47b397_probe(struct platform_device *pdev) | |||
295 | 289 | ||
296 | error_remove: | 290 | error_remove: |
297 | sysfs_remove_group(&dev->kobj, &smsc47b397_group); | 291 | sysfs_remove_group(&dev->kobj, &smsc47b397_group); |
298 | error_free: | ||
299 | kfree(data); | ||
300 | error_release: | ||
301 | release_region(res->start, SMSC_EXTENT); | ||
302 | return err; | 292 | return err; |
303 | } | 293 | } |
304 | 294 | ||
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index b5aa38dd7ab9..dba0c567e7a1 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c | |||
@@ -584,18 +584,17 @@ static void smsc47m1_restore(const struct smsc47m1_sio_data *sio_data) | |||
584 | 584 | ||
585 | #define CHECK 1 | 585 | #define CHECK 1 |
586 | #define REQUEST 2 | 586 | #define REQUEST 2 |
587 | #define RELEASE 3 | ||
588 | 587 | ||
589 | /* | 588 | /* |
590 | * This function can be used to: | 589 | * This function can be used to: |
591 | * - test for resource conflicts with ACPI | 590 | * - test for resource conflicts with ACPI |
592 | * - request the resources | 591 | * - request the resources |
593 | * - release the resources | ||
594 | * We only allocate the I/O ports we really need, to minimize the risk of | 592 | * We only allocate the I/O ports we really need, to minimize the risk of |
595 | * conflicts with ACPI or with other drivers. | 593 | * conflicts with ACPI or with other drivers. |
596 | */ | 594 | */ |
597 | static int smsc47m1_handle_resources(unsigned short address, enum chips type, | 595 | static int __init smsc47m1_handle_resources(unsigned short address, |
598 | int action, struct device *dev) | 596 | enum chips type, int action, |
597 | struct device *dev) | ||
599 | { | 598 | { |
600 | static const u8 ports_m1[] = { | 599 | static const u8 ports_m1[] = { |
601 | /* register, region length */ | 600 | /* register, region length */ |
@@ -642,21 +641,13 @@ static int smsc47m1_handle_resources(unsigned short address, enum chips type, | |||
642 | break; | 641 | break; |
643 | case REQUEST: | 642 | case REQUEST: |
644 | /* Request the resources */ | 643 | /* Request the resources */ |
645 | if (!request_region(start, len, DRVNAME)) { | 644 | if (!devm_request_region(dev, start, len, DRVNAME)) { |
646 | dev_err(dev, "Region 0x%hx-0x%hx already in " | 645 | dev_err(dev, |
647 | "use!\n", start, start + len); | 646 | "Region 0x%hx-0x%hx already in use!\n", |
648 | 647 | start, start + len); | |
649 | /* Undo all requests */ | ||
650 | for (i -= 2; i >= 0; i -= 2) | ||
651 | release_region(address + ports[i], | ||
652 | ports[i + 1]); | ||
653 | return -EBUSY; | 648 | return -EBUSY; |
654 | } | 649 | } |
655 | break; | 650 | break; |
656 | case RELEASE: | ||
657 | /* Release the resources */ | ||
658 | release_region(start, len); | ||
659 | break; | ||
660 | } | 651 | } |
661 | } | 652 | } |
662 | 653 | ||
@@ -694,11 +685,9 @@ static int __init smsc47m1_probe(struct platform_device *pdev) | |||
694 | if (err < 0) | 685 | if (err < 0) |
695 | return err; | 686 | return err; |
696 | 687 | ||
697 | data = kzalloc(sizeof(struct smsc47m1_data), GFP_KERNEL); | 688 | data = devm_kzalloc(dev, sizeof(struct smsc47m1_data), GFP_KERNEL); |
698 | if (!data) { | 689 | if (!data) |
699 | err = -ENOMEM; | 690 | return -ENOMEM; |
700 | goto error_release; | ||
701 | } | ||
702 | 691 | ||
703 | data->addr = res->start; | 692 | data->addr = res->start; |
704 | data->type = sio_data->type; | 693 | data->type = sio_data->type; |
@@ -733,8 +722,7 @@ static int __init smsc47m1_probe(struct platform_device *pdev) | |||
733 | } | 722 | } |
734 | if (!(fan1 || fan2 || fan3 || pwm1 || pwm2 || pwm3)) { | 723 | if (!(fan1 || fan2 || fan3 || pwm1 || pwm2 || pwm3)) { |
735 | dev_warn(dev, "Device not configured, will not use\n"); | 724 | dev_warn(dev, "Device not configured, will not use\n"); |
736 | err = -ENODEV; | 725 | return -ENODEV; |
737 | goto error_free; | ||
738 | } | 726 | } |
739 | 727 | ||
740 | /* | 728 | /* |
@@ -810,27 +798,16 @@ static int __init smsc47m1_probe(struct platform_device *pdev) | |||
810 | 798 | ||
811 | error_remove_files: | 799 | error_remove_files: |
812 | smsc47m1_remove_files(dev); | 800 | smsc47m1_remove_files(dev); |
813 | error_free: | ||
814 | platform_set_drvdata(pdev, NULL); | ||
815 | kfree(data); | ||
816 | error_release: | ||
817 | smsc47m1_handle_resources(res->start, sio_data->type, RELEASE, dev); | ||
818 | return err; | 801 | return err; |
819 | } | 802 | } |
820 | 803 | ||
821 | static int __exit smsc47m1_remove(struct platform_device *pdev) | 804 | static int __exit smsc47m1_remove(struct platform_device *pdev) |
822 | { | 805 | { |
823 | struct smsc47m1_data *data = platform_get_drvdata(pdev); | 806 | struct smsc47m1_data *data = platform_get_drvdata(pdev); |
824 | struct resource *res; | ||
825 | 807 | ||
826 | hwmon_device_unregister(data->hwmon_dev); | 808 | hwmon_device_unregister(data->hwmon_dev); |
827 | smsc47m1_remove_files(&pdev->dev); | 809 | smsc47m1_remove_files(&pdev->dev); |
828 | 810 | ||
829 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
830 | smsc47m1_handle_resources(res->start, data->type, RELEASE, &pdev->dev); | ||
831 | platform_set_drvdata(pdev, NULL); | ||
832 | kfree(data); | ||
833 | |||
834 | return 0; | 811 | return 0; |
835 | } | 812 | } |
836 | 813 | ||
diff --git a/drivers/hwmon/smsc47m192.c b/drivers/hwmon/smsc47m192.c index 4705a8bf11c2..36a3478d0799 100644 --- a/drivers/hwmon/smsc47m192.c +++ b/drivers/hwmon/smsc47m192.c | |||
@@ -554,11 +554,10 @@ static int smsc47m192_probe(struct i2c_client *client, | |||
554 | int config; | 554 | int config; |
555 | int err; | 555 | int err; |
556 | 556 | ||
557 | data = kzalloc(sizeof(struct smsc47m192_data), GFP_KERNEL); | 557 | data = devm_kzalloc(&client->dev, sizeof(struct smsc47m192_data), |
558 | if (!data) { | 558 | GFP_KERNEL); |
559 | err = -ENOMEM; | 559 | if (!data) |
560 | goto exit; | 560 | return -ENOMEM; |
561 | } | ||
562 | 561 | ||
563 | i2c_set_clientdata(client, data); | 562 | i2c_set_clientdata(client, data); |
564 | data->vrm = vid_which_vrm(); | 563 | data->vrm = vid_which_vrm(); |
@@ -570,7 +569,7 @@ static int smsc47m192_probe(struct i2c_client *client, | |||
570 | /* Register sysfs hooks */ | 569 | /* Register sysfs hooks */ |
571 | err = sysfs_create_group(&client->dev.kobj, &smsc47m192_group); | 570 | err = sysfs_create_group(&client->dev.kobj, &smsc47m192_group); |
572 | if (err) | 571 | if (err) |
573 | goto exit_free; | 572 | return err; |
574 | 573 | ||
575 | /* Pin 110 is either in4 (+12V) or VID4 */ | 574 | /* Pin 110 is either in4 (+12V) or VID4 */ |
576 | config = i2c_smbus_read_byte_data(client, SMSC47M192_REG_CONFIG); | 575 | config = i2c_smbus_read_byte_data(client, SMSC47M192_REG_CONFIG); |
@@ -592,9 +591,6 @@ static int smsc47m192_probe(struct i2c_client *client, | |||
592 | exit_remove_files: | 591 | exit_remove_files: |
593 | sysfs_remove_group(&client->dev.kobj, &smsc47m192_group); | 592 | sysfs_remove_group(&client->dev.kobj, &smsc47m192_group); |
594 | sysfs_remove_group(&client->dev.kobj, &smsc47m192_group_in4); | 593 | sysfs_remove_group(&client->dev.kobj, &smsc47m192_group_in4); |
595 | exit_free: | ||
596 | kfree(data); | ||
597 | exit: | ||
598 | return err; | 594 | return err; |
599 | } | 595 | } |
600 | 596 | ||
@@ -606,8 +602,6 @@ static int smsc47m192_remove(struct i2c_client *client) | |||
606 | sysfs_remove_group(&client->dev.kobj, &smsc47m192_group); | 602 | sysfs_remove_group(&client->dev.kobj, &smsc47m192_group); |
607 | sysfs_remove_group(&client->dev.kobj, &smsc47m192_group_in4); | 603 | sysfs_remove_group(&client->dev.kobj, &smsc47m192_group_in4); |
608 | 604 | ||
609 | kfree(data); | ||
610 | |||
611 | return 0; | 605 | return 0; |
612 | } | 606 | } |
613 | 607 | ||
diff --git a/drivers/hwmon/thmc50.c b/drivers/hwmon/thmc50.c index add9f019b24f..080c26370480 100644 --- a/drivers/hwmon/thmc50.c +++ b/drivers/hwmon/thmc50.c | |||
@@ -361,12 +361,10 @@ static int thmc50_probe(struct i2c_client *client, | |||
361 | struct thmc50_data *data; | 361 | struct thmc50_data *data; |
362 | int err; | 362 | int err; |
363 | 363 | ||
364 | data = kzalloc(sizeof(struct thmc50_data), GFP_KERNEL); | 364 | data = devm_kzalloc(&client->dev, sizeof(struct thmc50_data), |
365 | if (!data) { | 365 | GFP_KERNEL); |
366 | pr_debug("thmc50: detect failed, kzalloc failed!\n"); | 366 | if (!data) |
367 | err = -ENOMEM; | 367 | return -ENOMEM; |
368 | goto exit; | ||
369 | } | ||
370 | 368 | ||
371 | i2c_set_clientdata(client, data); | 369 | i2c_set_clientdata(client, data); |
372 | data->type = id->driver_data; | 370 | data->type = id->driver_data; |
@@ -377,7 +375,7 @@ static int thmc50_probe(struct i2c_client *client, | |||
377 | /* Register sysfs hooks */ | 375 | /* Register sysfs hooks */ |
378 | err = sysfs_create_group(&client->dev.kobj, &thmc50_group); | 376 | err = sysfs_create_group(&client->dev.kobj, &thmc50_group); |
379 | if (err) | 377 | if (err) |
380 | goto exit_free; | 378 | return err; |
381 | 379 | ||
382 | /* Register ADM1022 sysfs hooks */ | 380 | /* Register ADM1022 sysfs hooks */ |
383 | if (data->has_temp3) { | 381 | if (data->has_temp3) { |
@@ -400,9 +398,6 @@ exit_remove_sysfs: | |||
400 | sysfs_remove_group(&client->dev.kobj, &temp3_group); | 398 | sysfs_remove_group(&client->dev.kobj, &temp3_group); |
401 | exit_remove_sysfs_thmc50: | 399 | exit_remove_sysfs_thmc50: |
402 | sysfs_remove_group(&client->dev.kobj, &thmc50_group); | 400 | sysfs_remove_group(&client->dev.kobj, &thmc50_group); |
403 | exit_free: | ||
404 | kfree(data); | ||
405 | exit: | ||
406 | return err; | 401 | return err; |
407 | } | 402 | } |
408 | 403 | ||
@@ -415,8 +410,6 @@ static int thmc50_remove(struct i2c_client *client) | |||
415 | if (data->has_temp3) | 410 | if (data->has_temp3) |
416 | sysfs_remove_group(&client->dev.kobj, &temp3_group); | 411 | sysfs_remove_group(&client->dev.kobj, &temp3_group); |
417 | 412 | ||
418 | kfree(data); | ||
419 | |||
420 | return 0; | 413 | return 0; |
421 | } | 414 | } |
422 | 415 | ||
diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c index 0d466b9d8908..4e1ff82c63e0 100644 --- a/drivers/hwmon/tmp102.c +++ b/drivers/hwmon/tmp102.c | |||
@@ -159,17 +159,16 @@ static int __devinit tmp102_probe(struct i2c_client *client, | |||
159 | return -ENODEV; | 159 | return -ENODEV; |
160 | } | 160 | } |
161 | 161 | ||
162 | tmp102 = kzalloc(sizeof(*tmp102), GFP_KERNEL); | 162 | tmp102 = devm_kzalloc(&client->dev, sizeof(*tmp102), GFP_KERNEL); |
163 | if (!tmp102) { | 163 | if (!tmp102) |
164 | dev_dbg(&client->dev, "kzalloc failed\n"); | ||
165 | return -ENOMEM; | 164 | return -ENOMEM; |
166 | } | 165 | |
167 | i2c_set_clientdata(client, tmp102); | 166 | i2c_set_clientdata(client, tmp102); |
168 | 167 | ||
169 | status = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG); | 168 | status = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG); |
170 | if (status < 0) { | 169 | if (status < 0) { |
171 | dev_err(&client->dev, "error reading config register\n"); | 170 | dev_err(&client->dev, "error reading config register\n"); |
172 | goto fail_free; | 171 | return status; |
173 | } | 172 | } |
174 | tmp102->config_orig = status; | 173 | tmp102->config_orig = status; |
175 | status = i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, | 174 | status = i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, |
@@ -213,9 +212,6 @@ fail_remove_sysfs: | |||
213 | fail_restore_config: | 212 | fail_restore_config: |
214 | i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, | 213 | i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, |
215 | tmp102->config_orig); | 214 | tmp102->config_orig); |
216 | fail_free: | ||
217 | kfree(tmp102); | ||
218 | |||
219 | return status; | 215 | return status; |
220 | } | 216 | } |
221 | 217 | ||
@@ -236,8 +232,6 @@ static int __devexit tmp102_remove(struct i2c_client *client) | |||
236 | config | TMP102_CONF_SD); | 232 | config | TMP102_CONF_SD); |
237 | } | 233 | } |
238 | 234 | ||
239 | kfree(tmp102); | ||
240 | |||
241 | return 0; | 235 | return 0; |
242 | } | 236 | } |
243 | 237 | ||
diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c index ea54c3384671..e62054875164 100644 --- a/drivers/hwmon/tmp401.c +++ b/drivers/hwmon/tmp401.c | |||
@@ -594,7 +594,6 @@ static int tmp401_remove(struct i2c_client *client) | |||
594 | &tmp411_attr[i].dev_attr); | 594 | &tmp411_attr[i].dev_attr); |
595 | } | 595 | } |
596 | 596 | ||
597 | kfree(data); | ||
598 | return 0; | 597 | return 0; |
599 | } | 598 | } |
600 | 599 | ||
@@ -605,7 +604,8 @@ static int tmp401_probe(struct i2c_client *client, | |||
605 | struct tmp401_data *data; | 604 | struct tmp401_data *data; |
606 | const char *names[] = { "TMP401", "TMP411" }; | 605 | const char *names[] = { "TMP401", "TMP411" }; |
607 | 606 | ||
608 | data = kzalloc(sizeof(struct tmp401_data), GFP_KERNEL); | 607 | data = devm_kzalloc(&client->dev, sizeof(struct tmp401_data), |
608 | GFP_KERNEL); | ||
609 | if (!data) | 609 | if (!data) |
610 | return -ENOMEM; | 610 | return -ENOMEM; |
611 | 611 | ||
@@ -646,7 +646,7 @@ static int tmp401_probe(struct i2c_client *client, | |||
646 | return 0; | 646 | return 0; |
647 | 647 | ||
648 | exit_remove: | 648 | exit_remove: |
649 | tmp401_remove(client); /* will also free data for us */ | 649 | tmp401_remove(client); |
650 | return err; | 650 | return err; |
651 | } | 651 | } |
652 | 652 | ||
diff --git a/drivers/hwmon/tmp421.c b/drivers/hwmon/tmp421.c index 8fac87a38544..6a8ded29f1ed 100644 --- a/drivers/hwmon/tmp421.c +++ b/drivers/hwmon/tmp421.c | |||
@@ -267,7 +267,8 @@ static int tmp421_probe(struct i2c_client *client, | |||
267 | struct tmp421_data *data; | 267 | struct tmp421_data *data; |
268 | int err; | 268 | int err; |
269 | 269 | ||
270 | data = kzalloc(sizeof(struct tmp421_data), GFP_KERNEL); | 270 | data = devm_kzalloc(&client->dev, sizeof(struct tmp421_data), |
271 | GFP_KERNEL); | ||
271 | if (!data) | 272 | if (!data) |
272 | return -ENOMEM; | 273 | return -ENOMEM; |
273 | 274 | ||
@@ -277,11 +278,11 @@ static int tmp421_probe(struct i2c_client *client, | |||
277 | 278 | ||
278 | err = tmp421_init_client(client); | 279 | err = tmp421_init_client(client); |
279 | if (err) | 280 | if (err) |
280 | goto exit_free; | 281 | return err; |
281 | 282 | ||
282 | err = sysfs_create_group(&client->dev.kobj, &tmp421_group); | 283 | err = sysfs_create_group(&client->dev.kobj, &tmp421_group); |
283 | if (err) | 284 | if (err) |
284 | goto exit_free; | 285 | return err; |
285 | 286 | ||
286 | data->hwmon_dev = hwmon_device_register(&client->dev); | 287 | data->hwmon_dev = hwmon_device_register(&client->dev); |
287 | if (IS_ERR(data->hwmon_dev)) { | 288 | if (IS_ERR(data->hwmon_dev)) { |
@@ -293,10 +294,6 @@ static int tmp421_probe(struct i2c_client *client, | |||
293 | 294 | ||
294 | exit_remove: | 295 | exit_remove: |
295 | sysfs_remove_group(&client->dev.kobj, &tmp421_group); | 296 | sysfs_remove_group(&client->dev.kobj, &tmp421_group); |
296 | |||
297 | exit_free: | ||
298 | kfree(data); | ||
299 | |||
300 | return err; | 297 | return err; |
301 | } | 298 | } |
302 | 299 | ||
@@ -307,8 +304,6 @@ static int tmp421_remove(struct i2c_client *client) | |||
307 | hwmon_device_unregister(data->hwmon_dev); | 304 | hwmon_device_unregister(data->hwmon_dev); |
308 | sysfs_remove_group(&client->dev.kobj, &tmp421_group); | 305 | sysfs_remove_group(&client->dev.kobj, &tmp421_group); |
309 | 306 | ||
310 | kfree(data); | ||
311 | |||
312 | return 0; | 307 | return 0; |
313 | } | 308 | } |
314 | 309 | ||
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index 288135d85e11..299399aa30fe 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c | |||
@@ -690,18 +690,17 @@ static int __devinit via686a_probe(struct platform_device *pdev) | |||
690 | 690 | ||
691 | /* Reserve the ISA region */ | 691 | /* Reserve the ISA region */ |
692 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 692 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
693 | if (!request_region(res->start, VIA686A_EXTENT, | 693 | if (!devm_request_region(&pdev->dev, res->start, VIA686A_EXTENT, |
694 | via686a_driver.driver.name)) { | 694 | via686a_driver.driver.name)) { |
695 | dev_err(&pdev->dev, "Region 0x%lx-0x%lx already in use!\n", | 695 | dev_err(&pdev->dev, "Region 0x%lx-0x%lx already in use!\n", |
696 | (unsigned long)res->start, (unsigned long)res->end); | 696 | (unsigned long)res->start, (unsigned long)res->end); |
697 | return -ENODEV; | 697 | return -ENODEV; |
698 | } | 698 | } |
699 | 699 | ||
700 | data = kzalloc(sizeof(struct via686a_data), GFP_KERNEL); | 700 | data = devm_kzalloc(&pdev->dev, sizeof(struct via686a_data), |
701 | if (!data) { | 701 | GFP_KERNEL); |
702 | err = -ENOMEM; | 702 | if (!data) |
703 | goto exit_release; | 703 | return -ENOMEM; |
704 | } | ||
705 | 704 | ||
706 | platform_set_drvdata(pdev, data); | 705 | platform_set_drvdata(pdev, data); |
707 | data->addr = res->start; | 706 | data->addr = res->start; |
@@ -714,7 +713,7 @@ static int __devinit via686a_probe(struct platform_device *pdev) | |||
714 | /* Register sysfs hooks */ | 713 | /* Register sysfs hooks */ |
715 | err = sysfs_create_group(&pdev->dev.kobj, &via686a_group); | 714 | err = sysfs_create_group(&pdev->dev.kobj, &via686a_group); |
716 | if (err) | 715 | if (err) |
717 | goto exit_free; | 716 | return err; |
718 | 717 | ||
719 | data->hwmon_dev = hwmon_device_register(&pdev->dev); | 718 | data->hwmon_dev = hwmon_device_register(&pdev->dev); |
720 | if (IS_ERR(data->hwmon_dev)) { | 719 | if (IS_ERR(data->hwmon_dev)) { |
@@ -726,10 +725,6 @@ static int __devinit via686a_probe(struct platform_device *pdev) | |||
726 | 725 | ||
727 | exit_remove_files: | 726 | exit_remove_files: |
728 | sysfs_remove_group(&pdev->dev.kobj, &via686a_group); | 727 | sysfs_remove_group(&pdev->dev.kobj, &via686a_group); |
729 | exit_free: | ||
730 | kfree(data); | ||
731 | exit_release: | ||
732 | release_region(res->start, VIA686A_EXTENT); | ||
733 | return err; | 728 | return err; |
734 | } | 729 | } |
735 | 730 | ||
@@ -740,10 +735,6 @@ static int __devexit via686a_remove(struct platform_device *pdev) | |||
740 | hwmon_device_unregister(data->hwmon_dev); | 735 | hwmon_device_unregister(data->hwmon_dev); |
741 | sysfs_remove_group(&pdev->dev.kobj, &via686a_group); | 736 | sysfs_remove_group(&pdev->dev.kobj, &via686a_group); |
742 | 737 | ||
743 | release_region(data->addr, VIA686A_EXTENT); | ||
744 | platform_set_drvdata(pdev, NULL); | ||
745 | kfree(data); | ||
746 | |||
747 | return 0; | 738 | return 0; |
748 | } | 739 | } |
749 | 740 | ||
diff --git a/drivers/hwmon/vt1211.c b/drivers/hwmon/vt1211.c index c2c5c72fb8f0..f2c61153dba9 100644 --- a/drivers/hwmon/vt1211.c +++ b/drivers/hwmon/vt1211.c | |||
@@ -1148,19 +1148,18 @@ static int __devinit vt1211_probe(struct platform_device *pdev) | |||
1148 | struct resource *res; | 1148 | struct resource *res; |
1149 | int i, err; | 1149 | int i, err; |
1150 | 1150 | ||
1151 | data = kzalloc(sizeof(struct vt1211_data), GFP_KERNEL); | 1151 | data = devm_kzalloc(dev, sizeof(struct vt1211_data), GFP_KERNEL); |
1152 | if (!data) { | 1152 | if (!data) { |
1153 | err = -ENOMEM; | ||
1154 | dev_err(dev, "Out of memory\n"); | 1153 | dev_err(dev, "Out of memory\n"); |
1155 | goto EXIT; | 1154 | return -ENOMEM; |
1156 | } | 1155 | } |
1157 | 1156 | ||
1158 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 1157 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
1159 | if (!request_region(res->start, resource_size(res), DRVNAME)) { | 1158 | if (!devm_request_region(dev, res->start, resource_size(res), |
1160 | err = -EBUSY; | 1159 | DRVNAME)) { |
1161 | dev_err(dev, "Failed to request region 0x%lx-0x%lx\n", | 1160 | dev_err(dev, "Failed to request region 0x%lx-0x%lx\n", |
1162 | (unsigned long)res->start, (unsigned long)res->end); | 1161 | (unsigned long)res->start, (unsigned long)res->end); |
1163 | goto EXIT_KFREE; | 1162 | return -EBUSY; |
1164 | } | 1163 | } |
1165 | data->addr = res->start; | 1164 | data->addr = res->start; |
1166 | data->name = DRVNAME; | 1165 | data->name = DRVNAME; |
@@ -1215,26 +1214,15 @@ EXIT_DEV_REMOVE: | |||
1215 | dev_err(dev, "Sysfs interface creation failed (%d)\n", err); | 1214 | dev_err(dev, "Sysfs interface creation failed (%d)\n", err); |
1216 | EXIT_DEV_REMOVE_SILENT: | 1215 | EXIT_DEV_REMOVE_SILENT: |
1217 | vt1211_remove_sysfs(pdev); | 1216 | vt1211_remove_sysfs(pdev); |
1218 | release_region(res->start, resource_size(res)); | ||
1219 | EXIT_KFREE: | ||
1220 | platform_set_drvdata(pdev, NULL); | ||
1221 | kfree(data); | ||
1222 | EXIT: | ||
1223 | return err; | 1217 | return err; |
1224 | } | 1218 | } |
1225 | 1219 | ||
1226 | static int __devexit vt1211_remove(struct platform_device *pdev) | 1220 | static int __devexit vt1211_remove(struct platform_device *pdev) |
1227 | { | 1221 | { |
1228 | struct vt1211_data *data = platform_get_drvdata(pdev); | 1222 | struct vt1211_data *data = platform_get_drvdata(pdev); |
1229 | struct resource *res; | ||
1230 | 1223 | ||
1231 | hwmon_device_unregister(data->hwmon_dev); | 1224 | hwmon_device_unregister(data->hwmon_dev); |
1232 | vt1211_remove_sysfs(pdev); | 1225 | vt1211_remove_sysfs(pdev); |
1233 | platform_set_drvdata(pdev, NULL); | ||
1234 | kfree(data); | ||
1235 | |||
1236 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
1237 | release_region(res->start, resource_size(res)); | ||
1238 | 1226 | ||
1239 | return 0; | 1227 | return 0; |
1240 | } | 1228 | } |
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index 54922ed12978..1821b7423d5b 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c | |||
@@ -599,6 +599,7 @@ static void nct6775_write_fan_div(struct w83627ehf_data *data, int nr) | |||
599 | reg = (w83627ehf_read_value(data, NCT6775_REG_FANDIV1) & 0x7) | 599 | reg = (w83627ehf_read_value(data, NCT6775_REG_FANDIV1) & 0x7) |
600 | | ((data->fan_div[1] << 4) & 0x70); | 600 | | ((data->fan_div[1] << 4) & 0x70); |
601 | w83627ehf_write_value(data, NCT6775_REG_FANDIV1, reg); | 601 | w83627ehf_write_value(data, NCT6775_REG_FANDIV1, reg); |
602 | break; | ||
602 | case 2: | 603 | case 2: |
603 | reg = (w83627ehf_read_value(data, NCT6775_REG_FANDIV2) & 0x70) | 604 | reg = (w83627ehf_read_value(data, NCT6775_REG_FANDIV2) & 0x70) |
604 | | (data->fan_div[2] & 0x7); | 605 | | (data->fan_div[2] & 0x7); |
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 5ce54a297249..ab4825205a9d 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c | |||
@@ -1359,19 +1359,17 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1359 | }; | 1359 | }; |
1360 | 1360 | ||
1361 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 1361 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
1362 | if (!request_region(res->start, WINB_REGION_SIZE, DRVNAME)) { | 1362 | if (!devm_request_region(dev, res->start, WINB_REGION_SIZE, DRVNAME)) { |
1363 | dev_err(dev, "Failed to request region 0x%lx-0x%lx\n", | 1363 | dev_err(dev, "Failed to request region 0x%lx-0x%lx\n", |
1364 | (unsigned long)res->start, | 1364 | (unsigned long)res->start, |
1365 | (unsigned long)(res->start + WINB_REGION_SIZE - 1)); | 1365 | (unsigned long)(res->start + WINB_REGION_SIZE - 1)); |
1366 | err = -EBUSY; | 1366 | return -EBUSY; |
1367 | goto ERROR0; | ||
1368 | } | 1367 | } |
1369 | 1368 | ||
1370 | data = kzalloc(sizeof(struct w83627hf_data), GFP_KERNEL); | 1369 | data = devm_kzalloc(dev, sizeof(struct w83627hf_data), GFP_KERNEL); |
1371 | if (!data) { | 1370 | if (!data) |
1372 | err = -ENOMEM; | 1371 | return -ENOMEM; |
1373 | goto ERROR1; | 1372 | |
1374 | } | ||
1375 | data->addr = res->start; | 1373 | data->addr = res->start; |
1376 | data->type = sio_data->type; | 1374 | data->type = sio_data->type; |
1377 | data->name = names[sio_data->type]; | 1375 | data->name = names[sio_data->type]; |
@@ -1391,7 +1389,7 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1391 | /* Register common device attributes */ | 1389 | /* Register common device attributes */ |
1392 | err = sysfs_create_group(&dev->kobj, &w83627hf_group); | 1390 | err = sysfs_create_group(&dev->kobj, &w83627hf_group); |
1393 | if (err) | 1391 | if (err) |
1394 | goto ERROR3; | 1392 | return err; |
1395 | 1393 | ||
1396 | /* Register chip-specific device attributes */ | 1394 | /* Register chip-specific device attributes */ |
1397 | if (data->type == w83627hf || data->type == w83697hf) | 1395 | if (data->type == w83627hf || data->type == w83697hf) |
@@ -1419,7 +1417,7 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1419 | &sensor_dev_attr_pwm1_freq.dev_attr)) | 1417 | &sensor_dev_attr_pwm1_freq.dev_attr)) |
1420 | || (err = device_create_file(dev, | 1418 | || (err = device_create_file(dev, |
1421 | &sensor_dev_attr_pwm2_freq.dev_attr))) | 1419 | &sensor_dev_attr_pwm2_freq.dev_attr))) |
1422 | goto ERROR4; | 1420 | goto error; |
1423 | 1421 | ||
1424 | if (data->type != w83697hf) | 1422 | if (data->type != w83697hf) |
1425 | if ((err = device_create_file(dev, | 1423 | if ((err = device_create_file(dev, |
@@ -1454,7 +1452,7 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1454 | &sensor_dev_attr_temp3_beep.dev_attr)) | 1452 | &sensor_dev_attr_temp3_beep.dev_attr)) |
1455 | || (err = device_create_file(dev, | 1453 | || (err = device_create_file(dev, |
1456 | &sensor_dev_attr_temp3_type.dev_attr))) | 1454 | &sensor_dev_attr_temp3_type.dev_attr))) |
1457 | goto ERROR4; | 1455 | goto error; |
1458 | 1456 | ||
1459 | if (data->type != w83697hf && data->vid != 0xff) { | 1457 | if (data->type != w83697hf && data->vid != 0xff) { |
1460 | /* Convert VID to voltage based on VRM */ | 1458 | /* Convert VID to voltage based on VRM */ |
@@ -1462,14 +1460,14 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1462 | 1460 | ||
1463 | if ((err = device_create_file(dev, &dev_attr_cpu0_vid)) | 1461 | if ((err = device_create_file(dev, &dev_attr_cpu0_vid)) |
1464 | || (err = device_create_file(dev, &dev_attr_vrm))) | 1462 | || (err = device_create_file(dev, &dev_attr_vrm))) |
1465 | goto ERROR4; | 1463 | goto error; |
1466 | } | 1464 | } |
1467 | 1465 | ||
1468 | if (data->type == w83627thf || data->type == w83637hf | 1466 | if (data->type == w83627thf || data->type == w83637hf |
1469 | || data->type == w83687thf) { | 1467 | || data->type == w83687thf) { |
1470 | err = device_create_file(dev, &sensor_dev_attr_pwm3.dev_attr); | 1468 | err = device_create_file(dev, &sensor_dev_attr_pwm3.dev_attr); |
1471 | if (err) | 1469 | if (err) |
1472 | goto ERROR4; | 1470 | goto error; |
1473 | } | 1471 | } |
1474 | 1472 | ||
1475 | if (data->type == w83637hf || data->type == w83687thf) | 1473 | if (data->type == w83637hf || data->type == w83687thf) |
@@ -1479,57 +1477,45 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1479 | &sensor_dev_attr_pwm2_freq.dev_attr)) | 1477 | &sensor_dev_attr_pwm2_freq.dev_attr)) |
1480 | || (err = device_create_file(dev, | 1478 | || (err = device_create_file(dev, |
1481 | &sensor_dev_attr_pwm3_freq.dev_attr))) | 1479 | &sensor_dev_attr_pwm3_freq.dev_attr))) |
1482 | goto ERROR4; | 1480 | goto error; |
1483 | 1481 | ||
1484 | if (data->type != w83627hf) | 1482 | if (data->type != w83627hf) |
1485 | if ((err = device_create_file(dev, | 1483 | if ((err = device_create_file(dev, |
1486 | &sensor_dev_attr_pwm1_enable.dev_attr)) | 1484 | &sensor_dev_attr_pwm1_enable.dev_attr)) |
1487 | || (err = device_create_file(dev, | 1485 | || (err = device_create_file(dev, |
1488 | &sensor_dev_attr_pwm2_enable.dev_attr))) | 1486 | &sensor_dev_attr_pwm2_enable.dev_attr))) |
1489 | goto ERROR4; | 1487 | goto error; |
1490 | 1488 | ||
1491 | if (data->type == w83627thf || data->type == w83637hf | 1489 | if (data->type == w83627thf || data->type == w83637hf |
1492 | || data->type == w83687thf) { | 1490 | || data->type == w83687thf) { |
1493 | err = device_create_file(dev, | 1491 | err = device_create_file(dev, |
1494 | &sensor_dev_attr_pwm3_enable.dev_attr); | 1492 | &sensor_dev_attr_pwm3_enable.dev_attr); |
1495 | if (err) | 1493 | if (err) |
1496 | goto ERROR4; | 1494 | goto error; |
1497 | } | 1495 | } |
1498 | 1496 | ||
1499 | data->hwmon_dev = hwmon_device_register(dev); | 1497 | data->hwmon_dev = hwmon_device_register(dev); |
1500 | if (IS_ERR(data->hwmon_dev)) { | 1498 | if (IS_ERR(data->hwmon_dev)) { |
1501 | err = PTR_ERR(data->hwmon_dev); | 1499 | err = PTR_ERR(data->hwmon_dev); |
1502 | goto ERROR4; | 1500 | goto error; |
1503 | } | 1501 | } |
1504 | 1502 | ||
1505 | return 0; | 1503 | return 0; |
1506 | 1504 | ||
1507 | ERROR4: | 1505 | error: |
1508 | sysfs_remove_group(&dev->kobj, &w83627hf_group); | 1506 | sysfs_remove_group(&dev->kobj, &w83627hf_group); |
1509 | sysfs_remove_group(&dev->kobj, &w83627hf_group_opt); | 1507 | sysfs_remove_group(&dev->kobj, &w83627hf_group_opt); |
1510 | ERROR3: | ||
1511 | platform_set_drvdata(pdev, NULL); | ||
1512 | kfree(data); | ||
1513 | ERROR1: | ||
1514 | release_region(res->start, WINB_REGION_SIZE); | ||
1515 | ERROR0: | ||
1516 | return err; | 1508 | return err; |
1517 | } | 1509 | } |
1518 | 1510 | ||
1519 | static int __devexit w83627hf_remove(struct platform_device *pdev) | 1511 | static int __devexit w83627hf_remove(struct platform_device *pdev) |
1520 | { | 1512 | { |
1521 | struct w83627hf_data *data = platform_get_drvdata(pdev); | 1513 | struct w83627hf_data *data = platform_get_drvdata(pdev); |
1522 | struct resource *res; | ||
1523 | 1514 | ||
1524 | hwmon_device_unregister(data->hwmon_dev); | 1515 | hwmon_device_unregister(data->hwmon_dev); |
1525 | 1516 | ||
1526 | sysfs_remove_group(&pdev->dev.kobj, &w83627hf_group); | 1517 | sysfs_remove_group(&pdev->dev.kobj, &w83627hf_group); |
1527 | sysfs_remove_group(&pdev->dev.kobj, &w83627hf_group_opt); | 1518 | sysfs_remove_group(&pdev->dev.kobj, &w83627hf_group_opt); |
1528 | platform_set_drvdata(pdev, NULL); | ||
1529 | kfree(data); | ||
1530 | |||
1531 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
1532 | release_region(res->start, WINB_REGION_SIZE); | ||
1533 | 1519 | ||
1534 | return 0; | 1520 | return 0; |
1535 | } | 1521 | } |
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index b03d54a799e3..5a5046d94c3e 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c | |||
@@ -867,6 +867,7 @@ w83781d_detect_subclients(struct i2c_client *new_client) | |||
867 | struct i2c_adapter *adapter = new_client->adapter; | 867 | struct i2c_adapter *adapter = new_client->adapter; |
868 | struct w83781d_data *data = i2c_get_clientdata(new_client); | 868 | struct w83781d_data *data = i2c_get_clientdata(new_client); |
869 | enum chips kind = data->type; | 869 | enum chips kind = data->type; |
870 | int num_sc = 1; | ||
870 | 871 | ||
871 | id = i2c_adapter_id(adapter); | 872 | id = i2c_adapter_id(adapter); |
872 | 873 | ||
@@ -891,6 +892,7 @@ w83781d_detect_subclients(struct i2c_client *new_client) | |||
891 | } | 892 | } |
892 | 893 | ||
893 | if (kind != w83783s) { | 894 | if (kind != w83783s) { |
895 | num_sc = 2; | ||
894 | if (force_subclients[0] == id && | 896 | if (force_subclients[0] == id && |
895 | force_subclients[1] == address) { | 897 | force_subclients[1] == address) { |
896 | sc_addr[1] = force_subclients[3]; | 898 | sc_addr[1] = force_subclients[3]; |
@@ -906,7 +908,7 @@ w83781d_detect_subclients(struct i2c_client *new_client) | |||
906 | } | 908 | } |
907 | } | 909 | } |
908 | 910 | ||
909 | for (i = 0; i <= 1; i++) { | 911 | for (i = 0; i < num_sc; i++) { |
910 | data->lm75[i] = i2c_new_dummy(adapter, sc_addr[i]); | 912 | data->lm75[i] = i2c_new_dummy(adapter, sc_addr[i]); |
911 | if (!data->lm75[i]) { | 913 | if (!data->lm75[i]) { |
912 | dev_err(&new_client->dev, "Subclient %d " | 914 | dev_err(&new_client->dev, "Subclient %d " |
@@ -917,8 +919,6 @@ w83781d_detect_subclients(struct i2c_client *new_client) | |||
917 | goto ERROR_SC_3; | 919 | goto ERROR_SC_3; |
918 | goto ERROR_SC_2; | 920 | goto ERROR_SC_2; |
919 | } | 921 | } |
920 | if (kind == w83783s) | ||
921 | break; | ||
922 | } | 922 | } |
923 | 923 | ||
924 | return 0; | 924 | return 0; |
@@ -1213,11 +1213,9 @@ w83781d_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1213 | struct w83781d_data *data; | 1213 | struct w83781d_data *data; |
1214 | int err; | 1214 | int err; |
1215 | 1215 | ||
1216 | data = kzalloc(sizeof(struct w83781d_data), GFP_KERNEL); | 1216 | data = devm_kzalloc(dev, sizeof(struct w83781d_data), GFP_KERNEL); |
1217 | if (!data) { | 1217 | if (!data) |
1218 | err = -ENOMEM; | 1218 | return -ENOMEM; |
1219 | goto ERROR1; | ||
1220 | } | ||
1221 | 1219 | ||
1222 | i2c_set_clientdata(client, data); | 1220 | i2c_set_clientdata(client, data); |
1223 | mutex_init(&data->lock); | 1221 | mutex_init(&data->lock); |
@@ -1229,7 +1227,7 @@ w83781d_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1229 | /* attach secondary i2c lm75-like clients */ | 1227 | /* attach secondary i2c lm75-like clients */ |
1230 | err = w83781d_detect_subclients(client); | 1228 | err = w83781d_detect_subclients(client); |
1231 | if (err) | 1229 | if (err) |
1232 | goto ERROR3; | 1230 | return err; |
1233 | 1231 | ||
1234 | /* Initialize the chip */ | 1232 | /* Initialize the chip */ |
1235 | w83781d_init_device(dev); | 1233 | w83781d_init_device(dev); |
@@ -1237,25 +1235,22 @@ w83781d_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1237 | /* Register sysfs hooks */ | 1235 | /* Register sysfs hooks */ |
1238 | err = w83781d_create_files(dev, data->type, 0); | 1236 | err = w83781d_create_files(dev, data->type, 0); |
1239 | if (err) | 1237 | if (err) |
1240 | goto ERROR4; | 1238 | goto exit_remove_files; |
1241 | 1239 | ||
1242 | data->hwmon_dev = hwmon_device_register(dev); | 1240 | data->hwmon_dev = hwmon_device_register(dev); |
1243 | if (IS_ERR(data->hwmon_dev)) { | 1241 | if (IS_ERR(data->hwmon_dev)) { |
1244 | err = PTR_ERR(data->hwmon_dev); | 1242 | err = PTR_ERR(data->hwmon_dev); |
1245 | goto ERROR4; | 1243 | goto exit_remove_files; |
1246 | } | 1244 | } |
1247 | 1245 | ||
1248 | return 0; | 1246 | return 0; |
1249 | 1247 | ||
1250 | ERROR4: | 1248 | exit_remove_files: |
1251 | w83781d_remove_files(dev); | 1249 | w83781d_remove_files(dev); |
1252 | if (data->lm75[0]) | 1250 | if (data->lm75[0]) |
1253 | i2c_unregister_device(data->lm75[0]); | 1251 | i2c_unregister_device(data->lm75[0]); |
1254 | if (data->lm75[1]) | 1252 | if (data->lm75[1]) |
1255 | i2c_unregister_device(data->lm75[1]); | 1253 | i2c_unregister_device(data->lm75[1]); |
1256 | ERROR3: | ||
1257 | kfree(data); | ||
1258 | ERROR1: | ||
1259 | return err; | 1254 | return err; |
1260 | } | 1255 | } |
1261 | 1256 | ||
@@ -1273,8 +1268,6 @@ w83781d_remove(struct i2c_client *client) | |||
1273 | if (data->lm75[1]) | 1268 | if (data->lm75[1]) |
1274 | i2c_unregister_device(data->lm75[1]); | 1269 | i2c_unregister_device(data->lm75[1]); |
1275 | 1270 | ||
1276 | kfree(data); | ||
1277 | |||
1278 | return 0; | 1271 | return 0; |
1279 | } | 1272 | } |
1280 | 1273 | ||
@@ -1780,17 +1773,16 @@ w83781d_isa_probe(struct platform_device *pdev) | |||
1780 | 1773 | ||
1781 | /* Reserve the ISA region */ | 1774 | /* Reserve the ISA region */ |
1782 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 1775 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
1783 | if (!request_region(res->start + W83781D_ADDR_REG_OFFSET, 2, | 1776 | if (!devm_request_region(&pdev->dev, |
1784 | "w83781d")) { | 1777 | res->start + W83781D_ADDR_REG_OFFSET, 2, |
1785 | err = -EBUSY; | 1778 | "w83781d")) |
1786 | goto exit; | 1779 | return -EBUSY; |
1787 | } | 1780 | |
1781 | data = devm_kzalloc(&pdev->dev, sizeof(struct w83781d_data), | ||
1782 | GFP_KERNEL); | ||
1783 | if (!data) | ||
1784 | return -ENOMEM; | ||
1788 | 1785 | ||
1789 | data = kzalloc(sizeof(struct w83781d_data), GFP_KERNEL); | ||
1790 | if (!data) { | ||
1791 | err = -ENOMEM; | ||
1792 | goto exit_release_region; | ||
1793 | } | ||
1794 | mutex_init(&data->lock); | 1786 | mutex_init(&data->lock); |
1795 | data->isa_addr = res->start; | 1787 | data->isa_addr = res->start; |
1796 | platform_set_drvdata(pdev, data); | 1788 | platform_set_drvdata(pdev, data); |
@@ -1829,10 +1821,6 @@ w83781d_isa_probe(struct platform_device *pdev) | |||
1829 | exit_remove_files: | 1821 | exit_remove_files: |
1830 | w83781d_remove_files(&pdev->dev); | 1822 | w83781d_remove_files(&pdev->dev); |
1831 | device_remove_file(&pdev->dev, &dev_attr_name); | 1823 | device_remove_file(&pdev->dev, &dev_attr_name); |
1832 | kfree(data); | ||
1833 | exit_release_region: | ||
1834 | release_region(res->start + W83781D_ADDR_REG_OFFSET, 2); | ||
1835 | exit: | ||
1836 | return err; | 1824 | return err; |
1837 | } | 1825 | } |
1838 | 1826 | ||
@@ -1844,8 +1832,6 @@ w83781d_isa_remove(struct platform_device *pdev) | |||
1844 | hwmon_device_unregister(data->hwmon_dev); | 1832 | hwmon_device_unregister(data->hwmon_dev); |
1845 | w83781d_remove_files(&pdev->dev); | 1833 | w83781d_remove_files(&pdev->dev); |
1846 | device_remove_file(&pdev->dev, &dev_attr_name); | 1834 | device_remove_file(&pdev->dev, &dev_attr_name); |
1847 | release_region(data->isa_addr + W83781D_ADDR_REG_OFFSET, 2); | ||
1848 | kfree(data); | ||
1849 | 1835 | ||
1850 | return 0; | 1836 | return 0; |
1851 | } | 1837 | } |
diff --git a/drivers/hwmon/w83791d.c b/drivers/hwmon/w83791d.c index 2f446f92acf2..9ade4d4e2185 100644 --- a/drivers/hwmon/w83791d.c +++ b/drivers/hwmon/w83791d.c | |||
@@ -1384,18 +1384,17 @@ static int w83791d_probe(struct i2c_client *client, | |||
1384 | (val1 >> 5) & 0x07, (val1 >> 1) & 0x0f, val1); | 1384 | (val1 >> 5) & 0x07, (val1 >> 1) & 0x0f, val1); |
1385 | #endif | 1385 | #endif |
1386 | 1386 | ||
1387 | data = kzalloc(sizeof(struct w83791d_data), GFP_KERNEL); | 1387 | data = devm_kzalloc(&client->dev, sizeof(struct w83791d_data), |
1388 | if (!data) { | 1388 | GFP_KERNEL); |
1389 | err = -ENOMEM; | 1389 | if (!data) |
1390 | goto error0; | 1390 | return -ENOMEM; |
1391 | } | ||
1392 | 1391 | ||
1393 | i2c_set_clientdata(client, data); | 1392 | i2c_set_clientdata(client, data); |
1394 | mutex_init(&data->update_lock); | 1393 | mutex_init(&data->update_lock); |
1395 | 1394 | ||
1396 | err = w83791d_detect_subclients(client); | 1395 | err = w83791d_detect_subclients(client); |
1397 | if (err) | 1396 | if (err) |
1398 | goto error1; | 1397 | return err; |
1399 | 1398 | ||
1400 | /* Initialize the chip */ | 1399 | /* Initialize the chip */ |
1401 | w83791d_init_client(client); | 1400 | w83791d_init_client(client); |
@@ -1440,9 +1439,6 @@ error3: | |||
1440 | i2c_unregister_device(data->lm75[0]); | 1439 | i2c_unregister_device(data->lm75[0]); |
1441 | if (data->lm75[1] != NULL) | 1440 | if (data->lm75[1] != NULL) |
1442 | i2c_unregister_device(data->lm75[1]); | 1441 | i2c_unregister_device(data->lm75[1]); |
1443 | error1: | ||
1444 | kfree(data); | ||
1445 | error0: | ||
1446 | return err; | 1442 | return err; |
1447 | } | 1443 | } |
1448 | 1444 | ||
@@ -1458,7 +1454,6 @@ static int w83791d_remove(struct i2c_client *client) | |||
1458 | if (data->lm75[1] != NULL) | 1454 | if (data->lm75[1] != NULL) |
1459 | i2c_unregister_device(data->lm75[1]); | 1455 | i2c_unregister_device(data->lm75[1]); |
1460 | 1456 | ||
1461 | kfree(data); | ||
1462 | return 0; | 1457 | return 0; |
1463 | } | 1458 | } |
1464 | 1459 | ||
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index ffb5fdfecf0d..0ba5a2bd562e 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c | |||
@@ -1422,11 +1422,9 @@ w83792d_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1422 | struct device *dev = &client->dev; | 1422 | struct device *dev = &client->dev; |
1423 | int i, val1, err; | 1423 | int i, val1, err; |
1424 | 1424 | ||
1425 | data = kzalloc(sizeof(struct w83792d_data), GFP_KERNEL); | 1425 | data = devm_kzalloc(dev, sizeof(struct w83792d_data), GFP_KERNEL); |
1426 | if (!data) { | 1426 | if (!data) |
1427 | err = -ENOMEM; | 1427 | return -ENOMEM; |
1428 | goto ERROR0; | ||
1429 | } | ||
1430 | 1428 | ||
1431 | i2c_set_clientdata(client, data); | 1429 | i2c_set_clientdata(client, data); |
1432 | data->valid = 0; | 1430 | data->valid = 0; |
@@ -1434,7 +1432,7 @@ w83792d_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1434 | 1432 | ||
1435 | err = w83792d_detect_subclients(client); | 1433 | err = w83792d_detect_subclients(client); |
1436 | if (err) | 1434 | if (err) |
1437 | goto ERROR1; | 1435 | return err; |
1438 | 1436 | ||
1439 | /* Initialize the chip */ | 1437 | /* Initialize the chip */ |
1440 | w83792d_init_client(client); | 1438 | w83792d_init_client(client); |
@@ -1448,7 +1446,7 @@ w83792d_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1448 | /* Register sysfs hooks */ | 1446 | /* Register sysfs hooks */ |
1449 | err = sysfs_create_group(&dev->kobj, &w83792d_group); | 1447 | err = sysfs_create_group(&dev->kobj, &w83792d_group); |
1450 | if (err) | 1448 | if (err) |
1451 | goto ERROR3; | 1449 | goto exit_i2c_unregister; |
1452 | 1450 | ||
1453 | /* | 1451 | /* |
1454 | * Read GPIO enable register to check if pins for fan 4,5 are used as | 1452 | * Read GPIO enable register to check if pins for fan 4,5 are used as |
@@ -1493,14 +1491,11 @@ exit_remove_files: | |||
1493 | sysfs_remove_group(&dev->kobj, &w83792d_group); | 1491 | sysfs_remove_group(&dev->kobj, &w83792d_group); |
1494 | for (i = 0; i < ARRAY_SIZE(w83792d_group_fan); i++) | 1492 | for (i = 0; i < ARRAY_SIZE(w83792d_group_fan); i++) |
1495 | sysfs_remove_group(&dev->kobj, &w83792d_group_fan[i]); | 1493 | sysfs_remove_group(&dev->kobj, &w83792d_group_fan[i]); |
1496 | ERROR3: | 1494 | exit_i2c_unregister: |
1497 | if (data->lm75[0] != NULL) | 1495 | if (data->lm75[0] != NULL) |
1498 | i2c_unregister_device(data->lm75[0]); | 1496 | i2c_unregister_device(data->lm75[0]); |
1499 | if (data->lm75[1] != NULL) | 1497 | if (data->lm75[1] != NULL) |
1500 | i2c_unregister_device(data->lm75[1]); | 1498 | i2c_unregister_device(data->lm75[1]); |
1501 | ERROR1: | ||
1502 | kfree(data); | ||
1503 | ERROR0: | ||
1504 | return err; | 1499 | return err; |
1505 | } | 1500 | } |
1506 | 1501 | ||
@@ -1521,7 +1516,6 @@ w83792d_remove(struct i2c_client *client) | |||
1521 | if (data->lm75[1] != NULL) | 1516 | if (data->lm75[1] != NULL) |
1522 | i2c_unregister_device(data->lm75[1]); | 1517 | i2c_unregister_device(data->lm75[1]); |
1523 | 1518 | ||
1524 | kfree(data); | ||
1525 | return 0; | 1519 | return 0; |
1526 | } | 1520 | } |
1527 | 1521 | ||
diff --git a/drivers/hwmon/w83795.c b/drivers/hwmon/w83795.c index d887cb3b72e8..b813c646c7ca 100644 --- a/drivers/hwmon/w83795.c +++ b/drivers/hwmon/w83795.c | |||
@@ -2157,11 +2157,9 @@ static int w83795_probe(struct i2c_client *client, | |||
2157 | struct w83795_data *data; | 2157 | struct w83795_data *data; |
2158 | int err; | 2158 | int err; |
2159 | 2159 | ||
2160 | data = kzalloc(sizeof(struct w83795_data), GFP_KERNEL); | 2160 | data = devm_kzalloc(dev, sizeof(struct w83795_data), GFP_KERNEL); |
2161 | if (!data) { | 2161 | if (!data) |
2162 | err = -ENOMEM; | 2162 | return -ENOMEM; |
2163 | goto exit; | ||
2164 | } | ||
2165 | 2163 | ||
2166 | i2c_set_clientdata(client, data); | 2164 | i2c_set_clientdata(client, data); |
2167 | data->chip_type = id->driver_data; | 2165 | data->chip_type = id->driver_data; |
@@ -2247,8 +2245,6 @@ static int w83795_probe(struct i2c_client *client, | |||
2247 | 2245 | ||
2248 | exit_remove: | 2246 | exit_remove: |
2249 | w83795_handle_files(dev, device_remove_file_wrapper); | 2247 | w83795_handle_files(dev, device_remove_file_wrapper); |
2250 | kfree(data); | ||
2251 | exit: | ||
2252 | return err; | 2248 | return err; |
2253 | } | 2249 | } |
2254 | 2250 | ||
@@ -2258,7 +2254,6 @@ static int w83795_remove(struct i2c_client *client) | |||
2258 | 2254 | ||
2259 | hwmon_device_unregister(data->hwmon_dev); | 2255 | hwmon_device_unregister(data->hwmon_dev); |
2260 | w83795_handle_files(&client->dev, device_remove_file_wrapper); | 2256 | w83795_handle_files(&client->dev, device_remove_file_wrapper); |
2261 | kfree(data); | ||
2262 | 2257 | ||
2263 | return 0; | 2258 | return 0; |
2264 | } | 2259 | } |
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index 5f14e3897058..39dbe990dc10 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c | |||
@@ -176,19 +176,18 @@ static int w83l785ts_detect(struct i2c_client *client, | |||
176 | return 0; | 176 | return 0; |
177 | } | 177 | } |
178 | 178 | ||
179 | static int w83l785ts_probe(struct i2c_client *new_client, | 179 | static int w83l785ts_probe(struct i2c_client *client, |
180 | const struct i2c_device_id *id) | 180 | const struct i2c_device_id *id) |
181 | { | 181 | { |
182 | struct w83l785ts_data *data; | 182 | struct w83l785ts_data *data; |
183 | int err = 0; | 183 | struct device *dev = &client->dev; |
184 | int err; | ||
184 | 185 | ||
185 | data = kzalloc(sizeof(struct w83l785ts_data), GFP_KERNEL); | 186 | data = devm_kzalloc(dev, sizeof(struct w83l785ts_data), GFP_KERNEL); |
186 | if (!data) { | 187 | if (!data) |
187 | err = -ENOMEM; | 188 | return -ENOMEM; |
188 | goto exit; | ||
189 | } | ||
190 | 189 | ||
191 | i2c_set_clientdata(new_client, data); | 190 | i2c_set_clientdata(client, data); |
192 | data->valid = 0; | 191 | data->valid = 0; |
193 | mutex_init(&data->update_lock); | 192 | mutex_init(&data->update_lock); |
194 | 193 | ||
@@ -200,18 +199,16 @@ static int w83l785ts_probe(struct i2c_client *new_client, | |||
200 | * Nothing yet, assume it is already started. | 199 | * Nothing yet, assume it is already started. |
201 | */ | 200 | */ |
202 | 201 | ||
203 | err = device_create_file(&new_client->dev, | 202 | err = device_create_file(dev, &sensor_dev_attr_temp1_input.dev_attr); |
204 | &sensor_dev_attr_temp1_input.dev_attr); | ||
205 | if (err) | 203 | if (err) |
206 | goto exit_remove; | 204 | return err; |
207 | 205 | ||
208 | err = device_create_file(&new_client->dev, | 206 | err = device_create_file(dev, &sensor_dev_attr_temp1_max.dev_attr); |
209 | &sensor_dev_attr_temp1_max.dev_attr); | ||
210 | if (err) | 207 | if (err) |
211 | goto exit_remove; | 208 | goto exit_remove; |
212 | 209 | ||
213 | /* Register sysfs hooks */ | 210 | /* Register sysfs hooks */ |
214 | data->hwmon_dev = hwmon_device_register(&new_client->dev); | 211 | data->hwmon_dev = hwmon_device_register(dev); |
215 | if (IS_ERR(data->hwmon_dev)) { | 212 | if (IS_ERR(data->hwmon_dev)) { |
216 | err = PTR_ERR(data->hwmon_dev); | 213 | err = PTR_ERR(data->hwmon_dev); |
217 | goto exit_remove; | 214 | goto exit_remove; |
@@ -220,12 +217,8 @@ static int w83l785ts_probe(struct i2c_client *new_client, | |||
220 | return 0; | 217 | return 0; |
221 | 218 | ||
222 | exit_remove: | 219 | exit_remove: |
223 | device_remove_file(&new_client->dev, | 220 | device_remove_file(dev, &sensor_dev_attr_temp1_input.dev_attr); |
224 | &sensor_dev_attr_temp1_input.dev_attr); | 221 | device_remove_file(dev, &sensor_dev_attr_temp1_max.dev_attr); |
225 | device_remove_file(&new_client->dev, | ||
226 | &sensor_dev_attr_temp1_max.dev_attr); | ||
227 | kfree(data); | ||
228 | exit: | ||
229 | return err; | 222 | return err; |
230 | } | 223 | } |
231 | 224 | ||
@@ -239,7 +232,6 @@ static int w83l785ts_remove(struct i2c_client *client) | |||
239 | device_remove_file(&client->dev, | 232 | device_remove_file(&client->dev, |
240 | &sensor_dev_attr_temp1_max.dev_attr); | 233 | &sensor_dev_attr_temp1_max.dev_attr); |
241 | 234 | ||
242 | kfree(data); | ||
243 | return 0; | 235 | return 0; |
244 | } | 236 | } |
245 | 237 | ||
diff --git a/drivers/hwmon/wm831x-hwmon.c b/drivers/hwmon/wm831x-hwmon.c index 07cb25ae69be..d0db1f2738fb 100644 --- a/drivers/hwmon/wm831x-hwmon.c +++ b/drivers/hwmon/wm831x-hwmon.c | |||
@@ -163,7 +163,8 @@ static int __devinit wm831x_hwmon_probe(struct platform_device *pdev) | |||
163 | struct wm831x_hwmon *hwmon; | 163 | struct wm831x_hwmon *hwmon; |
164 | int ret; | 164 | int ret; |
165 | 165 | ||
166 | hwmon = kzalloc(sizeof(struct wm831x_hwmon), GFP_KERNEL); | 166 | hwmon = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_hwmon), |
167 | GFP_KERNEL); | ||
167 | if (!hwmon) | 168 | if (!hwmon) |
168 | return -ENOMEM; | 169 | return -ENOMEM; |
169 | 170 | ||
@@ -171,7 +172,7 @@ static int __devinit wm831x_hwmon_probe(struct platform_device *pdev) | |||
171 | 172 | ||
172 | ret = sysfs_create_group(&pdev->dev.kobj, &wm831x_attr_group); | 173 | ret = sysfs_create_group(&pdev->dev.kobj, &wm831x_attr_group); |
173 | if (ret) | 174 | if (ret) |
174 | goto err; | 175 | return ret; |
175 | 176 | ||
176 | hwmon->classdev = hwmon_device_register(&pdev->dev); | 177 | hwmon->classdev = hwmon_device_register(&pdev->dev); |
177 | if (IS_ERR(hwmon->classdev)) { | 178 | if (IS_ERR(hwmon->classdev)) { |
@@ -185,8 +186,6 @@ static int __devinit wm831x_hwmon_probe(struct platform_device *pdev) | |||
185 | 186 | ||
186 | err_sysfs: | 187 | err_sysfs: |
187 | sysfs_remove_group(&pdev->dev.kobj, &wm831x_attr_group); | 188 | sysfs_remove_group(&pdev->dev.kobj, &wm831x_attr_group); |
188 | err: | ||
189 | kfree(hwmon); | ||
190 | return ret; | 189 | return ret; |
191 | } | 190 | } |
192 | 191 | ||
@@ -196,8 +195,6 @@ static int __devexit wm831x_hwmon_remove(struct platform_device *pdev) | |||
196 | 195 | ||
197 | hwmon_device_unregister(hwmon->classdev); | 196 | hwmon_device_unregister(hwmon->classdev); |
198 | sysfs_remove_group(&pdev->dev.kobj, &wm831x_attr_group); | 197 | sysfs_remove_group(&pdev->dev.kobj, &wm831x_attr_group); |
199 | platform_set_drvdata(pdev, NULL); | ||
200 | kfree(hwmon); | ||
201 | 198 | ||
202 | return 0; | 199 | return 0; |
203 | } | 200 | } |