]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
clk: hisilicon: Remove unnecessary local variable
authorThorsten Blum <thorsten.blum@toblux.com>
Thu, 1 Aug 2024 10:36:16 +0000 (12:36 +0200)
committerStephen Boyd <sboyd@kernel.org>
Thu, 8 Aug 2024 19:48:33 +0000 (12:48 -0700)
The local u64 variable refdiv_val has the same value as the local u32
variable val and can be removed. Remove it and use val directly as the
divisor to also remove the following Coccinelle/coccicheck warning
reported by do_div.cocci:

  WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead

Use the preferred div_u64() function instead of the do_div() macro.

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Link: https://lore.kernel.org/r/20240801103616.20430-1-thorsten.blum@toblux.com
Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/hisilicon/clk-hi3559a.c

index c79a94f6d9d24c28217586df4ee2c2e19201ed27..8646e9d352ed448cdf00363e32f0e49ad9d5b3d9 100644 (file)
@@ -407,7 +407,7 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw,
                unsigned long parent_rate)
 {
        struct hi3559av100_clk_pll *clk = to_pll_clk(hw);
-       u64 frac_val, fbdiv_val, refdiv_val;
+       u64 frac_val, fbdiv_val;
        u32 postdiv1_val, postdiv2_val;
        u32 val;
        u64 tmp, rate;
@@ -435,14 +435,13 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw,
        val = readl_relaxed(clk->ctrl_reg2);
        val = val >> clk->refdiv_shift;
        val &= ((1 << clk->refdiv_width) - 1);
-       refdiv_val = val;
 
        /* rate = 24000000 * (fbdiv + frac / (1<<24) ) / refdiv  */
        rate = 0;
        tmp = 24000000 * fbdiv_val + (24000000 * frac_val) / (1 << 24);
        rate += tmp;
-       do_div(rate, refdiv_val);
-       do_div(rate, postdiv1_val * postdiv2_val);
+       rate = div_u64(rate, val);
+       rate = div_u64(rate, postdiv1_val * postdiv2_val);
 
        return rate;
 }