diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 14:20:23 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-22 00:48:42 -0400 |
commit | bd91d3bab8787f53c1b937ac817b0c59f8146b97 (patch) | |
tree | c96cc2c7f6bf8d37fcd2884f89f9840b5535e1b3 /drivers/hwmon/thmc50.c | |
parent | 5d224ade31f0a08c0a0eef9e74a6187c0b8747b4 (diff) |
hwmon: (thmc50) 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>
Diffstat (limited to 'drivers/hwmon/thmc50.c')
-rw-r--r-- | drivers/hwmon/thmc50.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/drivers/hwmon/thmc50.c b/drivers/hwmon/thmc50.c index add9f019b24f..080c26370480 100644 --- a/drivers/hwmon/thmc50.c +++ b/drivers/hwmon/thmc50.c | |||
@@ -361,12 +361,10 @@ static int thmc50_probe(struct i2c_client *client, | |||
361 | struct thmc50_data *data; | 361 | struct thmc50_data *data; |
362 | int err; | 362 | int err; |
363 | 363 | ||
364 | data = kzalloc(sizeof(struct thmc50_data), GFP_KERNEL); | 364 | data = devm_kzalloc(&client->dev, sizeof(struct thmc50_data), |
365 | if (!data) { | 365 | GFP_KERNEL); |
366 | pr_debug("thmc50: detect failed, kzalloc failed!\n"); | 366 | if (!data) |
367 | err = -ENOMEM; | 367 | return -ENOMEM; |
368 | goto exit; | ||
369 | } | ||
370 | 368 | ||
371 | i2c_set_clientdata(client, data); | 369 | i2c_set_clientdata(client, data); |
372 | data->type = id->driver_data; | 370 | data->type = id->driver_data; |
@@ -377,7 +375,7 @@ static int thmc50_probe(struct i2c_client *client, | |||
377 | /* Register sysfs hooks */ | 375 | /* Register sysfs hooks */ |
378 | err = sysfs_create_group(&client->dev.kobj, &thmc50_group); | 376 | err = sysfs_create_group(&client->dev.kobj, &thmc50_group); |
379 | if (err) | 377 | if (err) |
380 | goto exit_free; | 378 | return err; |
381 | 379 | ||
382 | /* Register ADM1022 sysfs hooks */ | 380 | /* Register ADM1022 sysfs hooks */ |
383 | if (data->has_temp3) { | 381 | if (data->has_temp3) { |
@@ -400,9 +398,6 @@ exit_remove_sysfs: | |||
400 | sysfs_remove_group(&client->dev.kobj, &temp3_group); | 398 | sysfs_remove_group(&client->dev.kobj, &temp3_group); |
401 | exit_remove_sysfs_thmc50: | 399 | exit_remove_sysfs_thmc50: |
402 | sysfs_remove_group(&client->dev.kobj, &thmc50_group); | 400 | sysfs_remove_group(&client->dev.kobj, &thmc50_group); |
403 | exit_free: | ||
404 | kfree(data); | ||
405 | exit: | ||
406 | return err; | 401 | return err; |
407 | } | 402 | } |
408 | 403 | ||
@@ -415,8 +410,6 @@ static int thmc50_remove(struct i2c_client *client) | |||
415 | if (data->has_temp3) | 410 | if (data->has_temp3) |
416 | sysfs_remove_group(&client->dev.kobj, &temp3_group); | 411 | sysfs_remove_group(&client->dev.kobj, &temp3_group); |
417 | 412 | ||
418 | kfree(data); | ||
419 | |||
420 | return 0; | 413 | return 0; |
421 | } | 414 | } |
422 | 415 | ||