clocksource/drivers/timer-ti-dm: Handle runtime resume failure

omap_dm_timer_write_counter() accesses timer registers and updates the
saved counter value after requesting a runtime PM reference. If runtime
resume fails, the timer remains inaccessible and no reference is
acquired, but the function still writes the register, drops a
reference, updates the cached value, and reports success.

Check the return value and propagate an error before touching the timer
state.

Fixes: 0494fc345b ("clocksource/drivers/timer-ti-dm : Capture functionality for OMAP DM timer")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Link: https://patch.msgid.link/20261003080812.429386-1-yaojiale02@163.com
This commit is contained in:
Jiale Yao 2026-10-03 16:08:11 +08:00 committed by Daniel Lezcano
parent e234d40823
commit c40b76c8cf

View File

@ -1095,6 +1095,7 @@ static int omap_dm_timer_write_counter(struct omap_dm_timer *cookie, unsigned in
{
struct dmtimer *timer;
struct device *dev;
int ret;
timer = to_dmtimer(cookie);
if (unlikely(!timer)) {
@ -1104,7 +1105,10 @@ static int omap_dm_timer_write_counter(struct omap_dm_timer *cookie, unsigned in
dev = &timer->pdev->dev;
pm_runtime_resume_and_get(dev);
ret = pm_runtime_resume_and_get(dev);
if (ret < 0)
return ret;
dmtimer_write(timer, OMAP_TIMER_COUNTER_REG, value);
pm_runtime_put_sync(dev);