clk: fix some determine_rate implementations
authorBoris Brezillon <boris.brezillon@free-electrons.com>
Thu, 9 Jul 2015 20:39:38 +0000 (22:39 +0200)
committerStephen Boyd <sboyd@codeaurora.org>
Tue, 28 Jul 2015 01:13:32 +0000 (18:13 -0700)
Some determine_rate implementations are not returning an error
when they failed to adapt the rate according to the rate request.
Fix them so that they return an error instead of silently
returning 0.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
CC: Jonathan Corbet <corbet@lwn.net>
CC: Tony Lindgren <tony@atomide.com>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: "Emilio López" <emilio@elopez.com.ar>
CC: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Tero Kristo <t-kristo@ti.com>
CC: Peter De Schrijver <pdeschrijver@nvidia.com>
CC: Prashant Gaikwad <pgaikwad@nvidia.com>
CC: Stephen Warren <swarren@wwwdotorg.org>
CC: Thierry Reding <thierry.reding@gmail.com>
CC: Alexandre Courbot <gnurou@gmail.com>
CC: linux-doc@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-arm-kernel@lists.infradead.org
CC: linux-omap@vger.kernel.org
CC: linux-mips@linux-mips.org
CC: linux-tegra@vger.kernel.org
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
arch/mips/alchemy/common/clock.c
drivers/clk/clk-composite.c
drivers/clk/clk.c
drivers/clk/hisilicon/clk-hi3620.c
drivers/clk/mmp/clk-mix.c
drivers/clk/sunxi/clk-factors.c
drivers/clk/sunxi/clk-sun6i-ar100.c
drivers/clk/sunxi/clk-sunxi.c

index 0b4cf3e9f005f1a936e79389c055c10d8cb48524..7cc3eed83a1e186f4450a92c91309163e1c5401f 100644 (file)
@@ -469,9 +469,13 @@ static int alchemy_clk_fgcs_detr(struct clk_hw *hw,
                }
        }
 
+       if (br < 0)
+               return br;
+
        req->best_parent_rate = bpr;
        req->best_parent_hw = __clk_get_hw(bpc);
        req->rate = br;
+
        return 0;
 }
 
index 9e69f346ecc63c7e99b7bae1eb0541c492de7c11..35ac062d7df65ca07fa71f702cf93f61679b29fa 100644 (file)
@@ -125,8 +125,7 @@ static int clk_composite_determine_rate(struct clk_hw *hw,
                return mux_ops->determine_rate(mux_hw, req);
        } else {
                pr_err("clk: clk_composite_determine_rate function called, but no mux or rate callback set!\n");
-               req->rate = 0;
-               return 0;
+               return -EINVAL;
        }
 }
 
index 4e9ff928ef88ddbe500cbfc8d78fbf22692aa97c..c907289ff03c992c8889566a2bb45dae906303cd 100644 (file)
@@ -487,6 +487,9 @@ clk_mux_determine_rate_flags(struct clk_hw *hw, struct clk_rate_request *req,
                }
        }
 
+       if (!best_parent)
+               return -EINVAL;
+
 out:
        if (best_parent)
                req->best_parent_hw = best_parent->hw;
index a0674ba6659ec372a5a80ea6341daf7eb2267994..c84ec867a91c656b6a1a817cc5ff72465486b774 100644 (file)
@@ -316,7 +316,7 @@ static int mmc_clk_determine_rate(struct clk_hw *hw,
                req->rate = 180000000;
                req->best_parent_rate = 1440000000;
        }
-       return 0;
+       return -EINVAL;
 }
 
 static u32 mmc_clk_delay(u32 val, u32 para, u32 off, u32 len)
index 7a37432761f9250fc2cd44c1bc6639a9a041082e..665cb6794639606595024287a6d38e04592b3669 100644 (file)
@@ -218,7 +218,7 @@ static int mmp_clk_mix_determine_rate(struct clk_hw *hw,
        parent = NULL;
        mix_rate_best = 0;
        parent_rate_best = 0;
-       gap_best = req->rate;
+       gap_best = ULONG_MAX;
        parent_best = NULL;
 
        if (mix->table) {
@@ -262,6 +262,9 @@ static int mmp_clk_mix_determine_rate(struct clk_hw *hw,
        }
 
 found:
+       if (!parent_best)
+               return -EINVAL;
+
        req->best_parent_rate = parent_rate_best;
        req->best_parent_hw = __clk_get_hw(parent_best);
        req->rate = mix_rate_best;
index 7a485870991daa9e1009211fadd79e84ce6f05ab..94e2570a2409d9b6f4973125a3066ef6106cf81d 100644 (file)
@@ -107,8 +107,10 @@ static int clk_factors_determine_rate(struct clk_hw *hw,
                }
        }
 
-       if (best_parent)
-               req->best_parent_hw = __clk_get_hw(best_parent);
+       if (!best_parent)
+               return -EINVAL;
+
+       req->best_parent_hw = __clk_get_hw(best_parent);
        req->best_parent_rate = best;
        req->rate = best_child_rate;
 
index d70c1ea345dbf1866ac9cf1669dc240790485fc3..21b076ee59d1dae79a936bc8f6022f0e929c6bf4 100644 (file)
@@ -105,6 +105,9 @@ static int ar100_determine_rate(struct clk_hw *hw,
                }
        }
 
+       if (best_rate < 0)
+               return best_rate;
+
        req->rate = best_rate;
 
        return 0;
index d0f72a151bf183b733547b15659f15308acd6605..0e15165280dcda209a009bf1c56d21a3965e1c22 100644 (file)
@@ -146,8 +146,10 @@ static int sun6i_ahb1_clk_determine_rate(struct clk_hw *hw,
                }
        }
 
-       if (best_parent)
-               req->best_parent_hw = __clk_get_hw(best_parent);
+       if (!best_parent)
+               return -EINVAL;
+
+       req->best_parent_hw = __clk_get_hw(best_parent);
        req->best_parent_rate = best;
        req->rate = best_child_rate;