summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/pmbus/lm25066.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/lm25066.c
parent07404aab52f5106ec436692474cf8f40978f5dac (diff)
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/lm25066.c')
-rw-r--r--drivers/hwmon/pmbus/lm25066.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
index 86ac15ade6a..e70d4ca14fb 100644
--- a/drivers/hwmon/pmbus/lm25066.c
+++ b/drivers/hwmon/pmbus/lm25066.c
@@ -176,7 +176,6 @@ static int lm25066_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
int config;
- int ret;
struct lm25066_data *data;
struct pmbus_driver_info *info;
@@ -184,15 +183,14 @@ static int lm25066_probe(struct i2c_client *client,
I2C_FUNC_SMBUS_READ_BYTE_DATA))
return -ENODEV;
- data = kzalloc(sizeof(struct lm25066_data), GFP_KERNEL);
+ data = devm_kzalloc(&client->dev, sizeof(struct lm25066_data),
+ GFP_KERNEL);
if (!data)
return -ENOMEM;
config = i2c_smbus_read_byte_data(client, LM25066_DEVICE_SETUP);
- if (config < 0) {
- ret = config;
- goto err_mem;
- }
+ if (config < 0)
+ return config;
data->id = id->driver_data;
info = &data->info;
@@ -291,27 +289,15 @@ static int lm25066_probe(struct i2c_client *client,
}
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 lm25066_remove(struct i2c_client *client)
{
- const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
- const struct lm25066_data *data = to_lm25066_data(info);
-
pmbus_do_remove(client);
- kfree(data);
return 0;
}