]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ARM: OMAP: More NULL clock checks
authorTony Lindgren <tony@atomide.com>
Wed, 15 Feb 2006 20:57:18 +0000 (12:57 -0800)
committerTony Lindgren <tony@atomide.com>
Wed, 15 Feb 2006 20:57:18 +0000 (12:57 -0800)
NULL pointer checks were not added to all functions as pointed
out by Richards Woodruff.

arch/arm/plat-omap/clock.c

index 679ae12b2d81320eca714b73906fffa7b487e8ee..29071ad3421e56d482777aabdffe4081b72c0dc9 100644 (file)
@@ -81,7 +81,7 @@ int clk_enable(struct clk *clk)
        int ret = 0;
 
        if (clk == NULL || IS_ERR(clk))
-               return -ENODEV;
+               return -EINVAL;
 
        spin_lock_irqsave(&clockfw_lock, flags);
        if (arch_clock->clk_enable)
@@ -154,6 +154,9 @@ long clk_round_rate(struct clk *clk, unsigned long rate)
        unsigned long flags;
        long ret = 0;
 
+       if (clk == NULL || IS_ERR(clk))
+               return ret;
+
        spin_lock_irqsave(&clockfw_lock, flags);
        if (arch_clock->clk_round_rate)
                ret = arch_clock->clk_round_rate(clk, rate);
@@ -166,7 +169,10 @@ EXPORT_SYMBOL(clk_round_rate);
 int clk_set_rate(struct clk *clk, unsigned long rate)
 {
        unsigned long flags;
-       int ret = 0;
+       int ret = -EINVAL;
+
+       if (clk == NULL || IS_ERR(clk))
+               return ret;
 
        spin_lock_irqsave(&clockfw_lock, flags);
        if (arch_clock->clk_set_rate)
@@ -180,7 +186,10 @@ EXPORT_SYMBOL(clk_set_rate);
 int clk_set_parent(struct clk *clk, struct clk *parent)
 {
        unsigned long flags;
-       int ret = 0;
+       int ret = -EINVAL;
+
+       if (clk == NULL || IS_ERR(clk) || parent == NULL || IS_ERR(parent))
+               return ret;
 
        spin_lock_irqsave(&clockfw_lock, flags);
        if (arch_clock->clk_set_parent)
@@ -196,6 +205,9 @@ struct clk *clk_get_parent(struct clk *clk)
        unsigned long flags;
        struct clk * ret = NULL;
 
+       if (clk == NULL || IS_ERR(clk))
+               return ret;
+
        spin_lock_irqsave(&clockfw_lock, flags);
        if (arch_clock->clk_get_parent)
                ret = arch_clock->clk_get_parent(clk);
@@ -232,6 +244,9 @@ __setup("mpurate=", omap_clk_setup);
 /* Used for clocks that always have same value as the parent clock */
 void followparent_recalc(struct clk *clk)
 {
+       if (clk == NULL || IS_ERR(clk))
+               return;
+
        clk->rate = clk->parent->rate;
 }
 
@@ -240,6 +255,9 @@ void propagate_rate(struct clk * tclk)
 {
        struct clk *clkp;
 
+       if (tclk == NULL || IS_ERR(tclk))
+               return;
+
        list_for_each_entry(clkp, &clocks, node) {
                if (likely(clkp->parent != tclk))
                        continue;
@@ -250,6 +268,9 @@ void propagate_rate(struct clk * tclk)
 
 int clk_register(struct clk *clk)
 {
+       if (clk == NULL || IS_ERR(clk))
+               return -EINVAL;
+
        mutex_lock(&clocks_mutex);
        list_add(&clk->node, &clocks);
        if (clk->init)
@@ -262,6 +283,9 @@ EXPORT_SYMBOL(clk_register);
 
 void clk_unregister(struct clk *clk)
 {
+       if (clk == NULL || IS_ERR(clk))
+               return;
+
        mutex_lock(&clocks_mutex);
        list_del(&clk->node);
        mutex_unlock(&clocks_mutex);
@@ -272,6 +296,9 @@ void clk_deny_idle(struct clk *clk)
 {
        unsigned long flags;
 
+       if (clk == NULL || IS_ERR(clk))
+               return;
+
        spin_lock_irqsave(&clockfw_lock, flags);
        if (arch_clock->clk_deny_idle)
                arch_clock->clk_deny_idle(clk);
@@ -283,6 +310,9 @@ void clk_allow_idle(struct clk *clk)
 {
        unsigned long flags;
 
+       if (clk == NULL || IS_ERR(clk))
+               return;
+
        spin_lock_irqsave(&clockfw_lock, flags);
        if (arch_clock->clk_allow_idle)
                arch_clock->clk_allow_idle(clk);