From 647ff514d8a099fcce029283c1ecc38519b218d6 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Sat, 2 Jun 2012 09:58:07 -0700 Subject: 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 Acked-by: Jean Delvare --- drivers/hwmon/gl520sm.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'drivers/hwmon') diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index 5ff452b6a4d0..a21ff252f2f1 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c @@ -779,11 +779,10 @@ static int gl520_probe(struct i2c_client *client, struct gl520_data *data; int err; - data = kzalloc(sizeof(struct gl520_data), GFP_KERNEL); - if (!data) { - err = -ENOMEM; - goto exit; - } + data = devm_kzalloc(&client->dev, sizeof(struct gl520_data), + GFP_KERNEL); + if (!data) + return -ENOMEM; i2c_set_clientdata(client, data); mutex_init(&data->update_lock); @@ -794,7 +793,7 @@ static int gl520_probe(struct i2c_client *client, /* Register sysfs hooks */ err = sysfs_create_group(&client->dev.kobj, &gl520_group); if (err) - goto exit_free; + return err; if (data->two_temps) 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_in4); sysfs_remove_group(&client->dev.kobj, &gl520_group_temp2); -exit_free: - kfree(data); -exit: 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_temp2); - kfree(data); return 0; } -- cgit v1.2.1