hwmon: (max6650) Convert to use devm_ functions

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

Cc: Hans J. Koch <hjk@hansjkoch.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Hans J. Koch <hjk@hansjkoch.de>
This commit is contained in:
Guenter Roeck 2012-06-02 09:58:13 -07:00
Родитель e7d5bf7ed5
Коммит 94cd52027a
1 изменённых файлов: 4 добавлений и 6 удалений

Просмотреть файл

@ -545,7 +545,8 @@ static int max6650_probe(struct i2c_client *client,
struct max6650_data *data;
int err;
data = kzalloc(sizeof(struct max6650_data), GFP_KERNEL);
data = devm_kzalloc(&client->dev, sizeof(struct max6650_data),
GFP_KERNEL);
if (!data) {
dev_err(&client->dev, "out of memory.\n");
return -ENOMEM;
@ -560,11 +561,11 @@ static int max6650_probe(struct i2c_client *client,
*/
err = max6650_init_client(client);
if (err)
goto err_free;
return err;
err = sysfs_create_group(&client->dev.kobj, &max6650_attr_grp);
if (err)
goto err_free;
return err;
/* 3 additional fan inputs for the MAX6651 */
if (data->nr_fans == 4) {
err = sysfs_create_group(&client->dev.kobj, &max6651_attr_grp);
@ -582,8 +583,6 @@ static int max6650_probe(struct i2c_client *client,
sysfs_remove_group(&client->dev.kobj, &max6651_attr_grp);
err_remove:
sysfs_remove_group(&client->dev.kobj, &max6650_attr_grp);
err_free:
kfree(data);
return err;
}
@ -595,7 +594,6 @@ static int max6650_remove(struct i2c_client *client)
if (data->nr_fans == 4)
sysfs_remove_group(&client->dev.kobj, &max6651_attr_grp);
sysfs_remove_group(&client->dev.kobj, &max6650_attr_grp);
kfree(data);
return 0;
}