* [PATCH v2 0/3] ALSA: Fix compiler warnings in sound subsystem
@ 2026-07-17 9:15 wangdich9700
2026-07-17 9:15 ` [PATCH v2 1/3] ASoC: mediatek: mt8189: Remove redundant else-if branch with identical body wangdich9700
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: wangdich9700 @ 2026-07-17 9:15 UTC (permalink / raw)
To: tiwai, david.laight.linux, wangdich9700
Cc: wangdicheng, linux-sound, linux-kernel
From: wangdicheng <wangdicheng@kylinos.cn>
This series fixes three compiler warnings in the sound subsystem,
covering both logical redundancies and a potential runtime bug.
Two categories of warnings are addressed:
1. "possible condition with no effect (if == else)" -- redundant
conditional branches that produce identical code.
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.
Changes in v2:
- Dropped "ASoC: tlv320aic32x4: Use div64_ul for division by unsigned long".
Per David's review, parent_rate is bounded by AIC32X4_MAX_PLL_CLKIN
(20MHz) and will never exceed 32 bits, so do_div() is fine there.
- Updated patch 3 (fsl_easrc) commit message with concrete numerical
proof that val1 can exceed 32 bits after >> 12, and clarified that
the truncation happens when val1 is used as a divisor.
wangdicheng (3):
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
sound/soc/fsl/fsl_easrc.c | 2 +-
sound/soc/mediatek/mt8189/mt8189-dai-adda.c | 2 --
sound/sparc/dbri.c | 2 ++
3 files changed, 3 insertions(+), 3 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/3] ASoC: mediatek: mt8189: Remove redundant else-if branch with identical body
2026-07-17 9:15 [PATCH v2 0/3] ALSA: Fix compiler warnings in sound subsystem wangdich9700
@ 2026-07-17 9:15 ` wangdich9700
2026-07-17 9:15 ` [PATCH v2 2/3] ALSA: sparc/dbri: Fix "possible condition with no effect" warning wangdich9700
2026-07-17 9:15 ` [PATCH v2 3/3] ASoC: fsl_easrc: Use div64_u64 for 64-by-64 division wangdich9700
2 siblings, 0 replies; 4+ messages in thread
From: wangdich9700 @ 2026-07-17 9:15 UTC (permalink / raw)
To: tiwai, david.laight.linux, wangdich9700
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 [flat|nested] 4+ messages in thread
* [PATCH v2 2/3] ALSA: sparc/dbri: Fix "possible condition with no effect" warning
2026-07-17 9:15 [PATCH v2 0/3] ALSA: Fix compiler warnings in sound subsystem wangdich9700
2026-07-17 9:15 ` [PATCH v2 1/3] ASoC: mediatek: mt8189: Remove redundant else-if branch with identical body wangdich9700
@ 2026-07-17 9:15 ` wangdich9700
2026-07-17 9:15 ` [PATCH v2 3/3] ASoC: fsl_easrc: Use div64_u64 for 64-by-64 division wangdich9700
2 siblings, 0 replies; 4+ messages in thread
From: wangdich9700 @ 2026-07-17 9:15 UTC (permalink / raw)
To: tiwai, david.laight.linux, wangdich9700
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 [flat|nested] 4+ messages in thread
* [PATCH v2 3/3] ASoC: fsl_easrc: Use div64_u64 for 64-by-64 division
2026-07-17 9:15 [PATCH v2 0/3] ALSA: Fix compiler warnings in sound subsystem wangdich9700
2026-07-17 9:15 ` [PATCH v2 1/3] ASoC: mediatek: mt8189: Remove redundant else-if branch with identical body wangdich9700
2026-07-17 9:15 ` [PATCH v2 2/3] ALSA: sparc/dbri: Fix "possible condition with no effect" warning wangdich9700
@ 2026-07-17 9:15 ` wangdich9700
2 siblings, 0 replies; 4+ messages in thread
From: wangdich9700 @ 2026-07-17 9:15 UTC (permalink / raw)
To: tiwai, david.laight.linux, wangdich9700
Cc: wangdicheng, linux-sound, linux-kernel, stable
From: wangdicheng <wangdicheng@kylinos.cn>
Fix a coccinelle 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.
In fsl_easrc_m2m_calc_out_len(), val1 is computed as:
val1 = (u64)in_rate << frac_bits; // frac_bits up to 39
do_div(val1, out_rate);
val1 += (s64)ctx_priv->ratio_mod << (frac_bits - 31);
val1 = val1 >> 12;
In the worst case (in_rate=384000, out_rate=8000, frac_bits=39):
val1 = 384000 << 39 / 8000 = 26,388,279,068,672
val1 >> 12 = 6,440,497,829 (33 bits, exceeds 32-bit range)
val1 is then used as the divisor in do_div(val2, val1), where
do_div() silently truncates it to 32 bits, producing incorrect
results. Use div64_u64() to perform a proper 64-by-64 division.
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 [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-17 9:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-17 9:15 [PATCH v2 0/3] ALSA: Fix compiler warnings in sound subsystem wangdich9700
2026-07-17 9:15 ` [PATCH v2 1/3] ASoC: mediatek: mt8189: Remove redundant else-if branch with identical body wangdich9700
2026-07-17 9:15 ` [PATCH v2 2/3] ALSA: sparc/dbri: Fix "possible condition with no effect" warning wangdich9700
2026-07-17 9:15 ` [PATCH v2 3/3] ASoC: fsl_easrc: Use div64_u64 for 64-by-64 division wangdich9700
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox