Skip to content

Commit

Permalink
clk: sunxi: Fix M factor computation for APB1
Browse files Browse the repository at this point in the history
commit cfa6368 ("clk: sunxi: factors: Consolidate get_factors
parameters into a struct") introduced a regression for m factor
computation in sun4i_get_apb1_factors function.

The old code reassigned the "parent_rate" parameter to the targeted
divisor value and was buggy for the returned frequency but not for the
computed factors. Now, returned frequency is good but m factor is
incorrectly computed (its max value 31 is always set resulting in a
significantly slower frequency than the requested one...)

This patch simply restores the original proper computation for m while
keeping the good changes for returned rate.

Fixes: cfa6368 ("clk: sunxi: factors: Consolidate get_factors parameters into a struct")
Signed-off-by: Stéphan Rafin <stephan@soliotek.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
  • Loading branch information
Stéphan Rafin authored and Maxime Ripard committed Nov 4, 2016
1 parent a17b9e4 commit ac95330
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/clk/sunxi/clk-sunxi.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ static void sun4i_get_apb1_factors(struct factors_request *req)
else
calcp = 3;

calcm = (req->parent_rate >> calcp) - 1;
calcm = (div >> calcp) - 1;

req->rate = (req->parent_rate >> calcp) / (calcm + 1);
req->m = calcm;
Expand Down

0 comments on commit ac95330

Please sign in to comment.