diff options
author | Jean Delvare <khali@linux-fr.org> | 2010-08-14 21:09:00 +0200 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2010-08-14 21:09:00 +0200 |
commit | c6b8724647eb1c24dc37cec8518bb6957f0000a8 (patch) | |
tree | ff5c9d77d023d049c51b84323b809bd16bd080f8 | |
parent | 008e5f3350e0a474baff3ed3eb4f79653a6b6745 (diff) | |
download | op-kernel-dev-c6b8724647eb1c24dc37cec8518bb6957f0000a8.zip op-kernel-dev-c6b8724647eb1c24dc37cec8518bb6957f0000a8.tar.gz |
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>
-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 189dad4..9ec4daa 100644 --- a/drivers/hwmon/pc87427.c +++ b/drivers/hwmon/pc87427.c @@ -1045,6 +1045,29 @@ static void __devinit pc87427_init_device(struct device *dev) } } +static void pc87427_remove_files(struct device *dev) +{ + struct pc87427_data *data = dev_get_drvdata(dev); + int i; + + device_remove_file(dev, &dev_attr_name); + for (i = 0; i < 8; i++) { + if (!(data->fan_enabled & (1 << i))) + continue; + sysfs_remove_group(&dev->kobj, &pc87427_group_fan[i]); + } + for (i = 0; i < 4; i++) { + if (!(data->pwm_enabled & (1 << i))) + continue; + sysfs_remove_group(&dev->kobj, &pc87427_group_pwm[i]); + } + for (i = 0; i < 6; i++) { + if (!(data->temp_enabled & (1 << i))) + continue; + sysfs_remove_group(&dev->kobj, &pc87427_group_temp[i]); + } +} + static int __devinit pc87427_probe(struct platform_device *pdev) { struct pc87427_sio_data *sio_data = pdev->dev.platform_data; @@ -1110,21 +1133,7 @@ static int __devinit pc87427_probe(struct platform_device *pdev) return 0; exit_remove_files: - for (i = 0; i < 8; i++) { - if (!(data->fan_enabled & (1 << i))) - continue; - sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_fan[i]); - } - for (i = 0; i < 4; i++) { - if (!(data->pwm_enabled & (1 << i))) - continue; - sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_pwm[i]); - } - for (i = 0; i < 6; i++) { - if (!(data->temp_enabled & (1 << i))) - continue; - sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_temp[i]); - } + pc87427_remove_files(&pdev->dev); exit_release_region: pc87427_release_regions(pdev, res_count); exit_kfree: @@ -1137,27 +1146,12 @@ exit: static int __devexit pc87427_remove(struct platform_device *pdev) { struct pc87427_data *data = platform_get_drvdata(pdev); - int i, res_count; + int res_count; res_count = (data->address[0] != 0) + (data->address[1] != 0); hwmon_device_unregister(data->hwmon_dev); - device_remove_file(&pdev->dev, &dev_attr_name); - for (i = 0; i < 8; i++) { - if (!(data->fan_enabled & (1 << i))) - continue; - sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_fan[i]); - } - for (i = 0; i < 4; i++) { - if (!(data->pwm_enabled & (1 << i))) - continue; - sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_pwm[i]); - } - for (i = 0; i < 6; i++) { - if (!(data->temp_enabled & (1 << i))) - continue; - sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_temp[i]); - } + pc87427_remove_files(&pdev->dev); platform_set_drvdata(pdev, NULL); kfree(data); |