Linux RTC
 help / color / mirror / Atom feed
* [PATCH v4 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe
@ 2025-10-24  6:49 Kartik Rajput
  2025-10-24  6:49 ` [PATCH v4 2/3] rtc: tegra: Add ACPI support Kartik Rajput
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Kartik Rajput @ 2025-10-24  6:49 UTC (permalink / raw)
  To: alexandre.belloni, thierry.reding, jonathanh, andriy.shevchenko,
	linux-rtc, linux-tegra, linux-kernel
  Cc: Kartik Rajput

Simplify clock management by replacing devm_clk_get() and manual clock
enable/disable with devm_clk_get_enabled(). This also simplifies the
error handling logic. Also remove tegra_rtc_remove() as the clock will
automatically be disabled when the device is unbound from the bus.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Kartik Rajput <kkartik@nvidia.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
Changes in v4:
	* Removed tegra_rtc_remove() as this is not required now.
	* Updated commit message to specify this.
---
 drivers/rtc/rtc-tegra.c | 26 ++++----------------------
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c
index 46788db89953..e8c83a6a96b3 100644
--- a/drivers/rtc/rtc-tegra.c
+++ b/drivers/rtc/rtc-tegra.c
@@ -300,14 +300,10 @@ static int tegra_rtc_probe(struct platform_device *pdev)
 	info->rtc->ops = &tegra_rtc_ops;
 	info->rtc->range_max = U32_MAX;
 
-	info->clk = devm_clk_get(&pdev->dev, NULL);
+	info->clk = devm_clk_get_enabled(&pdev->dev, NULL);
 	if (IS_ERR(info->clk))
 		return PTR_ERR(info->clk);
 
-	ret = clk_prepare_enable(info->clk);
-	if (ret < 0)
-		return ret;
-
 	/* set context info */
 	info->pdev = pdev;
 	spin_lock_init(&info->lock);
@@ -324,29 +320,16 @@ static int tegra_rtc_probe(struct platform_device *pdev)
 	ret = devm_request_irq(&pdev->dev, info->irq, tegra_rtc_irq_handler,
 			       IRQF_TRIGGER_HIGH, dev_name(&pdev->dev),
 			       &pdev->dev);
-	if (ret) {
-		dev_err(&pdev->dev, "failed to request interrupt: %d\n", ret);
-		goto disable_clk;
-	}
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "failed to request interrupt\n");
 
 	ret = devm_rtc_register_device(info->rtc);
 	if (ret)
-		goto disable_clk;
+		return ret;
 
 	dev_notice(&pdev->dev, "Tegra internal Real Time Clock\n");
 
 	return 0;
-
-disable_clk:
-	clk_disable_unprepare(info->clk);
-	return ret;
-}
-
-static void tegra_rtc_remove(struct platform_device *pdev)
-{
-	struct tegra_rtc_info *info = platform_get_drvdata(pdev);
-
-	clk_disable_unprepare(info->clk);
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -399,7 +382,6 @@ static void tegra_rtc_shutdown(struct platform_device *pdev)
 
 static struct platform_driver tegra_rtc_driver = {
 	.probe = tegra_rtc_probe,
-	.remove = tegra_rtc_remove,
 	.shutdown = tegra_rtc_shutdown,
 	.driver = {
 		.name = "tegra_rtc",
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-12-08 22:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-24  6:49 [PATCH v4 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe Kartik Rajput
2025-10-24  6:49 ` [PATCH v4 2/3] rtc: tegra: Add ACPI support Kartik Rajput
2025-10-24 10:48   ` Jon Hunter
2025-10-24  6:49 ` [PATCH v4 3/3] rtc: tegra: Replace deprecated SIMPLE_DEV_PM_OPS Kartik Rajput
2025-10-24 10:48   ` Jon Hunter
2025-10-24 10:48 ` [PATCH v4 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe Jon Hunter
2025-12-08 22:09 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox