diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 14:35:54 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-22 00:48:42 -0400 |
commit | fd55bc009aeed6265841d4c07d317ec2e557db03 (patch) | |
tree | 146f0ee40e19d7a9787f9de734db571371605a12 /drivers | |
parent | f625e0fd513fa12cfabec9ed19f71a9bd7dd60e1 (diff) |
hwmon: (via686a) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/via686a.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index 288135d85e11..299399aa30fe 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c | |||
@@ -690,18 +690,17 @@ static int __devinit via686a_probe(struct platform_device *pdev) | |||
690 | 690 | ||
691 | /* Reserve the ISA region */ | 691 | /* Reserve the ISA region */ |
692 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 692 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
693 | if (!request_region(res->start, VIA686A_EXTENT, | 693 | if (!devm_request_region(&pdev->dev, res->start, VIA686A_EXTENT, |
694 | via686a_driver.driver.name)) { | 694 | via686a_driver.driver.name)) { |
695 | dev_err(&pdev->dev, "Region 0x%lx-0x%lx already in use!\n", | 695 | dev_err(&pdev->dev, "Region 0x%lx-0x%lx already in use!\n", |
696 | (unsigned long)res->start, (unsigned long)res->end); | 696 | (unsigned long)res->start, (unsigned long)res->end); |
697 | return -ENODEV; | 697 | return -ENODEV; |
698 | } | 698 | } |
699 | 699 | ||
700 | data = kzalloc(sizeof(struct via686a_data), GFP_KERNEL); | 700 | data = devm_kzalloc(&pdev->dev, sizeof(struct via686a_data), |
701 | if (!data) { | 701 | GFP_KERNEL); |
702 | err = -ENOMEM; | 702 | if (!data) |
703 | goto exit_release; | 703 | return -ENOMEM; |
704 | } | ||
705 | 704 | ||
706 | platform_set_drvdata(pdev, data); | 705 | platform_set_drvdata(pdev, data); |
707 | data->addr = res->start; | 706 | data->addr = res->start; |
@@ -714,7 +713,7 @@ static int __devinit via686a_probe(struct platform_device *pdev) | |||
714 | /* Register sysfs hooks */ | 713 | /* Register sysfs hooks */ |
715 | err = sysfs_create_group(&pdev->dev.kobj, &via686a_group); | 714 | err = sysfs_create_group(&pdev->dev.kobj, &via686a_group); |
716 | if (err) | 715 | if (err) |
717 | goto exit_free; | 716 | return err; |
718 | 717 | ||
719 | data->hwmon_dev = hwmon_device_register(&pdev->dev); | 718 | data->hwmon_dev = hwmon_device_register(&pdev->dev); |
720 | if (IS_ERR(data->hwmon_dev)) { | 719 | if (IS_ERR(data->hwmon_dev)) { |
@@ -726,10 +725,6 @@ static int __devinit via686a_probe(struct platform_device *pdev) | |||
726 | 725 | ||
727 | exit_remove_files: | 726 | exit_remove_files: |
728 | sysfs_remove_group(&pdev->dev.kobj, &via686a_group); | 727 | sysfs_remove_group(&pdev->dev.kobj, &via686a_group); |
729 | exit_free: | ||
730 | kfree(data); | ||
731 | exit_release: | ||
732 | release_region(res->start, VIA686A_EXTENT); | ||
733 | return err; | 728 | return err; |
734 | } | 729 | } |
735 | 730 | ||
@@ -740,10 +735,6 @@ static int __devexit via686a_remove(struct platform_device *pdev) | |||
740 | hwmon_device_unregister(data->hwmon_dev); | 735 | hwmon_device_unregister(data->hwmon_dev); |
741 | sysfs_remove_group(&pdev->dev.kobj, &via686a_group); | 736 | sysfs_remove_group(&pdev->dev.kobj, &via686a_group); |
742 | 737 | ||
743 | release_region(data->addr, VIA686A_EXTENT); | ||
744 | platform_set_drvdata(pdev, NULL); | ||
745 | kfree(data); | ||
746 | |||
747 | return 0; | 738 | return 0; |
748 | } | 739 | } |
749 | 740 | ||