]> git.baikalelectronics.ru Git - kernel.git/commit
clk: divider: fix calculation of maximal parent rate for a given divider
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Sat, 21 Feb 2015 10:40:23 +0000 (11:40 +0100)
committerMichael Turquette <mturquette@linaro.org>
Mon, 9 Mar 2015 21:19:27 +0000 (14:19 -0700)
commitf2342f717d026e719e18c2c68cb72b28aa34ec15
tree8684dc2cedc502ebd6066418833d4a59ad4c6e2a
parent1c1139d6269aca7d828fbd170e13fd3d023d986f
clk: divider: fix calculation of maximal parent rate for a given divider

The rate provided at the output of a clk-divider is calculated as:

DIV_ROUND_UP(parent_rate, div)

since commit 8c320f4985fb (clk: divider: fix rate calculation for
fractional rates). So to yield a rate not bigger than r parent_rate
must be <= r * div.

The effect of choosing a parent rate that is too big as was done before
this patch results in wrongly ruling out good dividers.

Note that this is not a complete fix as __clk_round_rate might return a
value >= its 2nd parameter. Also for dividers with
CLK_DIVIDER_ROUND_CLOSEST set the calculation is not accurate. But this
fixes the test case by Sascha Hauer that uses a chain of three dividers
under a fixed clock.

Fixes: 8c320f4985fb (clk: divider: fix rate calculation for fractional rates)
Suggested-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Michael Turquette <mturquette@linaro.org>
drivers/clk/clk-divider.c