提交 e7d5bf7e 编写于 作者: G Guenter Roeck

hwmon: (wm831x-hwmon) Convert to use devm_ functions

Convert to use devm_ functions to reduce code size and simplify the code.

Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
Reviewed-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 e41f6432
...@@ -163,7 +163,8 @@ static int __devinit wm831x_hwmon_probe(struct platform_device *pdev) ...@@ -163,7 +163,8 @@ static int __devinit wm831x_hwmon_probe(struct platform_device *pdev)
struct wm831x_hwmon *hwmon; struct wm831x_hwmon *hwmon;
int ret; int ret;
hwmon = kzalloc(sizeof(struct wm831x_hwmon), GFP_KERNEL); hwmon = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_hwmon),
GFP_KERNEL);
if (!hwmon) if (!hwmon)
return -ENOMEM; return -ENOMEM;
...@@ -171,7 +172,7 @@ static int __devinit wm831x_hwmon_probe(struct platform_device *pdev) ...@@ -171,7 +172,7 @@ static int __devinit wm831x_hwmon_probe(struct platform_device *pdev)
ret = sysfs_create_group(&pdev->dev.kobj, &wm831x_attr_group); ret = sysfs_create_group(&pdev->dev.kobj, &wm831x_attr_group);
if (ret) if (ret)
goto err; return ret;
hwmon->classdev = hwmon_device_register(&pdev->dev); hwmon->classdev = hwmon_device_register(&pdev->dev);
if (IS_ERR(hwmon->classdev)) { if (IS_ERR(hwmon->classdev)) {
...@@ -185,8 +186,6 @@ static int __devinit wm831x_hwmon_probe(struct platform_device *pdev) ...@@ -185,8 +186,6 @@ static int __devinit wm831x_hwmon_probe(struct platform_device *pdev)
err_sysfs: err_sysfs:
sysfs_remove_group(&pdev->dev.kobj, &wm831x_attr_group); sysfs_remove_group(&pdev->dev.kobj, &wm831x_attr_group);
err:
kfree(hwmon);
return ret; return ret;
} }
...@@ -196,8 +195,6 @@ static int __devexit wm831x_hwmon_remove(struct platform_device *pdev) ...@@ -196,8 +195,6 @@ static int __devexit wm831x_hwmon_remove(struct platform_device *pdev)
hwmon_device_unregister(hwmon->classdev); hwmon_device_unregister(hwmon->classdev);
sysfs_remove_group(&pdev->dev.kobj, &wm831x_attr_group); sysfs_remove_group(&pdev->dev.kobj, &wm831x_attr_group);
platform_set_drvdata(pdev, NULL);
kfree(hwmon);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册