Skip to content

Commit

Permalink
clk: Use clamp instead of open-coding our own
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Maxime Ripard authored and Stephen Boyd committed Mar 12, 2022
1 parent 948fb09 commit a9b2693
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions drivers/clk/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit a9b2693

Please sign in to comment.