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

hwmon: (amc6821) Convert to use devm_ functions

Convert to use devm_ functions to reduce code size and simplify the code.
Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
上级 9cc7dcc5
...@@ -862,12 +862,10 @@ static int amc6821_probe( ...@@ -862,12 +862,10 @@ static int amc6821_probe(
struct amc6821_data *data; struct amc6821_data *data;
int err; int err;
data = kzalloc(sizeof(struct amc6821_data), GFP_KERNEL); data = devm_kzalloc(&client->dev, sizeof(struct amc6821_data),
if (!data) { GFP_KERNEL);
dev_err(&client->dev, "out of memory.\n"); if (!data)
return -ENOMEM; return -ENOMEM;
}
i2c_set_clientdata(client, data); i2c_set_clientdata(client, data);
mutex_init(&data->update_lock); mutex_init(&data->update_lock);
...@@ -877,11 +875,11 @@ static int amc6821_probe( ...@@ -877,11 +875,11 @@ static int amc6821_probe(
*/ */
err = amc6821_init_client(client); err = amc6821_init_client(client);
if (err) if (err)
goto err_free; return err;
err = sysfs_create_group(&client->dev.kobj, &amc6821_attr_grp); err = sysfs_create_group(&client->dev.kobj, &amc6821_attr_grp);
if (err) if (err)
goto err_free; return err;
data->hwmon_dev = hwmon_device_register(&client->dev); data->hwmon_dev = hwmon_device_register(&client->dev);
if (!IS_ERR(data->hwmon_dev)) if (!IS_ERR(data->hwmon_dev))
...@@ -890,8 +888,6 @@ static int amc6821_probe( ...@@ -890,8 +888,6 @@ static int amc6821_probe(
err = PTR_ERR(data->hwmon_dev); err = PTR_ERR(data->hwmon_dev);
dev_err(&client->dev, "error registering hwmon device.\n"); dev_err(&client->dev, "error registering hwmon device.\n");
sysfs_remove_group(&client->dev.kobj, &amc6821_attr_grp); sysfs_remove_group(&client->dev.kobj, &amc6821_attr_grp);
err_free:
kfree(data);
return err; return err;
} }
...@@ -902,8 +898,6 @@ static int amc6821_remove(struct i2c_client *client) ...@@ -902,8 +898,6 @@ static int amc6821_remove(struct i2c_client *client)
hwmon_device_unregister(data->hwmon_dev); hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &amc6821_attr_grp); sysfs_remove_group(&client->dev.kobj, &amc6821_attr_grp);
kfree(data);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册