Skip to content

Commit b665c1b

Browse files
Kartik Rajputalexandrebelloni
authored andcommitted
rtc: tegra: Use devm_clk_get_enabled() in probe
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> Reviewed-by: Jon Hunter <jonathanh@nvidia.com> Link: https://patch.msgid.link/20251024064952.775883-1-kkartik@nvidia.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
1 parent 53e71c1 commit b665c1b

1 file changed

Lines changed: 4 additions & 22 deletions

File tree

drivers/rtc/rtc-tegra.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,10 @@ static int tegra_rtc_probe(struct platform_device *pdev)
300300
info->rtc->ops = &tegra_rtc_ops;
301301
info->rtc->range_max = U32_MAX;
302302

303-
info->clk = devm_clk_get(&pdev->dev, NULL);
303+
info->clk = devm_clk_get_enabled(&pdev->dev, NULL);
304304
if (IS_ERR(info->clk))
305305
return PTR_ERR(info->clk);
306306

307-
ret = clk_prepare_enable(info->clk);
308-
if (ret < 0)
309-
return ret;
310-
311307
/* set context info */
312308
info->pdev = pdev;
313309
spin_lock_init(&info->lock);
@@ -324,29 +320,16 @@ static int tegra_rtc_probe(struct platform_device *pdev)
324320
ret = devm_request_irq(&pdev->dev, info->irq, tegra_rtc_irq_handler,
325321
IRQF_TRIGGER_HIGH, dev_name(&pdev->dev),
326322
&pdev->dev);
327-
if (ret) {
328-
dev_err(&pdev->dev, "failed to request interrupt: %d\n", ret);
329-
goto disable_clk;
330-
}
323+
if (ret)
324+
return dev_err_probe(&pdev->dev, ret, "failed to request interrupt\n");
331325

332326
ret = devm_rtc_register_device(info->rtc);
333327
if (ret)
334-
goto disable_clk;
328+
return ret;
335329

336330
dev_notice(&pdev->dev, "Tegra internal Real Time Clock\n");
337331

338332
return 0;
339-
340-
disable_clk:
341-
clk_disable_unprepare(info->clk);
342-
return ret;
343-
}
344-
345-
static void tegra_rtc_remove(struct platform_device *pdev)
346-
{
347-
struct tegra_rtc_info *info = platform_get_drvdata(pdev);
348-
349-
clk_disable_unprepare(info->clk);
350333
}
351334

352335
#ifdef CONFIG_PM_SLEEP
@@ -399,7 +382,6 @@ static void tegra_rtc_shutdown(struct platform_device *pdev)
399382

400383
static struct platform_driver tegra_rtc_driver = {
401384
.probe = tegra_rtc_probe,
402-
.remove = tegra_rtc_remove,
403385
.shutdown = tegra_rtc_shutdown,
404386
.driver = {
405387
.name = "tegra_rtc",

0 commit comments

Comments
 (0)