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>
This commit is contained in:
parent
a844af19b9
commit
7711f1bd03
1 changed files with 6 additions and 18 deletions
|
@ -789,18 +789,16 @@ static int vt8231_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
/* Reserve the ISA region */
|
/* Reserve the ISA region */
|
||||||
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
|
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
|
||||||
if (!request_region(res->start, VT8231_EXTENT,
|
if (!devm_request_region(&pdev->dev, res->start, VT8231_EXTENT,
|
||||||
vt8231_driver.driver.name)) {
|
vt8231_driver.driver.name)) {
|
||||||
dev_err(&pdev->dev, "Region 0x%lx-0x%lx already in use!\n",
|
dev_err(&pdev->dev, "Region 0x%lx-0x%lx already in use!\n",
|
||||||
(unsigned long)res->start, (unsigned long)res->end);
|
(unsigned long)res->start, (unsigned long)res->end);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = kzalloc(sizeof(struct vt8231_data), GFP_KERNEL);
|
data = devm_kzalloc(&pdev->dev, sizeof(struct vt8231_data), GFP_KERNEL);
|
||||||
if (!data) {
|
if (!data)
|
||||||
err = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto exit_release;
|
|
||||||
}
|
|
||||||
|
|
||||||
platform_set_drvdata(pdev, data);
|
platform_set_drvdata(pdev, data);
|
||||||
data->addr = res->start;
|
data->addr = res->start;
|
||||||
|
@ -812,7 +810,7 @@ static int vt8231_probe(struct platform_device *pdev)
|
||||||
/* Register sysfs hooks */
|
/* Register sysfs hooks */
|
||||||
err = sysfs_create_group(&pdev->dev.kobj, &vt8231_group);
|
err = sysfs_create_group(&pdev->dev.kobj, &vt8231_group);
|
||||||
if (err)
|
if (err)
|
||||||
goto exit_free;
|
return err;
|
||||||
|
|
||||||
/* Must update device information to find out the config field */
|
/* Must update device information to find out the config field */
|
||||||
data->uch_config = vt8231_read_value(data, VT8231_REG_UCH_CONFIG);
|
data->uch_config = vt8231_read_value(data, VT8231_REG_UCH_CONFIG);
|
||||||
|
@ -850,13 +848,6 @@ exit_remove_files:
|
||||||
sysfs_remove_group(&pdev->dev.kobj, &vt8231_group_temps[i]);
|
sysfs_remove_group(&pdev->dev.kobj, &vt8231_group_temps[i]);
|
||||||
|
|
||||||
sysfs_remove_group(&pdev->dev.kobj, &vt8231_group);
|
sysfs_remove_group(&pdev->dev.kobj, &vt8231_group);
|
||||||
|
|
||||||
exit_free:
|
|
||||||
platform_set_drvdata(pdev, NULL);
|
|
||||||
kfree(data);
|
|
||||||
|
|
||||||
exit_release:
|
|
||||||
release_region(res->start, VT8231_EXTENT);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -875,9 +866,6 @@ static int __devexit vt8231_remove(struct platform_device *pdev)
|
||||||
|
|
||||||
sysfs_remove_group(&pdev->dev.kobj, &vt8231_group);
|
sysfs_remove_group(&pdev->dev.kobj, &vt8231_group);
|
||||||
|
|
||||||
release_region(data->addr, VT8231_EXTENT);
|
|
||||||
platform_set_drvdata(pdev, NULL);
|
|
||||||
kfree(data);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue