diff options
author | Jean Delvare <khali@linux-fr.org> | 2010-08-14 15:09:00 -0400 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2010-08-14 15:09:00 -0400 |
commit | c6b8724647eb1c24dc37cec8518bb6957f0000a8 (patch) | |
tree | ff5c9d77d023d049c51b84323b809bd16bd080f8 /drivers/hwmon/pc87427.c | |
parent | 008e5f3350e0a474baff3ed3eb4f79653a6b6745 (diff) |
hwmon: (pc87427) Move sysfs file removal to a separate function
The sysfs file removal code is the same in the probe error path and in
the remove function, so move it to a separate function to avoid code
duplication.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
Diffstat (limited to 'drivers/hwmon/pc87427.c')
-rw-r--r-- | drivers/hwmon/pc87427.c | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/drivers/hwmon/pc87427.c b/drivers/hwmon/pc87427.c index 189dad428ac2..9ec4daaf6ca6 100644 --- a/drivers/hwmon/pc87427.c +++ b/drivers/hwmon/pc87427.c | |||
@@ -1045,6 +1045,29 @@ static void __devinit pc87427_init_device(struct device *dev) | |||
1045 | } | 1045 | } |
1046 | } | 1046 | } |
1047 | 1047 | ||
1048 | static void pc87427_remove_files(struct device *dev) | ||
1049 | { | ||
1050 | struct pc87427_data *data = dev_get_drvdata(dev); | ||
1051 | int i; | ||
1052 | |||
1053 | device_remove_file(dev, &dev_attr_name); | ||
1054 | for (i = 0; i < 8; i++) { | ||
1055 | if (!(data->fan_enabled & (1 << i))) | ||
1056 | continue; | ||
1057 | sysfs_remove_group(&dev->kobj, &pc87427_group_fan[i]); | ||
1058 | } | ||
1059 | for (i = 0; i < 4; i++) { | ||
1060 | if (!(data->pwm_enabled & (1 << i))) | ||
1061 | continue; | ||
1062 | sysfs_remove_group(&dev->kobj, &pc87427_group_pwm[i]); | ||
1063 | } | ||
1064 | for (i = 0; i < 6; i++) { | ||
1065 | if (!(data->temp_enabled & (1 << i))) | ||
1066 | continue; | ||
1067 | sysfs_remove_group(&dev->kobj, &pc87427_group_temp[i]); | ||
1068 | } | ||
1069 | } | ||
1070 | |||
1048 | static int __devinit pc87427_probe(struct platform_device *pdev) | 1071 | static int __devinit pc87427_probe(struct platform_device *pdev) |
1049 | { | 1072 | { |
1050 | struct pc87427_sio_data *sio_data = pdev->dev.platform_data; | 1073 | struct pc87427_sio_data *sio_data = pdev->dev.platform_data; |
@@ -1110,21 +1133,7 @@ static int __devinit pc87427_probe(struct platform_device *pdev) | |||
1110 | return 0; | 1133 | return 0; |
1111 | 1134 | ||
1112 | exit_remove_files: | 1135 | exit_remove_files: |
1113 | for (i = 0; i < 8; i++) { | 1136 | pc87427_remove_files(&pdev->dev); |
1114 | if (!(data->fan_enabled & (1 << i))) | ||
1115 | continue; | ||
1116 | sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_fan[i]); | ||
1117 | } | ||
1118 | for (i = 0; i < 4; i++) { | ||
1119 | if (!(data->pwm_enabled & (1 << i))) | ||
1120 | continue; | ||
1121 | sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_pwm[i]); | ||
1122 | } | ||
1123 | for (i = 0; i < 6; i++) { | ||
1124 | if (!(data->temp_enabled & (1 << i))) | ||
1125 | continue; | ||
1126 | sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_temp[i]); | ||
1127 | } | ||
1128 | exit_release_region: | 1137 | exit_release_region: |
1129 | pc87427_release_regions(pdev, res_count); | 1138 | pc87427_release_regions(pdev, res_count); |
1130 | exit_kfree: | 1139 | exit_kfree: |
@@ -1137,27 +1146,12 @@ exit: | |||
1137 | static int __devexit pc87427_remove(struct platform_device *pdev) | 1146 | static int __devexit pc87427_remove(struct platform_device *pdev) |
1138 | { | 1147 | { |
1139 | struct pc87427_data *data = platform_get_drvdata(pdev); | 1148 | struct pc87427_data *data = platform_get_drvdata(pdev); |
1140 | int i, res_count; | 1149 | int res_count; |
1141 | 1150 | ||
1142 | res_count = (data->address[0] != 0) + (data->address[1] != 0); | 1151 | res_count = (data->address[0] != 0) + (data->address[1] != 0); |
1143 | 1152 | ||
1144 | hwmon_device_unregister(data->hwmon_dev); | 1153 | hwmon_device_unregister(data->hwmon_dev); |
1145 | device_remove_file(&pdev->dev, &dev_attr_name); | 1154 | pc87427_remove_files(&pdev->dev); |
1146 | for (i = 0; i < 8; i++) { | ||
1147 | if (!(data->fan_enabled & (1 << i))) | ||
1148 | continue; | ||
1149 | sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_fan[i]); | ||
1150 | } | ||
1151 | for (i = 0; i < 4; i++) { | ||
1152 | if (!(data->pwm_enabled & (1 << i))) | ||
1153 | continue; | ||
1154 | sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_pwm[i]); | ||
1155 | } | ||
1156 | for (i = 0; i < 6; i++) { | ||
1157 | if (!(data->temp_enabled & (1 << i))) | ||
1158 | continue; | ||
1159 | sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_temp[i]); | ||
1160 | } | ||
1161 | platform_set_drvdata(pdev, NULL); | 1155 | platform_set_drvdata(pdev, NULL); |
1162 | kfree(data); | 1156 | kfree(data); |
1163 | 1157 | ||