diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-03-05 15:13:41 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-03-05 15:17:13 +0100 |
commit | 85799d1b755ad3ea1fd80cecd913eea6b00a5c87 (patch) | |
tree | b805d4a44fa952de290c63e463125e974f0dfdf1 /drivers/clk | |
parent | 3d61b7b6a9b9967f4d3e64a985abd2500abb202d (diff) | |
download | barebox-85799d1b755ad3ea1fd80cecd913eea6b00a5c87.tar.gz barebox-85799d1b755ad3ea1fd80cecd913eea6b00a5c87.tar.xz |
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>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 584e2f3242..1f11bb3686 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -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); |