hwmon: (gl520sm) 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:
parent
bba636d059
commit
647ff514d8
|
@ -779,11 +779,10 @@ static int gl520_probe(struct i2c_client *client,
|
||||||
struct gl520_data *data;
|
struct gl520_data *data;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
data = kzalloc(sizeof(struct gl520_data), GFP_KERNEL);
|
data = devm_kzalloc(&client->dev, sizeof(struct gl520_data),
|
||||||
if (!data) {
|
GFP_KERNEL);
|
||||||
err = -ENOMEM;
|
if (!data)
|
||||||
goto exit;
|
return -ENOMEM;
|
||||||
}
|
|
||||||
|
|
||||||
i2c_set_clientdata(client, data);
|
i2c_set_clientdata(client, data);
|
||||||
mutex_init(&data->update_lock);
|
mutex_init(&data->update_lock);
|
||||||
|
@ -794,7 +793,7 @@ static int gl520_probe(struct i2c_client *client,
|
||||||
/* Register sysfs hooks */
|
/* Register sysfs hooks */
|
||||||
err = sysfs_create_group(&client->dev.kobj, &gl520_group);
|
err = sysfs_create_group(&client->dev.kobj, &gl520_group);
|
||||||
if (err)
|
if (err)
|
||||||
goto exit_free;
|
return err;
|
||||||
|
|
||||||
if (data->two_temps)
|
if (data->two_temps)
|
||||||
err = sysfs_create_group(&client->dev.kobj, &gl520_group_temp2);
|
err = sysfs_create_group(&client->dev.kobj, &gl520_group_temp2);
|
||||||
|
@ -816,9 +815,6 @@ exit_remove_files:
|
||||||
sysfs_remove_group(&client->dev.kobj, &gl520_group);
|
sysfs_remove_group(&client->dev.kobj, &gl520_group);
|
||||||
sysfs_remove_group(&client->dev.kobj, &gl520_group_in4);
|
sysfs_remove_group(&client->dev.kobj, &gl520_group_in4);
|
||||||
sysfs_remove_group(&client->dev.kobj, &gl520_group_temp2);
|
sysfs_remove_group(&client->dev.kobj, &gl520_group_temp2);
|
||||||
exit_free:
|
|
||||||
kfree(data);
|
|
||||||
exit:
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -870,7 +866,6 @@ static int gl520_remove(struct i2c_client *client)
|
||||||
sysfs_remove_group(&client->dev.kobj, &gl520_group_in4);
|
sysfs_remove_group(&client->dev.kobj, &gl520_group_in4);
|
||||||
sysfs_remove_group(&client->dev.kobj, &gl520_group_temp2);
|
sysfs_remove_group(&client->dev.kobj, &gl520_group_temp2);
|
||||||
|
|
||||||
kfree(data);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue