Skip to content

Commit 5517357

Browse files
committed
clk: bcm-2835: Pick the closest clock rate
The driver currently tries to pick the closest rate that is lower than the rate being requested. This causes an issue with clk_set_min_rate() since it actively checks for the rounded rate to be above the minimum that was just set. Let's change the logic a bit to pick the closest rate to the requested rate, no matter if it's actually higher or lower. Fixes: 6d18b8a ("clk: bcm2835: Support for clock parent selection") Signed-off-by: Maxime Ripard <maxime@cerno.tech> Acked-by: Stephen Boyd <sboyd@kernel.org> Reviewed-by: Nicolas Saenz Julienne <nsaenz@kernel.org> Tested-by: Nicolas Saenz Julienne <nsaenz@kernel.org> # boot and basic functionality Tested-by: Michael Stapelberg <michael@stapelberg.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20210922125419.4125779-2-maxime@cerno.tech
1 parent 7366382 commit 5517357

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/clk/bcm/clk-bcm2835.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ static int bcm2835_clock_determine_rate(struct clk_hw *hw,
12161216
rate = bcm2835_clock_choose_div_and_prate(hw, i, req->rate,
12171217
&div, &prate,
12181218
&avgrate);
1219-
if (rate > best_rate && rate <= req->rate) {
1219+
if (abs(req->rate - rate) < abs(req->rate - best_rate)) {
12201220
best_parent = parent;
12211221
best_prate = prate;
12221222
best_rate = rate;

0 commit comments

Comments
 (0)