]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
clk: vc5: Use `clamp()` to restrict PLL range
authorLars-Peter Clausen <lars@metafoo.de>
Sat, 14 Jan 2023 23:34:58 +0000 (15:34 -0800)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Mon, 2 Oct 2023 15:19:39 +0000 (17:19 +0200)
BugLink: https://bugs.launchpad.net/bugs/2034469
[ Upstream commit 3ed741db04f58e8df0d46cec7ecfc4bfd075f047 ]

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>
Stable-dep-of: be3471c5bd9b ("clk: vc5: Fix .driver_data content in i2c_device_id")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/clk/clk-versaclock5.c

index e9737969170e1e08548f8bcdc084eaf1c6f675c9..54fee43d65642f4b04876d751b9b3213cb2e0897 100644 (file)
@@ -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;