diff options
author | Maxime Ripard <maxime@cerno.tech> | 2022-02-25 17:35:27 +0300 |
---|---|---|
committer | Stephen Boyd <sboyd@kernel.org> | 2022-03-12 06:14:40 +0300 |
commit | a9b269310ad9abb2f206fe814fd3afcadddce3aa (patch) | |
tree | 81fddac32910fd317a01d8f12585ae0157c2af20 /drivers/clk | |
parent | 948fb0969eae856f9b65d8c9b98042afed08454f (diff) | |
download | linux-a9b269310ad9abb2f206fe814fd3afcadddce3aa.tar.xz |
clk: Use clamp instead of open-coding our own
The code in clk_set_rate_range() will, if the current rate is outside of
the new range, force it to the minimum or maximum.
Since it's running under the condition that the rate is either lower
than the minimum, or higher than the maximum, this is equivalent to
using clamp, while being less readable. Let's switch to using clamp
instead.
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20220225143534.405820-6-maxime@cerno.tech
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 6c4e10209568..c15ee5070f52 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2388,11 +2388,7 @@ int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max) * this corner case when determining the rate */ - if (rate < min) - rate = min; - else - rate = max; - + rate = clamp(clk->core->req_rate, min, max); ret = clk_core_set_rate_nolock(clk->core, rate); if (ret) { /* rollback the changes */ |