* [PATCH 0/4] ALSA: Fix compiler warnings in sound subsystem
@ 2026-07-17 7:02 wangdich9700
2026-07-17 7:02 ` [PATCH 1/4] ASoC: mediatek: mt8189: Remove redundant else-if branch with identical body wangdich9700
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: wangdich9700 @ 2026-07-17 7:02 UTC (permalink / raw)
To: tiwai, wangdich9700, broonie; +Cc: wangdicheng, linux-sound, linux-kernel
From: wangdicheng <wangdicheng@kylinos.cn>
This series fixes four compiler warnings in the sound subsystem,
covering both logical redundancies and potential runtime bugs.
Two categories of warnings are addressed:
1. "possible condition with no effect (if == else)" -- redundant
conditional branches that produce identical code. These are
cosmetic issues but should be cleaned up.
2. "do_div() does a 64-by-32 division" -- use of do_div() with
a 64-bit divisor, which silently truncates the upper 32 bits.
These are potential runtime bugs on 64-bit platforms where the
divisor may exceed the 32-bit range.
Patches 1-2 fix the if==else warnings.
Patches 3-4 fix the do_div() warnings.
wangdicheng (4):
ASoC: mediatek: mt8189: Remove redundant else-if branch with identical
body
ALSA: sparc/dbri: Fix "possible condition with no effect" warning
ASoC: fsl_easrc: Use div64_u64 for 64-by-64 division
ASoC: tlv320aic32x4: Use div64_ul for division by unsigned long
sound/soc/codecs/tlv320aic32x4-clk.c | 2 +-
sound/soc/fsl/fsl_easrc.c | 2 +-
sound/soc/mediatek/mt8189/mt8189-dai-adda.c | 2 --
sound/sparc/dbri.c | 2 ++
4 files changed, 4 insertions(+), 4 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/4] ASoC: mediatek: mt8189: Remove redundant else-if branch with identical body
2026-07-17 7:02 [PATCH 0/4] ALSA: Fix compiler warnings in sound subsystem wangdich9700
@ 2026-07-17 7:02 ` wangdich9700
2026-07-17 7:02 ` [PATCH 2/4] ALSA: sparc/dbri: Fix "possible condition with no effect" warning wangdich9700
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: wangdich9700 @ 2026-07-17 7:02 UTC (permalink / raw)
To: tiwai, wangdich9700, broonie; +Cc: wangdicheng, linux-sound, linux-kernel
From: wangdicheng <wangdicheng@kylinos.cn>
Fix a compiler warning about a condition with no effect:
sound/mediatek/mt8189/mt8189-dai-adda.c:388:7-9: WARNING: possible condition with no effect (if == else)
The MTKAIF_PROTOCOL_2 branch and the else branch both write the same
value 0xB0 to AFE_AUD_PAD_TOP_CFG0, making the else-if condition
meaningless. Remove the redundant branch.
Signed-off-by: wangdicheng <wangdicheng@kylinos.cn>
---
sound/soc/mediatek/mt8189/mt8189-dai-adda.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/sound/soc/mediatek/mt8189/mt8189-dai-adda.c b/sound/soc/mediatek/mt8189/mt8189-dai-adda.c
index ad5b9546ff63..5c41a6386204 100644
--- a/sound/soc/mediatek/mt8189/mt8189-dai-adda.c
+++ b/sound/soc/mediatek/mt8189/mt8189-dai-adda.c
@@ -385,8 +385,6 @@ static int mtk_adda_pad_top_event(struct snd_soc_dapm_widget *w,
if (event == SND_SOC_DAPM_PRE_PMU) {
if (afe_priv->mtkaif_protocol == MTKAIF_PROTOCOL_2_CLK_P2)
regmap_write(afe->regmap, AFE_AUD_PAD_TOP_CFG0, 0xB8);
- else if (afe_priv->mtkaif_protocol == MTKAIF_PROTOCOL_2)
- regmap_write(afe->regmap, AFE_AUD_PAD_TOP_CFG0, 0xB0);
else
regmap_write(afe->regmap, AFE_AUD_PAD_TOP_CFG0, 0xB0);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/4] ALSA: sparc/dbri: Fix "possible condition with no effect" warning
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 ` wangdich9700
2026-07-17 7:02 ` [PATCH 3/4] ASoC: fsl_easrc: Use div64_u64 for 64-by-64 division wangdich9700
2026-07-17 7:02 ` [PATCH 4/4] ASoC: tlv320aic32x4: Use div64_ul for division by unsigned long wangdich9700
3 siblings, 0 replies; 7+ messages in thread
From: wangdich9700 @ 2026-07-17 7:02 UTC (permalink / raw)
To: tiwai, wangdich9700, broonie; +Cc: wangdicheng, linux-sound, linux-kernel
From: wangdicheng <wangdicheng@kylinos.cn>
Fix a compiler warning about a condition with no effect:
sound/sparc/dbri.c:1843:1-3: WARNING: possible condition with no effect (if == else)
When DBRI_DEBUG is not defined, dprintk expands to an empty do-while
statement, making both branches of the if-else no-ops. Guard the entire
debug block with #ifdef DBRI_DEBUG to eliminate the warning and keep
the rval reference consistent with its declaration scope.
Signed-off-by: wangdicheng <wangdicheng@kylinos.cn>
---
sound/sparc/dbri.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c
index 2f5f62079fa4..ccaa36525f8d 100644
--- a/sound/sparc/dbri.c
+++ b/sound/sparc/dbri.c
@@ -1840,6 +1840,7 @@ static void dbri_process_one_interrupt(struct snd_dbri *dbri, int x)
int rval = D_INTR_GETRVAL(x);
#endif
+#ifdef DBRI_DEBUG
if (channel == D_INTR_CMD) {
dprintk(D_CMD, "INTR: Command: %-5s Value:%d\n",
cmds[command], val);
@@ -1847,6 +1848,7 @@ static void dbri_process_one_interrupt(struct snd_dbri *dbri, int x)
dprintk(D_INT, "INTR: Chan:%d Code:%d Val:%#x\n",
channel, code, rval);
}
+#endif
switch (code) {
case D_INTR_CMDI:
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/4] ASoC: fsl_easrc: Use div64_u64 for 64-by-64 division
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 ` wangdich9700
2026-07-17 8:04 ` David Laight
2026-07-17 7:02 ` [PATCH 4/4] ASoC: tlv320aic32x4: Use div64_ul for division by unsigned long wangdich9700
3 siblings, 1 reply; 7+ messages in thread
From: wangdich9700 @ 2026-07-17 7:02 UTC (permalink / raw)
To: tiwai, wangdich9700, broonie
Cc: wangdicheng, linux-sound, linux-kernel, stable
From: wangdicheng <wangdicheng@kylinos.cn>
Fix a compiler warning about do_div() truncating a 64-bit divisor:
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);
out_samples = val2;
out_length = out_samples * out_width * channels;
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/4] ASoC: tlv320aic32x4: Use div64_ul for division by unsigned long
2026-07-17 7:02 [PATCH 0/4] ALSA: Fix compiler warnings in sound subsystem wangdich9700
` (2 preceding siblings ...)
2026-07-17 7:02 ` [PATCH 3/4] ASoC: fsl_easrc: Use div64_u64 for 64-by-64 division wangdich9700
@ 2026-07-17 7:02 ` wangdich9700
2026-07-17 8:06 ` David Laight
3 siblings, 1 reply; 7+ messages in thread
From: wangdich9700 @ 2026-07-17 7:02 UTC (permalink / raw)
To: tiwai, wangdich9700, broonie
Cc: wangdicheng, linux-sound, linux-kernel, stable
From: wangdicheng <wangdicheng@kylinos.cn>
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.
Fixes: 514b044cba66 ("ASoC: tlv320aic32x4: Model PLL in CCF")
Cc: <stable@vger.kernel.org>
Signed-off-by: wangdicheng <wangdicheng@kylinos.cn>
---
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.
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 3/4] ASoC: fsl_easrc: Use div64_u64 for 64-by-64 division
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
0 siblings, 0 replies; 7+ messages in thread
From: David Laight @ 2026-07-17 8:04 UTC (permalink / raw)
To: wangdich9700
Cc: tiwai, broonie, wangdicheng, linux-sound, linux-kernel, stable
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;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 4/4] ASoC: tlv320aic32x4: Use div64_ul for division by unsigned long
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
0 siblings, 0 replies; 7+ messages in thread
From: David Laight @ 2026-07-17 8:06 UTC (permalink / raw)
To: wangdich9700
Cc: tiwai, broonie, wangdicheng, linux-sound, linux-kernel, stable
On Fri, 17 Jul 2026 15:02:52 +0800
wangdich9700@163.com wrote:
> From: wangdicheng <wangdicheng@kylinos.cn>
>
> 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@vger.kernel.org>
> Signed-off-by: wangdicheng <wangdicheng@kylinos.cn>
> ---
> 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-07-17 8:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox