Commit 8fc55a5b authored by Tony Lindgren's avatar Tony Lindgren

ARM: OMAP: Add error checking to clock functions

Add error checking to clock functions
parent 202b883f
...@@ -59,6 +59,9 @@ int clk_enable(struct clk *clk) ...@@ -59,6 +59,9 @@ int clk_enable(struct clk *clk)
unsigned long flags; unsigned long flags;
int ret = 0; int ret = 0;
if (clk == NULL || IS_ERR(clk))
return -ENODEV;
spin_lock_irqsave(&clockfw_lock, flags); spin_lock_irqsave(&clockfw_lock, flags);
if (arch_clock->clk_enable) if (arch_clock->clk_enable)
ret = arch_clock->clk_enable(clk); ret = arch_clock->clk_enable(clk);
...@@ -72,6 +75,9 @@ void clk_disable(struct clk *clk) ...@@ -72,6 +75,9 @@ void clk_disable(struct clk *clk)
{ {
unsigned long flags; unsigned long flags;
if (clk == NULL || IS_ERR(clk))
return;
spin_lock_irqsave(&clockfw_lock, flags); spin_lock_irqsave(&clockfw_lock, flags);
if (arch_clock->clk_disable) if (arch_clock->clk_disable)
arch_clock->clk_disable(clk); arch_clock->clk_disable(clk);
...@@ -84,6 +90,9 @@ int clk_get_usecount(struct clk *clk) ...@@ -84,6 +90,9 @@ int clk_get_usecount(struct clk *clk)
unsigned long flags; unsigned long flags;
int ret = 0; int ret = 0;
if (clk == NULL || IS_ERR(clk))
return 0;
spin_lock_irqsave(&clockfw_lock, flags); spin_lock_irqsave(&clockfw_lock, flags);
ret = clk->usecount; ret = clk->usecount;
spin_unlock_irqrestore(&clockfw_lock, flags); spin_unlock_irqrestore(&clockfw_lock, flags);
...@@ -97,6 +106,9 @@ unsigned long clk_get_rate(struct clk *clk) ...@@ -97,6 +106,9 @@ unsigned long clk_get_rate(struct clk *clk)
unsigned long flags; unsigned long flags;
unsigned long ret = 0; unsigned long ret = 0;
if (clk == NULL || IS_ERR(clk))
return 0;
spin_lock_irqsave(&clockfw_lock, flags); spin_lock_irqsave(&clockfw_lock, flags);
ret = clk->rate; ret = clk->rate;
spin_unlock_irqrestore(&clockfw_lock, flags); spin_unlock_irqrestore(&clockfw_lock, flags);
......
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