summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 11:20:19 -0700
committerGuenter Roeck <linux@roeck-us.net>2012-09-23 21:08:32 -0700
commit79831fd4e0820bdc882d08707e4650ed4dfff3b8 (patch)
tree4c1ea24c39319e26b0085aad006b991b4fe15e19 /drivers/hwmon
parenteffb8ab114f7ed574f3c033dac642cd2c4ae0021 (diff)
hwmon: (mcp3021) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Cc: Mingkai Hu <Mingkai.hu@freescale.com> Cc: Xie Xiaobo <X.Xie@freescale.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/mcp3021.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/hwmon/mcp3021.c b/drivers/hwmon/mcp3021.c
index d0afc0cd3ff..5162bb95bc6 100644
--- a/drivers/hwmon/mcp3021.c
+++ b/drivers/hwmon/mcp3021.c
@@ -103,7 +103,8 @@ static int mcp3021_probe(struct i2c_client *client,
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -ENODEV;
- data = kzalloc(sizeof(struct mcp3021_data), GFP_KERNEL);
+ data = devm_kzalloc(&client->dev, sizeof(struct mcp3021_data),
+ GFP_KERNEL);
if (!data)
return -ENOMEM;
@@ -111,17 +112,14 @@ static int mcp3021_probe(struct i2c_client *client,
if (client->dev.platform_data) {
data->vdd = *(u32 *)client->dev.platform_data;
- if (data->vdd > MCP3021_VDD_MAX ||
- data->vdd < MCP3021_VDD_MIN) {
- err = -EINVAL;
- goto exit_free;
- }
+ if (data->vdd > MCP3021_VDD_MAX || data->vdd < MCP3021_VDD_MIN)
+ return -EINVAL;
} else
data->vdd = MCP3021_VDD_REF;
err = sysfs_create_file(&client->dev.kobj, &dev_attr_in0_input.attr);
if (err)
- goto exit_free;
+ return err;
data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) {
@@ -133,8 +131,6 @@ static int mcp3021_probe(struct i2c_client *client,
exit_remove:
sysfs_remove_file(&client->dev.kobj, &dev_attr_in0_input.attr);
-exit_free:
- kfree(data);
return err;
}
@@ -144,7 +140,6 @@ static int mcp3021_remove(struct i2c_client *client)
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_file(&client->dev.kobj, &dev_attr_in0_input.attr);
- kfree(data);
return 0;
}