diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-04-29 19:20:52 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 21:28:38 -0400 |
commit | b8a4b4e2f76d660c36afd1c4a5f5ff578dc7b124 (patch) | |
tree | 6a63be3bccc874b9a117770e26262e7b3e270e1a /drivers/rtc/rtc-rs5c372.c | |
parent | 8fb1ecb36f7e00d97ea2fea3b8f61be07c19e933 (diff) |
rtc: rtc-rs5c372: 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-rs5c372.c')
-rw-r--r-- | drivers/rtc/rtc-rs5c372.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c index 581739f40097..224d634322b4 100644 --- a/drivers/rtc/rtc-rs5c372.c +++ b/drivers/rtc/rtc-rs5c372.c | |||
@@ -579,7 +579,9 @@ static int rs5c372_probe(struct i2c_client *client, | |||
579 | } | 579 | } |
580 | } | 580 | } |
581 | 581 | ||
582 | if (!(rs5c372 = kzalloc(sizeof(struct rs5c372), GFP_KERNEL))) { | 582 | rs5c372 = devm_kzalloc(&client->dev, sizeof(struct rs5c372), |
583 | GFP_KERNEL); | ||
584 | if (!rs5c372) { | ||
583 | err = -ENOMEM; | 585 | err = -ENOMEM; |
584 | goto exit; | 586 | goto exit; |
585 | } | 587 | } |
@@ -594,7 +596,7 @@ static int rs5c372_probe(struct i2c_client *client, | |||
594 | 596 | ||
595 | err = rs5c_get_regs(rs5c372); | 597 | err = rs5c_get_regs(rs5c372); |
596 | if (err < 0) | 598 | if (err < 0) |
597 | goto exit_kfree; | 599 | goto exit; |
598 | 600 | ||
599 | /* clock may be set for am/pm or 24 hr time */ | 601 | /* clock may be set for am/pm or 24 hr time */ |
600 | switch (rs5c372->type) { | 602 | switch (rs5c372->type) { |
@@ -617,7 +619,7 @@ static int rs5c372_probe(struct i2c_client *client, | |||
617 | break; | 619 | break; |
618 | default: | 620 | default: |
619 | dev_err(&client->dev, "unknown RTC type\n"); | 621 | dev_err(&client->dev, "unknown RTC type\n"); |
620 | goto exit_kfree; | 622 | goto exit; |
621 | } | 623 | } |
622 | 624 | ||
623 | /* if the oscillator lost power and no other software (like | 625 | /* if the oscillator lost power and no other software (like |
@@ -629,7 +631,7 @@ static int rs5c372_probe(struct i2c_client *client, | |||
629 | err = rs5c_oscillator_setup(rs5c372); | 631 | err = rs5c_oscillator_setup(rs5c372); |
630 | if (unlikely(err < 0)) { | 632 | if (unlikely(err < 0)) { |
631 | dev_err(&client->dev, "setup error\n"); | 633 | dev_err(&client->dev, "setup error\n"); |
632 | goto exit_kfree; | 634 | goto exit; |
633 | } | 635 | } |
634 | 636 | ||
635 | if (rs5c372_get_datetime(client, &tm) < 0) | 637 | if (rs5c372_get_datetime(client, &tm) < 0) |
@@ -648,38 +650,28 @@ static int rs5c372_probe(struct i2c_client *client, | |||
648 | ); | 650 | ); |
649 | 651 | ||
650 | /* REVISIT use client->irq to register alarm irq ... */ | 652 | /* REVISIT use client->irq to register alarm irq ... */ |
651 | 653 | rs5c372->rtc = devm_rtc_device_register(&client->dev, | |
652 | rs5c372->rtc = rtc_device_register(rs5c372_driver.driver.name, | 654 | rs5c372_driver.driver.name, |
653 | &client->dev, &rs5c372_rtc_ops, THIS_MODULE); | 655 | &rs5c372_rtc_ops, THIS_MODULE); |
654 | 656 | ||
655 | if (IS_ERR(rs5c372->rtc)) { | 657 | if (IS_ERR(rs5c372->rtc)) { |
656 | err = PTR_ERR(rs5c372->rtc); | 658 | err = PTR_ERR(rs5c372->rtc); |
657 | goto exit_kfree; | 659 | goto exit; |
658 | } | 660 | } |
659 | 661 | ||
660 | err = rs5c_sysfs_register(&client->dev); | 662 | err = rs5c_sysfs_register(&client->dev); |
661 | if (err) | 663 | if (err) |
662 | goto exit_devreg; | 664 | goto exit; |
663 | 665 | ||
664 | return 0; | 666 | return 0; |
665 | 667 | ||
666 | exit_devreg: | ||
667 | rtc_device_unregister(rs5c372->rtc); | ||
668 | |||
669 | exit_kfree: | ||
670 | kfree(rs5c372); | ||
671 | |||
672 | exit: | 668 | exit: |
673 | return err; | 669 | return err; |
674 | } | 670 | } |
675 | 671 | ||
676 | static int rs5c372_remove(struct i2c_client *client) | 672 | static int rs5c372_remove(struct i2c_client *client) |
677 | { | 673 | { |
678 | struct rs5c372 *rs5c372 = i2c_get_clientdata(client); | ||
679 | |||
680 | rtc_device_unregister(rs5c372->rtc); | ||
681 | rs5c_sysfs_unregister(&client->dev); | 674 | rs5c_sysfs_unregister(&client->dev); |
682 | kfree(rs5c372); | ||
683 | return 0; | 675 | return 0; |
684 | } | 676 | } |
685 | 677 | ||