Skip to content

Commit 2f80dfa

Browse files
Pei Xiaobebarino
authored andcommitted
clk: sophgo: Use div64* for 64-by-32 division to simplify
Fixes Coccinelle/coccicheck warnings reported by do_div.cocci. cocci warnings: drivers/clk/sophgo/clk-sg2042-pll.c:217:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead. drivers/clk/sophgo/clk-sg2042-pll.c:160:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. replace do_div() with div64_*() which doesn't implicitly cast the divisor. Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn> Link: https://lore.kernel.org/r/tencent_D5D35C992B70843CF70F5533E49717D24906@qq.com Reviewed-by: Inochi Amaoto <inochiama@gmail.com> Reviewed-by: Chen Wang <wangchen20@iscas.ac.cn> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 13de464 commit 2f80dfa

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/clk/sophgo/clk-sg2042-pll.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static unsigned long sg2042_pll_recalc_rate(unsigned int reg_value,
155155

156156
numerator = (u64)parent_rate * ctrl_table.fbdiv;
157157
denominator = ctrl_table.refdiv * ctrl_table.postdiv1 * ctrl_table.postdiv2;
158-
do_div(numerator, denominator);
158+
numerator = div64_u64(numerator, denominator);
159159
return numerator;
160160
}
161161

@@ -212,7 +212,7 @@ static int sg2042_pll_get_postdiv_1_2(unsigned long rate,
212212
tmp0 *= fbdiv;
213213

214214
/* ((prate/REFDIV) x FBDIV)/rate and result save to tmp0 */
215-
do_div(tmp0, rate);
215+
tmp0 = div64_ul(tmp0, rate);
216216

217217
/* tmp0 is POSTDIV1*POSTDIV2, now we calculate div1 and div2 value */
218218
if (tmp0 <= 7) {

0 commit comments

Comments
 (0)