From f986c58443d750176d0434624c942f9cd4bd0f58 Mon Sep 17 00:00:00 2001 From: "zhiqiang.liang" Date: Tue, 21 Aug 2018 16:44:23 +0800 Subject: [PATCH] Clk: clean the coverity errors of clk module PD#166793: code defects in clk part Change-Id: Iee2753552c6f345ea78329833415e607b141d188 Signed-off-by: zhiqiang.liang --- drivers/amlogic/clk/clk-cpu-fclk-composite.c | 7 ++++--- drivers/amlogic/clk/clk-scpi.c | 2 +- drivers/amlogic/clk/g12a/g12a_clk-pll.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/amlogic/clk/clk-cpu-fclk-composite.c b/drivers/amlogic/clk/clk-cpu-fclk-composite.c index cfe9618..ba722e5 100644 --- a/drivers/amlogic/clk/clk-cpu-fclk-composite.c +++ b/drivers/amlogic/clk/clk-cpu-fclk-composite.c @@ -274,14 +274,15 @@ int meson_fclk_mux_divider_determine_rate(struct clk_hw *hw, premux = rate_set->premux; best_parent = clk_hw_get_parent_by_index(hw, premux); + + if (!best_parent) + return -EINVAL; + best = clk_hw_get_rate(best_parent); if (best != parent_req.rate) meson_fclk_cpu_set_parent(hw, premux); - if (!best_parent) - return -EINVAL; - if (best_parent) req->best_parent_hw = best_parent; diff --git a/drivers/amlogic/clk/clk-scpi.c b/drivers/amlogic/clk/clk-scpi.c index 33294d5..501b8a4 100644 --- a/drivers/amlogic/clk/clk-scpi.c +++ b/drivers/amlogic/clk/clk-scpi.c @@ -198,7 +198,7 @@ static int scpi_clk_setup(struct device *dev, struct device_node *np, struct scpi_clk *) = data; struct clk_onecell_data *clk_data; struct clk **clks; - size_t count; + int count; int idx; count = of_property_count_strings(np, "clock-output-names"); diff --git a/drivers/amlogic/clk/g12a/g12a_clk-pll.c b/drivers/amlogic/clk/g12a/g12a_clk-pll.c index 929477c..7e2c21d 100644 --- a/drivers/amlogic/clk/g12a/g12a_clk-pll.c +++ b/drivers/amlogic/clk/g12a/g12a_clk-pll.c @@ -123,7 +123,7 @@ static unsigned long meson_g12a_pll_recalc_rate(struct clk_hw *hw, p = &pll->frac; - if (p->width) { + if (p->width >= 2) { reg = readl(pll->base + p->reg_off); frac = PARM_GET(p->width - 1, p->shift, reg); -- 2.7.4