From: Brian Masney Date: Mon, 11 Aug 2025 15:17:55 +0000 (-0400) Subject: clk: fixed-factor: add determine_rate() ops X-Git-Tag: v6.18-rc1~50^2^2~2^2~109 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=582de809b052892e1338508374f562e823b29566;p=thirdparty%2Fkernel%2Flinux.git clk: fixed-factor: add determine_rate() ops The round_rate() clk ops is deprecated, and determine_rate() should be used instead. We can't just simply convert this driver over initially since other drivers depend on this. So let's go ahead and add a determine_rate() clk ops. Once all of the drivers have been converted, then the round_rate() clk ops can be dropped. Signed-off-by: Brian Masney --- diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c index e62ae8794d44..79b9a8c57d4b 100644 --- a/drivers/clk/clk-fixed-factor.c +++ b/drivers/clk/clk-fixed-factor.c @@ -30,6 +30,23 @@ static unsigned long clk_factor_recalc_rate(struct clk_hw *hw, return (unsigned long)rate; } +static int clk_factor_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) +{ + struct clk_fixed_factor *fix = to_clk_fixed_factor(hw); + + if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) { + unsigned long best_parent; + + best_parent = (req->rate / fix->mult) * fix->div; + req->best_parent_rate = clk_hw_round_rate(clk_hw_get_parent(hw), best_parent); + } + + req->rate = (req->best_parent_rate / fix->div) * fix->mult; + + return 0; +} + static long clk_factor_round_rate(struct clk_hw *hw, unsigned long rate, unsigned long *prate) { @@ -50,7 +67,7 @@ static int clk_factor_set_rate(struct clk_hw *hw, unsigned long rate, { /* * We must report success but we can do so unconditionally because - * clk_factor_round_rate returns values that ensure this call is a + * clk_factor_determine_rate returns values that ensure this call is a * nop. */ @@ -69,6 +86,7 @@ static unsigned long clk_factor_recalc_accuracy(struct clk_hw *hw, } const struct clk_ops clk_fixed_factor_ops = { + .determine_rate = clk_factor_determine_rate, .round_rate = clk_factor_round_rate, .set_rate = clk_factor_set_rate, .recalc_rate = clk_factor_recalc_rate,