* [PATCH] clk: Treat NULL as dummy clocks
@ 2015-03-05 14:17 Sascha Hauer
0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2015-03-05 14:17 UTC (permalink / raw)
To: Barebox List
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>
---
drivers/clk/clk.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 584e2f3..1f11bb3 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);
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-03-05 14:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-05 14:17 [PATCH] clk: Treat NULL as dummy clocks Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox