MLK-14993 clk: imx: check pd before use
authorPeng Fan <peng.fan@nxp.com>
Wed, 31 May 2017 09:54:44 +0000 (17:54 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:22:29 +0000 (15:22 -0500)
If we could not get a valid pd for gate/mux, print a warning log.
And use IS_ERR_OR_NULL to check the pd pointer.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
drivers/clk/imx/clk-gate-scu.c
drivers/clk/imx/clk-mux-scu.c

index f70cc0b..9432ca6 100644 (file)
@@ -198,6 +198,8 @@ static void populate_gate_pd(struct clk_gate2_scu *clk)
                pd_args.np = np;
                pd_args.args_count = 0;
                clk->pd = genpd_get_from_provider(&pd_args);
+               if (IS_ERR(clk->pd))
+                       pr_warn("%s: failed to get pd\n", __func__);
        }
 }
 
@@ -213,7 +215,7 @@ static int clk_gate2_scu_enable(struct clk_hw *hw)
        if (gate->pd == NULL && gate->pd_name)
                populate_gate_pd(gate);
 
-       if (!gate->pd)
+       if (IS_ERR_OR_NULL(gate->pd))
                return -1;
 
        if (gate->pd->status != GPD_STATE_ACTIVE)
@@ -240,7 +242,7 @@ static void clk_gate2_scu_disable(struct clk_hw *hw)
        if (gate->pd == NULL && gate->pd_name)
                populate_gate_pd(gate);
 
-       if (!gate->pd)
+       if (IS_ERR_OR_NULL(gate->pd))
                return;
 
        if (gate->pd->status != GPD_STATE_ACTIVE)
@@ -261,7 +263,7 @@ static int clk_gate2_scu_is_enabled(struct clk_hw *hw)
        if (gate->pd == NULL && gate->pd_name)
                populate_gate_pd(gate);
 
-       if (!gate->pd)
+       if (IS_ERR_OR_NULL(gate->pd))
                return 0;
 
        if (gate->pd->status != GPD_STATE_ACTIVE)
index 84184c4..597d4c7 100644 (file)
@@ -68,6 +68,8 @@ static void populate_mux_pd(struct clk_mux_scu *clk)
                pd_args.np = np;
                pd_args.args_count = 0;
                clk->pd = genpd_get_from_provider(&pd_args);
+               if (IS_ERR(clk->pd))
+                       pr_warn("%s: failed to get pd\n", __func__);
        }
 }
 
@@ -83,7 +85,7 @@ static u8 clk_mux_get_parent_scu(struct clk_hw *hw)
        if (mux->pd == NULL && mux->pd_name)
                populate_mux_pd(mux);
 
-       if (!mux->pd)
+       if (IS_ERR_OR_NULL(mux->pd))
                return 0;
 
        if (mux->pd->status != GPD_STATE_ACTIVE)
@@ -132,7 +134,7 @@ static int clk_mux_set_parent_scu(struct clk_hw *hw, u8 index)
        if (mux->pd == NULL && mux->pd_name)
                populate_mux_pd(mux);
 
-       if (!mux->pd)
+       if (IS_ERR_OR_NULL(mux->pd))
                return -1;
 
        if (mux->pd->status != GPD_STATE_ACTIVE)