summaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2019-08-30 09:31:23 -0400
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2019-09-01 03:18:35 -0400
commit59a7f24fceb3aef6bd16f5aeb852c823dddab04d (patch)
treeac029c2b756095596a2af4b721ba7609757a04a1 /drivers/rtc
parent7ef66122bdb3b839e9f51b76d7e600b6e21ef648 (diff)
rtc: max77686: convert to devm_i2c_new_dummy_device()
I was about to simplify the call to i2c_unregister_device() when I realized that converting to devm_i2c_new_dummy_device() will simplify the driver a lot. So I took this approach. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://lore.kernel.org/r/20190830133124.21633-2-wsa+renesas@sang-engineering.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-max77686.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
index 7a98e0744878..d5a0e27dd0a0 100644
--- a/drivers/rtc/rtc-max77686.c
+++ b/drivers/rtc/rtc-max77686.c
@@ -690,8 +690,8 @@ static int max77686_init_rtc_regmap(struct max77686_rtc_info *info)
690 goto add_rtc_irq; 690 goto add_rtc_irq;
691 } 691 }
692 692
693 info->rtc = i2c_new_dummy_device(parent_i2c->adapter, 693 info->rtc = devm_i2c_new_dummy_device(info->dev, parent_i2c->adapter,
694 info->drv_data->rtc_i2c_addr); 694 info->drv_data->rtc_i2c_addr);
695 if (IS_ERR(info->rtc)) { 695 if (IS_ERR(info->rtc)) {
696 dev_err(info->dev, "Failed to allocate I2C device for RTC\n"); 696 dev_err(info->dev, "Failed to allocate I2C device for RTC\n");
697 return PTR_ERR(info->rtc); 697 return PTR_ERR(info->rtc);
@@ -702,7 +702,7 @@ static int max77686_init_rtc_regmap(struct max77686_rtc_info *info)
702 if (IS_ERR(info->rtc_regmap)) { 702 if (IS_ERR(info->rtc_regmap)) {
703 ret = PTR_ERR(info->rtc_regmap); 703 ret = PTR_ERR(info->rtc_regmap);
704 dev_err(info->dev, "Failed to allocate RTC regmap: %d\n", ret); 704 dev_err(info->dev, "Failed to allocate RTC regmap: %d\n", ret);
705 goto err_unregister_i2c; 705 return ret;
706 } 706 }
707 707
708add_rtc_irq: 708add_rtc_irq:
@@ -712,15 +712,10 @@ add_rtc_irq:
712 &info->rtc_irq_data); 712 &info->rtc_irq_data);
713 if (ret < 0) { 713 if (ret < 0) {
714 dev_err(info->dev, "Failed to add RTC irq chip: %d\n", ret); 714 dev_err(info->dev, "Failed to add RTC irq chip: %d\n", ret);
715 goto err_unregister_i2c; 715 return ret;
716 } 716 }
717 717
718 return 0; 718 return 0;
719
720err_unregister_i2c:
721 if (info->rtc)
722 i2c_unregister_device(info->rtc);
723 return ret;
724} 719}
725 720
726static int max77686_rtc_probe(struct platform_device *pdev) 721static int max77686_rtc_probe(struct platform_device *pdev)
@@ -783,8 +778,6 @@ static int max77686_rtc_probe(struct platform_device *pdev)
783 778
784err_rtc: 779err_rtc:
785 regmap_del_irq_chip(info->rtc_irq, info->rtc_irq_data); 780 regmap_del_irq_chip(info->rtc_irq, info->rtc_irq_data);
786 if (info->rtc)
787 i2c_unregister_device(info->rtc);
788 781
789 return ret; 782 return ret;
790} 783}
@@ -795,8 +788,6 @@ static int max77686_rtc_remove(struct platform_device *pdev)
795 788
796 free_irq(info->virq, info); 789 free_irq(info->virq, info);
797 regmap_del_irq_chip(info->rtc_irq, info->rtc_irq_data); 790 regmap_del_irq_chip(info->rtc_irq, info->rtc_irq_data);
798 if (info->rtc)
799 i2c_unregister_device(info->rtc);
800 791
801 return 0; 792 return 0;
802} 793}