diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 12:58:06 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-22 00:48:39 -0400 |
commit | bba636d0592e5d33b960ba480459180ad5dc1fdd (patch) | |
tree | d378a3ffd96a7c8afdf5f2464bfc6d3264708fef /drivers | |
parent | 6ecffe16911dc79b079b6fb4491fd157c62d4371 (diff) |
hwmon: (gl518sm) 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')
-rw-r--r-- | drivers/hwmon/gl518sm.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 764a083ac7a7..2c74673f48e5 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c | |||
@@ -544,11 +544,10 @@ static int gl518_probe(struct i2c_client *client, | |||
544 | struct gl518_data *data; | 544 | struct gl518_data *data; |
545 | int err, revision; | 545 | int err, revision; |
546 | 546 | ||
547 | data = kzalloc(sizeof(struct gl518_data), GFP_KERNEL); | 547 | data = devm_kzalloc(&client->dev, sizeof(struct gl518_data), |
548 | if (!data) { | 548 | GFP_KERNEL); |
549 | err = -ENOMEM; | 549 | if (!data) |
550 | goto exit; | 550 | return -ENOMEM; |
551 | } | ||
552 | 551 | ||
553 | i2c_set_clientdata(client, data); | 552 | i2c_set_clientdata(client, data); |
554 | revision = gl518_read_value(client, GL518_REG_REVISION); | 553 | revision = gl518_read_value(client, GL518_REG_REVISION); |
@@ -562,7 +561,7 @@ static int gl518_probe(struct i2c_client *client, | |||
562 | /* Register sysfs hooks */ | 561 | /* Register sysfs hooks */ |
563 | err = sysfs_create_group(&client->dev.kobj, &gl518_group); | 562 | err = sysfs_create_group(&client->dev.kobj, &gl518_group); |
564 | if (err) | 563 | if (err) |
565 | goto exit_free; | 564 | return err; |
566 | if (data->type == gl518sm_r80) { | 565 | if (data->type == gl518sm_r80) { |
567 | err = sysfs_create_group(&client->dev.kobj, &gl518_group_r80); | 566 | err = sysfs_create_group(&client->dev.kobj, &gl518_group_r80); |
568 | if (err) | 567 | if (err) |
@@ -581,9 +580,6 @@ exit_remove_files: | |||
581 | sysfs_remove_group(&client->dev.kobj, &gl518_group); | 580 | sysfs_remove_group(&client->dev.kobj, &gl518_group); |
582 | if (data->type == gl518sm_r80) | 581 | if (data->type == gl518sm_r80) |
583 | sysfs_remove_group(&client->dev.kobj, &gl518_group_r80); | 582 | sysfs_remove_group(&client->dev.kobj, &gl518_group_r80); |
584 | exit_free: | ||
585 | kfree(data); | ||
586 | exit: | ||
587 | return err; | 583 | return err; |
588 | } | 584 | } |
589 | 585 | ||
@@ -617,7 +613,6 @@ static int gl518_remove(struct i2c_client *client) | |||
617 | if (data->type == gl518sm_r80) | 613 | if (data->type == gl518sm_r80) |
618 | sysfs_remove_group(&client->dev.kobj, &gl518_group_r80); | 614 | sysfs_remove_group(&client->dev.kobj, &gl518_group_r80); |
619 | 615 | ||
620 | kfree(data); | ||
621 | return 0; | 616 | return 0; |
622 | } | 617 | } |
623 | 618 | ||