ALSA: Fix compiler warnings in sound subsystem
Subsystems (5)
v2 cover ALSA: Fix compiler warnings in sound subsystem
From: wangdicheng <[email protected]>
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(-)
Signature · 1 line
2.25.1
PATCH v2 1/3 ASoC: mediatek: mt8189: Remove redundant else-if branch with identical body
From: wangdicheng <[email protected]>
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.
--- sound/soc/mediatek/mt8189/mt8189-dai-adda.c | 2 -- 1 file changed, 2 deletions(-)
sound/soc/mediatek/mt8189/mt8189-dai-adda.c +0 -2
@@ -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 ); }
Signature · 1 line
2.25.1
PATCH v2 2/3 ALSA: sparc/dbri: Fix "possible condition with no effect" warning
In reply to [email protected]From: wangdicheng <[email protected]>
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.
--- sound/sparc/dbri.c | 2 ++ 1 file changed, 2 insertions(+)
sound/sparc/dbri.c +2 -0
@@ -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 :
Signature · 1 line
2.25.1
Takashi Iwai
AppliedRe: [PATCH v2 2/3] ALSA: sparc/dbri: Fix "possible condition with no effect" warning
Quoted 5 lines · On Fri, 17 Jul 2026 11:15:41 +0200, [email protected] wrote:
From: wangdicheng <[email protected]>
Fix a compiler warning about a condition with no effect:
Quoted 8 lines
sound/sparc/dbri.c:1843:1-3: WARNING: possible condition with no effect (if == else)
When
DBRI_DEBUGis 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 #ifdefDBRI_DEBUGto eliminate the warning and keep the rval reference consistent with its declaration scope.Signed-off-by wangdicheng <[email protected]>
Applied to for-next branch. Thanks.
Takashi
PATCH v2 3/3 ASoC: fsl_easrc: Use div64_u64 for 64-by-64 division
In reply to [email protected]From: wangdicheng <[email protected]>
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.
--- sound/soc/fsl/fsl_easrc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/fsl/fsl_easrc.c +1 -1
@@ -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;
Signature · 1 line
2.25.1
Mark Brown
maintainerRe: (subset) [PATCH v2 0/3] ALSA: Fix compiler warnings in sound subsystem
In reply to [email protected]Quoted 8 lines · On Fri, 17 Jul 2026 17:15:39 +0800, [email protected] wrote:
ALSA: Fix compiler warnings in sound subsystem
From: wangdicheng <[email protected]>
This series fixes three compiler warnings in the sound subsystem, covering both logical redundancies and a potential runtime bug.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3
Thanks!
[1/3] ASoC: mediatek: mt8189: Remove redundant else-if branch with identical body
https://git.kernel.org/broonie/sound/c/fcf2a365da23 [3/3] ASoC: fsl_easrc: Use div64_u64 for 64-by-64 division https://git.kernel.org/broonie/sound/c/a46ccc71877e
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark