diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-02-22 17:56:43 +0100 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-03-19 02:27:45 +0100 |
commit | 8b313ca7f1b98263ce22519b25a9c2a362eeb898 (patch) | |
tree | 36c4e576662996be3fcac1f34d339dcd53e569e3 /drivers/hwmon/pmbus/ucd9200.c | |
parent | hwmon: (lineage-pem) Convert to use devm_kzalloc (diff) | |
download | linux-8b313ca7f1b98263ce22519b25a9c2a362eeb898.tar.xz linux-8b313ca7f1b98263ce22519b25a9c2a362eeb898.zip |
hwmon: (pmbus) Convert pmbus drivers 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/pmbus/ucd9200.c')
-rw-r--r-- | drivers/hwmon/pmbus/ucd9200.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/drivers/hwmon/pmbus/ucd9200.c b/drivers/hwmon/pmbus/ucd9200.c index 629d0c93cac6..c0d41b993a53 100644 --- a/drivers/hwmon/pmbus/ucd9200.c +++ b/drivers/hwmon/pmbus/ucd9200.c @@ -81,7 +81,8 @@ static int ucd9200_probe(struct i2c_client *client, "Device mismatch: Configured %s, detected %s\n", id->name, mid->name); - info = kzalloc(sizeof(struct pmbus_driver_info), GFP_KERNEL); + info = devm_kzalloc(&client->dev, sizeof(struct pmbus_driver_info), + GFP_KERNEL); if (!info) return -ENOMEM; @@ -89,7 +90,7 @@ static int ucd9200_probe(struct i2c_client *client, block_buffer); if (ret < 0) { dev_err(&client->dev, "Failed to read phase information\n"); - goto out; + return ret; } /* @@ -106,8 +107,7 @@ static int ucd9200_probe(struct i2c_client *client, } if (!info->pages) { dev_err(&client->dev, "No rails configured\n"); - ret = -ENODEV; - goto out; + return -ENODEV; } dev_info(&client->dev, "%d rails configured\n", info->pages); @@ -137,7 +137,7 @@ static int ucd9200_probe(struct i2c_client *client, if (ret < 0) { dev_err(&client->dev, "Failed to initialize PHASE registers\n"); - goto out; + return ret; } } if (info->pages > 1) @@ -160,22 +160,12 @@ static int ucd9200_probe(struct i2c_client *client, if (mid->driver_data == ucd9240) info->func[0] |= PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12; - ret = pmbus_do_probe(client, mid, info); - if (ret < 0) - goto out; - return 0; -out: - kfree(info); - return ret; + return pmbus_do_probe(client, mid, info); } static int ucd9200_remove(struct i2c_client *client) { - const struct pmbus_driver_info *info; - - info = pmbus_get_driver_info(client); pmbus_do_remove(client); - kfree(info); return 0; } |