diff options
author | Guenter Roeck <linux@roeck-us.net> | 2014-02-16 18:29:55 -0500 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2014-03-03 11:01:05 -0500 |
commit | c503a811e44f4a861e3db0540dd7d4f2146a10f2 (patch) | |
tree | 24489dbbf7201888e296029dead59c3efb6e676b /drivers/hwmon | |
parent | 1075305de47d8ebf909acd3d52cade78b9e8f160 (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.c | 12 |
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, | |||
582 | 582 | ||
583 | static int coretemp_probe(struct platform_device *pdev) | 583 | static int coretemp_probe(struct platform_device *pdev) |
584 | { | 584 | { |
585 | struct device *dev = &pdev->dev; | ||
585 | struct platform_data *pdata; | 586 | struct platform_data *pdata; |
586 | int err; | 587 | int err; |
587 | 588 | ||
588 | /* Initialize the per-package data structures */ | 589 | /* Initialize the per-package data structures */ |
589 | pdata = kzalloc(sizeof(struct platform_data), GFP_KERNEL); | 590 | pdata = devm_kzalloc(dev, sizeof(struct platform_data), GFP_KERNEL); |
590 | if (!pdata) | 591 | if (!pdata) |
591 | return -ENOMEM; | 592 | return -ENOMEM; |
592 | 593 | ||
593 | err = create_name_attr(pdata, &pdev->dev); | 594 | err = create_name_attr(pdata, dev); |
594 | if (err) | 595 | if (err) |
595 | goto exit_free; | 596 | return err; |
596 | 597 | ||
597 | pdata->phys_proc_id = pdev->id; | 598 | pdata->phys_proc_id = pdev->id; |
598 | platform_set_drvdata(pdev, pdata); | 599 | platform_set_drvdata(pdev, pdata); |
599 | 600 | ||
600 | pdata->hwmon_dev = hwmon_device_register(&pdev->dev); | 601 | pdata->hwmon_dev = hwmon_device_register(dev); |
601 | if (IS_ERR(pdata->hwmon_dev)) { | 602 | if (IS_ERR(pdata->hwmon_dev)) { |
602 | err = PTR_ERR(pdata->hwmon_dev); | 603 | err = PTR_ERR(pdata->hwmon_dev); |
603 | dev_err(&pdev->dev, "Class registration failed (%d)\n", err); | 604 | dev_err(&pdev->dev, "Class registration failed (%d)\n", err); |
@@ -607,8 +608,6 @@ static int coretemp_probe(struct platform_device *pdev) | |||
607 | 608 | ||
608 | exit_name: | 609 | exit_name: |
609 | device_remove_file(&pdev->dev, &pdata->name_attr); | 610 | device_remove_file(&pdev->dev, &pdata->name_attr); |
610 | exit_free: | ||
611 | kfree(pdata); | ||
612 | return err; | 611 | return err; |
613 | } | 612 | } |
614 | 613 | ||
@@ -623,7 +622,6 @@ static int coretemp_remove(struct platform_device *pdev) | |||
623 | 622 | ||
624 | device_remove_file(&pdev->dev, &pdata->name_attr); | 623 | device_remove_file(&pdev->dev, &pdata->name_attr); |
625 | hwmon_device_unregister(pdata->hwmon_dev); | 624 | hwmon_device_unregister(pdata->hwmon_dev); |
626 | kfree(pdata); | ||
627 | return 0; | 625 | return 0; |
628 | } | 626 | } |
629 | 627 | ||