aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm80.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 12:58:09 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-07-22 00:48:40 -0400
commitc38b2820cb4014b86b0bf45f334d3436c03b14be (patch)
tree9a13c3b0980acefda196f562216a50315dca394c /drivers/hwmon/lm80.c
parent52714c04df4b12ca308a1d792d50681df43365c2 (diff)
hwmon: (lm80) 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/lm80.c')
-rw-r--r--drivers/hwmon/lm80.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
index e2c43e1774be..28a8b71f4571 100644
--- a/drivers/hwmon/lm80.c
+++ b/drivers/hwmon/lm80.c
@@ -543,11 +543,9 @@ static int lm80_probe(struct i2c_client *client,
543 struct lm80_data *data; 543 struct lm80_data *data;
544 int err; 544 int err;
545 545
546 data = kzalloc(sizeof(struct lm80_data), GFP_KERNEL); 546 data = devm_kzalloc(&client->dev, sizeof(struct lm80_data), GFP_KERNEL);
547 if (!data) { 547 if (!data)
548 err = -ENOMEM; 548 return -ENOMEM;
549 goto exit;
550 }
551 549
552 i2c_set_clientdata(client, data); 550 i2c_set_clientdata(client, data);
553 mutex_init(&data->update_lock); 551 mutex_init(&data->update_lock);
@@ -562,7 +560,7 @@ static int lm80_probe(struct i2c_client *client,
562 /* Register sysfs hooks */ 560 /* Register sysfs hooks */
563 err = sysfs_create_group(&client->dev.kobj, &lm80_group); 561 err = sysfs_create_group(&client->dev.kobj, &lm80_group);
564 if (err) 562 if (err)
565 goto error_free; 563 return err;
566 564
567 data->hwmon_dev = hwmon_device_register(&client->dev); 565 data->hwmon_dev = hwmon_device_register(&client->dev);
568 if (IS_ERR(data->hwmon_dev)) { 566 if (IS_ERR(data->hwmon_dev)) {
@@ -574,9 +572,6 @@ static int lm80_probe(struct i2c_client *client,
574 572
575error_remove: 573error_remove:
576 sysfs_remove_group(&client->dev.kobj, &lm80_group); 574 sysfs_remove_group(&client->dev.kobj, &lm80_group);
577error_free:
578 kfree(data);
579exit:
580 return err; 575 return err;
581} 576}
582 577
@@ -587,7 +582,6 @@ static int lm80_remove(struct i2c_client *client)
587 hwmon_device_unregister(data->hwmon_dev); 582 hwmon_device_unregister(data->hwmon_dev);
588 sysfs_remove_group(&client->dev.kobj, &lm80_group); 583 sysfs_remove_group(&client->dev.kobj, &lm80_group);
589 584
590 kfree(data);
591 return 0; 585 return 0;
592} 586}
593 587