aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 12:57:59 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-09-24 00:08:29 -0400
commit08940b8aba8ded377e546c12c5b932364c0a03cc (patch)
tree242ce26b8308f40a5822e64d3053bde70ded9963 /drivers
parentc60da82593b30d3b3b97e80f6f74b5f4afa9d0b5 (diff)
hwmon: (adm1029) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Cc: Corentin Labbe <corentin.labbe@geomatys.fr> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hwmon/adm1029.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c
index 80cc465d8ac7..97f4718382f6 100644
--- a/drivers/hwmon/adm1029.c
+++ b/drivers/hwmon/adm1029.c
@@ -342,11 +342,10 @@ static int adm1029_probe(struct i2c_client *client,
342 struct adm1029_data *data; 342 struct adm1029_data *data;
343 int err; 343 int err;
344 344
345 data = kzalloc(sizeof(struct adm1029_data), GFP_KERNEL); 345 data = devm_kzalloc(&client->dev, sizeof(struct adm1029_data),
346 if (!data) { 346 GFP_KERNEL);
347 err = -ENOMEM; 347 if (!data)
348 goto exit; 348 return -ENOMEM;
349 }
350 349
351 i2c_set_clientdata(client, data); 350 i2c_set_clientdata(client, data);
352 mutex_init(&data->update_lock); 351 mutex_init(&data->update_lock);
@@ -355,15 +354,13 @@ static int adm1029_probe(struct i2c_client *client,
355 * Initialize the ADM1029 chip 354 * Initialize the ADM1029 chip
356 * Check config register 355 * Check config register
357 */ 356 */
358 if (adm1029_init_client(client) == 0) { 357 if (adm1029_init_client(client) == 0)
359 err = -ENODEV; 358 return -ENODEV;
360 goto exit_free;
361 }
362 359
363 /* Register sysfs hooks */ 360 /* Register sysfs hooks */
364 err = sysfs_create_group(&client->dev.kobj, &adm1029_group); 361 err = sysfs_create_group(&client->dev.kobj, &adm1029_group);
365 if (err) 362 if (err)
366 goto exit_free; 363 return err;
367 364
368 data->hwmon_dev = hwmon_device_register(&client->dev); 365 data->hwmon_dev = hwmon_device_register(&client->dev);
369 if (IS_ERR(data->hwmon_dev)) { 366 if (IS_ERR(data->hwmon_dev)) {
@@ -375,9 +372,6 @@ static int adm1029_probe(struct i2c_client *client,
375 372
376 exit_remove_files: 373 exit_remove_files:
377 sysfs_remove_group(&client->dev.kobj, &adm1029_group); 374 sysfs_remove_group(&client->dev.kobj, &adm1029_group);
378 exit_free:
379 kfree(data);
380 exit:
381 return err; 375 return err;
382} 376}
383 377
@@ -405,7 +399,6 @@ static int adm1029_remove(struct i2c_client *client)
405 hwmon_device_unregister(data->hwmon_dev); 399 hwmon_device_unregister(data->hwmon_dev);
406 sysfs_remove_group(&client->dev.kobj, &adm1029_group); 400 sysfs_remove_group(&client->dev.kobj, &adm1029_group);
407 401
408 kfree(data);
409 return 0; 402 return 0;
410} 403}
411 404