Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: hisilicon: Remove unnecessary local variable

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>

authored by

Thorsten Blum and committed by
Stephen Boyd
de7aeb5d ec562c9a

+3 -4
+3 -4
drivers/clk/hisilicon/clk-hi3559a.c
··· 407 407 unsigned long parent_rate) 408 408 { 409 409 struct hi3559av100_clk_pll *clk = to_pll_clk(hw); 410 - u64 frac_val, fbdiv_val, refdiv_val; 410 + u64 frac_val, fbdiv_val; 411 411 u32 postdiv1_val, postdiv2_val; 412 412 u32 val; 413 413 u64 tmp, rate; ··· 435 435 val = readl_relaxed(clk->ctrl_reg2); 436 436 val = val >> clk->refdiv_shift; 437 437 val &= ((1 << clk->refdiv_width) - 1); 438 - refdiv_val = val; 439 438 440 439 /* rate = 24000000 * (fbdiv + frac / (1<<24) ) / refdiv */ 441 440 rate = 0; 442 441 tmp = 24000000 * fbdiv_val + (24000000 * frac_val) / (1 << 24); 443 442 rate += tmp; 444 - do_div(rate, refdiv_val); 445 - do_div(rate, postdiv1_val * postdiv2_val); 443 + rate = div_u64(rate, val); 444 + rate = div_u64(rate, postdiv1_val * postdiv2_val); 446 445 447 446 return rate; 448 447 }