diff options
author | Stephen Boyd <[email protected]> | 2023-05-05 13:25:05 +0200 |
---|---|---|
committer | Stephen Boyd <[email protected]> | 2023-06-08 18:01:05 -0700 |
commit | 1b4e99fda73fd030635f378ee059257f6ad0f780 (patch) | |
tree | dfeec91c1429c3896dcf802870b6c75ae8b85718 | |
parent | 9633b4c17b734de8308461182facc931042824b7 (diff) |
clk: Move no reparent case into a separate function
We'll need to turn the code in clk_mux_determine_rate_flags() to deal
with CLK_SET_RATE_NO_REPARENT into a helper clock drivers will be able
to use if they don't want to allow reparenting.
Cc: Abel Vesa <[email protected]>
Cc: Alessandro Zummo <[email protected]>
Cc: Alexandre Belloni <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: "Andreas Färber" <[email protected]>
Cc: AngeloGioacchino Del Regno <[email protected]>
Cc: Baolin Wang <[email protected]>
Cc: Charles Keepax <[email protected]>
Cc: Chen-Yu Tsai <[email protected]>
Cc: Chen-Yu Tsai <[email protected]>
Cc: Chunyan Zhang <[email protected]>
Cc: Claudiu Beznea <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: David Airlie <[email protected]>
Cc: David Lechner <[email protected]>
Cc: Dinh Nguyen <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Jaroslav Kysela <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonathan Hunter <[email protected]>
Cc: Kishon Vijay Abraham I <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: Luca Ceresoli <[email protected]>
Cc: Manivannan Sadhasivam <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Markus Schneider-Pargmann <[email protected]>
Cc: Max Filippov <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Mikko Perttunen <[email protected]>
Cc: Miles Chen <[email protected]>
Cc: Nicolas Ferre <[email protected]>
Cc: Orson Zhai <[email protected]>
Cc: Paul Cercueil <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Peter De Schrijver <[email protected]>
Cc: Prashant Gaikwad <[email protected]>
Cc: Richard Fitzgerald <[email protected]>
Cc: Samuel Holland <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Sekhar Nori <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Takashi Iwai <[email protected]>
Cc: Thierry Reding <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: NXP Linux Team <[email protected]>
Cc: [email protected]
Cc: Pengutronix Kernel Team <[email protected]>
Signed-off-by: Stephen Boyd <[email protected]>
Signed-off-by: Maxime Ripard <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
-rw-r--r-- | drivers/clk/clk.c | 75 |
1 files changed, 43 insertions, 32 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index e495dd7a1eae..f57f821a5e5a 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -594,45 +594,58 @@ clk_core_forward_rate_req(struct clk_core *core, req->max_rate = old_req->max_rate; } -int clk_mux_determine_rate_flags(struct clk_hw *hw, - struct clk_rate_request *req, - unsigned long flags) +static int +clk_core_determine_rate_no_reparent(struct clk_hw *hw, + struct clk_rate_request *req) { - struct clk_core *core = hw->core, *parent, *best_parent = NULL; - int i, num_parents, ret; - unsigned long best = 0; - - /* if NO_REPARENT flag set, pass through to current parent */ - if (core->flags & CLK_SET_RATE_NO_REPARENT) { - parent = core->parent; - if (core->flags & CLK_SET_RATE_PARENT) { - struct clk_rate_request parent_req; + struct clk_core *core = hw->core; + struct clk_core *parent = core->parent; + unsigned long best; + int ret; - if (!parent) { - req->rate = 0; - return 0; - } + if (core->flags & CLK_SET_RATE_PARENT) { + struct clk_rate_request parent_req; - clk_core_forward_rate_req(core, req, parent, &parent_req, req->rate); + if (!parent) { + req->rate = 0; + return 0; + } - trace_clk_rate_request_start(&parent_req); + clk_core_forward_rate_req(core, req, parent, &parent_req, + req->rate); - ret = clk_core_round_rate_nolock(parent, &parent_req); - if (ret) - return ret; + trace_clk_rate_request_start(&parent_req); - trace_clk_rate_request_done(&parent_req); + ret = clk_core_round_rate_nolock(parent, &parent_req); + if (ret) + return ret; - best = parent_req.rate; - } else if (parent) { - best = clk_core_get_rate_nolock(parent); - } else { - best = clk_core_get_rate_nolock(core); - } + trace_clk_rate_request_done(&parent_req); - goto out; + best = parent_req.rate; + } else if (parent) { + best = clk_core_get_rate_nolock(parent); + } else { + best = clk_core_get_rate_nolock(core); } + req->rate = best; + + return 0; +} + +int clk_mux_determine_rate_flags(struct clk_hw *hw, + struct clk_rate_request *req, + unsigned long flags) +{ + struct clk_core *core = hw->core, *parent, *best_parent = NULL; + int i, num_parents, ret; + unsigned long best = 0; + + /* if NO_REPARENT flag set, pass through to current parent */ + if (core->flags & CLK_SET_RATE_NO_REPARENT) + return clk_core_determine_rate_no_reparent(hw, req); + /* find the parent that can provide the fastest rate <= rate */ num_parents = core->num_parents; for (i = 0; i < num_parents; i++) { @@ -670,9 +683,7 @@ int clk_mux_determine_rate_flags(struct clk_hw *hw, if (!best_parent) return -EINVAL; -out: - if (best_parent) - req->best_parent_hw = best_parent->hw; + req->best_parent_hw = best_parent->hw; req->best_parent_rate = best; req->rate = best; |