diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 20:58:06 +0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-09-24 08:08:33 +0400 |
commit | 87432a2e22d1ff63bb44ced0fb77e6f13e856354 (patch) | |
tree | 6854dbd97975eb4976bb2e823f3497c782baec9a /drivers/hwmon/fam15h_power.c | |
parent | 505dc0cc7e99279d60f5c3508018682beee22d65 (diff) | |
download | linux-87432a2e22d1ff63bb44ced0fb77e6f13e856354.tar.xz |
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.c | 25 |
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, const struct pci_device_id *id) { struct fam15h_power_data *data; - struct device *dev; + struct device *dev = &pdev->dev; int err; /* @@ -208,23 +208,19 @@ static int __devinit fam15h_power_probe(struct pci_dev *pdev, */ tweak_runavg_range(pdev); - if (!fam15h_power_is_internal_node0(pdev)) { - err = -ENODEV; - goto exit; - } + if (!fam15h_power_is_internal_node0(pdev)) + return -ENODEV; + + data = devm_kzalloc(dev, sizeof(struct fam15h_power_data), GFP_KERNEL); + if (!data) + return -ENOMEM; - data = kzalloc(sizeof(struct fam15h_power_data), GFP_KERNEL); - if (!data) { - err = -ENOMEM; - goto exit; - } fam15h_power_init_data(pdev, data); - dev = &pdev->dev; dev_set_drvdata(dev, data); err = sysfs_create_group(&dev->kobj, &fam15h_power_attr_group); if (err) - goto exit_free_data; + return err; data->hwmon_dev = hwmon_device_register(dev); if (IS_ERR(data->hwmon_dev)) { @@ -236,9 +232,6 @@ static int __devinit fam15h_power_probe(struct pci_dev *pdev, exit_remove_group: sysfs_remove_group(&dev->kobj, &fam15h_power_attr_group); -exit_free_data: - kfree(data); -exit: return err; } @@ -251,8 +244,6 @@ static void __devexit fam15h_power_remove(struct pci_dev *pdev) data = dev_get_drvdata(dev); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&dev->kobj, &fam15h_power_attr_group); - dev_set_drvdata(dev, NULL); - kfree(data); } static DEFINE_PCI_DEVICE_TABLE(fam15h_power_id_table) = { |