aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-m41t80.c
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2013-04-29 19:20:42 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 21:28:37 -0400
commit4ebabb78e46d1bc3e8ddaa8b6b88a41142756f4b (patch)
tree3c7f6efa98ba6a3a3cb8d1e0c4c0953cef009bb6 /drivers/rtc/rtc-m41t80.c
parentdc831f9768a0fe898d8d3bc6f738d8079a6f5d7a (diff)
rtc: rtc-m41t80: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-m41t80.c')
-rw-r--r--drivers/rtc/rtc-m41t80.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index b885bcd08908..89674b5e6efd 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -637,7 +637,8 @@ static int m41t80_probe(struct i2c_client *client,
637 dev_info(&client->dev, 637 dev_info(&client->dev,
638 "chip found, driver version " DRV_VERSION "\n"); 638 "chip found, driver version " DRV_VERSION "\n");
639 639
640 clientdata = kzalloc(sizeof(*clientdata), GFP_KERNEL); 640 clientdata = devm_kzalloc(&client->dev, sizeof(*clientdata),
641 GFP_KERNEL);
641 if (!clientdata) { 642 if (!clientdata) {
642 rc = -ENOMEM; 643 rc = -ENOMEM;
643 goto exit; 644 goto exit;
@@ -646,8 +647,8 @@ static int m41t80_probe(struct i2c_client *client,
646 clientdata->features = id->driver_data; 647 clientdata->features = id->driver_data;
647 i2c_set_clientdata(client, clientdata); 648 i2c_set_clientdata(client, clientdata);
648 649
649 rtc = rtc_device_register(client->name, &client->dev, 650 rtc = devm_rtc_device_register(&client->dev, client->name,
650 &m41t80_rtc_ops, THIS_MODULE); 651 &m41t80_rtc_ops, THIS_MODULE);
651 if (IS_ERR(rtc)) { 652 if (IS_ERR(rtc)) {
652 rc = PTR_ERR(rtc); 653 rc = PTR_ERR(rtc);
653 rtc = NULL; 654 rtc = NULL;
@@ -718,26 +719,19 @@ ht_err:
718 goto exit; 719 goto exit;
719 720
720exit: 721exit:
721 if (rtc)
722 rtc_device_unregister(rtc);
723 kfree(clientdata);
724 return rc; 722 return rc;
725} 723}
726 724
727static int m41t80_remove(struct i2c_client *client) 725static int m41t80_remove(struct i2c_client *client)
728{ 726{
727#ifdef CONFIG_RTC_DRV_M41T80_WDT
729 struct m41t80_data *clientdata = i2c_get_clientdata(client); 728 struct m41t80_data *clientdata = i2c_get_clientdata(client);
730 struct rtc_device *rtc = clientdata->rtc;
731 729
732#ifdef CONFIG_RTC_DRV_M41T80_WDT
733 if (clientdata->features & M41T80_FEATURE_HT) { 730 if (clientdata->features & M41T80_FEATURE_HT) {
734 misc_deregister(&wdt_dev); 731 misc_deregister(&wdt_dev);
735 unregister_reboot_notifier(&wdt_notifier); 732 unregister_reboot_notifier(&wdt_notifier);
736 } 733 }
737#endif 734#endif
738 if (rtc)
739 rtc_device_unregister(rtc);
740 kfree(clientdata);
741 735
742 return 0; 736 return 0;
743} 737}