Skip to content

Commit 12b02b6

Browse files
tobluxbebarino
authored andcommitted
clk: mxs: Use clamp() in clk_ref_round_rate() and clk_ref_set_rate()
Use clamp() instead of duplicating its implementation. Signed-off-by: Thorsten Blum <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 7b34303 commit 12b02b6

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

drivers/clk/mxs/clk-ref.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,7 @@ static long clk_ref_round_rate(struct clk_hw *hw, unsigned long rate,
6666

6767
tmp = tmp * 18 + rate / 2;
6868
do_div(tmp, rate);
69-
frac = tmp;
70-
71-
if (frac < 18)
72-
frac = 18;
73-
else if (frac > 35)
74-
frac = 35;
69+
frac = clamp(tmp, 18, 35);
7570

7671
tmp = parent_rate;
7772
tmp *= 18;
@@ -91,12 +86,7 @@ static int clk_ref_set_rate(struct clk_hw *hw, unsigned long rate,
9186

9287
tmp = tmp * 18 + rate / 2;
9388
do_div(tmp, rate);
94-
frac = tmp;
95-
96-
if (frac < 18)
97-
frac = 18;
98-
else if (frac > 35)
99-
frac = 35;
89+
frac = clamp(tmp, 18, 35);
10090

10191
spin_lock_irqsave(&mxs_lock, flags);
10292

0 commit comments

Comments
 (0)