From c76b92531edfc447d78c223b8d447babad0a132f Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Fri, 16 Aug 2024 09:09:53 +0200 Subject: [PATCH] clock: only update clock frequency if actually changing it No need to set clock frequency if the new one is equal to the current one. Signed-off-by: Guennadi Liakhovetski --- src/lib/clk.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/clk.c b/src/lib/clk.c index 1c533fb91fa2..779d8b76e03d 100644 --- a/src/lib/clk.c +++ b/src/lib/clk.c @@ -62,13 +62,15 @@ void clock_set_freq(int clock, uint32_t hz) idx = clock_get_nearest_freq_idx(clk_info->freqs, clk_info->freqs_num, hz); - tr_info(&clock_tr, "clock %d set freq %dHz freq_idx %d", - clock, hz, idx); + if (clk_info->current_freq_idx != idx && + (!clk_info->set_freq || + clk_info->set_freq(clock, idx) == 0)) { + tr_info(&clock_tr, "clock %d set freq %dHz freq_idx %d old %d", + clock, hz, idx, clk_info->current_freq_idx); - if (!clk_info->set_freq || - clk_info->set_freq(clock, idx) == 0) /* update clock frequency */ clk_info->current_freq_idx = idx; + } clock_unlock(key); }