aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/vt8231.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 14:35:55 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-09-24 00:08:33 -0400
commit7711f1bd039233464dbde346f4a14a4bb874f77f (patch)
treeb9355536cdc715ac32d2077cbd8e019c8697e247 /drivers/hwmon/vt8231.c
parenta844af19b9a8c3bcd1169f60916b0f7c40b6295f (diff)
hwmon: (vt8231) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Cc: Roger Lucas <vt8231@hiddenengine.co.uk> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/vt8231.c')
-rw-r--r--drivers/hwmon/vt8231.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
index 386a84538010..84e3dc5e3a83 100644
--- a/drivers/hwmon/vt8231.c
+++ b/drivers/hwmon/vt8231.c
@@ -789,18 +789,16 @@ static int vt8231_probe(struct platform_device *pdev)
789 789
790 /* Reserve the ISA region */ 790 /* Reserve the ISA region */
791 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 791 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
792 if (!request_region(res->start, VT8231_EXTENT, 792 if (!devm_request_region(&pdev->dev, res->start, VT8231_EXTENT,
793 vt8231_driver.driver.name)) { 793 vt8231_driver.driver.name)) {
794 dev_err(&pdev->dev, "Region 0x%lx-0x%lx already in use!\n", 794 dev_err(&pdev->dev, "Region 0x%lx-0x%lx already in use!\n",
795 (unsigned long)res->start, (unsigned long)res->end); 795 (unsigned long)res->start, (unsigned long)res->end);
796 return -ENODEV; 796 return -ENODEV;
797 } 797 }
798 798
799 data = kzalloc(sizeof(struct vt8231_data), GFP_KERNEL); 799 data = devm_kzalloc(&pdev->dev, sizeof(struct vt8231_data), GFP_KERNEL);
800 if (!data) { 800 if (!data)
801 err = -ENOMEM; 801 return -ENOMEM;
802 goto exit_release;
803 }
804 802
805 platform_set_drvdata(pdev, data); 803 platform_set_drvdata(pdev, data);
806 data->addr = res->start; 804 data->addr = res->start;
@@ -812,7 +810,7 @@ static int vt8231_probe(struct platform_device *pdev)
812 /* Register sysfs hooks */ 810 /* Register sysfs hooks */
813 err = sysfs_create_group(&pdev->dev.kobj, &vt8231_group); 811 err = sysfs_create_group(&pdev->dev.kobj, &vt8231_group);
814 if (err) 812 if (err)
815 goto exit_free; 813 return err;
816 814
817 /* Must update device information to find out the config field */ 815 /* Must update device information to find out the config field */
818 data->uch_config = vt8231_read_value(data, VT8231_REG_UCH_CONFIG); 816 data->uch_config = vt8231_read_value(data, VT8231_REG_UCH_CONFIG);
@@ -850,13 +848,6 @@ exit_remove_files:
850 sysfs_remove_group(&pdev->dev.kobj, &vt8231_group_temps[i]); 848 sysfs_remove_group(&pdev->dev.kobj, &vt8231_group_temps[i]);
851 849
852 sysfs_remove_group(&pdev->dev.kobj, &vt8231_group); 850 sysfs_remove_group(&pdev->dev.kobj, &vt8231_group);
853
854exit_free:
855 platform_set_drvdata(pdev, NULL);
856 kfree(data);
857
858exit_release:
859 release_region(res->start, VT8231_EXTENT);
860 return err; 851 return err;
861} 852}
862 853
@@ -875,9 +866,6 @@ static int __devexit vt8231_remove(struct platform_device *pdev)
875 866
876 sysfs_remove_group(&pdev->dev.kobj, &vt8231_group); 867 sysfs_remove_group(&pdev->dev.kobj, &vt8231_group);
877 868
878 release_region(data->addr, VT8231_EXTENT);
879 platform_set_drvdata(pdev, NULL);
880 kfree(data);
881 return 0; 869 return 0;
882} 870}
883 871