Re: [PATCH 4/4] ASoC: tlv320aic32x4: Use div64_ul for division by unsigned long
From: David Laight
Date: Fri Jul 17 2026 - 04:11:22 EST
On Fri, 17 Jul 2026 15:02:52 +0800
wangdich9700@xxxxxxx wrote:
> From: wangdicheng <wangdicheng@xxxxxxxxxx>
>
> Fix a compiler warning about do_div() truncating an unsigned long divisor:
>
> sound/soc/codecs/tlv320aic32x4-clk.c:169:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead.
>
> do_div() truncates the divisor to 32 bits, but parent_rate is unsigned
> long which is 64-bit on 64-bit platforms. Use div64_ul() to correctly
> handle the unsigned long divisor across all architectures.
And the code has to process the same values on 32bit.
So the value must fit in 32bits and do_div() is fine.
Doesn't 'fix' anything.
David
>
> Fixes: 514b044cba66 ("ASoC: tlv320aic32x4: Model PLL in CCF")
> Cc: <stable@xxxxxxxxxxxxxxx>
> Signed-off-by: wangdicheng <wangdicheng@xxxxxxxxxx>
> ---
> sound/soc/codecs/tlv320aic32x4-clk.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/soc/codecs/tlv320aic32x4-clk.c b/sound/soc/codecs/tlv320aic32x4-clk.c
> index 5c0a76a4a106..9359492051ad 100644
> --- a/sound/soc/codecs/tlv320aic32x4-clk.c
> +++ b/sound/soc/codecs/tlv320aic32x4-clk.c
> @@ -166,7 +166,7 @@ static int clk_aic32x4_pll_calc_muldiv(struct clk_aic32x4_pll_muldiv *settings,
> * math in the kernel.
> */
> multiplier = (u64) rate * settings->p * 10000;
> - do_div(multiplier, parent_rate);
> + multiplier = div64_ul(multiplier, parent_rate);
>
> /*
> * J can't be over 64, so R can scale this.