clk: Treat NULL as dummy clocks
NULL pointers should be treated as dummy clocks as done in the kernel. Using a not fully filled in clk * array for of_clk_add_provider may result in NULL clks. When these are passed into the clk framework we should not crash. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
3d61b7b6a9
commit
85799d1b75
|
@ -44,6 +44,9 @@ int clk_enable(struct clk *clk)
|
|||
{
|
||||
int ret;
|
||||
|
||||
if (!clk)
|
||||
return 0;
|
||||
|
||||
if (IS_ERR(clk))
|
||||
return PTR_ERR(clk);
|
||||
|
||||
|
@ -68,6 +71,9 @@ int clk_enable(struct clk *clk)
|
|||
|
||||
void clk_disable(struct clk *clk)
|
||||
{
|
||||
if (!clk)
|
||||
return;
|
||||
|
||||
if (IS_ERR(clk))
|
||||
return;
|
||||
|
||||
|
@ -89,10 +95,15 @@ unsigned long clk_get_rate(struct clk *clk)
|
|||
struct clk *parent;
|
||||
unsigned long parent_rate = 0;
|
||||
|
||||
if (!clk)
|
||||
return 0;
|
||||
|
||||
if (IS_ERR(clk))
|
||||
return 0;
|
||||
|
||||
parent = clk_get_parent(clk);
|
||||
|
||||
|
||||
if (!IS_ERR_OR_NULL(parent))
|
||||
parent_rate = clk_get_rate(parent);
|
||||
|
||||
|
@ -107,6 +118,9 @@ long clk_round_rate(struct clk *clk, unsigned long rate)
|
|||
unsigned long parent_rate = 0;
|
||||
struct clk *parent;
|
||||
|
||||
if (!clk)
|
||||
return 0;
|
||||
|
||||
if (IS_ERR(clk))
|
||||
return 0;
|
||||
|
||||
|
@ -125,6 +139,9 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
|
|||
struct clk *parent;
|
||||
unsigned long parent_rate = 0;
|
||||
|
||||
if (!clk)
|
||||
return 0;
|
||||
|
||||
if (IS_ERR(clk))
|
||||
return PTR_ERR(clk);
|
||||
|
||||
|
|
Loading…
Reference in New Issue