devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] clk: vc5: Use `clamp()` to restrict PLL range
@ 2023-01-14 23:34 Lars-Peter Clausen
  2023-01-14 23:34 ` [PATCH 2/3] clk: vc5: Add support for 5P49V60 Lars-Peter Clausen
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Lars-Peter Clausen @ 2023-01-14 23:34 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: Luca Ceresoli, Rob Herring, Krzysztof Kozlowski, linux-clk,
	devicetree, Lars-Peter Clausen

The VCO frequency needs to be within a certain range and the driver
enforces this.

Make use of the clamp macro to implement this instead of open-coding it.
This makes the code a bit shorter and also semanticly stronger.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/clk/clk-versaclock5.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
index e9737969170e..54fee43d6564 100644
--- a/drivers/clk/clk-versaclock5.c
+++ b/drivers/clk/clk-versaclock5.c
@@ -449,10 +449,7 @@ static long vc5_pll_round_rate(struct clk_hw *hw, unsigned long rate,
 	u32 div_int;
 	u64 div_frc;
 
-	if (rate < VC5_PLL_VCO_MIN)
-		rate = VC5_PLL_VCO_MIN;
-	if (rate > VC5_PLL_VCO_MAX)
-		rate = VC5_PLL_VCO_MAX;
+	rate = clamp(rate, VC5_PLL_VCO_MIN, VC5_PLL_VCO_MAX);
 
 	/* Determine integer part, which is 12 bit wide */
 	div_int = rate / *parent_rate;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-01-18 18:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-14 23:34 [PATCH 1/3] clk: vc5: Use `clamp()` to restrict PLL range Lars-Peter Clausen
2023-01-14 23:34 ` [PATCH 2/3] clk: vc5: Add support for 5P49V60 Lars-Peter Clausen
2023-01-16  8:15   ` Luca Ceresoli
2023-01-18 18:57   ` Stephen Boyd
2023-01-14 23:35 ` [PATCH 3/3] dt-bindings: clock: versaclock5: Document 5P49V60 compatible string Lars-Peter Clausen
2023-01-15 14:55   ` Krzysztof Kozlowski
2023-01-16  8:15   ` Luca Ceresoli
2023-01-18 18:57   ` Stephen Boyd
2023-01-16  8:15 ` [PATCH 1/3] clk: vc5: Use `clamp()` to restrict PLL range Luca Ceresoli
2023-01-18 18:57 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).