Re: [PATCH] clk: sunxi-ng: nkm: use div64_ul() for the rate divisions
From: Romain TISSERAND
Date: Thu Dec 03 2026 - 02:36:53 EST
Hi David,
On Wed, 2 Dec 2026 22:40:25 +0000, David Laight wrote:
> Exactly when does the truncation happen?
> That is what actual values cause a truncation?
None. Every NKM clock in sunxi-ng has N <= 32, K <= 4 and M <= 16, so
n * k <= 128 and m <= 16: the divisor always fits in 32 bits and
do_div() gives the exact result today.
> And if there is one, why does it only happen on 64bit.
Only in the sense that the divisor is an unsigned long: on 64-bit it is
64 bits wide and do_div() takes a u32, so the conversion could in
theory drop high bits; on 32-bit unsigned long is already 32 bits, so
there is nothing to drop. With the real factor ranges it never happens
on either.
So "on 64-bit it would be truncated" overstates it, sorry for the
misleading wording and for the Fixes: tag: there is no bug to fix. The
patch only quiets the coccinelle do_div() check the robot reported,
with no functional change. If the maintainers want it, I will send a v2
whose commit message says just that, without the Fixes: tag; otherwise
it can simply be dropped.
Thanks,
Romain