Commit 89dc59fb authored by Stephen Boyd's avatar Stephen Boyd Committed by Greg Kroah-Hartman

clk: sirf: Don't reference clk_init_data after registration

[ Upstream commit af55dadf ]

A future patch is going to change semantics of clk_register() so that
clk_hw::init is guaranteed to be NULL after a clk is registered. Avoid
referencing this member here so that we don't run into NULL pointer
exceptions.

Cc: Guo Zeng <Guo.Zeng@csr.com>
Cc: Barry Song <Baohua.Song@csr.com>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
Link: https://lkml.kernel.org/r/20190731193517.237136-6-sboyd@kernel.orgSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
parent bd3a445c
...@@ -298,9 +298,10 @@ static u8 dmn_clk_get_parent(struct clk_hw *hw) ...@@ -298,9 +298,10 @@ static u8 dmn_clk_get_parent(struct clk_hw *hw)
{ {
struct clk_dmn *clk = to_dmnclk(hw); struct clk_dmn *clk = to_dmnclk(hw);
u32 cfg = clkc_readl(clk->regofs); u32 cfg = clkc_readl(clk->regofs);
const char *name = clk_hw_get_name(hw);
/* parent of io domain can only be pll3 */ /* parent of io domain can only be pll3 */
if (strcmp(hw->init->name, "io") == 0) if (strcmp(name, "io") == 0)
return 4; return 4;
WARN_ON((cfg & (BIT(3) - 1)) > 4); WARN_ON((cfg & (BIT(3) - 1)) > 4);
...@@ -312,9 +313,10 @@ static int dmn_clk_set_parent(struct clk_hw *hw, u8 parent) ...@@ -312,9 +313,10 @@ static int dmn_clk_set_parent(struct clk_hw *hw, u8 parent)
{ {
struct clk_dmn *clk = to_dmnclk(hw); struct clk_dmn *clk = to_dmnclk(hw);
u32 cfg = clkc_readl(clk->regofs); u32 cfg = clkc_readl(clk->regofs);
const char *name = clk_hw_get_name(hw);
/* parent of io domain can only be pll3 */ /* parent of io domain can only be pll3 */
if (strcmp(hw->init->name, "io") == 0) if (strcmp(name, "io") == 0)
return -EINVAL; return -EINVAL;
cfg &= ~(BIT(3) - 1); cfg &= ~(BIT(3) - 1);
...@@ -354,7 +356,8 @@ static long dmn_clk_round_rate(struct clk_hw *hw, unsigned long rate, ...@@ -354,7 +356,8 @@ static long dmn_clk_round_rate(struct clk_hw *hw, unsigned long rate,
{ {
unsigned long fin; unsigned long fin;
unsigned ratio, wait, hold; unsigned ratio, wait, hold;
unsigned bits = (strcmp(hw->init->name, "mem") == 0) ? 3 : 4; const char *name = clk_hw_get_name(hw);
unsigned bits = (strcmp(name, "mem") == 0) ? 3 : 4;
fin = *parent_rate; fin = *parent_rate;
ratio = fin / rate; ratio = fin / rate;
...@@ -376,7 +379,8 @@ static int dmn_clk_set_rate(struct clk_hw *hw, unsigned long rate, ...@@ -376,7 +379,8 @@ static int dmn_clk_set_rate(struct clk_hw *hw, unsigned long rate,
struct clk_dmn *clk = to_dmnclk(hw); struct clk_dmn *clk = to_dmnclk(hw);
unsigned long fin; unsigned long fin;
unsigned ratio, wait, hold, reg; unsigned ratio, wait, hold, reg;
unsigned bits = (strcmp(hw->init->name, "mem") == 0) ? 3 : 4; const char *name = clk_hw_get_name(hw);
unsigned bits = (strcmp(name, "mem") == 0) ? 3 : 4;
fin = parent_rate; fin = parent_rate;
ratio = fin / rate; ratio = fin / rate;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment