clk: use private clk struct in CLK_CCF's enable/disable functions
PATCH 1/1 clk: use private clk struct in CLK_CCF's enable/disable functions
In clk_enable()/clk_disable() functions, when CCF is activated, we must pass a private clk struct to enable()/disable() ops functions. Otherwise, the use of a container_of() construction within these ops should be banned. Because passing a non-private clk struct to container_of() results in an out of range error.
At the moment, clk-mux, clk-fixed-factor, clk-gate and possibly other clocks use container_of() in their enable()/disable() functions. Therefore, for these functions to work correclty, private clk struct must be passed.
--- drivers/clk/clk-uclass.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/clk-uclass.c +2 -2
@@ -649,7 +649,7 @@ int clk_enable(struct clk *clk) }if (ops->enable) { - ret = ops->enable (clk); + ret = ops->enable (clkp ? clkp : clk);if (ret) {printf ("Enable %s failed\n" , clk->dev->name);return ret;
@@ -706,7 +706,7 @@ int clk_disable(struct clk *clk) }if (ops->disable) { - ret = ops->disable (clk); + ret = ops->disable (clkp ? clkp : clk);if (ret)return ret; }
Signature · 1 line
2.39.2
Quoted 5 lines · Maksim Kiselev
In clk_enable()/clk_disable() functions, when CCF is activated, we must pass a private clk struct to enable()/disable() ops functions. Otherwise, the use of a
container_of()construction within these ops should be banned. Because passing a non-private clk struct tocontainer_of()results in an out of range error.
Yeah...
This is a big problem in the CCF code, where struct clk in U-Boot is both struct clk from Linux (a "thick" pointer) and struct clk_core (all the clock private data).
Quoted 3 lines
At the moment, clk-mux, clk-fixed-factor, clk-gate and possibly other clocks use
container_of()in their enable()/disable() functions. Therefore, for these functions to work correclty, private clk struct
correctly
Quoted 21 lines
must be passed.
Signed-off-by Maksim Kiselev <[email protected]>--- drivers/clk/clk-uclass.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/clk/clk-uclass.c +1
-1@@ -649,7 +649,7 @@ int clk_enable(struct clk *clk) }if (ops->enable) { - ret = ops->enable (clk); + ret = ops->enable (clkp ? clkp : clk);if (ret) {printf ("Enable %s failed\n" , clk->dev->name);return ret;
drivers/clk/clk-uclass.c int clk_disable(struct clk *clk) · line 712
Quoted 8 lines
drivers/clk/clk-uclass.c +1
-1@@ -706,7 +706,7 @@ int clk_disable(struct clk *clk) }if (ops->disable) { - ret = ops->disable (clk); + ret = ops->disable (clkp ? clkp : clk);if (ret)return ret; }
Sean Anderson
AppliedQuoted 6 lines · Maksim Kiselev
In clk_enable()/clk_disable() functions, when CCF is activated, we must pass a private clk struct to enable()/disable() ops functions. Otherwise, the use of a
container_of()construction within these ops should be banned. Because passing a non-private clk struct tocontainer_of()results in an out of range error.
Quoted 6 lines
At the moment, clk-mux, clk-fixed-factor, clk-gate and possibly other clocks use
container_of()in their enable()/disable() functions. Therefore, for these functions to work correclty, private clk struct must be passed.[...]
Applied, thanks!
[1/1] clk: use private clk struct in CLK_CCF's enable/disable functions
commit: 0755db477fa7478e2659568bb7da038a9eaabb8d
Best regards,
Signature · 1 line
Sean Anderson <[email protected]>