diff mbox series

[v2,7/7] rtc:rtc-xgene:Use devm_clk_get_enabled() helpers

Message ID 20240829072209.7253-8-liaoyuanhong@vivo.com
State Rejected
Headers show
Series rtc:Use devm_clk_get_enabled() helpers | expand

Commit Message

Liao Yuanhong Aug. 29, 2024, 7:22 a.m. UTC
Use devm_clk_get_enabled() instead of clk functions in rtc-xgene.

Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
---
 drivers/rtc/rtc-xgene.c | 26 ++++----------------------
 1 file changed, 4 insertions(+), 22 deletions(-)
diff mbox series

Patch

diff --git a/drivers/rtc/rtc-xgene.c b/drivers/rtc/rtc-xgene.c
index f78efc9760c0..cff29d18454c 100644
--- a/drivers/rtc/rtc-xgene.c
+++ b/drivers/rtc/rtc-xgene.c
@@ -162,43 +162,33 @@  static int xgene_rtc_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	pdata->clk = devm_clk_get(&pdev->dev, NULL);
+	pdata->clk = devm_clk_get_enabled(&pdev->dev, NULL);
 	if (IS_ERR(pdata->clk)) {
 		dev_err(&pdev->dev, "Couldn't get the clock for RTC\n");
 		return -ENODEV;
 	}
-	ret = clk_prepare_enable(pdata->clk);
-	if (ret)
-		return ret;
 
 	/* Turn on the clock and the crystal */
 	writel(RTC_CCR_EN, pdata->csr_base + RTC_CCR);
 
 	ret = device_init_wakeup(&pdev->dev, 1);
-	if (ret) {
-		clk_disable_unprepare(pdata->clk);
+	if (ret)
 		return ret;
-	}
 
 	pdata->rtc->ops = &xgene_rtc_ops;
 	pdata->rtc->range_max = U32_MAX;
 
 	ret = devm_rtc_register_device(pdata->rtc);
-	if (ret) {
-		clk_disable_unprepare(pdata->clk);
+	if (ret)
 		return ret;
-	}
 
 	return 0;
 }
 
 static void xgene_rtc_remove(struct platform_device *pdev)
 {
-	struct xgene_rtc_dev *pdata = platform_get_drvdata(pdev);
-
 	xgene_rtc_alarm_irq_enable(&pdev->dev, 0);
 	device_init_wakeup(&pdev->dev, 0);
-	clk_disable_unprepare(pdata->clk);
 }
 
 static int __maybe_unused xgene_rtc_suspend(struct device *dev)
@@ -220,7 +210,6 @@  static int __maybe_unused xgene_rtc_suspend(struct device *dev)
 	} else {
 		pdata->irq_enabled = xgene_rtc_alarm_irq_enabled(dev);
 		xgene_rtc_alarm_irq_enable(dev, 0);
-		clk_disable_unprepare(pdata->clk);
 	}
 	return 0;
 }
@@ -230,7 +219,6 @@  static int __maybe_unused xgene_rtc_resume(struct device *dev)
 	struct platform_device *pdev = to_platform_device(dev);
 	struct xgene_rtc_dev *pdata = platform_get_drvdata(pdev);
 	int irq;
-	int rc;
 
 	irq = platform_get_irq(pdev, 0);
 
@@ -239,14 +227,8 @@  static int __maybe_unused xgene_rtc_resume(struct device *dev)
 			disable_irq_wake(irq);
 			pdata->irq_wake = 0;
 		}
-	} else {
-		rc = clk_prepare_enable(pdata->clk);
-		if (rc) {
-			dev_err(dev, "Unable to enable clock error %d\n", rc);
-			return rc;
-		}
+	} else
 		xgene_rtc_alarm_irq_enable(dev, pdata->irq_enabled);
-	}
 
 	return 0;
 }