[U-Boot] [i.MX8MM+CCF 01/41] clk: correct get clk_x pointer

Peng Fan peng.fan at nxp.com
Tue Apr 30 10:17:33 UTC 2019


Directly use driver data is wrong, need to the helper to get
the correct clk_divider and etc

Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
 drivers/clk/clk-divider.c   | 2 +-
 drivers/clk/imx/clk-gate2.c | 4 ++--
 drivers/clk/imx/clk-pfd.c   | 2 +-
 drivers/clk/imx/clk-pllv3.c | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 3841d8bfbb..1d2c1b1ec4 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -70,7 +70,7 @@ unsigned long divider_recalc_rate(struct clk *hw, unsigned long parent_rate,
 static ulong clk_divider_recalc_rate(struct clk *clk)
 {
 	struct clk_divider *divider =
-		(struct clk_divider *)dev_get_driver_data(clk->dev);
+		to_clk_divider((struct clk *)dev_get_driver_data(clk->dev));
 	unsigned long parent_rate = clk_get_parent_rate(clk);
 	unsigned int val;
 
diff --git a/drivers/clk/imx/clk-gate2.c b/drivers/clk/imx/clk-gate2.c
index 1e53e4f9db..83589b9206 100644
--- a/drivers/clk/imx/clk-gate2.c
+++ b/drivers/clk/imx/clk-gate2.c
@@ -38,7 +38,7 @@ struct clk_gate2 {
 static int clk_gate2_enable(struct clk *clk)
 {
 	struct clk_gate2 *gate =
-		(struct clk_gate2 *)dev_get_driver_data(clk->dev);
+		to_clk_gate2((struct clk *)dev_get_driver_data(clk->dev));
 	u32 reg;
 
 	reg = readl(gate->reg);
@@ -52,7 +52,7 @@ static int clk_gate2_enable(struct clk *clk)
 static int clk_gate2_disable(struct clk *clk)
 {
 	struct clk_gate2 *gate =
-		(struct clk_gate2 *)dev_get_driver_data(clk->dev);
+		to_clk_gate2((struct clk *)dev_get_driver_data(clk->dev));
 	u32 reg;
 
 	reg = readl(gate->reg);
diff --git a/drivers/clk/imx/clk-pfd.c b/drivers/clk/imx/clk-pfd.c
index 2293d481d4..51521ccee6 100644
--- a/drivers/clk/imx/clk-pfd.c
+++ b/drivers/clk/imx/clk-pfd.c
@@ -41,7 +41,7 @@ struct clk_pfd {
 static unsigned long clk_pfd_recalc_rate(struct clk *clk)
 {
 	struct clk_pfd *pfd =
-		(struct clk_pfd *)dev_get_driver_data(clk->dev);
+		to_clk_pfd((struct clk *)dev_get_driver_data(clk->dev));
 	unsigned long parent_rate = clk_get_parent_rate(clk);
 	u64 tmp = parent_rate;
 	u8 frac = (readl(pfd->reg) >> (pfd->idx * 8)) & 0x3f;
diff --git a/drivers/clk/imx/clk-pllv3.c b/drivers/clk/imx/clk-pllv3.c
index 3fe9b7c03d..28c0439878 100644
--- a/drivers/clk/imx/clk-pllv3.c
+++ b/drivers/clk/imx/clk-pllv3.c
@@ -27,7 +27,7 @@ struct clk_pllv3 {
 static ulong clk_pllv3_get_rate(struct clk *clk)
 {
 	struct clk_pllv3 *pll =
-		(struct clk_pllv3 *)dev_get_driver_data(clk->dev);
+		to_clk_pllv3((struct clk *)dev_get_driver_data(clk->dev));
 	unsigned long parent_rate = clk_get_parent_rate(clk);
 
 	u32 div = (readl(pll->base) >> pll->div_shift) & pll->div_mask;
-- 
2.16.4



More information about the U-Boot mailing list