Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: qcom: clk-hfpll: switch to .determine_rate

.determine_rate is meant to replace .round_rate. The former comes with a
benefit which is especially relevant on 32-bit systems: since
.determine_rate uses an "unsigned long" (compared to a "signed long"
which is used by .round_rate) the maximum value on 32-bit systems
increases from 2^31 (or approx. 2.14GHz) to 2^32 (or approx. 4.29GHz).

Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
Tested-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20230212-clk-qcom-determine_rate-v1-2-b4e447d4926e@z3ntu.xyz

authored by

Luca Weiss and committed by
Bjorn Andersson
04648b8f a7074c3e

+7 -7
+7 -7
drivers/clk/qcom/clk-hfpll.c
··· 128 128 spin_unlock_irqrestore(&h->lock, flags); 129 129 } 130 130 131 - static long clk_hfpll_round_rate(struct clk_hw *hw, unsigned long rate, 132 - unsigned long *parent_rate) 131 + static int clk_hfpll_determine_rate(struct clk_hw *hw, struct clk_rate_request *req) 133 132 { 134 133 struct clk_hfpll *h = to_clk_hfpll(hw); 135 134 struct hfpll_data const *hd = h->d; 136 135 unsigned long rrate; 137 136 138 - rate = clamp(rate, hd->min_rate, hd->max_rate); 137 + req->rate = clamp(req->rate, hd->min_rate, hd->max_rate); 139 138 140 - rrate = DIV_ROUND_UP(rate, *parent_rate) * *parent_rate; 139 + rrate = DIV_ROUND_UP(req->rate, req->best_parent_rate) * req->best_parent_rate; 141 140 if (rrate > hd->max_rate) 142 - rrate -= *parent_rate; 141 + rrate -= req->best_parent_rate; 143 142 144 - return rrate; 143 + req->rate = rrate; 144 + return 0; 145 145 } 146 146 147 147 /* ··· 241 241 .enable = clk_hfpll_enable, 242 242 .disable = clk_hfpll_disable, 243 243 .is_enabled = hfpll_is_enabled, 244 - .round_rate = clk_hfpll_round_rate, 244 + .determine_rate = clk_hfpll_determine_rate, 245 245 .set_rate = clk_hfpll_set_rate, 246 246 .recalc_rate = clk_hfpll_recalc_rate, 247 247 .init = clk_hfpll_init,