aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 12:58:11 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-07-22 00:48:41 -0400
commit705375cc41f2bd63dfffcf4830afff76c63e5681 (patch)
treeba9166711c2b22aed3a7a6c7eabd5ac2c9914598 /drivers/hwmon
parent35bb95a17a1c04ec9620553867f29a336e868707 (diff)
hwmon: (lm92) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/lm92.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c
index fdc691a4028f..2282d77e83e8 100644
--- a/drivers/hwmon/lm92.c
+++ b/drivers/hwmon/lm92.c
@@ -373,11 +373,10 @@ static int lm92_probe(struct i2c_client *new_client,
373 struct lm92_data *data; 373 struct lm92_data *data;
374 int err; 374 int err;
375 375
376 data = kzalloc(sizeof(struct lm92_data), GFP_KERNEL); 376 data = devm_kzalloc(&new_client->dev, sizeof(struct lm92_data),
377 if (!data) { 377 GFP_KERNEL);
378 err = -ENOMEM; 378 if (!data)
379 goto exit; 379 return -ENOMEM;
380 }
381 380
382 i2c_set_clientdata(new_client, data); 381 i2c_set_clientdata(new_client, data);
383 data->valid = 0; 382 data->valid = 0;
@@ -389,7 +388,7 @@ static int lm92_probe(struct i2c_client *new_client,
389 /* Register sysfs hooks */ 388 /* Register sysfs hooks */
390 err = sysfs_create_group(&new_client->dev.kobj, &lm92_group); 389 err = sysfs_create_group(&new_client->dev.kobj, &lm92_group);
391 if (err) 390 if (err)
392 goto exit_free; 391 return err;
393 392
394 data->hwmon_dev = hwmon_device_register(&new_client->dev); 393 data->hwmon_dev = hwmon_device_register(&new_client->dev);
395 if (IS_ERR(data->hwmon_dev)) { 394 if (IS_ERR(data->hwmon_dev)) {
@@ -401,9 +400,6 @@ static int lm92_probe(struct i2c_client *new_client,
401 400
402exit_remove: 401exit_remove:
403 sysfs_remove_group(&new_client->dev.kobj, &lm92_group); 402 sysfs_remove_group(&new_client->dev.kobj, &lm92_group);
404exit_free:
405 kfree(data);
406exit:
407 return err; 403 return err;
408} 404}
409 405
@@ -414,7 +410,6 @@ static int lm92_remove(struct i2c_client *client)
414 hwmon_device_unregister(data->hwmon_dev); 410 hwmon_device_unregister(data->hwmon_dev);
415 sysfs_remove_group(&client->dev.kobj, &lm92_group); 411 sysfs_remove_group(&client->dev.kobj, &lm92_group);
416 412
417 kfree(data);
418 return 0; 413 return 0;
419} 414}
420 415