提交 59da32d8 编写于 作者: G Guenter Roeck

hwmon: (emc2103) Convert to use devm_ functions

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

Cc: Steve Glendinning <steve.glendinning@smsc.com>
Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
上级 7b52eefe
...@@ -590,7 +590,8 @@ emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -590,7 +590,8 @@ emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id)
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -EIO; return -EIO;
data = kzalloc(sizeof(struct emc2103_data), GFP_KERNEL); data = devm_kzalloc(&client->dev, sizeof(struct emc2103_data),
GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
...@@ -608,7 +609,7 @@ emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -608,7 +609,7 @@ emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id)
if (status < 0) { if (status < 0) {
dev_dbg(&client->dev, "reg 0x%02x, err %d\n", REG_CONF1, dev_dbg(&client->dev, "reg 0x%02x, err %d\n", REG_CONF1,
status); status);
goto exit_free; return status;
} }
/* detect current state of hardware */ /* detect current state of hardware */
...@@ -631,7 +632,7 @@ emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -631,7 +632,7 @@ emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id)
/* Register sysfs hooks */ /* Register sysfs hooks */
status = sysfs_create_group(&client->dev.kobj, &emc2103_group); status = sysfs_create_group(&client->dev.kobj, &emc2103_group);
if (status) if (status)
goto exit_free; return status;
if (data->temp_count >= 3) { if (data->temp_count >= 3) {
status = sysfs_create_group(&client->dev.kobj, status = sysfs_create_group(&client->dev.kobj,
...@@ -666,8 +667,6 @@ emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -666,8 +667,6 @@ emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id)
sysfs_remove_group(&client->dev.kobj, &emc2103_temp3_group); sysfs_remove_group(&client->dev.kobj, &emc2103_temp3_group);
exit_remove: exit_remove:
sysfs_remove_group(&client->dev.kobj, &emc2103_group); sysfs_remove_group(&client->dev.kobj, &emc2103_group);
exit_free:
kfree(data);
return status; return status;
} }
...@@ -685,7 +684,6 @@ static int emc2103_remove(struct i2c_client *client) ...@@ -685,7 +684,6 @@ static int emc2103_remove(struct i2c_client *client)
sysfs_remove_group(&client->dev.kobj, &emc2103_group); sysfs_remove_group(&client->dev.kobj, &emc2103_group);
kfree(data);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册