Skip to content

Commit

Permalink
clock: only update clock frequency if actually changing it
Browse files Browse the repository at this point in the history
No need to set clock frequency if the new one is equal to the current
one.

Signed-off-by: Guennadi Liakhovetski <[email protected]>
  • Loading branch information
lyakh committed Aug 16, 2024
1 parent 09e7a8f commit c76b925
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lib/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit c76b925

Please sign in to comment.