* Re: [PATCH] clk: sophgo: Fixes Coccinelle/coccicheck warnings reported by do_div.cocci.
2025-04-07 3:21 [PATCH] clk: sophgo: Fixes Coccinelle/coccicheck warnings reported by do_div.cocci xiaopeitux
@ 2025-04-07 3:55 ` Inochi Amaoto
2025-04-07 9:01 ` Chen Wang
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Inochi Amaoto @ 2025-04-07 3:55 UTC (permalink / raw)
To: xiaopeitux, sboyd, mturquette, unicorn_wang, inochiama,
linux-clk, linux-kernel
Cc: Pei Xiao
On Mon, Apr 07, 2025 at 11:21:46AM +0800, xiaopeitux@foxmail.com wrote:
> From: Pei Xiao <xiaopei01@kylinos.cn>
>
> 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>
> ---
> drivers/clk/sophgo/clk-sg2042-pll.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
LGTM.
Reviewed-by: Inochi Amaoto <inochiama@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] clk: sophgo: Fixes Coccinelle/coccicheck warnings reported by do_div.cocci.
2025-04-07 3:21 [PATCH] clk: sophgo: Fixes Coccinelle/coccicheck warnings reported by do_div.cocci xiaopeitux
2025-04-07 3:55 ` Inochi Amaoto
@ 2025-04-07 9:01 ` Chen Wang
2025-04-25 13:06 ` Chen Wang
2025-06-19 23:50 ` Stephen Boyd
3 siblings, 0 replies; 5+ messages in thread
From: Chen Wang @ 2025-04-07 9:01 UTC (permalink / raw)
To: xiaopeitux, Pei Xiao
Cc: sboyd, mturquette, inochiama, linux-clk, linux-kernel
On 2025/4/7 11:21, xiaopeitux@foxmail.com wrote:
> From: Pei Xiao <xiaopei01@kylinos.cn>
>
> 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.
hi Pei,I'm not sure if you discovered this issue via the test robot, see
this: https://lore.kernel.org/lkml/202504051456.niworhgJ-lkp@intel.com/.
If so, please add its Reported-by signature in the commit as required.
Otherwise please ignore my input.
As per this patch itself, LGTM.
Reviewed-by: Chen Wang <wangchen20@iscas.ac.cn>
>
> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
> ---
> drivers/clk/sophgo/clk-sg2042-pll.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/sophgo/clk-sg2042-pll.c b/drivers/clk/sophgo/clk-sg2042-pll.c
> index 1537f4f05860..e5fb0bb7ac4f 100644
> --- a/drivers/clk/sophgo/clk-sg2042-pll.c
> +++ b/drivers/clk/sophgo/clk-sg2042-pll.c
> @@ -155,7 +155,7 @@ static unsigned long sg2042_pll_recalc_rate(unsigned int reg_value,
>
> numerator = (u64)parent_rate * ctrl_table.fbdiv;
> denominator = ctrl_table.refdiv * ctrl_table.postdiv1 * ctrl_table.postdiv2;
> - do_div(numerator, denominator);
> + numerator = div64_u64(numerator, denominator);
> return numerator;
> }
>
> @@ -212,7 +212,7 @@ static int sg2042_pll_get_postdiv_1_2(unsigned long rate,
> tmp0 *= fbdiv;
>
> /* ((prate/REFDIV) x FBDIV)/rate and result save to tmp0 */
> - do_div(tmp0, rate);
> + tmp0 = div64_ul(tmp0, rate);
>
> /* tmp0 is POSTDIV1*POSTDIV2, now we calculate div1 and div2 value */
> if (tmp0 <= 7) {
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] clk: sophgo: Fixes Coccinelle/coccicheck warnings reported by do_div.cocci.
2025-04-07 3:21 [PATCH] clk: sophgo: Fixes Coccinelle/coccicheck warnings reported by do_div.cocci xiaopeitux
2025-04-07 3:55 ` Inochi Amaoto
2025-04-07 9:01 ` Chen Wang
@ 2025-04-25 13:06 ` Chen Wang
2025-06-19 23:50 ` Stephen Boyd
3 siblings, 0 replies; 5+ messages in thread
From: Chen Wang @ 2025-04-25 13:06 UTC (permalink / raw)
To: sboyd
Cc: Pei Xiao, xiaopeitux, mturquette, inochiama, linux-clk, linux-kernel
hi, Stephen,
Could you please pick this fix?
Thanks,
Chen
On 2025/4/7 11:21, xiaopeitux@foxmail.com wrote:
> From: Pei Xiao <xiaopei01@kylinos.cn>
>
> 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>
> ---
> drivers/clk/sophgo/clk-sg2042-pll.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/sophgo/clk-sg2042-pll.c b/drivers/clk/sophgo/clk-sg2042-pll.c
> index 1537f4f05860..e5fb0bb7ac4f 100644
> --- a/drivers/clk/sophgo/clk-sg2042-pll.c
> +++ b/drivers/clk/sophgo/clk-sg2042-pll.c
> @@ -155,7 +155,7 @@ static unsigned long sg2042_pll_recalc_rate(unsigned int reg_value,
>
> numerator = (u64)parent_rate * ctrl_table.fbdiv;
> denominator = ctrl_table.refdiv * ctrl_table.postdiv1 * ctrl_table.postdiv2;
> - do_div(numerator, denominator);
> + numerator = div64_u64(numerator, denominator);
> return numerator;
> }
>
> @@ -212,7 +212,7 @@ static int sg2042_pll_get_postdiv_1_2(unsigned long rate,
> tmp0 *= fbdiv;
>
> /* ((prate/REFDIV) x FBDIV)/rate and result save to tmp0 */
> - do_div(tmp0, rate);
> + tmp0 = div64_ul(tmp0, rate);
>
> /* tmp0 is POSTDIV1*POSTDIV2, now we calculate div1 and div2 value */
> if (tmp0 <= 7) {
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] clk: sophgo: Fixes Coccinelle/coccicheck warnings reported by do_div.cocci.
2025-04-07 3:21 [PATCH] clk: sophgo: Fixes Coccinelle/coccicheck warnings reported by do_div.cocci xiaopeitux
` (2 preceding siblings ...)
2025-04-25 13:06 ` Chen Wang
@ 2025-06-19 23:50 ` Stephen Boyd
3 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2025-06-19 23:50 UTC (permalink / raw)
To: inochiama, linux-clk, linux-kernel, mturquette, unicorn_wang, xiaopeitux
Cc: Pei Xiao
Quoting xiaopeitux@foxmail.com (2025-04-06 20:21:46)
> From: Pei Xiao <xiaopei01@kylinos.cn>
>
> 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>
> ---
Applied to clk-next
^ permalink raw reply [flat|nested] 5+ messages in thread