summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/pmbus/zl6100.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-02-22 08:56:43 -0800
committerGuenter Roeck <guenter.roeck@ericsson.com>2012-03-18 18:27:45 -0700
commit8b313ca7f1b98263ce22519b25a9c2a362eeb898 (patch)
tree36c4e576662996be3fcac1f34d339dcd53e569e3 /drivers/hwmon/pmbus/zl6100.c
parent07404aab52f5106ec436692474cf8f40978f5dac (diff)
downloadlinux-8b313ca7f1b98263ce22519b25a9c2a362eeb898.tar.bz2
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/zl6100.c')
-rw-r--r--drivers/hwmon/pmbus/zl6100.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/drivers/hwmon/pmbus/zl6100.c b/drivers/hwmon/pmbus/zl6100.c
index 8ae658118bec..9d3b84535e73 100644
--- a/drivers/hwmon/pmbus/zl6100.c
+++ b/drivers/hwmon/pmbus/zl6100.c
@@ -193,7 +193,8 @@ static int zl6100_probe(struct i2c_client *client,
"Device mismatch: Configured %s, detected %s\n",
id->name, mid->name);
- data = kzalloc(sizeof(struct zl6100_data), GFP_KERNEL);
+ data = devm_kzalloc(&client->dev, sizeof(struct zl6100_data),
+ GFP_KERNEL);
if (!data)
return -ENOMEM;
@@ -223,7 +224,8 @@ static int zl6100_probe(struct i2c_client *client,
ret = i2c_smbus_read_word_data(client, ZL6100_MFR_CONFIG);
if (ret < 0)
- goto err_mem;
+ return ret;
+
if (ret & ZL6100_MFR_XTEMP_ENABLE)
info->func[0] |= PMBUS_HAVE_TEMP2;
@@ -235,23 +237,12 @@ static int zl6100_probe(struct i2c_client *client,
info->write_word_data = zl6100_write_word_data;
info->write_byte = zl6100_write_byte;
- ret = pmbus_do_probe(client, mid, info);
- if (ret)
- goto err_mem;
- return 0;
-
-err_mem:
- kfree(data);
- return ret;
+ return pmbus_do_probe(client, mid, info);
}
static int zl6100_remove(struct i2c_client *client)
{
- const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
- const struct zl6100_data *data = to_zl6100_data(info);
-
pmbus_do_remove(client);
- kfree(data);
return 0;
}