Commit 12b02b63 authored by Thorsten Blum's avatar Thorsten Blum Committed by Stephen Boyd

clk: mxs: Use clamp() in clk_ref_round_rate() and clk_ref_set_rate()

Use clamp() instead of duplicating its implementation.
Signed-off-by: default avatarThorsten Blum <thorsten.blum@toblux.com>
Link: https://lore.kernel.org/r/20240710143309.706135-2-thorsten.blum@toblux.comSigned-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent 7b34303d
......@@ -66,12 +66,7 @@ static long clk_ref_round_rate(struct clk_hw *hw, unsigned long rate,
tmp = tmp * 18 + rate / 2;
do_div(tmp, rate);
frac = tmp;
if (frac < 18)
frac = 18;
else if (frac > 35)
frac = 35;
frac = clamp(tmp, 18, 35);
tmp = parent_rate;
tmp *= 18;
......@@ -91,12 +86,7 @@ static int clk_ref_set_rate(struct clk_hw *hw, unsigned long rate,
tmp = tmp * 18 + rate / 2;
do_div(tmp, rate);
frac = tmp;
if (frac < 18)
frac = 18;
else if (frac > 35)
frac = 35;
frac = clamp(tmp, 18, 35);
spin_lock_irqsave(&mxs_lock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment