Skip to content

Commit 3ed741d

Browse files
larsclausenbebarino
authored andcommitted
clk: vc5: Use clamp() to restrict PLL range
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> Link: https://lore.kernel.org/r/20230114233500.3294789-1-lars@metafoo.de Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 1b929c0 commit 3ed741d

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

drivers/clk/clk-versaclock5.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,7 @@ static long vc5_pll_round_rate(struct clk_hw *hw, unsigned long rate,
449449
u32 div_int;
450450
u64 div_frc;
451451

452-
if (rate < VC5_PLL_VCO_MIN)
453-
rate = VC5_PLL_VCO_MIN;
454-
if (rate > VC5_PLL_VCO_MAX)
455-
rate = VC5_PLL_VCO_MAX;
452+
rate = clamp(rate, VC5_PLL_VCO_MIN, VC5_PLL_VCO_MAX);
456453

457454
/* Determine integer part, which is 12 bit wide */
458455
div_int = rate / *parent_rate;

0 commit comments

Comments
 (0)