Skip to content

Commit

Permalink
hwmon: (max6639) Convert to use devm_ functions
Browse files Browse the repository at this point in the history
Convert to use devm_ functions to reduce code size and simplify the code.

Cc: Roland Stigge <stigge@antcom.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Roland Stigge <stigge@antcom.de>
  • Loading branch information
Guenter Roeck committed Jul 22, 2012
1 parent 94cd520 commit b07405f
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions drivers/hwmon/max6639.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,24 +548,23 @@ static int max6639_probe(struct i2c_client *client,
struct max6639_data *data;
int err;

data = kzalloc(sizeof(struct max6639_data), GFP_KERNEL);
if (!data) {
err = -ENOMEM;
goto exit;
}
data = devm_kzalloc(&client->dev, sizeof(struct max6639_data),
GFP_KERNEL);
if (!data)
return -ENOMEM;

i2c_set_clientdata(client, data);
mutex_init(&data->update_lock);

/* Initialize the max6639 chip */
err = max6639_init_client(client);
if (err < 0)
goto error_free;
return err;

/* Register sysfs hooks */
err = sysfs_create_group(&client->dev.kobj, &max6639_group);
if (err)
goto error_free;
return err;

data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) {
Expand All @@ -579,9 +578,6 @@ static int max6639_probe(struct i2c_client *client,

error_remove:
sysfs_remove_group(&client->dev.kobj, &max6639_group);
error_free:
kfree(data);
exit:
return err;
}

Expand All @@ -592,7 +588,6 @@ static int max6639_remove(struct i2c_client *client)
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &max6639_group);

kfree(data);
return 0;
}

Expand Down

0 comments on commit b07405f

Please sign in to comment.