diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-02-22 11:56:48 -0500 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-03-18 21:27:47 -0400 |
commit | b8a5a7cebded23eb311b8db73a11ed23b4135170 (patch) | |
tree | 4d7abaa0d2933fad737471e63cd1ba023963a3b0 /drivers/hwmon/smm665.c | |
parent | 36839287204f1c419907d3873f1e45062000e8a2 (diff) |
hwmon: (smm665) Convert to use devm_kzalloc
Marginally less code and eliminate the possibility of memory leaks.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/smm665.c')
-rw-r--r-- | drivers/hwmon/smm665.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/hwmon/smm665.c b/drivers/hwmon/smm665.c index 5877078aaca5..cbc51fb30dba 100644 --- a/drivers/hwmon/smm665.c +++ b/drivers/hwmon/smm665.c | |||
@@ -584,10 +584,9 @@ static int smm665_probe(struct i2c_client *client, | |||
584 | if (i2c_smbus_read_byte_data(client, SMM665_ADOC_ENABLE) < 0) | 584 | if (i2c_smbus_read_byte_data(client, SMM665_ADOC_ENABLE) < 0) |
585 | return -ENODEV; | 585 | return -ENODEV; |
586 | 586 | ||
587 | ret = -ENOMEM; | 587 | data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); |
588 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
589 | if (!data) | 588 | if (!data) |
590 | goto out_return; | 589 | return -ENOMEM; |
591 | 590 | ||
592 | i2c_set_clientdata(client, data); | 591 | i2c_set_clientdata(client, data); |
593 | mutex_init(&data->update_lock); | 592 | mutex_init(&data->update_lock); |
@@ -596,7 +595,7 @@ static int smm665_probe(struct i2c_client *client, | |||
596 | data->cmdreg = i2c_new_dummy(adapter, (client->addr & ~SMM665_REGMASK) | 595 | data->cmdreg = i2c_new_dummy(adapter, (client->addr & ~SMM665_REGMASK) |
597 | | SMM665_CMDREG_BASE); | 596 | | SMM665_CMDREG_BASE); |
598 | if (!data->cmdreg) | 597 | if (!data->cmdreg) |
599 | goto out_kfree; | 598 | return -ENOMEM; |
600 | 599 | ||
601 | switch (data->type) { | 600 | switch (data->type) { |
602 | case smm465: | 601 | case smm465: |
@@ -679,9 +678,6 @@ out_remove_group: | |||
679 | sysfs_remove_group(&client->dev.kobj, &smm665_group); | 678 | sysfs_remove_group(&client->dev.kobj, &smm665_group); |
680 | out_unregister: | 679 | out_unregister: |
681 | i2c_unregister_device(data->cmdreg); | 680 | i2c_unregister_device(data->cmdreg); |
682 | out_kfree: | ||
683 | kfree(data); | ||
684 | out_return: | ||
685 | return ret; | 681 | return ret; |
686 | } | 682 | } |
687 | 683 | ||
@@ -693,8 +689,6 @@ static int smm665_remove(struct i2c_client *client) | |||
693 | hwmon_device_unregister(data->hwmon_dev); | 689 | hwmon_device_unregister(data->hwmon_dev); |
694 | sysfs_remove_group(&client->dev.kobj, &smm665_group); | 690 | sysfs_remove_group(&client->dev.kobj, &smm665_group); |
695 | 691 | ||
696 | kfree(data); | ||
697 | |||
698 | return 0; | 692 | return 0; |
699 | } | 693 | } |
700 | 694 | ||