clk: Add our request boundaries in clk_core_init_rate_req
authorMaxime Ripard <maxime@cerno.tech>
Tue, 16 Aug 2022 11:25:22 +0000 (13:25 +0200)
committerStephen Boyd <sboyd@kernel.org>
Thu, 15 Sep 2022 16:31:49 +0000 (09:31 -0700)
The expectation is that a new clk_rate_request is initialized through a
call to clk_core_init_rate_req().

However, at the moment it only fills the parent rate and clk_hw pointer,
but omits the other fields such as the clock rate boundaries.

Some users of that function will update them after calling it, but most
don't.

As we are passed the clk_core pointer, we have access to those
boundaries in clk_core_init_rate_req() however, so let's just fill it
there and remove it from the few callers that do it right.

Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com> # imx8mp
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> # exynos4210, meson g12b
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20220816112530.1837489-18-maxime@cerno.tech
Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/clk.c

index 96b372ff23c218c92107b913014a7b7da40142db..2794bd3bef4b8787671dafdc2ca60148c6d0f2d2 100644 (file)
@@ -1389,6 +1389,7 @@ static void clk_core_init_rate_req(struct clk_core * const core,
                return;
 
        req->rate = rate;
+       clk_core_get_boundaries(core, &req->min_rate, &req->max_rate);
 
        parent = core->parent;
        if (parent) {
@@ -1483,7 +1484,6 @@ unsigned long clk_hw_round_rate(struct clk_hw *hw, unsigned long rate)
        struct clk_rate_request req;
 
        clk_core_init_rate_req(hw->core, &req, rate);
-       clk_core_get_boundaries(hw->core, &req.min_rate, &req.max_rate);
 
        ret = clk_core_round_rate_nolock(hw->core, &req);
        if (ret)
@@ -1516,7 +1516,6 @@ long clk_round_rate(struct clk *clk, unsigned long rate)
                clk_core_rate_unprotect(clk->core);
 
        clk_core_init_rate_req(clk->core, &req, rate);
-       clk_core_get_boundaries(clk->core, &req.min_rate, &req.max_rate);
 
        ret = clk_core_round_rate_nolock(clk->core, &req);
 
@@ -2025,9 +2024,6 @@ static struct clk_core *clk_calc_new_rates(struct clk_core *core,
        if (clk_core_can_round(core)) {
                struct clk_rate_request req;
 
-               req.min_rate = min_rate;
-               req.max_rate = max_rate;
-
                clk_core_init_rate_req(core, &req, rate);
 
                ret = clk_core_determine_round_nolock(core, &req);
@@ -2228,7 +2224,6 @@ static unsigned long clk_core_req_round_rate_nolock(struct clk_core *core,
                return cnt;
 
        clk_core_init_rate_req(core, &req, req_rate);
-       clk_core_get_boundaries(core, &req.min_rate, &req.max_rate);
 
        ret = clk_core_round_rate_nolock(core, &req);