aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 13:35:52 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-09-24 00:08:32 -0400
commitd2b95e58ea28eedc126ce9b714e2c7620869fdf4 (patch)
tree8591a60a21372d0ea4a3e9a4a1c9a94b3f6e270c /drivers/hwmon
parent78968642cc4b57c37d18b0242643026abc92717b (diff)
hwmon: (ltc4215) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Cc: Ira W. Snyder <iws@ovro.caltech.edu> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/ltc4215.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/hwmon/ltc4215.c b/drivers/hwmon/ltc4215.c
index 429c5b2b66fd..98b3d04f98b7 100644
--- a/drivers/hwmon/ltc4215.c
+++ b/drivers/hwmon/ltc4215.c
@@ -253,11 +253,9 @@ static int ltc4215_probe(struct i2c_client *client,
253 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 253 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
254 return -ENODEV; 254 return -ENODEV;
255 255
256 data = kzalloc(sizeof(*data), GFP_KERNEL); 256 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
257 if (!data) { 257 if (!data)
258 ret = -ENOMEM; 258 return -ENOMEM;
259 goto out_kzalloc;
260 }
261 259
262 i2c_set_clientdata(client, data); 260 i2c_set_clientdata(client, data);
263 mutex_init(&data->update_lock); 261 mutex_init(&data->update_lock);
@@ -268,7 +266,7 @@ static int ltc4215_probe(struct i2c_client *client,
268 /* Register sysfs hooks */ 266 /* Register sysfs hooks */
269 ret = sysfs_create_group(&client->dev.kobj, &ltc4215_group); 267 ret = sysfs_create_group(&client->dev.kobj, &ltc4215_group);
270 if (ret) 268 if (ret)
271 goto out_sysfs_create_group; 269 return ret;
272 270
273 data->hwmon_dev = hwmon_device_register(&client->dev); 271 data->hwmon_dev = hwmon_device_register(&client->dev);
274 if (IS_ERR(data->hwmon_dev)) { 272 if (IS_ERR(data->hwmon_dev)) {
@@ -280,9 +278,6 @@ static int ltc4215_probe(struct i2c_client *client,
280 278
281out_hwmon_device_register: 279out_hwmon_device_register:
282 sysfs_remove_group(&client->dev.kobj, &ltc4215_group); 280 sysfs_remove_group(&client->dev.kobj, &ltc4215_group);
283out_sysfs_create_group:
284 kfree(data);
285out_kzalloc:
286 return ret; 281 return ret;
287} 282}
288 283
@@ -293,8 +288,6 @@ static int ltc4215_remove(struct i2c_client *client)
293 hwmon_device_unregister(data->hwmon_dev); 288 hwmon_device_unregister(data->hwmon_dev);
294 sysfs_remove_group(&client->dev.kobj, &ltc4215_group); 289 sysfs_remove_group(&client->dev.kobj, &ltc4215_group);
295 290
296 kfree(data);
297
298 return 0; 291 return 0;
299} 292}
300 293