aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/fam15h_power.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 12:58:06 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-09-24 00:08:33 -0400
commit87432a2e22d1ff63bb44ced0fb77e6f13e856354 (patch)
tree6854dbd97975eb4976bb2e823f3497c782baec9a /drivers/hwmon/fam15h_power.c
parent505dc0cc7e99279d60f5c3508018682beee22d65 (diff)
hwmon: (fam15h_power) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Cc: Andreas Herrmann <andreas.herrmann3@amd.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/fam15h_power.c')
-rw-r--r--drivers/hwmon/fam15h_power.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
index af69073b3fe8..68ad7d255512 100644
--- a/drivers/hwmon/fam15h_power.c
+++ b/drivers/hwmon/fam15h_power.c
@@ -198,7 +198,7 @@ static int __devinit fam15h_power_probe(struct pci_dev *pdev,
198 const struct pci_device_id *id) 198 const struct pci_device_id *id)
199{ 199{
200 struct fam15h_power_data *data; 200 struct fam15h_power_data *data;
201 struct device *dev; 201 struct device *dev = &pdev->dev;
202 int err; 202 int err;
203 203
204 /* 204 /*
@@ -208,23 +208,19 @@ static int __devinit fam15h_power_probe(struct pci_dev *pdev,
208 */ 208 */
209 tweak_runavg_range(pdev); 209 tweak_runavg_range(pdev);
210 210
211 if (!fam15h_power_is_internal_node0(pdev)) { 211 if (!fam15h_power_is_internal_node0(pdev))
212 err = -ENODEV; 212 return -ENODEV;
213 goto exit; 213
214 } 214 data = devm_kzalloc(dev, sizeof(struct fam15h_power_data), GFP_KERNEL);
215 if (!data)
216 return -ENOMEM;
215 217
216 data = kzalloc(sizeof(struct fam15h_power_data), GFP_KERNEL);
217 if (!data) {
218 err = -ENOMEM;
219 goto exit;
220 }
221 fam15h_power_init_data(pdev, data); 218 fam15h_power_init_data(pdev, data);
222 dev = &pdev->dev;
223 219
224 dev_set_drvdata(dev, data); 220 dev_set_drvdata(dev, data);
225 err = sysfs_create_group(&dev->kobj, &fam15h_power_attr_group); 221 err = sysfs_create_group(&dev->kobj, &fam15h_power_attr_group);
226 if (err) 222 if (err)
227 goto exit_free_data; 223 return err;
228 224
229 data->hwmon_dev = hwmon_device_register(dev); 225 data->hwmon_dev = hwmon_device_register(dev);
230 if (IS_ERR(data->hwmon_dev)) { 226 if (IS_ERR(data->hwmon_dev)) {
@@ -236,9 +232,6 @@ static int __devinit fam15h_power_probe(struct pci_dev *pdev,
236 232
237exit_remove_group: 233exit_remove_group:
238 sysfs_remove_group(&dev->kobj, &fam15h_power_attr_group); 234 sysfs_remove_group(&dev->kobj, &fam15h_power_attr_group);
239exit_free_data:
240 kfree(data);
241exit:
242 return err; 235 return err;
243} 236}
244 237
@@ -251,8 +244,6 @@ static void __devexit fam15h_power_remove(struct pci_dev *pdev)
251 data = dev_get_drvdata(dev); 244 data = dev_get_drvdata(dev);
252 hwmon_device_unregister(data->hwmon_dev); 245 hwmon_device_unregister(data->hwmon_dev);
253 sysfs_remove_group(&dev->kobj, &fam15h_power_attr_group); 246 sysfs_remove_group(&dev->kobj, &fam15h_power_attr_group);
254 dev_set_drvdata(dev, NULL);
255 kfree(data);
256} 247}
257 248
258static DEFINE_PCI_DEVICE_TABLE(fam15h_power_id_table) = { 249static DEFINE_PCI_DEVICE_TABLE(fam15h_power_id_table) = {