From: David Laight <david.laight.linux@gmail.com>
To: wangdich9700@163.com
Cc: tiwai@suse.de, broonie@kernel.org, wangdicheng@kylinos.cn,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH 3/4] ASoC: fsl_easrc: Use div64_u64 for 64-by-64 division
Date: Fri, 17 Jul 2026 09:04:15 +0100 [thread overview]
Message-ID: <20260717090415.07b0e46c@pumpkin> (raw)
In-Reply-To: <20260717070252.525545-4-wangdich9700@163.com>
On Fri, 17 Jul 2026 15:02:51 +0800
wangdich9700@163.com wrote:
> From: wangdicheng <wangdicheng@kylinos.cn>
>
> Fix a compiler warning about do_div() truncating a 64-bit divisor:
It's not a compiler warning.
>
> sound/soc/fsl/fsl_easrc.c:2061:2-8: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.
>
> do_div() truncates the divisor to 32 bits, but val1 is u64 and may
> exceed the 32-bit range after (u64)in_rate << frac_bits >> 12 with
> frac_bits up to 39. Use div64_u64() to perform a proper 64-by-64
> division and avoid potential truncation.
>
> Fixes: 955ac624058f ("ASoC: fsl_easrc: Add EASRC ASoC CPU DAI drivers")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: wangdicheng <wangdicheng@kylinos.cn>
> ---
> sound/soc/fsl/fsl_easrc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/soc/fsl/fsl_easrc.c b/sound/soc/fsl/fsl_easrc.c
> index 114a6c0b6b73..d0bbe9f71e36 100644
> --- a/sound/soc/fsl/fsl_easrc.c
> +++ b/sound/soc/fsl/fsl_easrc.c
> @@ -2058,7 +2058,7 @@ static int fsl_easrc_m2m_calc_out_len(struct fsl_asrc_pair *pair, int input_buff
> /* right shift 12 bit to make ratio in 32bit space */
> val2 = (u64)in_samples << (frac_bits - 12);
> val1 = val1 >> 12;
> - do_div(val2, val1);
> + val2 = div64_u64(val2, val1);
Are you sure the domain of val1 can exceed 32 bits?
There is a comment in the patch block that implies otherwise.
David
> out_samples = val2;
>
> out_length = out_samples * out_width * channels;
next prev parent reply other threads:[~2026-07-17 8:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 7:02 [PATCH 0/4] ALSA: Fix compiler warnings in sound subsystem wangdich9700
2026-07-17 7:02 ` [PATCH 1/4] ASoC: mediatek: mt8189: Remove redundant else-if branch with identical body wangdich9700
2026-07-17 7:02 ` [PATCH 2/4] ALSA: sparc/dbri: Fix "possible condition with no effect" warning wangdich9700
2026-07-17 7:02 ` [PATCH 3/4] ASoC: fsl_easrc: Use div64_u64 for 64-by-64 division wangdich9700
2026-07-17 8:04 ` David Laight [this message]
2026-07-17 7:02 ` [PATCH 4/4] ASoC: tlv320aic32x4: Use div64_ul for division by unsigned long wangdich9700
2026-07-17 8:06 ` David Laight
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260717090415.07b0e46c@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.de \
--cc=wangdich9700@163.com \
--cc=wangdicheng@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox