* [PATCH] clk: mxs: Use clamp() in clk_ref_round_rate() and clk_ref_set_rate()
@ 2024-07-10 14:33 Thorsten Blum
2024-07-10 20:10 ` Stephen Boyd
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2024-07-10 14:33 UTC (permalink / raw)
To: mturquette, sboyd, shawnguo, s.hauer, kernel, festevam
Cc: linux-clk, imx, linux-arm-kernel, linux-kernel, Thorsten Blum
Use clamp() instead of duplicating its implementation.
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
drivers/clk/mxs/clk-ref.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/drivers/clk/mxs/clk-ref.c b/drivers/clk/mxs/clk-ref.c
index 3161a0b021ee..2297259da89a 100644
--- a/drivers/clk/mxs/clk-ref.c
+++ b/drivers/clk/mxs/clk-ref.c
@@ -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);
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] clk: mxs: Use clamp() in clk_ref_round_rate() and clk_ref_set_rate()
2024-07-10 14:33 [PATCH] clk: mxs: Use clamp() in clk_ref_round_rate() and clk_ref_set_rate() Thorsten Blum
@ 2024-07-10 20:10 ` Stephen Boyd
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2024-07-10 20:10 UTC (permalink / raw)
To: Thorsten Blum, festevam, kernel, mturquette, s.hauer, shawnguo
Cc: linux-clk, imx, linux-arm-kernel, linux-kernel, Thorsten Blum
Quoting Thorsten Blum (2024-07-10 07:33:10)
> Use clamp() instead of duplicating its implementation.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
> ---
Applied to clk-next
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-10 20:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-10 14:33 [PATCH] clk: mxs: Use clamp() in clk_ref_round_rate() and clk_ref_set_rate() Thorsten Blum
2024-07-10 20:10 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox