summaryrefslogtreecommitdiff
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2014-02-16 15:29:55 -0800
committerGuenter Roeck <linux@roeck-us.net>2014-03-03 08:01:05 -0800
commitc503a811e44f4a861e3db0540dd7d4f2146a10f2 (patch)
tree24489dbbf7201888e296029dead59c3efb6e676b /drivers/hwmon
parent1075305de47d8ebf909acd3d52cade78b9e8f160 (diff)
hwmon: (coretemp) Allocate platform data with devm_kzalloc
This simplifies error handling. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Jean Delvare <jdelvare@suse.de> Tested-by: Jean Delvare <jdelvare@suse.de>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/coretemp.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 3f87db26433d..944f850d1118 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -582,22 +582,23 @@ static void coretemp_remove_core(struct platform_data *pdata,
static int coretemp_probe(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
struct platform_data *pdata;
int err;
/* Initialize the per-package data structures */
- pdata = kzalloc(sizeof(struct platform_data), GFP_KERNEL);
+ pdata = devm_kzalloc(dev, sizeof(struct platform_data), GFP_KERNEL);
if (!pdata)
return -ENOMEM;
- err = create_name_attr(pdata, &pdev->dev);
+ err = create_name_attr(pdata, dev);
if (err)
- goto exit_free;
+ return err;
pdata->phys_proc_id = pdev->id;
platform_set_drvdata(pdev, pdata);
- pdata->hwmon_dev = hwmon_device_register(&pdev->dev);
+ pdata->hwmon_dev = hwmon_device_register(dev);
if (IS_ERR(pdata->hwmon_dev)) {
err = PTR_ERR(pdata->hwmon_dev);
dev_err(&pdev->dev, "Class registration failed (%d)\n", err);
@@ -607,8 +608,6 @@ static int coretemp_probe(struct platform_device *pdev)
exit_name:
device_remove_file(&pdev->dev, &pdata->name_attr);
-exit_free:
- kfree(pdata);
return err;
}
@@ -623,7 +622,6 @@ static int coretemp_remove(struct platform_device *pdev)
device_remove_file(&pdev->dev, &pdata->name_attr);
hwmon_device_unregister(pdata->hwmon_dev);
- kfree(pdata);
return 0;
}