Skip to content

Commit 789d4b1

Browse files
tmlinddlezcano
authored andcommitted
clocksource/drivers/timer-ti-dm: Get clock in probe with devm_clk_get()
We can simplify the code a bit by getting the clock in probe, and using devm_clk_get(). This will also make further changes easier as the clock is available in probe instead of prepare. Signed-off-by: Tony Lindgren <tony@atomide.com> Reviewed-by: Janusz Krzysztofik <jmkrzyszt@gmail.com> Link: https://lore.kernel.org/r/20220815131250.34603-10-tony@atomide.com Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
1 parent 664ad59 commit 789d4b1

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

drivers/clocksource/timer-ti-dm.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -473,18 +473,6 @@ static int omap_dm_timer_prepare(struct dmtimer *timer)
473473
struct device *dev = &timer->pdev->dev;
474474
int rc;
475475

476-
/*
477-
* FIXME: OMAP1 devices do not use the clock framework for dmtimers so
478-
* do not call clk_get() for these devices.
479-
*/
480-
if (!timer->omap1) {
481-
timer->fclk = clk_get(&timer->pdev->dev, "fck");
482-
if (WARN_ON_ONCE(IS_ERR(timer->fclk))) {
483-
dev_err(&timer->pdev->dev, ": No fclk handle.\n");
484-
return -EINVAL;
485-
}
486-
}
487-
488476
rc = pm_runtime_resume_and_get(dev);
489477
if (rc)
490478
return rc;
@@ -650,8 +638,6 @@ static int omap_dm_timer_free(struct omap_dm_timer *cookie)
650638
if (unlikely(!timer))
651639
return -EINVAL;
652640

653-
clk_put(timer->fclk);
654-
655641
WARN_ON(!timer->reserved);
656642
timer->reserved = 0;
657643
return 0;
@@ -1098,7 +1084,6 @@ static int omap_dm_timer_probe(struct platform_device *pdev)
10981084
if (timer->irq < 0)
10991085
return timer->irq;
11001086

1101-
timer->fclk = ERR_PTR(-ENODEV);
11021087
timer->io_base = devm_platform_ioremap_resource(pdev, 0);
11031088
if (IS_ERR(timer->io_base))
11041089
return PTR_ERR(timer->io_base);
@@ -1122,6 +1107,15 @@ static int omap_dm_timer_probe(struct platform_device *pdev)
11221107

11231108
timer->omap1 = timer->capability & OMAP_TIMER_NEEDS_RESET;
11241109

1110+
/* OMAP1 devices do not yet use the clock framework for dmtimers */
1111+
if (!timer->omap1) {
1112+
timer->fclk = devm_clk_get(dev, "fck");
1113+
if (IS_ERR(timer->fclk))
1114+
return PTR_ERR(timer->fclk);
1115+
} else {
1116+
timer->fclk = ERR_PTR(-ENODEV);
1117+
}
1118+
11251119
if (!(timer->capability & OMAP_TIMER_ALWON)) {
11261120
timer->nb.notifier_call = omap_timer_context_notifier;
11271121
cpu_pm_register_notifier(&timer->nb);

0 commit comments

Comments
 (0)