Skip to content

Commit a9b2693

Browse files
mripardbebarino
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 948fb09 commit a9b2693

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

drivers/clk/clk.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,11 +2388,7 @@ int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max)
23882388
* this corner case when determining the rate
23892389
*/
23902390

2391-
if (rate < min)
2392-
rate = min;
2393-
else
2394-
rate = max;
2395-
2391+
rate = clamp(clk->core->req_rate, min, max);
23962392
ret = clk_core_set_rate_nolock(clk->core, rate);
23972393
if (ret) {
23982394
/* rollback the changes */

0 commit comments

Comments
 (0)