diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-02-22 08:56:43 -0800 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-03-18 18:27:45 -0700 |
commit | 8b313ca7f1b98263ce22519b25a9c2a362eeb898 (patch) | |
tree | 36c4e576662996be3fcac1f34d339dcd53e569e3 /drivers/hwmon/pmbus/ltc2978.c | |
parent | 07404aab52f5106ec436692474cf8f40978f5dac (diff) | |
download | linux-8b313ca7f1b98263ce22519b25a9c2a362eeb898.tar.gz linux-8b313ca7f1b98263ce22519b25a9c2a362eeb898.tar.bz2 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/ltc2978.c')
-rw-r--r-- | drivers/hwmon/pmbus/ltc2978.c | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c index c9e4dd20bf9c..5e07a363b3e9 100644 --- a/drivers/hwmon/pmbus/ltc2978.c +++ b/drivers/hwmon/pmbus/ltc2978.c @@ -287,7 +287,7 @@ MODULE_DEVICE_TABLE(i2c, ltc2978_id); static int ltc2978_probe(struct i2c_client *client, const struct i2c_device_id *id) { - int chip_id, ret, i; + int chip_id, i; struct ltc2978_data *data; struct pmbus_driver_info *info; @@ -295,15 +295,14 @@ static int ltc2978_probe(struct i2c_client *client, I2C_FUNC_SMBUS_READ_WORD_DATA)) return -ENODEV; - data = kzalloc(sizeof(struct ltc2978_data), GFP_KERNEL); + data = devm_kzalloc(&client->dev, sizeof(struct ltc2978_data), + GFP_KERNEL); if (!data) return -ENOMEM; chip_id = i2c_smbus_read_word_data(client, LTC2978_MFR_SPECIAL_ID); - if (chip_id < 0) { - ret = chip_id; - goto err_mem; - } + if (chip_id < 0) + return chip_id; if (chip_id == LTC2978_ID_REV1 || chip_id == LTC2978_ID_REV2) { data->id = ltc2978; @@ -311,8 +310,7 @@ static int ltc2978_probe(struct i2c_client *client, data->id = ltc3880; } else { dev_err(&client->dev, "Unsupported chip ID 0x%x\n", chip_id); - ret = -ENODEV; - goto err_mem; + return -ENODEV; } if (data->id != id->driver_data) dev_warn(&client->dev, @@ -357,27 +355,15 @@ static int ltc2978_probe(struct i2c_client *client, data->vout_min[1] = 0xffff; break; default: - ret = -ENODEV; - goto err_mem; + return -ENODEV; } - ret = pmbus_do_probe(client, id, info); - if (ret) - goto err_mem; - return 0; - -err_mem: - kfree(data); - return ret; + return pmbus_do_probe(client, id, info); } static int ltc2978_remove(struct i2c_client *client) { - const struct pmbus_driver_info *info = pmbus_get_driver_info(client); - const struct ltc2978_data *data = to_ltc2978_data(info); - pmbus_do_remove(client); - kfree(data); return 0; } |