This is a note to let you know that I've just added the patch titled clk: vc5: Use `clamp()` to restrict PLL range to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: clk-vc5-use-clamp-to-restrict-pll-range.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 199c1b56c309c06378cf291d3cca9985f4ff6158 Author: Lars-Peter Clausen <lars@xxxxxxxxxx> Date: Sat Jan 14 15:34:58 2023 -0800 clk: vc5: Use `clamp()` to restrict PLL range [ 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@xxxxxxxxxx> Link: https://lore.kernel.org/r/20230114233500.3294789-1-lars@xxxxxxxxxx Reviewed-by: Luca Ceresoli <luca.ceresoli@xxxxxxxxxxx> Signed-off-by: Stephen Boyd <sboyd@xxxxxxxxxx> Stable-dep-of: be3471c5bd9b ("clk: vc5: Fix .driver_data content in i2c_device_id") Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c index 88689415aff9c..abfe59ac4e487 100644 --- a/drivers/clk/clk-versaclock5.c +++ b/drivers/clk/clk-versaclock5.c @@ -450,10 +450,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;