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>
This commit is contained in:
Родитель
f625e0fd51
Коммит
fd55bc009a
|
@ -690,18 +690,17 @@ static int __devinit via686a_probe(struct platform_device *pdev)
|
|||
|
||||
/* Reserve the ISA region */
|
||||
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
|
||||
if (!request_region(res->start, VIA686A_EXTENT,
|
||||
via686a_driver.driver.name)) {
|
||||
if (!devm_request_region(&pdev->dev, res->start, VIA686A_EXTENT,
|
||||
via686a_driver.driver.name)) {
|
||||
dev_err(&pdev->dev, "Region 0x%lx-0x%lx already in use!\n",
|
||||
(unsigned long)res->start, (unsigned long)res->end);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
data = kzalloc(sizeof(struct via686a_data), GFP_KERNEL);
|
||||
if (!data) {
|
||||
err = -ENOMEM;
|
||||
goto exit_release;
|
||||
}
|
||||
data = devm_kzalloc(&pdev->dev, sizeof(struct via686a_data),
|
||||
GFP_KERNEL);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
platform_set_drvdata(pdev, data);
|
||||
data->addr = res->start;
|
||||
|
@ -714,7 +713,7 @@ static int __devinit via686a_probe(struct platform_device *pdev)
|
|||
/* Register sysfs hooks */
|
||||
err = sysfs_create_group(&pdev->dev.kobj, &via686a_group);
|
||||
if (err)
|
||||
goto exit_free;
|
||||
return err;
|
||||
|
||||
data->hwmon_dev = hwmon_device_register(&pdev->dev);
|
||||
if (IS_ERR(data->hwmon_dev)) {
|
||||
|
@ -726,10 +725,6 @@ static int __devinit via686a_probe(struct platform_device *pdev)
|
|||
|
||||
exit_remove_files:
|
||||
sysfs_remove_group(&pdev->dev.kobj, &via686a_group);
|
||||
exit_free:
|
||||
kfree(data);
|
||||
exit_release:
|
||||
release_region(res->start, VIA686A_EXTENT);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -740,10 +735,6 @@ static int __devexit via686a_remove(struct platform_device *pdev)
|
|||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&pdev->dev.kobj, &via686a_group);
|
||||
|
||||
release_region(data->addr, VIA686A_EXTENT);
|
||||
platform_set_drvdata(pdev, NULL);
|
||||
kfree(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче