aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorWolfram Sang <wsa@sang-engineering.com>2014-06-06 17:35:45 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-06 19:08:07 -0400
commitc67fedfab2d29de88a62282e0633d43329552703 (patch)
treeca0a5295450ec10e9ac6f13e23f318bcdce12f93 /drivers/rtc
parent5028578595e761a3e418092e04db2ebf6c752a3f (diff)
drivers/rtc/rtc-m41t80.c: clean up error paths
There is no cleanup needed when something fails in probe, so no need for goto. Directly return when something fails. Signed-off-by: Wolfram Sang <wsa@sang-engineering.com> Cc: Jingoo Han <jg1.han@samsung.com> Acked-by: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-m41t80.c64
1 files changed, 23 insertions, 41 deletions
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index c287c6d5d1a9..86eccb15f524 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -627,37 +627,28 @@ static int m41t80_probe(struct i2c_client *client,
627 struct m41t80_data *clientdata = NULL; 627 struct m41t80_data *clientdata = NULL;
628 628
629 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C 629 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C
630 | I2C_FUNC_SMBUS_BYTE_DATA)) { 630 | I2C_FUNC_SMBUS_BYTE_DATA))
631 rc = -ENODEV; 631 return -ENODEV;
632 goto exit;
633 }
634 632
635 clientdata = devm_kzalloc(&client->dev, sizeof(*clientdata), 633 clientdata = devm_kzalloc(&client->dev, sizeof(*clientdata),
636 GFP_KERNEL); 634 GFP_KERNEL);
637 if (!clientdata) { 635 if (!clientdata)
638 rc = -ENOMEM; 636 return -ENOMEM;
639 goto exit;
640 }
641 637
642 clientdata->features = id->driver_data; 638 clientdata->features = id->driver_data;
643 i2c_set_clientdata(client, clientdata); 639 i2c_set_clientdata(client, clientdata);
644 640
645 rtc = devm_rtc_device_register(&client->dev, client->name, 641 rtc = devm_rtc_device_register(&client->dev, client->name,
646 &m41t80_rtc_ops, THIS_MODULE); 642 &m41t80_rtc_ops, THIS_MODULE);
647 if (IS_ERR(rtc)) { 643 if (IS_ERR(rtc))
648 rc = PTR_ERR(rtc); 644 return PTR_ERR(rtc);
649 rtc = NULL;
650 goto exit;
651 }
652 645
653 clientdata->rtc = rtc; 646 clientdata->rtc = rtc;
654 647
655 /* Make sure HT (Halt Update) bit is cleared */ 648 /* Make sure HT (Halt Update) bit is cleared */
656 rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR); 649 rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR);
657 if (rc < 0)
658 goto ht_err;
659 650
660 if (rc & M41T80_ALHOUR_HT) { 651 if (rc >= 0 && rc & M41T80_ALHOUR_HT) {
661 if (clientdata->features & M41T80_FEATURE_HT) { 652 if (clientdata->features & M41T80_FEATURE_HT) {
662 m41t80_get_datetime(client, &tm); 653 m41t80_get_datetime(client, &tm);
663 dev_info(&client->dev, "HT bit was set!\n"); 654 dev_info(&client->dev, "HT bit was set!\n");
@@ -668,53 +659,44 @@ static int m41t80_probe(struct i2c_client *client,
668 tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, 659 tm.tm_mon + 1, tm.tm_mday, tm.tm_hour,
669 tm.tm_min, tm.tm_sec); 660 tm.tm_min, tm.tm_sec);
670 } 661 }
671 if (i2c_smbus_write_byte_data(client, 662 rc = i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_HOUR,
672 M41T80_REG_ALARM_HOUR, 663 rc & ~M41T80_ALHOUR_HT);
673 rc & ~M41T80_ALHOUR_HT) < 0) 664 }
674 goto ht_err; 665
666 if (rc < 0) {
667 dev_err(&client->dev, "Can't clear HT bit\n");
668 return -EIO;
675 } 669 }
676 670
677 /* Make sure ST (stop) bit is cleared */ 671 /* Make sure ST (stop) bit is cleared */
678 rc = i2c_smbus_read_byte_data(client, M41T80_REG_SEC); 672 rc = i2c_smbus_read_byte_data(client, M41T80_REG_SEC);
679 if (rc < 0)
680 goto st_err;
681 673
682 if (rc & M41T80_SEC_ST) { 674 if (rc >= 0 && rc & M41T80_SEC_ST)
683 if (i2c_smbus_write_byte_data(client, M41T80_REG_SEC, 675 rc = i2c_smbus_write_byte_data(client, M41T80_REG_SEC,
684 rc & ~M41T80_SEC_ST) < 0) 676 rc & ~M41T80_SEC_ST);
685 goto st_err; 677 if (rc < 0) {
678 dev_err(&client->dev, "Can't clear ST bit\n");
679 return -EIO;
686 } 680 }
687 681
688 rc = m41t80_sysfs_register(&client->dev); 682 rc = m41t80_sysfs_register(&client->dev);
689 if (rc) 683 if (rc)
690 goto exit; 684 return rc;
691 685
692#ifdef CONFIG_RTC_DRV_M41T80_WDT 686#ifdef CONFIG_RTC_DRV_M41T80_WDT
693 if (clientdata->features & M41T80_FEATURE_HT) { 687 if (clientdata->features & M41T80_FEATURE_HT) {
694 save_client = client; 688 save_client = client;
695 rc = misc_register(&wdt_dev); 689 rc = misc_register(&wdt_dev);
696 if (rc) 690 if (rc)
697 goto exit; 691 return rc;
698 rc = register_reboot_notifier(&wdt_notifier); 692 rc = register_reboot_notifier(&wdt_notifier);
699 if (rc) { 693 if (rc) {
700 misc_deregister(&wdt_dev); 694 misc_deregister(&wdt_dev);
701 goto exit; 695 return rc;
702 } 696 }
703 } 697 }
704#endif 698#endif
705 return 0; 699 return 0;
706
707st_err:
708 rc = -EIO;
709 dev_err(&client->dev, "Can't clear ST bit\n");
710 goto exit;
711ht_err:
712 rc = -EIO;
713 dev_err(&client->dev, "Can't clear HT bit\n");
714 goto exit;
715
716exit:
717 return rc;
718} 700}
719 701
720static int m41t80_remove(struct i2c_client *client) 702static int m41t80_remove(struct i2c_client *client)