diff options
author | Maxime Ripard <maxime@cerno.tech> | 2022-02-25 15:35:26 +0100 |
---|---|---|
committer | Stephen Boyd <sboyd@kernel.org> | 2022-03-12 04:14:39 +0100 |
commit | 948fb0969eae856f9b65d8c9b98042afed08454f (patch) | |
tree | dff63fc163aab1c453101353bea7e272178a01ae /drivers/clk/clk.c | |
parent | clk: Enforce that disjoints limits are invalid (diff) | |
download | linux-948fb0969eae856f9b65d8c9b98042afed08454f.tar.xz linux-948fb0969eae856f9b65d8c9b98042afed08454f.zip |
clk: Always clamp the rounded rate
The current core while setting the min and max rate properly in the
clk_request structure will not make sure that the requested rate is
within these boundaries, leaving it to each and every driver to make
sure it is.
It's not clear if this was on purpose or not, but this introduces some
inconsistencies within the API.
For example, a user setting a range and then calling clk_round_rate()
with a value outside of that range will get the same value back
(ignoring any driver adjustements), effectively ignoring the range that
was just set.
Another one, arguably worse, is that it also makes clk_round_rate() and
clk_set_rate() behave differently if there's a range and the rate being
used for both is outside that range. As we have seen, the rate will be
returned unchanged by clk_round_rate(), but clk_set_rate() will error
out returning -EINVAL.
Let's make sure the framework will always clamp the rate to the current
range found on the clock, which will fix both these inconsistencies.
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20220225143534.405820-5-maxime@cerno.tech
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r-- | drivers/clk/clk.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 112911138a7b..6c4e10209568 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1348,6 +1348,8 @@ static int clk_core_determine_round_nolock(struct clk_core *core, if (!core) return 0; + req->rate = clamp(req->rate, req->min_rate, req->max_rate); + /* * At this point, core protection will be disabled * - if the provider is not protected at all |