Skip to content

Commit

Permalink
clk: sunxi-ng: nm: Check if requested rate is supported by fractional…
Browse files Browse the repository at this point in the history
… clock

The round_rate callback for N-M-factor style clocks does not check if
the requested clock rate is supported by the fractional clock mode.
While this doesn't affect usage in practice, since the clock rates
are also supported through N-M factors, it does not match the set_rate
code.

Add a check to the round_rate callback so it matches the set_rate
callback.

Fixes: 6174a1e ("clk: sunxi-ng: Add N-M-factor clock support")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
  • Loading branch information
Chen-Yu Tsai authored and Maxime Ripard committed Oct 13, 2017
1 parent d51fe3b commit 4cdbc40
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/clk/sunxi-ng/ccu_nm.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ static long ccu_nm_round_rate(struct clk_hw *hw, unsigned long rate,
struct ccu_nm *nm = hw_to_ccu_nm(hw);
struct _ccu_nm _nm;

if (ccu_frac_helper_has_rate(&nm->common, &nm->frac, rate))
return rate;

_nm.min_n = nm->n.min ?: 1;
_nm.max_n = nm->n.max ?: 1 << nm->n.width;
_nm.min_m = 1;
Expand Down

0 comments on commit 4cdbc40

Please sign in to comment.